esp-rs / esp-idf-template

A "Hello, world!" template of a Rust binary crate for the ESP-IDF framework.
417 stars 50 forks source link

Boot loop after flash #27

Closed Trbe closed 1 year ago

Trbe commented 2 years ago

After I did cargo espflash --monitor /dev/ttyCH343USB0 then I get this

Serial port: /dev/ttyCH343USB0
Connecting...

    Finished dev [optimized + debuginfo] target(s) in 0.05s
Chip type:         ESP32-C3 (revision 3)
Crystal frequency: 40MHz
Flash size:        4MB
Features:          WiFi
MAC address:       60:55:f9:77:57:38
[00:00:01] ########################################      12/12      segment 0x0
[00:00:00] ########################################       1/1       segment 0x8000
[00:00:23] ########################################     212/212     segment 0x10000

Flashing has completed!
Commands:
    CTRL+R    Reset chip
    CTRL+C    Exit

�
 �ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x172c
load:0x3ce00000,len:0x92840
ets_loader.c 78
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x40049a42 [chip726_phyrom_version_num:??:??]
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x172c
load:0x3ce00000,len:0x92840
ets_loader.c 78
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x40049a42 [chip726_phyrom_version_num:??:??]
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x172c
load:0x3ce00000,len:0x92840
ets_loader.c 78
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x10 (RTCWDT_RTC_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x172c
load:0x3ce00000,len:0x92840
ets_loader.c 78
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x40049a42 [chip726_phyrom_version_num:??:??]
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x172c
load:0x3ce00000,len:0x92840
ets_loader.c 78
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x40049a42 [chip726_phyrom_version_num:??:??]
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x172c
load:0x3ce00000,len:0x92840
ets_loader.c 78
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x10 (RTCWDT_RTC_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x172c
load:0x3ce00000,len:0x92840
ets_loader.c 78
...

loop in rst:0x7 and rst:0x10 While I re-plug the board, it boots normally.

$~/.cargo/bin/espmonitor /dev/ttyCH343USB0

ESPMonitor 0.7.0

Commands:
    CTRL+R    Reset chip
    CTRL+C    Exit

Opening /dev/ttyCH343USB0 with speed 115200
Resetting device... done
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xd (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x172c
load:0x403ce000,len:0x928
load:0x403d0000,len:0x2ce0
entry 0x403ce000
I (30) boot: ESP-IDF v4.4-dev-2825-gb63ec47238 2nd stage bootloader
I (30) boot: compile time 12:10:40
I (30) boot: chip revision: 3
I (33) boot_comm: chip revision: 3, min. bootloader chip revision: 0
I (40) boot.esp32c3: SPI Speed      : 80MHz
I (45) boot.esp32c3: SPI Mode       : DIO
I (50) boot.esp32c3: SPI Flash Size : 4MB
I (55) boot: Enabling RNG early entropy source...
I (60) boot: Partition Table:
I (64) boot: ## Label            Usage          Type ST Offset   Length
I (71) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (78) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (86) boot:  2 factory          factory app      00 00 00010000 003f0000
I (93) boot: End of partition table
I (98) boot_comm: chip revision: 3, min. application chip revision: 0
I (105) esp_image: segment 0: paddr=00010020 vaddr=3c050020 size=19228h (102952) map
I (129) esp_image: segment 1: paddr=00029250 vaddr=3fc89c00 size=0152ch (  5420) load
I (130) esp_image: segment 2: paddr=0002a784 vaddr=40380000 size=05894h ( 22676) load
I (139) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=47f7ch (294780) map
I (187) esp_image: segment 4: paddr=00077fa4 vaddr=40385894 size=041b4h ( 16820) load
I (191) esp_image: segment 5: paddr=0007c160 vaddr=50000010 size=00010h (    16) load
I (196) boot: Loaded app from partition at offset 0x10000
I (199) boot: Disabling RNG early entropy source...
I (216) cpu_start: Pro cpu up.
I (224) cpu_start: Pro cpu start user code
I (224) cpu_start: cpu freq: 160000000
I (224) cpu_start: Application information:
I (227) cpu_start: Project name:     libespidf
I (232) cpu_start: App version:      1
I (237) cpu_start: Compile time:     May 27 2022 23:26:18
I (243) cpu_start: ELF file SHA256:  0000000000000000...
I (249) cpu_start: ESP-IDF:          692c1a6
I (254) heap_init: Initializing. RAM available for dynamic allocation:
I (261) heap_init: At 3FC8C040 len 00033FC0 (207 KiB): DRAM
I (267) heap_init: At 3FCC0000 len 0001F060 (124 KiB): STACK/DRAM
I (274) heap_init: At 50000020 len 00001FE0 (7 KiB): RTCRAM
I (281) spi_flash: detected chip: mxic
I (285) spi_flash: flash io: dio
I (289) sleep: Configure to isolate all GPIO pins in sleep state
I (295) sleep: Enable automatic switching of GPIO sleep configuration
I (303) cpu_start: Starting scheduler.
Hello, ESP32-C3!

It seems like the loading address is wrong.

MabezDev commented 2 years ago

Saved PC:0x40049a42 [chip726_phyrom_version_num:??:??]

This means it's hanging inside the ROM bootloader, the second stage bootloader (part of what is flashed to the board) isn't even running yet.

The fact when you cycle the power it starts working shows that everything is flashed correctly. Very strange :thinking:. What happens when you try and flash the board with esptool.py?

Trbe commented 2 years ago

@MabezDev I don't really know how to do that. But I tried esptool.py -c esp32c3 -p /dev/ttyCH343USB0 -b 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x10000 target/riscv32imc-esp-espidf/debug/esp-hello and get this

esptool.py v4.1
Serial port /dev/ttyCH343USB0
Connecting...
Failed to get PID of a device on /dev/ttyCH343USB0, using standard reset sequence.
.
Chip is ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 60:55:f9:77:57:38
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...

A fatal error occurred: File target/riscv32imc-esp-espidf/debug/esp-hello (length 15118644) at offset 65536 will not fit in 4194304 bytes of flash. Use --flash_size argument, or change flashing address.

I also tried esptool.py -c esp32c3 -p /dev/ttyCH343USB0 -b 921600 write_flash -z 0x10000 target/riscv32imc-esp-espidf/debug/esp-hello and get

esptool.py v4.1
Serial port /dev/ttyCH343USB0
Connecting...
Failed to get PID of a device on /dev/ttyCH343USB0, using standard reset sequence.
.
Chip is ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 60:55:f9:77:57:38
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00010000 to 0x00e78fff...
Compressed 15106792 bytes to 3662516...
Wrote 15106792 bytes (3662516 compressed) at 0x00010000 in 177.9 seconds (effective 679.2 kbit/s)...
File  md5: 7f1368e9cfa8b525ff5e88b32169fdd3
Flash md5: 16f35777ec98e430e2ed62c14572ba90
MD5 of 0xFF is 0a2e10eeb2a5361078456398d41c84ec

A fatal error occurred: MD5 of file does not match data in flash!

And the monitor shows

...
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid heade�ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x7 (TG0WDT_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
Saved PC:0x4004d1fa
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
invalid header: 0x00000000
...

I also test flash at 0x0, which gets the same result.

Trbe commented 2 years ago

More over, I tested the example under .espressif/esp-idf/release-v4.4/examples/get-started . I use the idf.py to build and flash, and everything goes right.

flash ``` % idf.py -p /dev/ttyCH343USB0 flash Executing action: flash Running ninja in directory /home/proben/.espressif/esp-idf/release-v4.4/examples/get-started/hello_world/build Executing "ninja flash"... [1/5] cd /home/proben/.espressif/esp-idf/release-v4.4/examples/get-started/hello_world/build/esp-idf/esptool_py &...ion-table.bin /home/proben/.espressif/esp-idf/release-v4.4/examples/get-started/hello_world/build/hello_world.bin hello_world.bin binary size 0x24d80 bytes. Smallest app partition is 0x100000 bytes. 0xdb280 bytes (86%) free. [2/5] Performing build step for 'bootloader' [1/1] cd /home/proben/.espressif/esp-idf/release-v4.4/examples/get-started/hello_world/build/bootloader/esp-idf/esptool_py && /home/proben/.espressif/python_env/idf4.4_py3.10_env/bin/python /home/proben/.espressif/esp-idf/release-v4.4/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x0 /home/proben/.espressif/esp-idf/release-v4.4/examples/get-started/hello_world/build/bootloader/bootloader.bin Bootloader binary size 0x4d80 bytes. 0x3280 bytes (39%) free. [2/3] cd /home/proben/.espressif/esp-idf/release-v4.4/components/esptool_py && /home/proben/.espressif/tools/cmak...ed/hello_world/build" -P /home/proben/.espressif/esp-idf/release-v4.4/components/esptool_py/run_serial_tool.cmake esptool.py esp32c3 -p /dev/ttyCH343USB0 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 4MB 0x0 bootloader/bootloader.bin 0x10000 hello_world.bin 0x8000 partition_table/partition-table.bin esptool.py v3.3.2-dev Serial port /dev/ttyCH343USB0 Connecting... Failed to get PID of a device on /dev/ttyCH343USB0, using standard reset sequence. . Chip is ESP32-C3 (revision 3) Features: Wi-Fi Crystal is 40MHz MAC: 60:55:f9:77:57:38 Uploading stub... Running stub... Stub running... Changing baud rate to 460800 Changed. Configuring flash size... Flash will be erased from 0x00000000 to 0x00004fff... Flash will be erased from 0x00010000 to 0x00034fff... Flash will be erased from 0x00008000 to 0x00008fff... Compressed 19840 bytes to 12029... Writing at 0x00000000... (100 %) Wrote 19840 bytes (12029 compressed) at 0x00000000 in 0.5 seconds (effective 294.9 kbit/s)... Hash of data verified. Compressed 150912 bytes to 81536... Writing at 0x00010000... (20 %) Writing at 0x0001996e... (40 %) Writing at 0x0002027d... (60 %) Writing at 0x00027476... (80 %) Writing at 0x0002d9f1... (100 %) Wrote 150912 bytes (81536 compressed) at 0x00010000 in 2.6 seconds (effective 455.8 kbit/s)... Hash of data verified. Compressed 3072 bytes to 103... Writing at 0x00008000... (100 %) Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 533.4 kbit/s)... Hash of data verified. Leaving... Hard resetting via RTS pin... Done ```
output ``` % idf.py -p /dev/ttyCH343USB0 monitor Executing action: monitor Running idf_monitor in directory /home/proben/.espressif/esp-idf/release-v4.4/examples/get-started/hello_world Executing "/home/proben/.espressif/python_env/idf4.4_py3.10_env/bin/python /home/proben/.espressif/esp-idf/release-v4.4/tools/idf_monitor.py -p /dev/ttyCH343USB0 -b 115200 --toolchain-prefix riscv32-esp-elf- --target esp32c3 --decode-panic backtrace /home/proben/.espressif/esp-idf/release-v4.4/examples/get-started/hello_world/build/hello_world.elf -m '/home/proben/.espressif/python_env/idf4.4_py3.10_env/bin/python' '/home/proben/.espressif/esp-idf/release-v4.4/tools/idf.py' '-p' '/dev/ttyCH343USB0'"... --- idf_monitor on /dev/ttyCH343USB0 115200 --- --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H --- ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x16cc load:0x403ce000,len:0x930 load:0x403d0000,len:0x2d28 entry 0x403ce000 I (30) boot: ESP-IDF v4.4.1-163-gfc3036990 2nd stage bootloader I (30) boot: compile time 00:25:33 I (30) boot: chip revision: 3 I (33) boot.esp32c3: SPI Speed : 80MHz I (38) boot.esp32c3: SPI Mode : DIO I (43) boot.esp32c3: SPI Flash Size : 4MB I (47) boot: Enabling RNG early entropy source... I (53) boot: Partition Table: I (56) boot: ## Label Usage Type ST Offset Length I (64) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (71) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (79) boot: 2 factory factory app 00 00 00010000 00100000 I (86) boot: End of partition table I (90) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=06c98h ( 27800) map I (103) esp_image: segment 1: paddr=00016cc0 vaddr=3fc8a200 size=01474h ( 5236) load I (108) esp_image: segment 2: paddr=0001813c vaddr=40380000 size=07edch ( 32476) load I (122) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=12a18h ( 76312) map I (136) esp_image: segment 4: paddr=00032a40 vaddr=40387edc size=02304h ( 8964) load I (138) esp_image: segment 5: paddr=00034d4c vaddr=50000010 size=00010h ( 16) load I (145) boot: Loaded app from partition at offset 0x10000 I (148) boot: Disabling RNG early entropy source... I (164) cpu_start: Pro cpu up. I (173) cpu_start: Pro cpu start user code I (173) cpu_start: cpu freq: 160000000 I (173) cpu_start: Application information: I (176) cpu_start: Project name: hello_world I (181) cpu_start: App version: v4.4.1-163-gfc3036990 I (187) cpu_start: Compile time: Jun 1 2022 00:25:30 I (194) cpu_start: ELF file SHA256: 16e2f24e1bfc6b56... I (200) cpu_start: ESP-IDF: v4.4.1-163-gfc3036990 I (206) heap_init: Initializing. RAM available for dynamic allocation: I (213) heap_init: At 3FC8C4E0 len 00033B20 (206 KiB): DRAM I (219) heap_init: At 3FCC0000 len 0001F060 (124 KiB): STACK/DRAM I (226) heap_init: At 50000020 len 00001FE0 (7 KiB): RTCRAM I (233) spi_flash: detected chip: mxic I (237) spi_flash: flash io: dio I (241) sleep: Configure to isolate all GPIO pins in sleep state I (247) sleep: Enable automatic switching of GPIO sleep configuration I (255) cpu_start: Starting scheduler. Hello world! This is esp32c3 chip with 1 CPU core(s), WiFi/BLE, silicon revision 3, 4MB external flash Minimum free heap size: 328892 bytes Restarting in 10 seconds... Restarting in 9 seconds... Restarting in 8 seconds... Restarting in 7 seconds... Restarting in 6 seconds... Restarting in 5 seconds... Restarting in 4 seconds... Restarting in 3 seconds... Restarting in 2 seconds... Restarting in 1 seconds... Restarting in 0 seconds... Restarting now. ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x3 (RTC_SW_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT) Saved PC:0x4038057a 0x4038057a: esp_restart_noos_dig at /home/proben/.espressif/esp-idf/release-v4.4/components/esp_system/esp_system.c:44 (discriminator 1) SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x16cc load:0x403ce000,len:0x930 load:0x403d0000,len:0x2d28 entry 0x403ce000 I (35) boot: ESP-IDF v4.4.1-163-gfc3036990 2nd stage bootloader I (35) boot: compile time 00:25:33 ... ```
MabezDev commented 2 years ago

Hey sorry this dropped off my radar, could you try again with the 1.6 release of espflash? Hopefully that fixes these strange issues!

Trbe commented 2 years ago

Oops, new errors.

build and flash ``` % cargo espflash --monitor /dev/ttyCH343USB0 Serial port: /dev/ttyCH343USB0 Connecting... Finished dev [optimized + debuginfo] target(s) in 0.05s Chip type: ESP32-C3 (revision 3) Crystal frequency: 40MHz Flash size: 4MB Features: WiFi MAC address: 60:55:f9:77:57:38 [00:00:01] ######################################## 12/12 segment 0x0 [00:00:00] ######################################## 1/1 segment 0x8000 [00:00:22] ######################################## 209/209 segment 0x10000 Flashing has completed! Commands: CTRL+R Reset chip CTRL+C Exit � �ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x16b4 load:0x3ce00000,len:0x93040 load:0x05436348,len:0x1384aaff Invalid image block, can't boot. ets_main.c 333 ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT) Saved PC:0x40047ed2 0x40047ed2 - chip726_phyrom_version_num at ??:?? SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x16b4 load:0x3ce00000,len:0x93040 load:0x05436348,len:0x1384aaff Invalid image block, can't boot. ets_main.c 333 ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT) Saved PC:0x40047ed2 0x40047ed2 - chip726_phyrom_version_num at ??:?? SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x16b4 load:0x3ce00000,len:0x93040 load:0x05436348,len:0x1384aaff Invalid image block, can't boot. ets_main.c 333 ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x10 (RTCWDT_RTC_RST),boot:0xc (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x16b4 load:0x3ce00000,len:0x93040 load:0x05436348,len:0x1384aaff Invalid image block, can't boot. ets_main.c 333 ... ```
re-plug ``` % ~/.cargo/bin/espmonitor /dev/ttyCH343USB0 ESPMonitor 0.10.0 Commands: CTRL+R Reset chip CTRL+C Exit Opening /dev/ttyCH343USB0 with speed 115200 Resetting device... done ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x16b4 load:0x403ce000,len:0x930 load:0x403d0000,len:0x2d28 SHA-256 comparison failed: Calculated: 1d0b6cb886e242c146ec7b08edea125baaad603db54764d975ad0ede9ca690e1 Expected: ce79d81cbc9eb8b3c144ab91af3b2017cd1705f94c238631ad1c82817d418aa9 Attempting to boot anyway... entry 0x403ce000 I (48) boot: ESP-IDF ee2029c 2nd stage bootloader I (49) boot: compile time 01:39:15 I (49) boot: chip revision: 3 I (50) boot.esp32c3: SPI Speed : 80MHz I (55) boot.esp32c3: SPI Mode : DIO I (60) boot.esp32c3: SPI Flash Size : 4MB I (65) boot: Enabling RNG early entropy source... I (70) boot: Partition Table: I (74) boot: ## Label Usage Type ST Offset Length I (81) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (88) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (96) boot: 2 factory factory app 00 00 00010000 00100000 I (103) boot: End of partition table I (107) boot_comm: chip revision: 3, min. application chip revision: 0 I (115) esp_image: segment 0: paddr=00010020 vaddr=3c050020 size=17418h ( 95256) map I (138) esp_image: segment 1: paddr=00027440 vaddr=3fc89c00 size=014ech ( 5356) load I (139) esp_image: segment 2: paddr=00028934 vaddr=40380000 size=076e4h ( 30436) load I (150) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=45208h (283144) map I (197) esp_image: segment 4: paddr=00075230 vaddr=403876e4 size=023a4h ( 9124) load I (199) esp_image: segment 5: paddr=000775dc vaddr=50000010 size=00010h ( 16) load I (205) boot: Loaded app from partition at offset 0x10000 I (208) boot: Disabling RNG early entropy source... I (225) cpu_start: Pro cpu up. I (234) cpu_start: Pro cpu start user code I (234) cpu_start: cpu freq: 160000000 I (234) cpu_start: Application information: I (237) cpu_start: Project name: libespidf I (242) cpu_start: App version: 1 I (246) cpu_start: Compile time: Jul 17 2022 01:39:13 I (252) cpu_start: ELF file SHA256: 0000000000000000... I (258) cpu_start: ESP-IDF: ee2029c I (263) heap_init: Initializing. RAM available for dynamic allocation: I (270) heap_init: At 3FC8C000 len 00034000 (208 KiB): DRAM I (277) heap_init: At 3FCC0000 len 0001F060 (124 KiB): STACK/DRAM I (283) heap_init: At 50000020 len 00001FE0 (7 KiB): RTCRAM I (290) spi_flash: detected chip: mxic I (294) spi_flash: flash io: dio I (298) sleep: Configure to isolate all GPIO pins in sleep state I (305) sleep: Enable automatic switching of GPIO sleep configuration I (312) cpu_start: Starting scheduler. Hello, world! ```
hyx0329 commented 1 year ago

I encounter the issue as well, posting my logs

It's okay to

use esptool.py ``` > esptool.py -c esp32c3 elf2image --flash_mode dio --flash_freq 80m --flash_size 4MB -o hi.bin target/riscv32imc-esp-espidf/debug/esp32c3-rust-hands-on esptool.py v4.3 Creating esp32c3 image... Merged 2 ELF sections Successfully created esp32c3 image. > file hi.bin hi.bin: DOS executable (COM), start instruction 0xe905022f 42043840 > esptool.py -c esp32c3 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x10000 hi.bin esptool.py v4.3 Serial port /dev/ttyACM0 Connecting.... Chip is ESP32-C3 (revision v0.3) Features: WiFi, BLE Crystal is 40MHz MAC: redacted Uploading stub... Running stub... Stub running... Changing baud rate to 921600 Changed. Configuring flash size... Flash will be erased from 0x00010000 to 0x0007bfff... Compressed 441728 bytes to 221467... Wrote 441728 bytes (221467 compressed) at 0x00010000 in 6.4 seconds (effective 556.3 kbit/s)... Hash of data verified. Leaving... Hard resetting via RTS pin... > espmonitor /dev/ttyACM0 ESPMonitor 0.10.0 Commands: CTRL+R Reset chip CTRL+C Exit Opening /dev/ttyACM0 with speed 115200 Resetting device... done ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x172c load:0x403ce000,len:0x928 load:0x403d0000,len:0x2ce0 entry 0x403ce000 I (30) boot: ESP-IDF v4.4-dev-2825-gb63ec47238 2nd stage bootloader I (30) boot: compile time 12:10:40 I (30) boot: chip revision: 3 I (33) boot_comm: chip revision: 3, min. bootloader chip revision: 0 I (40) boot.esp32c3: SPI Speed : 80MHz I (45) boot.esp32c3: SPI Mode : DIO I (50) boot.esp32c3: SPI Flash Size : 4MB I (55) boot: Enabling RNG early entropy source... I (60) boot: Partition Table: I (64) boot: ## Label Usage Type ST Offset Length I (71) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (78) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (86) boot: 2 factory factory app 00 00 00010000 003f0000 I (93) boot: End of partition table I (98) boot_comm: chip revision: 3, min. application chip revision: 0 I (105) esp_image: segment 0: paddr=00010020 vaddr=3c050020 size=1c078h (114808) map I (130) esp_image: segment 1: paddr=0002c0a0 vaddr=3fc89e00 size=01468h ( 5224) load I (132) esp_image: segment 2: paddr=0002d510 vaddr=40380000 size=02b08h ( 11016) load I (138) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=44b0ch (281356) map I (187) esp_image: segment 4: paddr=00074b34 vaddr=40382b08 size=0721ch ( 29212) load I (195) boot: Loaded app from partition at offset 0x10000 I (195) boot: Disabling RNG early entropy source... I (207) cpu_start: Pro cpu up. I (215) cpu_start: Pro cpu start user code I (216) cpu_start: cpu freq: 160000000 I (216) cpu_start: Application information: I (218) cpu_start: Project name: libespidf I (223) cpu_start: App version: 1 I (228) cpu_start: Compile time: Nov 17 2022 14:18:57 I (234) cpu_start: ELF file SHA256: 0000000000000000... I (240) cpu_start: ESP-IDF: 76caa64-dirty I (245) heap_init: Initializing. RAM available for dynamic allocation: I (253) heap_init: At 3FC8C190 len 00050580 (321 KiB): DRAM I (259) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM I (266) heap_init: At 50000020 len 00001FE0 (7 KiB): RTCRAM I (272) spi_flash: detected chip: mxic I (276) spi_flash: flash io: dio I (281) sleep: Configure to isolate all GPIO pins in sleep state I (287) sleep: Enable automatic switching of GPIO sleep configuration I (294) cpu_start: Starting scheduler. hi there! ```

but with default configuration(I added the --flash-mode DIO)

use espflash(cargo run) ``` > cargo run Finished dev [optimized + debuginfo] target(s) in 0.10s Running `espflash --monitor --flash-mode DIO target/riscv32imc-esp-espidf/debug/esp32c3-rust-hands-on` New version of espflash is available: v2.0.0-rc.1 Serial port: /dev/ttyACM0 Connecting... Chip type: ESP32-C3 (revision 3) Crystal frequency: 40MHz Flash size: 4MB Features: WiFi MAC address: redacted App/part. size: 441728/4128768 bytes, 10.70% [00:00:01] ######################################## 12/12 segment 0x0 [00:00:00] ######################################## 1/1 segment 0x8000 [00:00:23] ######################################## 217/217 segment 0x10000 Flashing has completed! Commands: CTRL+R Reset chip CTRL+C Exit ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x172c load:0x3ce00000,len:0x92840 load:0x08000000,len:0x0 Checksum failure. Calculated 0x18 stored 0x00 ets_main.c 333 ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT) Saved PC:0x40047ed2 0x40047ed2 - chip726_phyrom_version_num at ??:?? SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x172c load:0x3ce00000,len:0x92840 load:0x08000000,len:0x0 Checksum failure. Calculated 0x18 stored 0x00 ets_main.c 333 ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT) Saved PC:0x40047ed2 0x40047ed2 - chip726_phyrom_version_num at ??:?? SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x172c load:0x3ce00000,len:0x92840 ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x10 (RTCWDT_RTC_RST),boot:0xc (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x172c load:0x3ce00000,len:0x92840 load:0x08000000,len:0x0 Checksum failure. Calculated 0x18 stored 0x00 ets_main.c 333 ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT) Saved PC:0x40047ed2 0x40047ed2 - chip726_phyrom_version_num at ??:?? SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x172c load:0x3ce00000,len:0x92840 load:0x08000000,len:0x0 Checksum failure. Calculated 0x18 stored 0x00 ets_main.c 333 ^C > espmonitor /dev/ttyACM0 ESPMonitor 0.10.0 Commands: CTRL+R Reset chip CTRL+C Exit Opening /dev/ttyACM0 with speed 115200 Resetting device... done SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x172c load:0x3ce00000,len:0x92840 ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x10 (RTCWDT_RTC_RST),boot:0xc (SPI_FAST_FLASHx00 ets_main.c 333 ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x172c load:0x3ce00000,len:0x92840 load:0x08000000,len:0x0 Checksum failure. Calculated 0x18 stored 0x00 ets_main.c 333 ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT) Saved PC:0x40047ed2 SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x172c load:0x3ce00000,len:0x92840 load:0x08000000,len:0x0 Checksum failure. Calculated 0x18 stored 0x00 ets_main.c 333 ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT) Saved PC:0x40047ed2 SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x172c load:0x3ce00000,len:0x92840 ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x10 (RTCWDT_RTC_RST),boot:0xc (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x172c load:0x3ce00000,len:0x92840 load:0x08000000,len:0x0 Checksum failure. Calculated 0x18 stored 0x00 ets_main.c 333 ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT) Saved PC:0x40047ed2 SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x172c load:0x3ce00000,len:0x92840 load:0x08000000,len:0x0 Checksum failure. Calculated 0x18 stored 0x00 ets_main.c 333 ```

after comparison, I found that when ram stub is used(add --use-stub), it works

cargo run with ram stub ``` > cargo run Finished dev [optimized + debuginfo] target(s) in 0.11s Running `espflash --monitor --flash-mode DIO --use-stub target/riscv32imc-esp-espidf/debug/esp32c3-rust-hands-on` New version of espflash is available: v2.0.0-rc.1 Serial port: /dev/ttyACM0 Connecting... Using flash stub Chip type: ESP32-C3 (revision 3) Crystal frequency: 40MHz Flash size: 4MB Features: WiFi MAC address: redacted App/part. size: 441728/4128768 bytes, 10.70% [00:00:01] ######################################## 12/12 segment 0x0 [00:00:00] ######################################## 1/1 segment 0x8000 [00:00:22] ######################################## 217/217 segment 0x10000 Flashing has completed! Commands: CTRL+R Reset chip CTRL+C Exit ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd6100,len:0x172c load:0x403ce000,len:0x928 0x403ce000 - _iram_data_end at ??:?? load:0x403d0000,len:0x2ce0 0x403d0000 - _iram_data_end at ??:?? entry 0x403ce000 0x403ce000 - _iram_data_end at ??:?? I (30) boot: ESP-IDF v4.4-dev-2825-gb63ec47238 2nd stage bootloader I (30) boot: compile time 12:10:40 I (30) boot: chip revision: 3 I (33) boot_comm: chip revision: 3, min. bootloader chip revision: 0 I (40) boot.esp32c3: SPI Speed : 80MHz I (45) boot.esp32c3: SPI Mode : DIO I (50) boot.esp32c3: SPI Flash Size : 4MB I (55) boot: Enabling RNG early entropy source... I (60) boot: Partition Table: I (64) boot: ## Label Usage Type ST Offset Length I (71) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (78) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (86) boot: 2 factory factory app 00 00 00010000 003f0000 I (93) boot: End of partition table I (98) boot_comm: chip revision: 3, min. application chip revision: 0 I (105) esp_image: segment 0: paddr=00010020 vaddr=3c050020 size=1c078h (114808) map I (130) esp_image: segment 1: paddr=0002c0a0 vaddr=3fc89e00 size=01468h ( 5224) load I (132) esp_image: segment 2: paddr=0002d510 vaddr=40380000 size=02b08h ( 11016) load I (138) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=44b0ch (281356) map I (187) esp_image: segment 4: paddr=00074b34 vaddr=40382b08 size=0721ch ( 29212) load I (195) boot: Loaded app from partition at offset 0x10000 I (195) boot: Disabling RNG early entropy source... I (207) cpu_start: Pro cpu up. I (215) cpu_start: Pro cpu start user code I (216) cpu_start: cpu freq: 160000000 I (216) cpu_start: Application information: I (218) cpu_start: Project name: libespidf I (223) cpu_start: App version: 1 I (228) cpu_start: Compile time: Nov 17 2022 14:18:57 I (234) cpu_start: ELF file SHA256: 0000000000000000... I (240) cpu_start: ESP-IDF: 76caa64-dirty I (245) heap_init: Initializing. RAM available for dynamic allocation: I (253) heap_init: At 3FC8C190 len 00050580 (321 KiB): DRAM I (259) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM I (266) heap_init: At 50000020 len 00001FE0 (7 KiB): RTCRAM I (272) spi_flash: detected chip: mxic I (276) spi_flash: flash io: dio I (281) sleep: Configure to isolate all GPIO pins in sleep state I (287) sleep: Enable automatic switching of GPIO sleep configuration I (294) cpu_start: Starting scheduler. hi there! ```
MabezDev commented 1 year ago

So I found out that some flash chips soldered to dev boards (I believe some XMC chips) behave very strangely and the ROM bootloader may not know about this, which could be why it fails. The stub has workarounds for these chips so that should be used instead. Soon we will switch to using the stub by default but for now you should pass --use-stub to espflash.