marcelstoer / nodemcu-pyflasher

Self-contained NodeMCU flasher with GUI based on esptool.py and wxPython.
MIT License
1.48k stars 401 forks source link

Restart error after flashing #102

Closed LkySlevin closed 1 year ago

LkySlevin commented 1 year ago

Setup: I have an ESP32 firebeetle board with Chip ESP32-D0WD (revision v1.0). I usually use VScode - PlattformIO to build/flash my board, which works fine. For a colleague I wanted to test NodeMCU-PyFLash for him to upload my bin-files without any hussle.

Problem: However, no matter what setting I use DIO/DOUT/QIO, after flashing my serial port shows constantly

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371

This is the console output from NodeMCU-PyFlash:

Command: esptool.py --baud 460800 --after no_reset write_flash --flash_size detect --flash_mode dio 0x00000 C:\Users\Slevin\Desktop\Datalogger.bin

esptool.py v3.0
Found 1 serial ports
Serial port COM3
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WD (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 84:cc:a8:00:e7:94
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 16MB
Compressed 546304 bytes to 275331...
Wrote 546304 bytes (275331 compressed) at 0x00000000 in 6.6 seconds (effective 660.1 kbit/s)...
Hash of data verified.

Leaving...
Staying in bootloader.

Firmware successfully flashed. Unplug/replug or reset device 
to switch back to normal boot mode.

and this is the output from VScode:

Auto-detected: COM3
Uploading .pio\build\firebeetle32\firmware.bin
esptool.py v4.5.1
Serial port COM3
Connecting.....
Chip is ESP32-D0WD (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 84:cc:a8:00:e7:94
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00095fff...
Compressed 17488 bytes to 12168...
Writing at 0x00001000... (100 %)
Wrote 17488 bytes (12168 compressed) at 0x00001000 in 0.5 seconds (effective 285.4 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (effective 489.7 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 763.7 kbit/s)...
Hash of data verified.
Compressed 546320 bytes to 275345...
Writing at 0x00010000... (5 %)
Writing at 0x0001af75... (11 %)
Writing at 0x0002e96d... (17 %)
Writing at 0x00038b84... (23 %)
Writing at 0x0003df29... (29 %)
Writing at 0x000438b1... (35 %)
Writing at 0x00049518... (41 %)
Writing at 0x0004e8c0... (47 %)
Writing at 0x00053c17... (52 %)
Writing at 0x00059eba... (58 %)
Writing at 0x0006352e... (64 %)
Writing at 0x0006a4a1... (70 %)
Writing at 0x00072496... (76 %)
Writing at 0x00078901... (82 %)
Writing at 0x00080a69... (88 %)
Writing at 0x00089119... (94 %)
Writing at 0x00090cd0... (100 %)
Wrote 546320 bytes (275345 compressed) at 0x00010000 in 6.7 seconds (effective 655.3 kbit/s)...
Hash of data verified.

What I noted is that in VScode it starts writing to address 0x00010000, however, NodeMCU starts at 0x00000000. I assume this is the problem, but how can I make sure to avoid this and get my code running properly?

marcelstoer commented 1 year ago

in VScode it starts writing to address 0x00010000, however, NodeMCU starts at 0x00000000

Spot on! NodeMCU PyFlasher is an app to flash self-contained firmware binaries. Hence, it expects binaries that already contain a bootloader and partitions bin such that it can write it to 0x0000. PlattformIO on the other hand flashes the individual binaries separately, each to its correct address as per the partitions definition.

-> to build self-contained binaries see e.g. https://github.com/marcelstoer/docker-nodemcu-build/blob/master/build-esp32#L80-L85 or https://github.com/ThingPulse/icon64-word-clock/blob/master/aggregate_bin.sh