espressif / openocd-esp32

OpenOCD branch with ESP32 JTAG support
Other
360 stars 132 forks source link

Debugging is not working with firmware from Arduino IDE #12

Closed valeros closed 6 years ago

valeros commented 7 years ago

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 commented 7 years ago

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

valeros commented 7 years ago

Hi @igrr ! Sure, openocd, GDB, elf

igrr commented 7 years ago

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

igrr commented 7 years ago

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 commented 7 years ago

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....