KooleControls / ESPTool

Created the Espressif ESPTool in native C#
12 stars 6 forks source link

bootloader problem rebooting #3

Closed KBS91WAW closed 9 months ago

KBS91WAW commented 2 years ago

Dear Sirs,

I used your code to develop easy programmer for multiple esp32-wroom-32UE.

I have .bin files generated by arduino-ide.

bootloader_dio_80m.bin --> 0x1000 partitions.bin --> 0x8000 boot_app0.bin --> 0xe000 program.bin --> 0x10000

First I program from Arduino-IDE and then all seems fine. When I load different program.bin from C# code I see program execution changing. So firmware loading works. Problem is with bootloader_dio_80m.bin loaded at 0x1000.

Then esp32 keeps rebooting: rst:0x3 (SW_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0030,len:1184 load:0x40078000,len:12812 load:0x40080400,len:3032 entry 0x400805e4

Maybe you had issue with replacing bootloader part?

Flashing once again with Arduin-IDE makes all correct working.

Regards, Chris

NeliusNDL commented 2 years ago

Hi I have a similar issue. Something must have recently changed in the "bootloader_dio_80m.bin", I have old devices in the field , when I upload new firmware.bin via OTA the fail to start up. The only way to recover them is to replace the "bootloader_dio_80m.bin" with the latest version.

KBS91WAW commented 2 years ago

Hello, I solved it in different way. I have noticed that when I program code from Arduino IDE then all runs correctly. So I programmed first unit from Arduino IDE and I read memory region 0- 0x10000 ( where bootloader is). esptool.exe --port COM30 --baud 921600 read_flash 0 0x10000 base.bin

Now when I load firmware by C# code I first put that base.bin at adress 0, and later firmware at 0x10000. All runs perfectly on every next unit I put program on.

NeliusNDL commented 2 years ago

seems like there is a hint here: https://github.com/esphome/esp-web-tools/issues/151#issuecomment-1004296924

"The First stage bootloader in ROM reads the Second stage bootloader header information from flash and uses this infomation to load the rest of the Second stage bootloader from flash. However, at this time the system clock speed is lower than configured and not all flash modes are supported. When the Second stage bootloader then runs, it will reconfigure the flash using values read from the currently selected app binary’s header (and NOT from the Second stage bootloader header). This allows an OTA update to change the SPI flash settings in use.

Bootloaders prior to ESP-IDF V4.0 used the bootloader’s own header to configure the SPI flash, meaning these values could not be changed in an update. To maintain compatibility with older bootloaders, the app re-initializes the flash settings during app startup using the configuration found in the app header.""

vanBassum commented 2 years ago

Hello,

I don't really have the time to dig into this issue right now. But I think this isn't an issue with the esptool but rather with an outdated bootloader you are trying to use. Am I correct in this assumption, if so would you mind closing this issue?

Ofcourse, if the problem still occurs you can keep the issue open so I can look into this later.

vanBassum commented 9 months ago

@KBS91WAW Can you confirm if this is a problem with the tool, or if it is on your end? I'll close this issue for now, since it's over a year old by now. If there is still a problem with the tool, please reopen the issue and let me know how I can reproduce this.