Hi - I’m new to ESP32 and PlatformIO. I am using the ESP-Prog and haven’t been able to get debugging to work correctly.
Here is my setup:
Forum rules for new users wouldn’t let me add pictures, but I can take pictures of my setup if they are helpful.
This is my platformio.ini file:
[env:esp32-s2-saola-1]
platform = espressif32
board = esp32-s2-saola-1
framework = espidf
debug_tool = esp-prog
upload_port = COM7
upload_protocol = esp-prog
monitor_speed = 115200
debug_speed = 500
; force debug mode during normal build & upload (makes backtrace symbols available)
build_type = debug
; enable exception decoding when seen on the serial
monitor_filters = esp32_exception_decoder
debug_init_break = tbreak setup
I’ve used the zadig tool and have one Com port that is the connection to the board’s serial - COM7 and have the remaining USB serial converter B.
I’m using the example hello world code:
#include <stdio.h> #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_system.h" #include "esp_spi_flash.h" void app_main() { printf("Hello world!\n"); /* Print chip information */ esp_chip_info_t chip_info; esp_chip_info(&chip_info); printf("This is ESP32 chip with %d CPU cores, WiFi%s%s, ", chip_info.cores, (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); printf("silicon revision %d, ", chip_info.revision); printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024), (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); for (int i = 10; i >= 0; i--) { printf("Restarting in %d seconds...\n", i); vTaskDelay(1000 / portTICK_PERIOD_MS); } printf("Restarting now.\n"); fflush(stdout); //esp_restart(); }
The code builds, uploads, and has the correct output when I monitor.
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6100,len:0x1a04
load:0x4004c000,len:0xb74
load:0x40050000,len:0x3220
entry 0x4004c25c
I (21) boot: ESP-IDF 4.3.1 2nd stage bootloader
I (21) boot: compile time 18:01:52
I (21) boot: chip revision: 0
I (24) boot.esp32s2: SPI Speed : 80MHz
I (29) boot.esp32s2: SPI Mode : DIO
I (33) boot.esp32s2: SPI Flash Size : 4MB
I (38) boot: Enabling RNG early entropy source…
I (43) boot: Partition Table:
I (47) boot: ## Label Usage Type ST Offset Length
I (54) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (62) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (69) boot: 2 factory factory app 00 00 00010000 00100000
I (77) boot: End of partition table
I (81) esp_image: segment 0: paddr=00010020 vaddr=3f000020 size=074a8h ( 29864) map
I (95) esp_image: segment 1: paddr=000174d0 vaddr=3ffbc9b0 size=028e8h ( 10472) load
I (100) esp_image: segment 2: paddr=00019dc0 vaddr=40022000 size=06258h ( 25176) load
I (112) esp_image: segment 3: paddr=00020020 vaddr=40080020 size=14628h ( 83496) map
I (129) esp_image: segment 4: paddr=00034650 vaddr=40028258 size=04754h ( 18260) load
I (134) esp_image: segment 5: paddr=00038dac vaddr=50000000 size=00010h ( 16) load
I (141) boot: Loaded app from partition at offset 0x10000
I (141) boot: Disabling RNG early entropy source…
I (158) cache: Instruction cache : size 8KB, 4Ways, cache line size 32Byte
�� 0����iW�5х����%���Ձ�����j5R"B���J��͕�J�UM} 1-��}Q��I�J́�͕�����́�х�ѥ�����ѡ����m��j
5R"B���J����E5�5����5�j
�V,+K�W,W��
�W,�W�’�M��&S���+L[ C�I (181) cpu_start: Pro cpu start user code
I (182) cpu_start: cpu freq: 160000000
I (182) cpu_start: Application information:
I (186) cpu_start: Project name: EspHelloWorld
I (192) cpu_start: App version: 1
I (196) cpu_start: Compile time: Jan 27 2022 17:59:31
I (202) cpu_start: ELF file SHA256: ce99202b632f75f9…
I (208) cpu_start: ESP-IDF: 4.3.1
V (213) memory_layout: reserved range is 0x3f0074a8 - 0x3f0074c8
D (219) memory_layout: Checking 4 reserved memory ranges:
D (224) memory_layout: Reserved memory range 0x3ff9e000 - 0x3ff9e000
D (231) memory_layout: Reserved memory range 0x3ffb2000 - 0x3ffbc9ac
D (237) memory_layout: Reserved memory range 0x3ffbc9b0 - 0x3ffbfac0
D (244) memory_layout: Reserved memory range 0x3ffffa10 - 0x40000000
D (250) memory_layout: Building list of available memory regions:
V (256) memory_layout: Examining memory region 0x3ff9e000 - 0x3ffa0000
D (263) memory_layout: Available memory region 0x3ff9e000 - 0x3ffa0000
V (269) memory_layout: Examining memory region 0x3ffb2000 - 0x3ffb4000
V (276) memory_layout: Region 0x3ffb2000 - 0x3ffb4000 inside of reserved 0x3ffb2000 - 0x3ffbc9ac
V (285) memory_layout: Examining memory region 0x3ffb4000 - 0x3ffb6000
V (292) memory_layout: Region 0x3ffb4000 - 0x3ffb6000 inside of reserved 0x3ffb2000 - 0x3ffbc9ac
V (300) memory_layout: Examining memory region 0x3ffb6000 - 0x3ffb8000
V (307) memory_layout: Region 0x3ffb6000 - 0x3ffb8000 inside of reserved 0x3ffb2000 - 0x3ffbc9ac
V (316) memory_layout: Examining memory region 0x3ffb8000 - 0x3ffbc000
V (322) memory_layout: Region 0x3ffb8000 - 0x3ffbc000 inside of reserved 0x3ffb2000 - 0x3ffbc9ac
V (331) memory_layout: Examining memory region 0x3ffbc000 - 0x3ffc0000
V (338) memory_layout: Start of region 0x3ffbc000 - 0x3ffc0000 overlaps reserved 0x3ffb2000 - 0x3ffbc9ac
V (347) memory_layout: Region 0x3ffbc9ac - 0x3ffc0000 contains reserved 0x3ffbc9b0 - 0x3ffbfac0
V (356) memory_layout: Examining memory region 0x3ffbfac0 - 0x3ffc0000
D (363) memory_layout: Available memory region 0x3ffbfac0 - 0x3ffc0000
V (369) memory_layout: Examining memory region 0x3ffc0000 - 0x3ffc4000
D (376) memory_layout: Available memory region 0x3ffc0000 - 0x3ffc4000
V (383) memory_layout: Examining memory region 0x3ffc4000 - 0x3ffc8000
D (389) memory_layout: Available memory region 0x3ffc4000 - 0x3ffc8000
V (396) memory_layout: Examining memory region 0x3ffc8000 - 0x3ffcc000
D (402) memory_layout: Available memory region 0x3ffc8000 - 0x3ffcc000
V (409) memory_layout: Examining memory region 0x3ffcc000 - 0x3ffd0000
D (416) memory_layout: Available memory region 0x3ffcc000 - 0x3ffd0000
V (422) memory_layout: Examining memory region 0x3ffd0000 - 0x3ffd4000
D (429) memory_layout: Available memory region 0x3ffd0000 - 0x3ffd4000
V (435) memory_layout: Examining memory region 0x3ffd4000 - 0x3ffd8000
D (442) memory_layout: Available memory region 0x3ffd4000 - 0x3ffd8000
V (449) memory_layout: Examining memory region 0x3ffd8000 - 0x3ffdc000
D (455) memory_layout: Available memory region 0x3ffd8000 - 0x3ffdc000
V (462) memory_layout: Examining memory region 0x3ffdc000 - 0x3ffe0000
D (468) memory_layout: Available memory region 0x3ffdc000 - 0x3ffe0000
V (475) memory_layout: Examining memory region 0x3ffe0000 - 0x3ffe4000
D (482) memory_layout: Available memory region 0x3ffe0000 - 0x3ffe4000
V (488) memory_layout: Examining memory region 0x3ffe4000 - 0x3ffe8000
D (495) memory_layout: Available memory region 0x3ffe4000 - 0x3ffe8000
V (501) memory_layout: Examining memory region 0x3ffe8000 - 0x3ffec000
D (508) memory_layout: Available memory region 0x3ffe8000 - 0x3ffec000
V (515) memory_layout: Examining memory region 0x3ffec000 - 0x3fff0000
D (521) memory_layout: Available memory region 0x3ffec000 - 0x3fff0000
V (528) memory_layout: Examining memory region 0x3fff0000 - 0x3fff4000
D (534) memory_layout: Available memory region 0x3fff0000 - 0x3fff4000
V (541) memory_layout: Examining memory region 0x3fff4000 - 0x3fff8000
D (547) memory_layout: Available memory region 0x3fff4000 - 0x3fff8000
V (554) memory_layout: Examining memory region 0x3fff8000 - 0x3fffc000
D (561) memory_layout: Available memory region 0x3fff8000 - 0x3fffc000
V (567) memory_layout: Examining memory region 0x3fffc000 - 0x40000000
V (574) memory_layout: End of region 0x3fffc000 - 0x40000000 overlaps reserved 0x3ffffa10 - 0x40000000
D (583) memory_layout: Available memory region 0x3fffc000 - 0x3ffffa10
I (590) heap_init: Initializing. RAM available for dynamic allocation:
D (597) heap_init: New heap initialised at 0x3ff9e000
I (602) heap_init: At 3FF9E000 len 00002000 (8 KiB): RTCRAM
D (608) heap_init: New heap initialised at 0x3ffbfac0
I (614) heap_init: At 3FFBFAC0 len 0003C540 (241 KiB): DRAM
I (620) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM
D (626) FLASH_HAL: extra_dummy: 0
V (629) memspi: raw_chip_id: 164020
V (633) memspi: chip_id: 204016
V (636) memspi: raw_chip_id: 164020
V (640) memspi: chip_id: 204016
D (644) spi_flash: trying chip: issi
D (647) spi_flash: trying chip: gd
D (651) spi_flash: trying chip: mxic
D (654) spi_flash: trying chip: winbond
D (658) spi_flash: trying chip: boya
D (662) spi_flash: trying chip: generic
I (666) spi_flash: detected chip: generic
I (671) spi_flash: flash io: dio
D (675) cpu_start: calling init function: 0x40080c28
V (680) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (686) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xE0E
D (694) intr_alloc: Connected src 73 to int 10 (cpu 0)
V (699) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (706) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0x40E
D (714) intr_alloc: Connected src 28 to int 2 (cpu 0)
I (719) cpu_start: Starting scheduler on PRO CPU.
D (724) heap_init: New heap initialised at 0x3fffc000
V (724) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (724) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xE
D (724) intr_alloc: Connected src 17 to int 3 (cpu 0)
Hello world!
D (744) efuse: In EFUSE_BLK1__DATA3_REG is used 4 bits starting with 21 bit
This is ESP32 chip with 1 CPU cores, WiFi, silicon revision 0, 4MB external flash
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.
When I select start debugging I get this in the debug console:
Reading symbols from C:\Projects\TE_Redesign\PlatformIOProjects\Test\EspHelloWorld.pio\build\esp32-s2-saola-1\firmware.elf…
Reading symbols from
done.
PlatformIO Unified Debugger → Redirecting...
PlatformIO: debug_tool = esp-prog
PlatformIO: Initializing remote target…
Open On-Chip Debugger v0.10.0-esp32-20210721 (2021-07-21-13:35)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
adapter speed: 20000 kHz
adapter speed: 500 kHz
Info : tcl server disabled
Info : telnet server disabled
Info : clock speed 500 kHz
Info : JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Core was reset.
Info : accepting ‘gdb’ connection from pipe
Warn : No symbols for FreeRTOS!
Info : esp32s2: Target halted, PC=0x40093E5E, debug_reason=00000000
Info : Detected ESP32-S2 chip
Info : esp32s2: Target halted, PC=0x40031F0C, debug_reason=00000001
Error: Failed to get flash maps (5)!
Warn : Failed to get flash mappings (-4)!
Info : esp32s2: Target halted, PC=0x40031F0C, debug_reason=00000001
Info : esp32s2: Target halted, PC=0x40031F0C, debug_reason=00000001
Info : Auto-detected flash bank ‘esp32s2.flash’ size 0 KB
Info : Using flash bank ‘esp32s2.flash’ size 0 KB
Info : esp32s2: Target halted, PC=0x40031F0C, debug_reason=00000001
Error: Failed to get flash maps (5)!
Warn : Failed to get flash mappings (-4)!
Info : esp32s2: Target halted, PC=0x40031F0C, debug_reason=00000001
Info : Using flash bank ‘esp32s2.irom’ size 0 KB
Info : esp32s2: Target halted, PC=0x40031F0C, debug_reason=00000001
Error: Failed to get flash maps (5)!
Warn : Failed to get flash mappings (-4)!
Info : esp32s2: Target halted, PC=0x40031F0C, debug_reason=00000001
Info : Using flash bank ‘esp32s2.drom’ size 0 KB
Warn : negative reply, retrying
0x40093e5e in esp_pm_impl_waiti () at C:\Users\10069805.platformio\packages\framework-espidf\components\hal\esp32s2\include/hal/cpu_ll.h:202
202 asm volatile (“waiti 0\n”);
Info : JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Core was reset.
esp32s2: Debug controller was reset.
esp32s2: Core was reset.
Info : esp32s2: Target halted, PC=0x40015D31, debug_reason=00000000
esp32s2: Target halted, PC=0x40015D31, debug_reason=00000000
Info : esp32s2: Core was reset.
esp32s2: Core was reset.
Info : esp32s2: Target halted, PC=0x40000400, debug_reason=00000000
esp32s2: Target halted, PC=0x40000400, debug_reason=00000000
** Programming Started **
** Programming Started **
Info : esp32s2: Target halted, PC=0x40031F22, debug_reason=00000001
esp32s2: Target halted, PC=0x40031F22, debug_reason=00000001
Error: Out of memory for flash bank buffer
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure ‘program_esp’
in procedure ‘program_error’ called at file “C:/Users/10069805/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg”, line 157
at file “embedded:startup.tcl”, line 449
Out of memory for flash bank buffer
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure ‘program_esp’
in procedure ‘program_error’ called at file “C:/Users/10069805/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg”, line 157
at file “embedded:startup.tcl”, line 449
Info : JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Core was reset.
esp32s2: Debug controller was reset.
esp32s2: Core was reset.
Info : esp32s2: Target halted, PC=0x4001276A, debug_reason=00000000
esp32s2: Target halted, PC=0x4001276A, debug_reason=00000000
Info : esp32s2: Core was reset.
esp32s2: Core was reset.
Info : esp32s2: Target halted, PC=0x40000400, debug_reason=00000000
** Programming Started **
esp32s2: Target halted, PC=0x40000400, debug_reason=00000000
** Programming Started **
Info : esp32s2: Target halted, PC=0x40031F22, debug_reason=00000001
esp32s2: Target halted, PC=0x40031F22, debug_reason=00000001
Error: Out of memory for flash bank buffer
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure ‘program_esp’
in procedure ‘program_error’ called at file “C:/Users/10069805/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg”, line 157
at file “embedded:startup.tcl”, line 449
Out of memory for flash bank buffer
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure ‘program_esp’
in procedure ‘program_error’ called at file “C:/Users/10069805/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg”, line 157
at file “embedded:startup.tcl”, line 449
Info : JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Core was reset.
esp32s2: Debug controller was reset.
esp32s2: Core was reset.
Info : esp32s2: Target halted, PC=0x4000F97D, debug_reason=00000000
esp32s2: Target halted, PC=0x4000F97D, debug_reason=00000000
Info : esp32s2: Core was reset.
esp32s2: Core was reset.
Info : esp32s2: Target halted, PC=0x40000400, debug_reason=00000000
** Programming Started **
esp32s2: Target halted, PC=0x40000400, debug_reason=00000000
** Programming Started **
Info : esp32s2: Target halted, PC=0x40031F22, debug_reason=00000001
esp32s2: Target halted, PC=0x40031F22, debug_reason=00000001
Error: Out of memory for flash bank buffer
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure ‘program_esp’
in procedure ‘program_error’ called at file “C:/Users/10069805/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg”, line 157
at file “embedded:startup.tcl”, line 449
Out of memory for flash bank buffer
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure ‘program_esp’
in procedure ‘program_error’ called at file “C:/Users/10069805/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg”, line 157
at file “embedded:startup.tcl”, line 449
Info : JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32s2.cpu tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32s2: Debug controller was reset.
Info : esp32s2: Core was reset.
esp32s2: Debug controller was reset.
esp32s2: Core was reset.
Info : esp32s2: Target halted, PC=0x40012B10, debug_reason=00000000
esp32s2: Target halted, PC=0x40012B10, debug_reason=00000000
Info : esp32s2: Core was reset.
esp32s2: Core was reset.
Info : esp32s2: Target halted, PC=0x40000400, debug_reason=00000000
esp32s2: Target halted, PC=0x40000400, debug_reason=00000000
Function “setup” not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
PlatformIO: Initialization completed
PlatformIO: Resume the execution todebug_init_break = tbreak setup
PlatformIO: More configuration options →
And the debugger doesn’t reach app_main and is stuck here:
static inline void cpu_ll_waiti(void) { asm volatile ("waiti 0\n"); }
I’m not sure what I’ve done wrong and any help would be appreciated. Function “setup” not defined seems odd to me. I’m not using arduino.