ESP32-C6 OpenOCD/GDB timeout

jomi26@gmail.com
Posts: 8
Joined: Wed Nov 18, 2020 12:59 pm

ESP32-C6 OpenOCD/GDB timeout

Postby jomi26@gmail.com » Sat Jul 01, 2023 5:25 am

Hi all,

I am having issues to get a debug session started on the ESP32C6 using openOCD and GDB.

Board: ESP32-C6-DevKitC-1-N8 (8MB FLASH)
ESP-IFD: Fresh install 5.1 latest release from yesterday incl. tools
Code: hello_world example modified to stay in a loop to not restart (see below)

I was able to debug the board before with a pre-release version of ESP-IDF (master branch) so I assume its due to the update of ESP-IDF and something with GDB but maybe I just made a stupid mistake somewhere?!
Help is very much appreciated!
  1. #include <stdio.h>
  2. #include <inttypes.h>
  3. #include "sdkconfig.h"
  4. #include "freertos/FreeRTOS.h"
  5. #include "freertos/task.h"
  6. #include "esp_chip_info.h"
  7. #include "esp_flash.h"
  8.  
  9. void app_main(void)
  10. {
  11.     printf("Hello world!\n");
  12.  
  13.     /* Print chip information */
  14.     esp_chip_info_t chip_info;
  15.     uint32_t flash_size;
  16.     esp_chip_info(&chip_info);
  17.     printf("This is %s chip with %d CPU core(s), WiFi%s%s%s, ",
  18.            CONFIG_IDF_TARGET,
  19.            chip_info.cores,
  20.            (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
  21.            (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "",
  22.            (chip_info.features & CHIP_FEATURE_IEEE802154) ? ", 802.15.4 (Zigbee/Thread)" : "");
  23.  
  24.     unsigned major_rev = chip_info.revision / 100;
  25.     unsigned minor_rev = chip_info.revision % 100;
  26.     printf("silicon revision v%d.%d, ", major_rev, minor_rev);
  27.     if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) {
  28.         printf("Get flash size failed");
  29.         return;
  30.     }
  31.  
  32.     printf("%" PRIu32 "MB %s flash\n", flash_size / (uint32_t)(1024 * 1024),
  33.            (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
  34.  
  35.     printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size());
  36.  
  37.     for (int i = 10; i >= 0; i--) {
  38.         printf("Restarting in %d seconds...\n", i);
  39.         vTaskDelay(1000 / portTICK_PERIOD_MS);
  40.     }
  41.  
  42.     while(1)
  43.     {
  44.         printf("Just sitting here waiting to debug... \n");
  45.         vTaskDelay(2000 / portTICK_PERIOD_MS);
  46.     }
  47.  
  48.     printf("Restarting now.\n");
  49.     fflush(stdout);
  50.     esp_restart();
  51. }

I am using the command line to start openOCD and GDB.
OpenOCD seems to work fine and able to connect to the target when started.


D:\ESP_VSC_Projects\hello_world>openocd -f /board/esp32c6-builtin,cfg
Open On-Chip Debugger v0.12.0-esp32-20230419 (2023-04-18-22:02)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
embedded:startup.tcl:28: Error: Can't find /board/esp32c6-builtin,cfg
in procedure 'script'
at file "embedded:startup.tcl", line 28

D:\ESP_VSC_Projects\hello_world>openocd -f /board/esp32c6-builtin.cfg
Open On-Chip Debugger v0.12.0-esp32-20230419 (2023-04-18-22:02)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselecting 'jtag'
Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001
Info : esp_usb_jtag: capabilities descriptor set to 0x2000
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: serial (60:55:F9:F7:2B:AC)
Info : esp_usb_jtag: Device found. Base speed 24000KHz, div range 1 to 255
Info : clock speed 24000 kHz
Info : JTAG tap: esp32c6.cpu tap/device found: 0x0000dc25 (mfg: 0x612 (Espressif Systems), part: 0x000d, ver: 0x0)
Info : datacount=2 progbufsize=16
Info : Examined RISC-V core; found 2 harts
Info : hart 0: XLEN=32, misa=0x40903105
Info : starting gdb server for esp32c6 on 3333
Info : Listening on port 3333 for gdb connections



Starting GDB I get "Remote replied unexpectedly to 'vMustReplyEmpty': timeout" see below.
My gdbInit includes these lines:

target remote :3333
set remote hardware-watchpoint-limit 2
mon reset halt
flushregs
thb app_main
c


GDB output:
D:\ESP_VSC_Projects\hello_world>riscv32-esp-elf-gdb -x gdbinit build/hello_world.elf
GNU gdb (esp-gdb) 12.1_20221002
Copyright (C) 2022 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-w64-mingw32 --target=riscv32-esp-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://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"...
Reading symbols from build/hello_world.elf...
Ignoring packet error, continuing...
warning: unrecognized item "timeout" in "qSupported" response
Ignoring packet error, continuing...
gdbinit:1: Error in sourced command file:
Remote replied unexpectedly to 'vMustReplyEmpty': timeout
(gdb)




Once I get the error in GDB openOCD prints the following:

Warn : No symbols for FreeRTOS!
Error: Algorithm timed out after 40001 ms.
Info : [esp32c6] Halt cause (5) - (PMP Load access fault)
Error: ra = 0x408012a2
Error: sp = 0x40804700
Error: gp = 0x40812040
Error: tp = 0x4080d920
Error: t0 = 0x0
Error: t1 = 0x0
Error: t2 = 0x0
Error: s0 = 0x40817210
Error: s1 = 0x0
Error: a0 = 0x5
Error: a1 = 0xffffffff
Error: a2 = 0x40804780
Error: a3 = 0x0
Error: a4 = 0x8
Error: a5 = 0x8
Error: a6 = 0x0
Error: a7 = 0x40801064
Error: s2 = 0x0
Error: s3 = 0x0
Error: s4 = 0x0
Error: s5 = 0x0
Error: s6 = 0x0
Error: s7 = 0x0
Error: s8 = 0x0
Error: s9 = 0x0
Error: s10 = 0x0
Error: s11 = 0x0
Error: t3 = 0x0
Error: t4 = 0x0
Error: t5 = 0x0
Error: t6 = 0x0
Error: pc = 0x40800000
Error: mstatus = 0x1800
Error: mepc = 0x40800000
Error: mcause = 0x5
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: Failed to run flasher stub (-4)!
Error: Target is already running an algorithm
Error: Failed to start algorithm (-4)!
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

sonojohn
Posts: 2
Joined: Sat Jul 01, 2023 9:21 pm

Re: ESP32-C6 OpenOCD/GDB timeout

Postby sonojohn » Sat Jul 01, 2023 10:18 pm

I'm encountering the same exact issue using the ESP-IDF 5.1 release and the example program from the esp-idf-template project.

jomi26@gmail.com
Posts: 8
Joined: Wed Nov 18, 2020 12:59 pm

Re: ESP32-C6 OpenOCD/GDB timeout

Postby jomi26@gmail.com » Sun Jul 02, 2023 6:38 am

Hi,

I have been trying different things but without success.
I am not sure where the issue is but here is a debug log from GDB. Can anyone interpret this?

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from build/hello_world.elf...
Ignoring packet error, continuing...
warning: unrecognized item "timeout" in "qSupported" response
Ignoring packet error, continuing...
gdbinit:1: Error in sourced command file:
Remote replied unexpectedly to 'vMustReplyEmpty': timeout
(gdb) set debug remote 1
(gdb) target remote 127.0.0.1:3333
Remote debugging using 127.0.0.1:3333
[remote] start_remote_1: enter
[remote] Sending packet: $qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;memory-tagging+#ec
[remote] Received Ack
[remote] getpkt_or_notif_sane_1: Timed out.
[remote] getpkt_or_notif_sane_1: Timed out.
[remote] getpkt_or_notif_sane_1: Timed out.
Ignoring packet error, continuing...
[remote] packet_ok: Packet qSupported (supported-packets) is supported
warning: unrecognized item "timeout" in "qSupported" response
[remote] Sending packet: $vMustReplyEmpty#3a
[remote] Sending packet: $vMustReplyEmpty#3a
[remote] Sending packet: $vMustReplyEmpty#3a
[remote] Sending packet: $vMustReplyEmpty#3a
[remote] getpkt_or_notif_sane_1: Timed out.
[remote] getpkt_or_notif_sane_1: Timed out.
[remote] getpkt_or_notif_sane_1: Timed out.
Ignoring packet error, continuing...
[remote] start_remote_1: exit
Remote replied unexpectedly to 'vMustReplyEmpty': timeout
(gdb)

jomi26@gmail.com
Posts: 8
Joined: Wed Nov 18, 2020 12:59 pm

Re: ESP32-C6 OpenOCD/GDB timeout

Postby jomi26@gmail.com » Sun Jul 02, 2023 10:24 am

Hi all,

to everyone that might run into this issue as well.
I found the root cause for what caused the problem for me.
After reading the GDB and openOCD debug logs the issue is that the physical memory protection (PMP) feature (if enabled) prevents the debug session to work.

I changed the setting in the idf menuconfig under Component config->ESP System Settings->Memory protection->Enable IRAM/DRAM split protection to disable

Problem for me is solved.

sonojohn
Posts: 2
Joined: Sat Jul 01, 2023 9:21 pm

Re: ESP32-C6 OpenOCD/GDB timeout

Postby sonojohn » Sun Jul 02, 2023 11:30 am

That seems to fix the issue for me as well, thank you for the update!

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: ESP32-C6 OpenOCD/GDB timeout

Postby ESP_igrr » Fri Jul 07, 2023 7:28 pm

We have fixed this on OpenOCD side in https://github.com/espressif/openocd-es ... e06d449f91, the fix will be available in the next OpenOCD release!

Vineethad
Posts: 55
Joined: Wed Jul 19, 2023 7:45 am

Re: ESP32-C6 OpenOCD/GDB timeout

Postby Vineethad » Fri Feb 09, 2024 6:01 am

Heloo,

Still I am getting same problem after I changed the setting in the idf menuconfig under Component config->ESP System Settings->Memory protection->Enable IRAM/DRAM split protection to disable.


Thanks & Regards,
D. Vineetha.

Who is online

Users browsing this forum: No registered users and 117 guests