-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP32C3 openocd fail -- Hart is not halted! (OCD-420) #183
Comments
Open On-Chip Debugger v0.10.0-esp32-20210902-15-g78ea2222 (2021-10-22-19:00) Debug: 176 3 command.c:143 script_debug(): command - esp32c3 esp32c3 configure -event gdb-attach Debug: 177 3 command.c:143 script_debug(): command - esp32c3 esp32c3 configure -work-area-phys 0x40380000 -work-area-virt 0x40380000 -work-area-size 0x4000 -work-area-backup 1 Debug: 335 24 command.c:143 script_debug(): command - arm arm semihosting enable Debug: 374 7424 command.c:143 script_debug(): command - halt halt |
I have this module, maybe they have used a flash chip you weren't expecting? ESP-C3-12F |
@jonsmirl This happens due to enable memory protection. You have two options:
In the next release OpenOCD will do reset itself if memory protection is enabled. |
This explains why it would sometimes work and sometimes fail, it was a function of me randomly resetting without being aware that the manual reset was required. This is very non-obvious. Please add a bug comment when you have the code checked in and I will test it. I would also recommend a debug message that is explicit about memory protection and inability to write to memory. |
Isn't there a way for the JTAG to turn memory protection on/off without a reset? Normally you would want to leave memory protected at all times. Then if JTAG needs to modify: turn protection off, modify, turn it back on. |
@jonsmirl In ESP32-S2 and later, memory protection peripheral has a "lock" feature. Memory protection configuration can be locked by software, preventing further changes. This is a security measure to prevent features such as no-execute protection and code protection from being disabled due to some code vulnerabilities. After the configuration is locked, it can only be changed on CPU reset. The change we will implement in OpenOCD is to detect that memory protection is locked, and reset the target if so. Note that disabling memory protection doesn't disable RISC-V PMP or Xtensa region protection. So exceptions on access to illegal addresses will still be generated. The only protections which are disabled are:
Overall with memory protection disabled you should get very similar debugging experience, as these protections are unlikely to be triggered by typical programming errors. |
If would be good to turn protection off/on around this one: For sure keep first 1K of memory protected, by far most invalid accesses occur in that range. NULL pointer and offset from NULL pointer for structure member. My target system is ESP32-C3. |
it's same bug OCD-402. |
This is working for me now that I know about the need for reset. When you encounter this there is no clue given that reset will fix it. I spent a couple weeks frustrated by the JTAG working sometimes and then failing on the next run. I was not able to correlate the success or failure of JTAG with pressing the reset button until I was told. If openocd has simply printed out "reset needed to clear lock bit" I would not have wasted so much time on this. |
|
I have been trying to get openocd functioning on the C3 for a couple of weeks now without success. Sometimes it will work for a little while and then it fails and nothing I do can revive it. So I built openocd-esp32 from source as of 10/22 to ensure I have the very latest version.
I am running nothing besides openocd from source and riscv32-esp-elf-gdb. The 'target remote :3333" command fails to execute. That is because openocd is failing to work properly.....
jonsmirl@ares:~/aosp/openocd-esp32$ ./src/openocd -f board/esp32c3-builtin.cfg
Open On-Chip Debugger v0.10.0-esp32-20210902-15-g78ea2222 (2021-10-22-19:00)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
Warn : Transport "jtag" was already selected
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255
Info : clock speed 40000 kHz
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
Info : datacount=2 progbufsize=16
Info : Examined RISC-V core; found 1 harts
Info : hart 0: XLEN=32, misa=0x40101104
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Warn : No symbols for FreeRTOS!
Error: Hart is not halted!
Error: Failed to wait algorithm (-4)!
Error: Algorithm run failed (-4)!
Error: Failed to run flasher stub (-4)!
Warn : Failed to get flash mappings (-4)!
Error: Abstract command ended in error 'exception' (abstractcs=0x10001302)
Error: Timed out after 5s waiting for busy to go low (abstractcs=0x10001302). Increase the timeout with riscv set_command_timeout_sec.
Error: Failed to write stub section!
Error: Failed to run flasher stub (-4)!
Error: Abstract command ended in error 'exception' (abstractcs=0x10001302)
Error: Timed out after 5s waiting for busy to go low (abstractcs=0x10001302). Increase the timeout with riscv set_command_timeout_sec.
Error: Failed to write stub section!
Error: Failed to run flasher stub (-4)!
Error: Failed to probe flash, size 0 KB
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
jonsmirl@ares:~/aosp/connectedhomeip/examples/lighting-app/esp32$ riscv32-esp-elf-gdb
GNU gdb (crosstool-NG esp-2021r2) 9.2.90.20200913-git
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=riscv32-esp-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) set target :3333
Ambiguous set command "target :3333": target-async, target-charset, target-file-system-kind, target-wide-charset.
(gdb) target remote :3333
Remote debugging using :3333
Ignoring packet error, continuing...
warning: unrecognized item "timeout" in "qSupported" response
Remote communication error. Target disconnected.: Connection reset by peer.
(gdb) target remote :3333
Remote debugging using :3333
Ignoring packet error, continuing...
warning: unrecognized item "timeout" in "qSupported" response
Remote communication error. Target disconnected.: Connection reset by peer.
(gdb) quit
The text was updated successfully, but these errors were encountered: