esp32-c3 keeps rebooting before even going into app_main()

Sunbelt57
Posts: 24
Joined: Wed Feb 12, 2025 5:41 pm
Location: Eastern Wyoming

esp32-c3 keeps rebooting before even going into app_main()

Postby Sunbelt57 » Sun Sep 07, 2025 9:15 pm

I'm try to flash the example code for protocols/sockets/tcp_client and it keeps rebooting with the following from the monitor:

Code: Select all

[803/804] Generating binary image from built executable
esptool.py v4.10.dev2
Creating esp32c3 image...
Merged 1 ELF section
Successfully created esp32c3 image.
Generated /home/dan/dev/esp/esp-idf/examples/protocols/sockets/tcp_client/build/tcp_client.bin
[804/804] cd /home/dan/dev/esp/esp-idf/examples/protocols/sockets/tcp_client/build/esp-idf/e...ble.bin /home/dan/dev/esp/esp-idf/examples/protocols/sockets/tcp_client/build/tcp_client.bin
tcp_client.bin binary size 0xd3240 bytes. Smallest app partition is 0x100000 bytes. 0x2cdc0 bytes (18%) free.

Project build complete. To flash, run:
 idf.py flash
or
 idf.py -p PORT flash
or
 python -m esptool --chip esp32c3 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 2MB --flash_freq 80m 0x0 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin 0x10000 build/tcp_client.bin
or from the "/home/dan/dev/esp/esp-idf/examples/protocols/sockets/tcp_client/build" directory
 python -m esptool --chip esp32c3 -b 460800 --before default_reset --after hard_reset write_flash "@flash_args"
Executing action: flash
Running ninja in directory /home/dan/dev/esp/esp-idf/examples/protocols/sockets/tcp_client/build
Executing "ninja flash"...
[1/5] cd /home/dan/dev/esp/esp-idf/examples/protocols/sockets/tcp_client/build/esp-idf/espto...ble.bin /home/dan/dev/esp/esp-idf/examples/protocols/sockets/tcp_client/build/tcp_client.bin
tcp_client.bin binary size 0xd3240 bytes. Smallest app partition is 0x100000 bytes. 0x2cdc0 bytes (18%) free.
[1/1] cd /home/dan/dev/esp/esp-idf/examples/protocols/sockets/tcp_client/build/bootloader/es...me/dan/dev/esp/esp-idf/examples/protocols/sockets/tcp_client/build/bootloader/bootloader.bin
Bootloader binary size 0x4ec0 bytes. 0x3140 bytes (38%) free.
[4/5] cd /home/dan/dev/esp/esp-idf/components/esptool_py && /usr/bin/cmake -D IDF_PATH=/home...ts/tcp_client/build -P /home/dan/dev/esp/esp-idf/components/esptool_py/run_serial_tool.cmake
esptool.py --chip esp32c3 -p /dev/ttyACM0 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 2MB 0x0 bootloader/bootloader.bin 0x10000 tcp_client.bin 0x8000 partition_table/partition-table.bin
esptool.py v4.10.dev2
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-C3 (QFN32) (revision v0.4)
Features: WiFi, BLE, Embedded Flash 4MB (XMC)
Crystal is 40MHz
USB mode: USB-Serial/JTAG
MAC: 98:3d:ae:ab:e5:94
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 0x000e3fff...
Flash will be erased from 0x00008000 to 0x00008fff...
SHA digest in image updated
Compressed 20160 bytes to 12654...
Writing at 0x00000000... (100 %)
Wrote 20160 bytes (12654 compressed) at 0x00000000 in 0.3 seconds (effective 620.2 kbit/s)...
Hash of data verified.
Compressed 864832 bytes to 488805...
Writing at 0x000ddd9b... (100 %)
Wrote 864832 bytes (488805 compressed) at 0x00010000 in 6.2 seconds (effective 1124.0 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 629.8 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
Done
Executing action: monitor
Running idf_monitor in directory /home/dan/dev/esp/esp-idf/examples/protocols/sockets/tcp_client
Executing "/home/dan/.espressif/python_env/idf5.5_py3.12_env/bin/python /home/dan/dev/esp/esp-idf/tools/idf_monitor.py -p /dev/ttyACM0 -b 115200 --toolchain-prefix riscv32-esp-elf- --target esp32c3 --revision 3 --decode-panic backtrace /home/dan/dev/esp/esp-idf/examples/protocols/sockets/tcp_client/build/tcp_client.elf /home/dan/dev/esp/esp-idf/examples/protocols/sockets/tcp_client/build/tcp_server.elf /home/dan/dev/esp/esp-idf/examples/protocols/sockets/tcp_client/build/bootloader/bootloader.elf -m '/home/dan/.espressif/python_env/idf5.5_py3.12_env/bin/python' '/home/dan/dev/esp/esp-idf/tools/idf.py' '-p' '/dev/ttyACM0'"...
--- esp-idf-monitor 1.7.0 on /dev/ttyACM0 115200
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
I (216) esp_image: segment 4: paddr=000cd894 vaddr=40380634 sizeESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x403808f8
--- 0x403808f8: panic_enable_cache at /home/dan/dev/esp/esp-idf/components/esp_system/port/panic_handler.c:275
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x15b8
load:0x403cbf10,len:0xbf8
load:0x403ce710,len:0x2cb4
--- 0x403cbf10: esp_bootloader_get_description at /home/dan/dev/esp/esp-idf/components/esp_bootloader_format/esp_bootloader_desc.c:39
--- 0x403ce710: esp_flash_encryption_enabled at /home/dan/dev/esp/esp-idf/components/bootloader_support/src/flash_encrypt.c:89
--- 0x403cbf1a: call_start_cpu0 at /home/dan/dev/esp/esp-idf/components/bootloader/subproject/main/bootloader_start.c:25
entry 0x403cbf1a
I (24) boot: ESP-IDF v5.5-dev-2183-gba8cb3a6ef-dirty 2nd stage bootloader
I (24) boot: compile time Sep  7 2025 15:05:55
I (25) boot: chip revision: v0.4
I (27) boot: efuse block revision: v1.3
I (30) boot.esp32c3: SPI Speed      : 80MHz
I (34) boot.esp32c3: SPI Mode       : DIO
I (38) boot.esp32c3: SPI Flash Size : 2MB
I (42) boot: Enabling RNG early entropy source...
I (46) boot: Partition Table:
I (49) boot: ## Label            Usage          Type ST Offset   Length
I (55) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (61) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (68) boot:  2 factory          factory app      00 00 00010000 00100000
I (74) boot: End of partition table
I (78) esp_image: segment 0: paddr=00010020 vaddr=3c0a0020 size=1cb74h (117620) map
I (104) esp_image: segment 1: paddr=0002cb9c vaddr=3fc96000 size=02e40h ( 11840) load
I (106) esp_image: segment 2: paddr=0002f9e4 vaddr=40380000 size=00634h (  1588) load
I (108) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=9d86ch (645228) map
I (216) esp_image: segment 4: paddr=000cd894 vaddr=40380634 size=1595ch ( 88412) load
I (232) esp_image: segment 5: paddr=000e31f8 vaddr=50000000 size=0001ch (    28) load
I (238) boot: Loaded app from partition at offset 0x10000
I (239) boot: Disabling RNG early entropy source...
I (249) cpu_start: Unicore app
I (258) cpu_start: Pro cpu start user code
I (258) cpu_start: cpu freq: 160000000 Hz
I (258) app_init: Application information:
I (258) app_init: Project name:     tcp_client
I (262) app_init: App version:      v5.5-dev-2183-gba8cb3a6ef-dirty
I (268) app_init: Compile time:     Sep  7 2025 15:06:06
I (273) app_init: ELF file SHA256:  5cc1ae039...
I (277) app_init: ESP-IDF:          v5.5-dev-2183-gba8cb3a6ef-dirty
I (283) efuse_init: Min chip rev:     v0.3
I (287) efuse_init: Max chip rev:     v1.99
I (291) efuse_init: Chip rev:         v0.4
I (295) heap_init: Initializing. RAM available for dynamic allocation:
I (301) heap_init: At 3FC9D180 len 00022E80 (139 KiB): RAM
I (307) heap_init: At 3FCC0000 len 0001C710 (113 KiB): Retention RAM
I (313) heap_init: At 3FCDC710 len 00002950 (10 KiB): Retention RAM
I (319) heap_init: At 5000001C len 00001FCC (7 KiB): RTCRAM
I (325) spi_flash: detected chip: generic
I (328) spi_flash: flash io: dio
W (331) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (343) sleep_gpio: Configure to isolate all GPIO pins in sleep state
I (349) sleep_gpio: Enable automatic switching of GPIO sleep configuration
I (356) main_task: Started on CPU0
I (356) main_task: Calling app_main()
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x8 (TG1WDT_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40380104
--- 0x40380104: _panic_handler at /home/dan/dev/esp/esp-idf/components/riscv/vectors.S:207
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x15b8
load:0x403cbf10,len:0xbf8
--- 0x403cbf10: esp_bootloader_get_description at /home/dan/dev/esp/esp-idf/components/esp_bootloader_format/esp_bootloader_desc.c:39
load:0x403ce710,len:0x2cb4
--- 0x403ce710: esp_flash_encryption_enabled at /home/dan/dev/esp/esp-idf/components/bootloader_support/src/flash_encrypt.c:89
entry 0x403cbf1a
--- 0x403cbf1a: call_start_cpu0 at /home/dan/dev/esp/esp-idf/components/bootloader/subproject/main/bootloader_start.c:25
I (24) boot: ESP-IDF v5.5-dev-2183-gba8cb3a6ef-dirty 2nd stage bootloader
I (24) boot: compile time Sep  7 2025 15:05:55
I (24) boot: chip revision: v0.4
I (26) boot: efuse block revision: v1.3
I (30) boot.esp32c3: SPI Speed      : 80MHz
I (34) boot.esp32c3: SPI Mode       : DIO
I (37) boot.esp32c3: SPI Flash Size : 2MB
W (41) boot.esp32c3: PRO CPU has been reset by WDT.
I (46) boot: Enabling RNG early entropy source...
I (50) boot: Partition Table:
I (53) boot: ## Label            Usage          Type ST Offset   Length
I (59) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (66) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (72) boot:  2 factory          factory app      00 00 00010000 00100000
I (79) boot: End of partition table
I (82) esp_image: segment 0: paddr=00010020 vaddr=3c0a0020 size=1cb74h (117620) map
I (108) esp_image: segment 1: paddr=0002cb9c vaddr=3fc96000 size=02e40h ( 11840) load
I (110) esp_image: segment 2: paddr=0002f9e4 vaddr=40380000 size=00634h (  1588) load
I (112) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=9d86ch (645228) map
I (220) esp_image: segment 4: paddr=000cd894 vaddr=40380634 size=1595ch ( 88412) load
I (236) esp_image: segment 5: paddr=000e31f8 vaddr=50000000 size=0001ch (    28) load
I (243) boot: Loaded app from partition at offset 0x10000
I (243) boot: Disabling RNG early entropy source...
I (253) cpu_start: Unicore app
I (262) cpu_start: Pro cpu start user code
I (262) cpu_start: cpu freq: 160000000 Hz
I (262) app_init: Application information:
I (262) app_init: Project name:     tcp_client
I (266) app_init: App version:      v5.5-dev-2183-gba8cb3a6ef-dirty
I (272) app_init: Compile time:     Sep  7 2025 15:06:06
I (277) app_init: ELF file SHA256:  5cc1ae039...
I (282) app_init: ESP-IDF:          v5.5-dev-2183-gba8cb3a6ef-dirty
I (288) efuse_init: Min chip rev:     v0.3
I (291) efuse_init: Max chip rev:     v1.99
I (295) efuse_init: Chip rev:         v0.4
I (299) heap_init: Initializing. RAM available for dynamic allocation:
I (306) heap_init: At 3FC9D180 len 00022E80 (139 KiB): RAM
I (311) heap_init: At 3FCC0000 len 0001C710 (113 KiB): Retention RAM
I (317) heap_init: At 3FCDC710 len 00002950 (10 KiB): Retention RAM
I (323) heap_init: At 5000001C len 00001FCC (7 KiB): RTCRAM
I (329) spi_flash: detected chip: generic
I (332) spi_flash: flash io: dio
W (335) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (347) sleep_gpio: Configure to isolate all GPIO pins in sleep state
I (353) sleep_gpio: Enable automatic switching of GPIO sleep configuration
I (360) main_task: Started on CPU0
I (360) main_task: Calling app_main()
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x8 (TG1WDT_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40380000
--- 0x40380000: _vector_table at /home/dan/dev/esp/esp-idf/components/riscv/vectors_intc.S:54
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x15b8
load:0x403cbf10,len:0xbf8
--- 0x403cbf10: esp_bootloader_get_description at /home/dan/dev/esp/esp-idf/components/esp_bootloader_format/esp_bootloader_desc.c:39
load:0x403ce710,len:0x2cb4
--- 0x403ce710: esp_flash_encryption_enabled at /home/dan/dev/esp/esp-idf/components/bootloader_support/src/flash_encrypt.c:89
entry 0x403cbf1a
I (24) boot: ESP-IDF v5.5-dev-2183-gba8cb3a6ef-dirty 2nd stage bootloader
I (24) boot: compile time Sep  7 2025 15:05:55
I (24) boot: chip revision: v0.4
I (26) boot: efuse block revision: v1.3
I (30) boot.esp32c3: SPI Speed      : 80MHz
I (34) boot.esp32c3: SPI Mode       : DIO
I (37) boot.esp32c3: SPI Flash Size : 2MB
W (41) boot.esp32c3: PRO CPU has been reset by WDT.
I (46) boot: Enabling RNG early entropy source...
I (50) boot: Partition Table:
I (53) boot: ## Label            Usage          Type ST Offset   Length
I (59) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (66) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (72) boot:  2 factory          factory app      00 00 00010000 00100000
--- 0x403cbf1a: call_start_cpu0 at /home/dan/dev/esp/esp-idf/components/bootloader/subproject/main/bootloader_start.c:25
I (79) boot: End of partition table
I (82) esp_image: segment 0: paddr=00010020 vaddr=3c0a0020 size=1cb74h (117620) map


Sunbelt57
Posts: 24
Joined: Wed Feb 12, 2025 5:41 pm
Location: Eastern Wyoming

Re: esp32-c3 keeps rebooting before even going into app_main()

Postby Sunbelt57 » Sun Sep 07, 2025 9:16 pm

at line 147:

Code: Select all

W (41) boot.esp32c3: PRO CPU has been reset by WDT.
I went into the menuconfig and disabled the watchdog timer

Sunbelt57
Posts: 24
Joined: Wed Feb 12, 2025 5:41 pm
Location: Eastern Wyoming

Re: esp32-c3 keeps rebooting before even going into app_main()

Postby Sunbelt57 » Sun Sep 07, 2025 9:42 pm

Nevermind, I didn't use the set-target command:

Code: Select all

idf.py set-target ESP32-C3

ahsrabrifat
Posts: 201
Joined: Sat Jan 18, 2025 2:31 pm

Re: esp32-c3 keeps rebooting before even going into app_main()

Postby ahsrabrifat » Mon Sep 08, 2025 3:41 pm

Your board’s chip has 4MB flash.

The app was built with a 2MB flash setting (--flash_size 2MB in your esptool line).

That means the image header doesn’t match the actual hardware, and the IDF chooses the smaller size (2MB), which can cause mis-addressing and watchdog resets.
Reconfigure the project to use the correct flash size:

Code: Select all

idf.py menuconfig
Go to: Serial flasher config → Flash size

Set it to 4 MB (not 2 MB).

Then idf.py fullclean && idf.py build flash monitor.

MicroController
Posts: 2663
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: esp32-c3 keeps rebooting before even going into app_main()

Postby MicroController » Tue Sep 09, 2025 8:15 am

Your board’s chip has 4MB flash.

The app was built with a 2MB flash setting ...
which can cause mis-addressing and watchdog resets.
No, this is not the case.

Sunbelt57
Posts: 24
Joined: Wed Feb 12, 2025 5:41 pm
Location: Eastern Wyoming

Re: esp32-c3 keeps rebooting before even going into app_main()

Postby Sunbelt57 » Tue Sep 09, 2025 8:39 pm

Your board’s chip has 4MB flash.

The app was built with a 2MB flash setting (--flash_size 2MB in your esptool line).

That means the image header doesn’t match the actual hardware, and the IDF chooses the smaller size (2MB), which can cause mis-addressing and watchdog resets.
Reconfigure the project to use the correct flash size:

Code: Select all

idf.py menuconfig
Go to: Serial flasher config → Flash size

Set it to 4 MB (not 2 MB).

Then idf.py fullclean && idf.py build flash monitor.
This works.

Who is online

Users browsing this forum: meta-externalagent, PetalBot and 5 guests