ESP32 OpenOCD can't set breakpoint

Okay, I now got this:

Executing task: C:\Users\Niels\.platformio\penv\Scripts\platformio.exe run --verbose --target upload --environment nodemcu-32s <

Processing nodemcu-32s (platform: https://github.com/platformio/platform-espressif32.git; board: nodemcu-32s; board_debug.adapter_speed: 500; board_upload.flash_size: 4MB; board_upload.maximum_size: 4194304; framework: espidf; monitor_speed: 115200; debug_tool: olimex-arm-usb-ocd-h; upload_protocol: olimex-arm-usb-ocd-h; board_build.partitions: ESP32_OTA_4M.csv)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/nodemcu-32s.html
PLATFORM: Espressif 32 (2.0.0+sha.07919d0) (git+https://github.com/platformio/platform-espressif32.git) > NodeMCU-32S
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (olimex-arm-usb-ocd-h) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-espidf 3.40100.200827 (4.1.0)
 - tool-cmake 3.16.4
 - tool-esptoolpy 1.20600.0 (2.6.0)
 - tool-idf 1.0.1
 - tool-mconf 1.4060000.20190628 (406.0.0)
 - tool-mkspiffs 2.230.0 (2.30)
 - tool-ninja 1.9.0
 - tool-openocd-esp32 2.1000.20200709 (10.0)
 - toolchain-esp32ulp 1.22851.191205 (2.28.51)
 - toolchain-xtensa32 2.80200.200827 (8.2.0)
Reading CMake configuration...
Framework incompatible library C:\Users\Niels\.platformio\lib\DallasTemperature_ID54
Framework incompatible library C:\Users\Niels\.platformio\lib\IniFile_ID1606 
Framework incompatible library C:\Users\Niels\.platformio\lib\MPL115A1_ID2547
Framework incompatible library C:\Users\Niels\.platformio\lib\NTPClient      
Framework incompatible library C:\Users\Niels\.platformio\lib\OneWire_ID1    
Framework incompatible library C:\Users\Niels\.platformio\lib\PID_ID2    
Framework incompatible library C:\Users\Niels\.platformio\lib\SdFat_ID322
Framework incompatible library C:\Users\Niels\.platformio\lib\Sqlite3Esp32_ID6173
Framework incompatible library C:\Users\Niels\.platformio\lib\TFT_eSPI
More details about "Library Compatibility Mode": https://docs.platformio.org/page/librarymanager/ldf.html#ldf-compat-mode
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Framework incompatible library C:\Users\Niels\.platformio\lib\DallasTemperature_ID54
Framework incompatible library C:\Users\Niels\.platformio\lib\IniFile_ID1606
Framework incompatible library C:\Users\Niels\.platformio\lib\MPL115A1_ID2547
Found 2 compatible libraries
Scanning dependencies...
Framework incompatible library C:\Users\Niels\.platformio\lib\NTPClient
Framework incompatible library C:\Users\Niels\.platformio\lib\OneWire_ID1
Framework incompatible library C:\Users\Niels\.platformio\lib\PID_ID2
Framework incompatible library C:\Users\Niels\.platformio\lib\SdFat_ID322
Framework incompatible library C:\Users\Niels\.platformio\lib\Sqlite3Esp32_ID6173
Framework incompatible library C:\Users\Niels\.platformio\lib\TFT_eSPI
More details about "Library Compatibility Mode": https://docs.platformio.org/page/librarymanager/ldf.html#ldf-compat-mode
Dependency Graph
|-- <TempIF> (C:\Users\Niels\Documents\PlatformIO\Projects\nanoBrewer\lib\TempIF)
|-- <mongoose_espidf> 0.1.0 (C:\Users\Niels\Documents\PlatformIO\Projects\nanoBrewer\lib\Mongoose)
Building in release mode
<lambda>(["checkprogsize"], [".pio\build\nodemcu-32s\firmware.elf"])
MethodWrapper(["checkprogsize"], [".pio\build\nodemcu-32s\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  11.6% (used 38104 bytes from 327680 bytes)
Flash: [=====     ]  53.6% (used 843218 bytes from 1572864 bytes)
.pio\build\nodemcu-32s\firmware.elf  :

section                                                size         addr

.rtc.text                                                 0   1074528256

.rtc.dummy                                                0   1073217536

.rtc.force_fast                                           0   1073217536

.rtc_noinit                                               0   1342177280

.rtc.force_slow                                           0   1342177280

Open On-Chip Debugger  v0.10.0-esp32-20200709 (2020-07-09-08:54)
.iram0.vectors                                         1027   1074266112

Licensed under GNU GPL v2
.iram0.text                                           94940   1074267140
For bug reports, read

        http://openocd.org/doc/doxygen/bugs.html
.dram0.data                                           14840   1073414144
debug_level: 2


.noinit                                                   0   1073428984
WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release.

Info : Configured 2 cores
.dram0.bss                                            23264   1073428984
adapter speed: 20000 kHz


.flash.rodata                                        132072   1061158944

.flash.text                                          600339   1074593824

.iram0.text_end                                           0   1074362080

.dram0.heap_start                                         0   1073452248

.xtensa.info                                             56            0

.comment                                                217            0

.xt.prop._ZN3nvs9NVSHandle8set_itemIaEEiPKcT_            36            0

.xt.prop._ZN3nvs9NVSHandle8set_itemIhEEiPKcT_            36            0

.xt.prop._ZN3nvs9NVSHandle8set_itemItEEiPKcT_            36            0

.xt.prop._ZN3nvs9NVSHandle8set_itemIjEEiPKcT_            36            0

.xt.prop._ZN3nvs9NVSHandle8get_itemIaEEiPKcRT_           36            0
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"

Info : clock speed 20000.xt.prop._ZN3nvs9NVSHandle8get_itemIhEEiPKcRT_           36            0
 k
Hz.xt.prop._ZN3nvs9NVSHandle8get_itemItEEiPKcRT_           36            0


Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
.xt.prop._ZN3nvs9NVSHandle8get_itemIjEEiPKcRT_           36            0

.xt.lit._ZN3nvs19NVSPartitionManagerD5Ev                  0            0
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : Listening on port 3333 fo
r gdb c.xt.prop._ZN3nvs19NVSPartitionManagerD5Ev                 0            0
onn
ect.xt.prop._ZN3nvs19NVSPartitionManagerD2Ev                36            0
io
ns.xt.prop._ZN3nvs19NVSPartitionManagerD0Ev                36            0


Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
.xt.prop._ZTVN3nvs19NVSPartitionManagerE                 12            0
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)

Info : cpu0: Target halted, PC=0x40007BA1, debug_reason=000.xt.prop._ZTVN3nvs15NVSHandleSimpleE                     12            0
00000

Info : cpu0: Debug controller 0 was reset.
.xt.prop._ZTISt9exception                                12            0
Info : cpu0: Core 0 was reset.

.xt.prop._ZTISt9bad_alloc                                12            0
Info : cpu0: Target halted, PC=0x50000
0CF, debug_reason=00.xt.prop._ZTVN10__cxxabiv120__si_class_type_infoE        12            0
000000

Info : esp32: Core 0 was reset.
.xt.prop._ZTVSt9bad_alloc                                12            0

Info : esp32: Debug controller 1 was reset.
.xt.prop._ZTVN10__cxxabiv117__class_type_infoE           12            0

Info : esp32: Core 1 was reset.
.debug_frame                                         109080            0
Info : Target halted. CPU0: PC=0x40000400 (active
).debug_info                                         3963645            0

Info : Target halted. CPU1: PC=0x4000
0400
.debug_abbrev                                        317612            0
** Programming Started **

.debug_aranges                                        42112            0

.debug_ranges                                         47360            0

.debug_line                                         1941276            0

.debug_str                                           310417            0

.debug_loc                                           854930            0

Total                                               8453631
<lambda>(["upload"], [".pio\build\nodemcu-32s\firmware.bin"])
AVAILABLE: esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = olimex-arm-usb-ocd-h
openocd -d2 -s C:/Users/Niels/.platformio/packages/tool-openocd-esp32/share/openocd/scripts -f interface/ftdi/olimex-arm-usb-ocd-h.cfg -f board/esp-wroom-32.cfg -c "adapter_khz 20000" -c "program_esp {{.pio\build\nodemcu-32s\firmware.bin}} 0x10000 verify" -c "program_esp {{C:\Users\Niels\Documents\PlatformIO\Projects\nanoBrewer\.pio\build\nodemcu-32s/bootloader.bin}} 0x1000 verify" -c "program_esp {{C:\Users\Niels\Documents\PlatformIO\Projects\nanoBrewer\.pio\build\nodemcu-32s/partitions.bin}} 0x8000 verify" -c "reset run; shutdown"
Error: timed out while waiting for target halted / 4 - 2
Info : cpu0: Target halted, PC=0x40090155, debug_reason=00000000
Error: xtensa_wait_algorithm: not halted 0, pc 0x40090155, ps 0x60025
Error: Failed to wait algorithm (-302)!
Error: Algorithm run failed (-302)!
Error: Failed to run flasher stub (-302)!
Warn : Failed to get flash mappings (-302)!
Error: Target is already running an algorithm
Error: Failed to start algorithm (-4)!
Error: Algorithm run failed (-4)!
Error: Failed to run flasher stub (-4)!
Error: Target is already running an algorithm
Error: Failed to start algorithm (-4)!
Error: Algorithm run failed (-4)!
Error: Failed to run flasher stub (-4)!
Error: Failed to probe flash, size 0 KB
Error: auto_probe failed
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure 'program_esp' 
in procedure 'program_error' called at file "C:/Users/Niels/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg", line 106
at file "embedded:startup.tcl", line 449
*** [upload] Error 1
============================================================================================= [FAILED] Took 65.14 seconds =============================================================================================The terminal process "C:\Users\Niels\.platformio\penv\Scripts\platformio.exe 'run', '--verbose', '--target', 'upload', '--environment', 'nodemcu-32s'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

I don’t seem to be able to change the adapter clock frequency?
I inserted the “adapter_khz 500” into the ‘/ftdi/olimex-arm-usb-ocd-h.cfg’ file as well and tried the ‘Verbose upload’ again. But the result is the same, always 20000 KHz?

HOWWWWW is it still doing a -c "adapter_khz 20000" if you wrote the board_debug.adapter_speed = 500 in the platformio.ini (which I can see that you did correctly by looking at the second line of the output). Let me double check what the Python code I posted above does there – this should work flawlessly. Even if you change the olimex-arm-usb-ocd-h.cfg it will still get overridden by the -c command flag that sets to 20MHz after. A radical way would be to go int C:\Users\<user>\.platformio\platforms\espressif32@src-***\platform.py and change the line to say "-c", "adapter_khz %d" % 500, but that’s crude hacking. Let me double check where debug is coming from.

I couldn’t help my self, so I tried the “crude way”, guess what - everything now works as a charm :+1: I can definitely say that the adapter clock frequency was the last issue in this long post. :clap:

The crude hack has been removed again. :no_entry_sign:

Okay great for now, I’ll check why setting board_debug.adapter_speed = 500 in the platformio.ini does not make debug.get("adapter_speed", 20000) return 500 but still 20000 when I have time.

@maxgerhardt: Did you get a chance to look at this (no rush), just need to know if I should use the “crude hacking” again. :wink:

Issues Make adapter_speed changable in platformio.ini · Issue #459 · platformio/platform-espressif32 · GitHub and Use a "safe" value for OpenOCD adapter speed by ryanplusplus · Pull Request #463 · platformio/platform-espressif32 · GitHub were recently closed as resolved so in the current bleeding edge platform version (not yet released as the new stable),

  1. the default JTAG speed is 5MHz instead of 20MHz
  2. the speed is easily changable as I once thought it should be, with debug_speed = 100 e.g. in the platformio.ini (per commit – original information about board_debug.adapter_speed was wrong.)

So if you want to test that in the upstream version see docs, otherwise it’ll be included in the next release as normal (and when you update the platforms of course)

Thanks for the outstanding support, I will for sure try it out.