Skip to content
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

Debugging is not working with firmware from Arduino IDE #12

Closed
valeros opened this issue Jun 10, 2017 · 5 comments
Closed

Debugging is not working with firmware from Arduino IDE #12

valeros opened this issue Jun 10, 2017 · 5 comments

Comments

@valeros
Copy link

valeros commented Jun 10, 2017

Hi! I'm having a strange problem with debugging a simple example from Arduino IDE, whereas "Hello World" example from ESP-IDF can be debugged perfectly.
Hardware: FT2232H + esp32 dev board connected via JTAG.

When I'm trying to debug a simple "WiFiScan" sketch from Arduino in GDB I see either this GDB log with next openOCD log (looks like MCU stuck in ResetVector) or this one and this openOCD log with a strange thread number.

gdbinit it the same for both cases:

target remote :3333
mon reset halt
hb app_main
x $a1=0
c

Am I missing something? Any advice and suggestions will be greatly appreciated!

@igrr
Copy link
Member

igrr commented Jun 10, 2017

Could you please attach the elf file, GDB remote log, and openocd log with increased log level (-d 3)? Thanks.

@valeros
Copy link
Author

valeros commented Jun 10, 2017

Hi @igrr ! Sure, openocd, GDB, elf

@igrr
Copy link
Member

igrr commented Jun 11, 2017

Ok, thanks. I've tried reproducing this, looks like there are three issues:

  • the ELF file doesn't include uxTopUsedPriority symbol, which must be linked in via an LD flag (source). Maybe the flag is missing in Arduino platform.txt.
  • mon reset doesn't work reliably if 240MHz CPU frequency is selected. Since we have lowered the default in IDF to 160MHz, I hadn't noticed this previously. Hopefully this is easy to fix...
  • Placing first breakpoint on a task which runs on APP CPU doesn't work: breakpoint doesn't get hit because APP CPU is reset one extra time by PRO CPU during startup... this also clears the breakpoint register. I'm not sure if this easy to fix or not, need to poke around a bit.
    Overall, thanks for the report, will keep you updated.

@igrr
Copy link
Member

igrr commented Jun 27, 2017

The 2nd point (mon reset issue) has now been fixed, merge pending.
The 3rd issue has been fixed in ESP-IDF and will propagate to Arduino next time library update happens.
The 1st point must still be added to Arduino build script, i think.

@freeck
Copy link

freeck commented Sep 14, 2017

Perhaps already solved in ESP-IDF, but I am using the Windows Sloeber-Arduino plugin.

I solved this problem in Eclipse, by doing 2 things:

1: Setting the parameters in Eclipse->DebugAs->DebugConfiguration->GdbHardwareDebuging->Startup as follows:
monitor reset halt
x $a1=0
thb loop
thr 0 // This was my lucky guess. Mind you: your application should reside in the APP-CPU.
c

2: Include file FreeRTOS-openocd.c the project...

Using gdb also works; open a command shell and enter:
xtensa-esp32-elf-gdb.exe -x application.elf
an error message is generated:
esp32: target state: halted
0x0: 0x00000000
Thread ID 0 not known.

Type ctrl-C and then you are able to enter GDB-commands i.e. set breakpoints , single step etc....

@FayeY FayeY closed this as completed Mar 6, 2018
gerekon pushed a commit that referenced this issue Jun 29, 2022
    #0 0x10c41485f in __asan_memcpy+0x1af (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x4285f)
    #1 0x10ab3dcfd in buf_cpy binarybuffer.c:60
    #2 0x10ab2774b in rtos_generic_stack_read rtos.c:664
    #3 0x10aac3ed9 in freertos_get_thread_registers_from_stack FreeRTOS.c:1148
    #4 0x10aab2ea2 in freertos_get_thread_reg_list FreeRTOS.c:1238
    #5 0x10aab32b1 in freertos_get_thread_reg FreeRTOS.c:1269
    #6 0x10aabe903 in freertos_get_tasks_details FreeRTOS.c:797
    #7 0x10aab270f in freertos_update_threads FreeRTOS.c:1060
    #8 0x10ab1d66e in rtos_thread_packet rtos.c:395
    #9 0x10ab1bad2 in gdb_thread_packet rtos.c:191
    #10 0x10aa4643d in gdb_input_inner gdb_server.c:3547
    #11 0x10aa3d534 in gdb_input gdb_server.c:3743
    #12 0x10aa8e565 in server_loop server.c:566
    #13 0x1099f6e66 in openocd_thread openocd.c:380
    #14 0x1099f685e in openocd_main openocd.c:419
    #15 0x1099f52b1 in main main.c:40
    #16 0x7fff6bf78cc8 in start+0x0 (libdyld.dylib:x86_64+0x1acc8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants