The folks at openocd say support for Eco3 silicon was added with v0.10.0-esp32-20191008.
They have also asked me to run OpenOCD with -d3
option to collect more verbose log. How would I be able to add this parameter using platformio?
The folks at openocd say support for Eco3 silicon was added with v0.10.0-esp32-20191008.
They have also asked me to run OpenOCD with -d3
option to collect more verbose log. How would I be able to add this parameter using platformio?
I’ve run openocd manually via terminal from the platformio install to supply the folks at github with the log, and to my personal surprise (I did not check the log toroughly and posted it anyway) it worked fine.
So it seems the issue is not openocd. Any ideas?
Either see Redirecting... for using debug_tool = custom
and debug_port = localhost:3333
etc for using a pre-opened openocd server, or modify this code locally on your machine
to say openocd_args = ["-d3"]
(or any other debug level. This file should be in <home directory>/.platformio/platforms/esp32/builder/main.py
.
Upload and stepping worked fine? Then there’s something with the timing. Running on -d3
adds a considerable amount of debug output and delay between individual executions of commands, which may influence things just in the right direction.
Seems familiar to my when you don’t use the --disable-werror
option in the ./configure <options>
command. But since it works on pre-compiled released versions, just a side note.
I only did an upload, assuming it would fail that’s why I posted the good log without checking
With your help I’ve managed to run openocd from within platformio with the d3 argument, and this is the output in the console: Uploading .pio/build/esp32dev/firmware.binOpen On-Chip Debugger v0.10.0-esp32 - Pastebin.com (too long to post, thus pastebin)
seems the problem has been identified: https://github.com/espressif/openocd-esp32/issues/125#issuecomment-716588856
Changing program_esp32
to program_esp
in main.py at L374 and L380 fixes the issue with uploading.
It did not fix debugging though, I guess it is a similar if not the same issue though. Any pointers would be very appreciated!
Thank you for your fast help!
Edit: This is the output of the debug console:
Open On-Chip Debugger v0.10.0-esp32-20200709 (2020-07-09-08:54)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 20000 kHz
WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release.
Info : Configured 2 cores
Info : tcl server disabled
Info : telnet server disabled
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 20000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : cpu0: Detected debug stubs @ 3ffd9834
Info : accepting 'gdb' connection from pipe
Error: No symbols for FreeRTOS
Info : Target halted. CPU0: PC=0x40127399 (active)
Info : Target halted. CPU1: PC=0x400F9DE0
Info : cpu0: Target halted, PC=0x40091856, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 721 KB
Info : Flash mapping 1: 0xd0018 -> 0x400d0018, 966 KB
Info : cpu0: Target halted, PC=0x40091856, debug_reason=00000001
Info : Auto-detected flash bank 'esp32.flash' size 4096 KB
Info : Using flash bank 'esp32.flash' size 4096 KB
Info : cpu0: Target halted, PC=0x40091856, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 721 KB
Info : Flash mapping 1: 0xd0018 -> 0x400d0018, 966 KB
Info : Using flash bank 'esp32.irom' size 968 KB
Info : cpu0: Target halted, PC=0x40091856, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 721 KB
Info : Flash mapping 1: 0xd0018 -> 0x400d0018, 966 KB
Info : Using flash bank 'esp32.drom' size 724 KB
0x40127399 in spiffs_object_modify (fd=0x0, offset=0, data=0x3ffc84cc <Wire> "x\244G?", len=106) at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/spiffs/spiffs/src/spiffs_nucleus.c:1607
1607 /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/spiffs/spiffs/src/spiffs_nucleus.c: No such file or directory.
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : cpu0: Debug controller 0 was reset.
Info : cpu0: Core 0 was reset.
cpu0: Debug controller 0 was reset.
cpu0: Core 0 was reset.
Info : cpu0: Target halted, PC=0x500000CF, debug_reason=00000000
cpu0: Target halted, PC=0x500000CF, debug_reason=00000000
Info : esp32: Core 0 was reset.
esp32: Core 0 was reset.
Info : esp32: Debug controller 1 was reset.
Info : esp32: Core 1 was reset.
esp32: Debug controller 1 was reset.
esp32: Core 1 was reset.
Info : Target halted. CPU0: PC=0x40000400 (active)
Info : Target halted. CPU1: PC=0x40000400
Target halted. CPU0: PC=0x40000400 (active)
Target halted. CPU1: PC=0x40000400
** Programming Started **
** Programming Started **
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure 'program_esp32'
in procedure 'program_esp' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp32.cfg", line 64
in procedure 'program_error' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg", line 106
at file "embedded:startup.tcl", line 449
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure 'program_esp32'
in procedure 'program_esp' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp32.cfg", line 64
in procedure 'program_error' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg", line 106
at file "embedded:startup.tcl", line 449
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : cpu0: Debug controller 0 was reset.
Info : cpu0: Core 0 was reset.
cpu0: Debug controller 0 was reset.
cpu0: Core 0 was reset.
Info : cpu0: Target halted, PC=0x500000CF, debug_reason=00000000
cpu0: Target halted, PC=0x500000CF, debug_reason=00000000
Info : esp32: Core 0 was reset.
esp32: Core 0 was reset.
Info : esp32: Debug controller 1 was reset.
Info : esp32: Core 1 was reset.
esp32: Debug controller 1 was reset.
esp32: Core 1 was reset.
Info : Target halted. CPU0: PC=0x40000400 (active)
Info : Target halted. CPU1: PC=0x40000400
Target halted. CPU0: PC=0x40000400 (active)
Target halted. CPU1: PC=0x40000400
** Programming Started **
** Programming Started **
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure 'program_esp32'
in procedure 'program_esp' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp32.cfg", line 64
in procedure 'program_error' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg", line 106
at file "embedded:startup.tcl", line 449
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure 'program_esp32'
in procedure 'program_esp' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp32.cfg", line 64
in procedure 'program_error' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg", line 106
at file "embedded:startup.tcl", line 449
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : cpu0: Debug controller 0 was reset.
Info : cpu0: Core 0 was reset.
cpu0: Debug controller 0 was reset.
cpu0: Core 0 was reset.
Info : cpu0: Target halted, PC=0x500000CF, debug_reason=00000000
cpu0: Target halted, PC=0x500000CF, debug_reason=00000000
Info : esp32: Core 0 was reset.
esp32: Core 0 was reset.
Info : esp32: Debug controller 1 was reset.
Info : esp32: Core 1 was reset.
esp32: Debug controller 1 was reset.
esp32: Core 1 was reset.
Info : Target halted. CPU0: PC=0x40000400 (active)
Target halted. CPU0: PC=0x40000400 (active)
Info : Target halted. CPU1: PC=0x40000400
Target halted. CPU1: PC=0x40000400
** Programming Started **
** Programming Started **
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure 'program_esp32'
in procedure 'program_esp' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp32.cfg", line 64
in procedure 'program_error' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg", line 106
at file "embedded:startup.tcl", line 449
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure 'program_esp32'
in procedure 'program_esp' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp32.cfg", line 64
in procedure 'program_error' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg", line 106
at file "embedded:startup.tcl", line 449
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : cpu0: Debug controller 0 was reset.
Info : cpu0: Core 0 was reset.
cpu0: Debug controller 0 was reset.
cpu0: Core 0 was reset.
Info : cpu0: Target halted, PC=0x500000CF, debug_reason=00000000
cpu0: Target halted, PC=0x500000CF, debug_reason=00000000
Info : esp32: Core 0 was reset.
esp32: Core 0 was reset.
Info : esp32: Debug controller 1 was reset.
Info : esp32: Core 1 was reset.
esp32: Debug controller 1 was reset.
esp32: Core 1 was reset.
Info : Target halted. CPU0: PC=0x40000400 (active)
Info : Target halted. CPU1: PC=0x40000400
Target halted. CPU0: PC=0x40000400 (active)
Target halted. CPU1: PC=0x40000400
** Programming Started **
** Programming Started **
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure 'program_esp32'
in procedure 'program_esp' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp32.cfg", line 64
in procedure 'program_error' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg", line 106
at file "embedded:startup.tcl", line 449
embedded:startup.tcl:449: Error: ** Programming Failed **
in procedure 'program_esp32'
in procedure 'program_esp' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp32.cfg", line 64
in procedure 'program_error' called at file "/Users/wolfgang/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg", line 106
at file "embedded:startup.tcl", line 449
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : cpu0: Debug controller 0 was reset.
Info : cpu0: Core 0 was reset.
cpu0: Debug controller 0 was reset.
cpu0: Core 0 was reset.
Info : cpu0: Target halted, PC=0x500000CF, debug_reason=00000000
cpu0: Target halted, PC=0x500000CF, debug_reason=00000000
Info : esp32: Core 0 was reset.
esp32: Core 0 was reset.
Info : esp32: Debug controller 1 was reset.
Info : esp32: Core 1 was reset.
esp32: Debug controller 1 was reset.
esp32: Core 1 was reset.
Info : Target halted. CPU0: PC=0x40000400 (active)
Target halted. CPU0: PC=0x40000400 (active)
Info : Target halted. CPU1: PC=0x40000400
Target halted. CPU1: PC=0x40000400
Hardware assisted breakpoint 1 at 0x40117598: file /Users/wolfgang/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp, line 24.
PlatformIO: Initialization completed
PlatformIO: Resume the execution to `debug_init_break = thb app_main`
PlatformIO: More configuration options -> http://bit.ly/pio-debug
Note: automatically using hardware breakpoints for read-only addresses.
Warn : cpu0: No free slots to add HW breakpoint!
Info : cpu0: Target halted, PC=0x40091856, debug_reason=00000001
Info : cpu0: Detected debug stubs @ 3ffd9834
cpu0: Detected debug stubs @ 3ffd9834
It looks as if the command:
flash flash write_image erase .pio/build/esp32dev/firmware.bin 0x10000 verify
was used instead of:
flash write_image erase .pio/build/esp32dev/firmware.bin 0x10000 verify
And then the command file parsing fails (error -1404 is raised if OpenOCD cannot determine the image type based on the filename).
If so, the problem could be in PlatformIO or in one of the config files.
Well, if you read the issue on github and this thread it seems rather clear to me that the problem is with platformio.
If by any chance you find a quick fix I can apply to get debugging working I’d be incredibly thankful! Uploading works now, which was not a big issue because I could always upload via serial. Spent all day tracking this down to get debugging working. I am glad it’s not a hardware issue with my prototypes though!
What have you changed? Why does uploading suddenly work?
We’ve just updated openOCD to the latest version but you will need the latest PlatformIO Core Dev and special branch of ESP32 dev-platform. If this works for you, we merge it into develop
branch when release PlatformIO Core 5.0.2.
pio upgrade --dev
platformio.ini
:[env:yourenv]
platform = https://github.com/platformio/platform-espressif32#feature/openocd-update
Does it work?
@ivankravets Before the update, it worked – both uploading and debugging with an old ESP32 chip. After the update it didn’t work anymore. As it turns out, program_esp32
needs to be changed to program_esp
in builder/main.py
. With the modification, both uploading and debugging worked again. So there is still a modification needed. I can’t tell anything about the newer chips. I will have to go through by collection of ESP32 boards.
@lienbacher On reading your post the second time, I’ve seen what you have changed. Thanks.
@manuelbl happens to me all the time, no worries
@ivankravets indeed the change in the post I linked above and that manuelbl highlighted is not in this update. seems it only updates the version of openocd, which in turn has some breaking changes explained by the openocd devs in the issue in github I linked above.
Changing main.py fixes uploading, but there’s still a fix necessary for the call of the debugger. Supposedly it is the same fix, but I was unable to find where the debugger is acutally called from.
I’ve changed program_esp32
to program_esp
in two places, about 5 lines apart. Did you do the same?
Sorry, fixed in Use "program_esp" command for new openOCD · platformio/platform-espressif32@7b932d1 · GitHub
Could you re-run pio update
to pull the latest changes from the temporary feature/openocd-update
branch?
Yes, that works. Thanks.
I don’t have any newer ESP32 boards that I could test. (I found an ESP32-SOLO-1 that doesn’t have all required debug pins, and I found an ESP32-S2, which is not supported yet.)
Great! I think the main goal was to switch to the latest openOCD. We had a blocker issue on the PlatformIO Core side where ESP32 was historically hardcoded.
This commit allows dev-platform to re-configure debugging options. An example:
https://github.com/platformio/platform-espressif32/blob/feature/openocd-update/platform.py#L159
We are going to release PIO Core 5.0.2 this week.
yes that’s what I did too.
@ivankravets thank you! Uploading works and the debugger at least starts and does not fail right away anymore.
I am only having the problem that the debugger does not stop on any breakpoints, which is a bit odd. In my experience it should stop right away in app_main()
and needs to be manually resumed. however it does neither stop there, and it also does not stop on any breakpoints
esp32: Debug controller 1 was reset.
esp32: Core 1 was reset.
Info : Target halted. CPU0: PC=0x40000400 (active)
Info : Target halted. CPU1: PC=0x40000400
Target halted. CPU0: PC=0x40000400 (active)
Target halted. CPU1: PC=0x40000400
Hardware assisted breakpoint 1 at 0x40117598: file /Users/wolfgang/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp, line 24.
PlatformIO: Initialization completed
PlatformIO: Resume the execution to `debug_init_break = thb app_main`
PlatformIO: More configuration options -> http://bit.ly/pio-debug
Note: automatically using hardware breakpoints for read-only addresses.
Warn : cpu0: No free slots to add HW breakpoint!
Info : cpu0: Target halted, PC=0x40091856, debug_reason=00000001
Info : cpu0: Detected debug stubs @ 3ffd9834
cpu0: Detected debug stubs @ 3ffd9834
The ESP32 has only two breakpoints. That’s quite limiting. If you set more breakpoints, it becomes quite unpredictable which ones are honoured and which ones aren’t. Single stepping also needs a breakpoint.
debug_init_break = thb app_main
sets a temporary breakpoint on app_main
. But the log also contains a warning:
Likely, it was already out of breakpoints… Try it again without setting any breakpoint before your start the debugger.
no dice, does not stop. If I remove all breakpoints the no free slots error is gone, but it still wont stop anywhere
[Switching to Thread 1073467744]
_frxt_int_enter () at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/portasm.S:132
132 /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/portasm.S: No such file or directory.
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : cpu0: Debug controller 0 was reset.
Info : cpu0: Core 0 was reset.
cpu0: Debug controller 0 was reset.
cpu0: Core 0 was reset.
Info : cpu0: Target halted, PC=0x500000CF, debug_reason=00000000
cpu0: Target halted, PC=0x500000CF, debug_reason=00000000
Info : esp32: Core 0 was reset.
esp32: Core 0 was reset.
Info : esp32: Debug controller 1 was reset.
Info : esp32: Core 1 was reset.
esp32: Debug controller 1 was reset.
esp32: Core 1 was reset.
Info : Target halted. CPU0: PC=0x40000400 (active)
Target halted. CPU0: PC=0x40000400 (active)
Info : Target halted. CPU1: PC=0x40000400
Target halted. CPU1: PC=0x40000400