Forum: Mikrocontroller und Digitale Elektronik OpenOCD + gdb Probleme


von Alexander M. (a_lexander)


Lesenswert?

Hallo Zusammen,

Hier ist doch bestimmt ein "Debug"-Experte dabei, der mir helfen kann 
;)…

Es geht um das Debuggen des ESP32 Wroom mit OpenOCD, in VSCode (oder 
vielleicht zuerst auf der CMD...)

Command für OpenOCD:
1
 openocd -f interface/ftdi/c232hm.cfg -f board/esp-wroom-32.cfg
Zusätzlich in board/esp-wroom-32.cfg zugefügt, ansonsten gibt er mir 
einen Fehler:
1
Adapter_khz 1000

Aktuelle Ausgabe:
1
Info : Configured 2 cores
2
adapter speed: 1000 kHz
3
Info : Listening on port 6666 for tcl connections
4
Info : Listening on port 4444 for telnet connections
5
Error: type 'esp32' is missing virt2phys
6
Info : clock speed 1000 kHz
7
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
8
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
9
Info : esp32: Debug controller 0 was reset.
10
Info : esp32: Core 0 was reset.
11
Info : esp32: Debug controller 1 was reset.
12
Info : esp32: Core 1 was reset.
13
Info : Listening on port 3333 for gdb Connections

Das sieht meiner Meinung nach schon mal gut aus... ;)

Nun fehlt aber noch der gdb:
Command:
1
C:\Users\alex\Desktop\blink>xtensa-esp32-elf-gdb -x gdbinit ./build/blink.elf

gdbinit:
1
"target remote :3333", // Connect to OpenOCD
2
"mon reset halt", // Reset the chip and keep the CPUs halted
3
"set remote hardware-watchpoint-limit 2", // Restrict GDB to using two hardware watchpoints supported by ESP32
4
"flushregs", // Force GDB to get new state from the target
5
"thb app_main", // Insert a temporary hardware breakpoint at the main function
6
"c" // Resume the program. It will then stop at breakpoint inserted at app_main

und die Ausgabe ist Folgende...
1
Type "show configuration" for configuration details.
2
For bug reporting instructions, please see:
3
<http://www.gnu.org/software/gdb/bugs/>.
4
Find the GDB manual and other documentation resources online at:
5
<http://www.gnu.org/software/gdb/documentation/>.
6
For help, type "help".
7
Type "apropos word" to search for commands related to "word"...
8
Reading symbols from ./build/blink.elf...done.
9
gdbinit:1: Error in sourced command file:
10
Undefined command: "".  Try "help".
11
(gdb)

Vielen Dank für eure Hilfe, mit einer Lösung könnte ich glücklich ins 
Wochenende starten ;)...

von Vincent H. (vinci)


Lesenswert?

Alexander M. schrieb:
> gdbinit:
>
1
> "target remote :3333", // Connect to OpenOCD
2
> "mon reset halt", // Reset the chip and keep the CPUs halted
3
> "set remote hardware-watchpoint-limit 2", // Restrict GDB to using two 
4
> hardware watchpoints supported by ESP32
5
> "flushregs", // Force GDB to get new state from the target
6
> "thb app_main", // Insert a temporary hardware breakpoint at the main 
7
> function
8
> "c" // Resume the program. It will then stop at breakpoint inserted at 
9
> app_main
10
>

Meines Wissens nach beinhalten gdbinit files keine "

/edit
Und auch keine Beistriche?

: Bearbeitet durch User
von Jörg W. (dl8dtl) (Moderator) Benutzerseite


Lesenswert?

Vincent H. schrieb:
> Meines Wissens nach beinhalten gdbinit files keine "

Sowie keine abschließenden Kommas und keine C++-Kommentare.

Kommentare fangen mit # an.

von Alexander M. (a_lexander)


Lesenswert?

Vielen Dank! Oh man... ;)
Ja er tut "etwas", so richtig debuggen kann ich allerdings noch nicht...
Vielleicht will mir da auch noch jemand auf die Sprünge helfen, 
ansonsten werde ich da wohl weitersuchen müssen...

Ausgabe GDB, hier bleib ich allerdings auch "stecken" und kann keine 
Eingabe mehr machen..
1
C:\Users\alex\Desktop\blink>xtensa-esp32-elf-gdb -x gdbinit -f ./build/blink.elf
2
GNU gdb (crosstool-NG esp-2019r2) 8.1.0.20180627-git
3
Copyright (C) 2018 Free Software Foundation, Inc.
4
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
5
This is free software: you are free to change and redistribute it.
6
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
7
and "show warranty" for details.
8
This GDB was configured as "--host=i686-host_w64-mingw32 --target=xtensa-esp32-elf".
9
Type "show configuration" for configuration details.
10
For bug reporting instructions, please see:
11
<http://www.gnu.org/software/gdb/bugs/>.
12
Find the GDB manual and other documentation resources online at:
13
<http://www.gnu.org/software/gdb/documentation/>.
14
For help, type "help".
15
Type "apropos word" to search for commands related to "word"...
16
Reading symbols from ./build/blink.elf...done.
17
0x40147b52 in ?? ()
18
  esp32 arp_examine ['allow-defer']
19
  esp32 arp_halt
20
  esp32 arp_halt_gdb
21
  esp32 arp_poll
22
  esp32 arp_reset
23
  esp32 arp_waitstate
24
    esp32 esp32 flashbootstrap none|1.8|3.3|high|low
25
  esp32 examine_deferred
26
  esp32 flashbootstrap none|1.8|3.3|high|low
27
  esp32 was_examined
28
ftdi_layout_init data direction
29
  jtag arp_init-reset
30
jtag_reset trst_active srst_active
31
power_restore
32
program <filename> [address] [verify] [reset] [exit]
33
program_esp <filename> [address] [verify] [reset] [exit]
34
program_esp32 <filename> [address] [verify] [reset] [exit]
35
reset [run|halt|init]
36
reset_config [none|trst_only|srst_only|trst_and_srst]
37
          [srst_pulls_trst|trst_pulls_srst|combined|separate]
38
          [srst_gates_jtag|srst_nogate] [trst_push_pull|trst_open_drain]
39
          [srst_push_pull|srst_open_drain]
40
          [connect_deassert_srst|connect_assert_srst]
41
reset_nag ['enable'|'disable']
42
soft_reset_halt
43
srst_deasserted
44
45
Hardware assisted breakpoint 1 at 0x400d394f: file ../main/blink.c, line 28.

Ausabe OpenOCD:
1
C:\Users\alex\esp\esp-idf>openocd -f interface/ftdi/c232hm.cfg -f board/esp-wroom-32.cfg
2
Open On-Chip Debugger  v0.10.0-esp32-20191114 (2019-11-14-14:19)
3
Licensed under GNU GPL v2
4
For bug reports, read
5
        http://openocd.org/doc/doxygen/bugs.html
6
WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release.
7
Info : Configured 2 cores
8
adapter speed: 1000 kHz
9
Info : Listening on port 6666 for tcl connections
10
Info : Listening on port 4444 for telnet connections
11
Error: type 'esp32' is missing virt2phys
12
Info : clock speed 1000 kHz
13
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
14
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
15
Info : esp32: Debug controller 0 was reset.
16
Info : esp32: Core 0 was reset.
17
Info : esp32: Debug controller 1 was reset.
18
Info : esp32: Core 1 was reset.
19
Info : Listening on port 3333 for gdb connections
20
Info : accepting 'gdb' connection on tcp/3333
21
Error: No symbols for FreeRTOS
22
Info : Target halted. CPU0: PC=0x40147B52 (active)
23
Info : Target halted. CPU1: PC=0x40147B52
24
Info : cpu0: Target halted, PC=0x400916EA, debug_reason=00000001
25
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 100 KB
26
Info : Flash mapping 1: 0x30020 -> 0x400d0020, 486 KB
27
Info : cpu0: Target halted, PC=0x400916EA, debug_reason=00000001
28
Info : Auto-detected flash bank 'esp32.flash' size 4096 KB
29
Info : Using flash bank 'esp32.flash' size 4096 KB
30
Info : cpu0: Target halted, PC=0x400916EA, debug_reason=00000001
31
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 100 KB
32
Info : Flash mapping 1: 0x30020 -> 0x400d0020, 486 KB
33
Info : Using flash bank 'esp32.irom' size 488 KB
34
Info : cpu0: Target halted, PC=0x400916EA, debug_reason=00000001
35
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 100 KB
36
Info : Flash mapping 1: 0x30020 -> 0x400d0020, 486 KB
37
Info : Using flash bank 'esp32.drom' size 104 KB
38
Warn : negative reply, retrying
39
Warn : negative reply, retrying
40
  esp32 arp_examine ['allow-defer']
41
  esp32 arp_halt
42
  esp32 arp_halt_gdb
43
  esp32 arp_poll
44
  esp32 arp_reset
45
  esp32 arp_waitstate
46
    esp32 esp32 flashbootstrap none|1.8|3.3|high|low
47
  esp32 examine_deferred
48
  esp32 flashbootstrap none|1.8|3.3|high|low
49
  esp32 was_examined
50
ftdi_layout_init data direction
51
  jtag arp_init-reset
52
jtag_reset trst_active srst_active
53
power_restore
54
program <filename> [address] [verify] [reset] [exit]
55
program_esp <filename> [address] [verify] [reset] [exit]
56
program_esp32 <filename> [address] [verify] [reset] [exit]
57
reset [run|halt|init]
58
reset_config [none|trst_only|srst_only|trst_and_srst]
59
          [srst_pulls_trst|trst_pulls_srst|combined|separate]
60
          [srst_gates_jtag|srst_nogate] [trst_push_pull|trst_open_drain]
61
          [srst_push_pull|srst_open_drain]
62
          [connect_deassert_srst|connect_assert_srst]
63
reset_nag ['enable'|'disable']
64
soft_reset_halt
65
srst_deasserted

Danke vorab ;)

von Alexander M. (a_lexander)


Lesenswert?

Okay ich bin irgendwie doch schon in einem Modus, ob ich den aktuell 
schon als "Debug" bezeichnen würde, eher nicht.. :D

Für alle Interessierten, so siehts aktuell aus ;)
GDB:
1
...
2
(gdb) where
3
#0  0x40147b52 in ?? ()
4
#1  0x400d36d2 in set_boot_time (time_us=8)
5
    at C:/Users/alex/esp/esp-idf/components/newlib/time.c:111
6
#2  0x40094618 in ?? () at C:/Users/alex/esp/esp-idf/components/newlib/time.c:278
7
#3  0x40092890 in ?? () at C:/Users/alex/esp/esp-idf/components/newlib/time.c:278
8
(gdb)

OpenOCD:
1
...
2
Warn : target esp32 is not halted (gdb fileio)
3
Error: FreeRTOS_update_threads not TARGET_HALTED!
4
Warn : xtensa_read_memory: cpu0: target not halted
5
Error: Could not read FreeRTOS thread count from target
6
Polling target esp32 failed, trying to reexamine
7
Examination failed, GDB will be halted. Polling again in 100ms
8
Info : esp32: Debug controller 0 was reset.
9
Info : esp32: Core 0 was reset.
10
Polling target esp32 failed, trying to reexamine
11
Info : esp32: Debug controller 1 was reset.
12
Info : esp32: Core 1 was reset.
13
Warn : xtensa_read_memory: cpu0: target not halted
14
Error: FreeRTOS_update_threads not TARGET_HALTED!
15
Warn : xtensa_read_memory: cpu0: target not halted
16
Error: Could not read FreeRTOS thread count from target
17
Warn : cpu0: target not halted
18
Error: esp32.cpu0: Failed to step!
19
Info : target esp32 was not halted when step was requested
20
Info : Target halted. CPU0: PC=0x40147B52 (active)
21
Info : Target halted. CPU1: PC=0x40147B52
22
Info : Target halted. CPU0: PC=0x40093DE7
23
Info : Target halted. CPU1: PC=0x40147B52 (active)
24
Info : Target halted. CPU0: PC=0x40147B52 (active)
25
Info : Target halted. CPU1: PC=0x40147B52
26
Info : Target halted. CPU0: PC=0x4012310B
27
Info : Target halted. CPU1: PC=0x40147B52 (active)
28
Info : Target halted. CPU0: PC=0x40147B52
29
Info : Target halted. CPU1: PC=0x40147B52 (active)
30
Info : Target halted. CPU0: PC=0x40147B52 (active)
31
Info : Target halted. CPU1: PC=0x400D36D2

Grüße

von Vincent H. (vinci)


Lesenswert?

Debug-Symbole?

von Alexander M. (a_lexander)


Lesenswert?

So im Groben funktioniert das jetzt, die Debug-Symbole werde ich mir die 
nächsten Tage anschauen ;)

Für die Interessierten:

- Ich habe die ESP-IDF Command Prompt verwendet 
(esp-idf-tools-setup-2.2.exe)
- der OpenOCD / der xtensa-esp32-elf-gdb müssen im Projekt aufgerufen 
werden
- der JTAG Adapter war der C232HM, Wichtig: mit dem Tool Zadig wurde der 
Treiber auf einen FTDI gewechselt --> somit war er lauffähig für den 
OpenOCD

Danke :)

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.