vanvught / GD32F407RE-DMX512-RDM

GD32F407RE DMX512 RDM
https://www.gd32-dmx.org
MIT License
10 stars 5 forks source link

Static IP network settings lost after power off/on #3

Closed particlerain closed 1 year ago

particlerain commented 1 year ago

Hi Arjan, Everything fine so far. Got some issues though: 1- After configuring the network.txt with a static IP and dhcp=0 & save it, and after pushing the reset button it is updating the IP and it works fine, but it looses the static IP settings and turns back to DHCP mode and gets again it's IP from the DHCP pool after powering the device on or after a power surge. In my setup i need to work only with static IP's. So how to make the device stuck to a static IP? Are the settings not stored in the eeprom?

2- The device is not accepting the reboot command from the remote configuration manager. But it is accepting it from the Firmware update UI. So i have to reboot the device manually through the reset button. What can cause this?

edit: well i could reserve an IP on the router side for that mac, but sometimes i just need to plug it on the PC's network card, and acces it directly with it's static IP.

Thanks.

vanvught commented 1 year ago

Hi,

  1. With the GD32F407 implementation the configuration is stored in. A. the battery backed-up RAM (BKPSRAM) or B. with a SPI flash rom (for example a W25Q128). My current development board (https://github.com/vanvught/GD32FxxxR-dev-board) has a connector for a rechargeable LIR battery. The next board will have the W25Q128 as well. I do not store the configuration (4KB) in the GD32F407 flash as its erase (sector) size is 128KB. This is a lot of wasted space storing it there. All other GD32 MCU's (not the GD32F4xx) have a 2KB or 4KB sector size. Hence the configuration is stored in the on-board flash ROM.

The choice for A. BKPSRAM or B. SPI flash ROM is defined in the make file: A. https://github.com/vanvught/GD32F407RE-DMX512-RDM/blob/main/gd32_emac_artnet_dmx_multi/Makefile.GD32#L18 B. https://github.com/vanvught/GD32F407RE-DMX512-RDM/blob/main/gd32_emac_artnet_dmx_multi/Makefile-dmx4.GD32#L18

It is on my To-Do list providing the firmware for all options. But as this is all an one-man-show, working in free time, it will take some time.

  1. The default setting does not allow a remote reboot. Using the remote configuration UI (https://github.com/vanvught/Remote-Config-UI) you can enable reboot. The problem is solved when the configuration store is made persistence.
particlerain commented 1 year ago

Hi again, I tried with a 3.3V battery (not rechargeble / CR2032) on VBAT, but it was not able to save the config. I also had a W25Q32 laying around here and used the v1.3 Artnet Multi DMX4 bin file (Its SPI as you mentioned), but was also not able to save the changes. I connected the CS pin to PA15 like shown on your board. Or do i have to uıse the W25Q128?

vanvught commented 1 year ago

tried with a 3.3V battery (not rechargeble / CR2032) on VBAT, but it was not able to save the config.

Are you using my development board? If so, then please be sure you are using a rechargeable LIR battery.

I have tested the battery backed-up RAM (BKPSRAM) with my development board and a LIR2032, and that is working fine for me.

I connected the CS pin to PA15 like shown on your board.

When using the generic DMX 4 configuration then the SPI FLASH /CS is PB1 -> https://github.com/vanvught/GD32F407RE-DMX512-RDM/blob/main/lib-gd32/include/board/dmx4.h#L161

The W25Q32 (https://github.com/vanvught/GD32F407RE-DMX512-RDM/blob/main/lib-flash/src/spi/winbond.cpp#L92) should work fine, however I have not tested it.

particlerain commented 1 year ago

Are you using my development board?

No, just a breadboardish design for now.

Edit: Found a rechargable battery. And it works great! Sorry for asking but why does the rechargable one works and not the normal battery? Just curious because it did not make sense to me...

When using the generic DMX 4 configuration then the SPI FLASH /CS is PB1 -> https://github.com/vanvught/GD32F407RE-DMX512-RDM/blob/main/lib-gd32/include/board/dmx4.h#L161

Which SPI port and pins are you using for the Winbond flash? I am using PB3-PB4-PB5. Is this correct?

vanvught commented 1 year ago

GD32F407

vanvught commented 1 year ago

Found a rechargable battery. And it works great! Sorry for asking but why does the rechargable one works and not the normal battery? Just curious because it did not make sense to me...

Good to hear that it is working. No worries. I am happy to receive feedback. I haven no idea as well why a normal battery is not working.

The VBAT is also used for the internal RTC. However, I am not using the RTC, yet. The RTC can be used for scheduling a pre-programmed show running from USB flash.

particlerain commented 1 year ago

GD32F407

Thank you.

particlerain commented 1 year ago

The VBAT is also used for the internal RTC. However, I am not using the RTC, yet. The RTC can be used for scheduling a pre-programmed show running from USB flash.

I do look in the source code as much as i can, and yes i noticed you did not activate the RTC. Thanks for the info. Good to know it can be used for scheduling though. Thats a cool implementation.

Btw, for a one-man-work and just in your free time, you did a industry standard great professional work. I was tired of bad coded open source artnet interfaces including my own codes and looks like you took over the game ;) Congrats for that and thank you so much for taking time for us.

particlerain commented 1 year ago

Edit: still testing spi flash before asking..

vanvught commented 1 year ago

When flashing the bootloader then make sure that only the first 32KB flash is erased.

˜˜The bootloader for dmx4 https://github.com/vanvught/GD32F407RE-Bootloader-TFTP/blob/main/bootloader-tftp/Makefile-dmx4.GD32 has support for console output on USART0. ˜˜

Correction: CONSOLE_I2C is enabled -> https://github.com/vanvught/GD32F407RE-Bootloader-TFTP/blob/main/firmware-template-gd32/Rules.mk#L37

particlerain commented 1 year ago

First 32kb erase on the ws25qxx?

vanvught commented 1 year ago

First 32kb erase on the ws25qxx?

No, the GD32F flashrom. Per default the GD32F flash util erases the complete flash. There is an option: Erase used only.

vanvught commented 1 year ago

You can always get in the bootloader with bringing KEY_BOOTLOADER_TFTP_GPIO_PINx to low during reset -> https://github.com/vanvught/GD32F407RE-Bootloader-TFTP/blob/main/lib-gd32/include/board/dmx4.h#L85

particlerain commented 1 year ago

i tested the ws25q32 on arduino and it reads writes well. I am able to get in the bootloader with the standart bootloader bin file which uses teh BSRAM. See:

No display found [V1.3] GD32F407RE Compiled on Nov 1 2022 at 14:57:08 Bootloader TFTP Server FMC: Detected GD32F407RE with total 524288 bytes [512 kB] GD32F407RE, sector size 16384, 524288 bytes [512 kB] BSRAM: Detected GD32F407RE with total 4096 bytes [4 kB] Network Hostname : gigadevice_472B14 IfName : 1: eth0 Inet : 192.168.0.112/24 Netmask : 255.255.255.0 Gateway : 192.168.0.1 Broadcast : 192.168.0.255 Mac : 02:35:32:47:2b:14 Mode : D

But after i flash the dmx4 with SPI support, the bootloader does not boot. Nothing in the UART terminal. I also tried the KEY_BOOTLOADER_TFTP_GPIO_PINx (in this case A11) to force it , but doesnt work.

No, the GD32F flashrom. Per default the GD32F flash util erases the complete flash. There is an option: Erase used only.

I don't understand this. Don't we have to put the bootlader on to an empty fully erased chip? I am using ST-link adaper to flash the device. There is only full or sector erase possible. I tried to erase the first two 16KB sector. And that did not help either.

vanvught commented 1 year ago

I've successfully tested the dmx4 bootloader before publishing on GitHub. Currently, I do not have access to GD32F407 boards. I will make a setup tomorrow.

particlerain commented 1 year ago

Well it turned out that the dmx4 bootlader binary you provided does not work here.

One question: do i have to use the bootloader also with the SPI compiled if i wanna use the firmware compiled with SPI or can i use the bootloader compiled with RAM and firmware with SPI?

Because now i use bootloader v1.2 and firmware with SPI , and it can detect the ws25q32 and somehow i can store settings. But sometimes after power on off , the settings come back as garbage. And the device will get a 129.x.y.z ip. I thought maybe its because of the spi speed and spi_flash_internal.h and lowered it to 1mhz . Testing right now.

particlerain commented 1 year ago

What really is a problem for me is that sometimes when i press just the reset button the device will jump to the bootloader, so i have to press reset again a couple of times. I already put the 1.5k resistor to A11, but it still happens. Do you have an idea what causes this? Does this happens to you too?

vanvught commented 1 year ago

I have just checked the Rules.mk and CONSOLE_I2C is enabled -> https://github.com/vanvught/GD32F407RE-Bootloader-TFTP/blob/main/firmware-template-gd32/Rules.mk#L37 Hence there is no USART0 output.

Do you have an idea what causes this? Does this happens to you too?

No. There an internal pull-up which will do the job -> https://github.com/vanvught/GD32F407RE-Bootloader-TFTP/blob/main/bootloader-tftp/firmware/main.cpp#L64

vanvught commented 1 year ago

One question: do i have to use the bootloader also with the SPI compiled if i wanna use the firmware compiled with SPI or can i use the bootloader compiled with RAM and firmware with SPI?

It must match. Otherwise the settings made in the firmware are not the same as with the bootloader.

particlerain commented 1 year ago

It must match. Otherwise the settings made in the firmware are not the same as with the bootloader.

Well then, i also compiled the bootloader with SPI, but compilatons with SPI defined disables the bootloader from booting. I would be happy if you can test this issue when you have your setup ready.

vanvught commented 1 year ago

gd32f4xx.bin.zip

This is the bootloader with SPI flash support and with USART0 output.

particlerain commented 1 year ago

This one worked. Its booting and spitting on usart0. Also detecting the ws25xxx.

Why not my compilation though? I thought just defining in the Makefile.gd32: CONFIG_STORE_USE_SPI should be enough?

particlerain commented 1 year ago

Hey Arjan,

After i flashed your bin file with spi & usart0 support, it worked fine but now when i flash a different bootlader (also your bin v1.2 or v1.3 ) i can not start the tftp server anymore and can not flash the firmware. On terminal i get ARP lookup failed message. I did not change anything in the hardware. I dont know why this happens. Any idea?

Edit: Solved by deleting arp cache with arp-d. Also attached stable 3.3v supply.