OpenOCD problem

RA5040
Posts: 26
Joined: Mon Jul 30, 2018 1:20 pm

OpenOCD problem

Postby RA5040 » Fri Aug 24, 2018 5:57 pm

I have installed OpenOCD, command-line, using the Espressif documentation (which is very good). For anyone who is interested, I have summarized the steps here (for Windows): http://www.irelandupclose.com/customer/esp32/jtag/

But I am still having some problems. The first one is that I get an information message/error every time I do a Next:
Info : Not full dbg stub table 1 of 2

The debug works OK up to a point: some tests (like the GPIO example) seem to debug reasonably well, but the Blink example does not. These are probably two separate problems. but if I could fix the 'Not full dbg stub table 1 of 2' error it would be a good start.

Any advice?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: OpenOCD problem

Postby kolban » Fri Aug 24, 2018 6:32 pm

I did a google search and found:

https://community.platformio.org/t/esp3 ... er/4541/22

Is it possible you are using the "Master" branch of the ESP-IDF? Unless there is something really compelling in a non-stable release, I usually recommend using the stable releases.

https://github.com/espressif/esp-idf/releases

The solid stable release is 3.0.3

while the pre-release is V3.1-rc1

The master branch is beyond even that and could be volatile at times.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

RA5040
Posts: 26
Joined: Mon Jul 30, 2018 1:20 pm

Re: OpenOCD problem

Postby RA5040 » Fri Aug 24, 2018 6:42 pm

I'm not sure of the version. I'm using this one: https://github.com/espressif/esp-idf.git

But I'll try 3.0.3

Thanks!

RA5040
Posts: 26
Joined: Mon Jul 30, 2018 1:20 pm

Re: OpenOCD problem

Postby RA5040 » Fri Aug 24, 2018 8:09 pm

Unfortunately 3.03 gives the same problems. The Blink project doesn't work at all (with either version of the idf).

Here is the gdb log:
===============
GNU gdb (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a5) 7.10
Copyright (C) 2015 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=i686-host_pc-mingw32 --target=xtensa-esp32-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"...
Reading symbols from build/blink.elf...done.
0x400d1ffa in app_main () at C:/msys32/home/Robert/esp/blink/main/blink.c:45
45 vTaskDelay(1000);
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
cpu0: Current bits set: BreakIn BreakOut RunStallIn
cpu1: Current bits set: BreakIn BreakOut RunStallIn
esp32: Debug controller was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core was reset (pwrstat=0x5F, after clear 0x0F).
Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
esp32: Core was reset (pwrstat=0x1F, after clear 0x0F).
Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
Hardware assisted breakpoint 1 at 0x400d1fdb: file C:/msys32/home/Robert/esp/blink/main/blink.c, line 43.
Target halted. PRO_CPU: PC=0x400D1FDB (active) APP_CPU: PC=0x400D1816
[New Thread 1073435384]
[New Thread 1073433996]
[New Thread 1073438040]
[New Thread 1073426884]
[New Thread 1073412716]
[New Thread 1073413484]
[New Thread 1073428016]
[Switching to Thread 1073432476]

Temporary breakpoint 1, app_main ()
at C:/msys32/home/Robert/esp/blink/main/blink.c:43
43 xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
(gdb)


(note that it says temporary breakpoint at app_main (as per the 'thb app_main' parameter)
----> Now some gdb commands

(gdb) n
Note: automatically using hardware breakpoints for read-only addresses.
Target halted. PRO_CPU: PC=0x400D1FF4 (active) APP_CPU: PC=0x40080340
[New Thread 1073439548]
45 vTaskDelay(1000);
(gdb)

2nd N
(gdb) n
... nothing for quite a while then every 5 seconds or so one of these lines is printed:
Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
=======================

and here is the OpenOCD log:
--------------------------------
Open On-Chip Debugger 0.10.0-dev (2018-07-24-09:39)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
none separate
adapter speed: 20000 kHz
esp32 interrupt mask on
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 20000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
cpu0: Current bits set: BreakIn BreakOut RunStallIn
cpu1: Current bits set: BreakIn BreakOut RunStallIn

>>>> now run app

Info : accepting 'gdb' connection on tcp/3333
Info : Target halted. PRO_CPU: PC=0x4009170E (active) APP_CPU: PC=0x400D1816
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 23 KB
Info : Flash mapping 1: 0x20018 -> 0x400d0018, 77 KB
Info : Target halted. PRO_CPU: PC=0x4009170E (active) APP_CPU: PC=0x400D1816
Info : Auto-detected flash size 4096 KB
Info : Using flash size 4096 KB
Info : Target halted. PRO_CPU: PC=0x4009170E (active) APP_CPU: PC=0x400D1816
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 23 KB
Info : Flash mapping 1: 0x20018 -> 0x400d0018, 77 KB
Info : Using flash size 80 KB
Info : Target halted. PRO_CPU: PC=0x4009170E (active) APP_CPU: PC=0x400D1816
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 23 KB
Info : Flash mapping 1: 0x20018 -> 0x400d0018, 77 KB
Info : Using flash size 24 KB
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
cpu0: Current bits set: BreakIn BreakOut RunStallIn
cpu1: Current bits set: BreakIn BreakOut RunStallIn
Info : esp32: Debug controller was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Info : esp32: Core was reset (pwrstat=0x1F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
Info : Target halted. PRO_CPU: PC=0x400D1FDB (active) APP_CPU: PC=0x400D1816

----> After pressing 'N first time:
Info : Target halted. PRO_CPU: PC=0x400D1FF4 (active) APP_CPU: PC=0x40080340

----> After pressing 'N' 2nd time:
nothing for quite a long time then every 5 seconds or so a line is printed:
Info : Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
Info : Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
Info : Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
Info : Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
Info : Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
Info : Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816
Info : Target halted. PRO_CPU: PC=0x400D1FFA (active) APP_CPU: PC=0x400D1816

--------------------------------

and here is the Blink code:
********************************
1 /* Blink Example
2
3 This example code is in the Public Domain (or CC0 licensed, at your option.)
4
5 Unless required by applicable law or agreed to in writing, this
6 software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
7 CONDITIONS OF ANY KIND, either express or implied.
8 */
9 #include <stdio.h>
10 #include "freertos/FreeRTOS.h"
11 #include "freertos/task.h"
12 #include "driver/gpio.h"
13 #include "sdkconfig.h"
14
15 /* Can run 'make menuconfig' to choose the GPIO to blink,
16 or you can edit the following line and set a number here.
17 */
18 #define BLINK_GPIO 2
19
20 void blink_task(void *pvParameter)
21 {
22 /* Configure the IOMUX register for pad BLINK_GPIO (some pads are
23 muxed to GPIO on reset already, but some default to other
24 functions and need to be switched to GPIO. Consult the
25 Technical Reference for a list of pads and their default
26 functions.)
27 */
28 gpio_pad_select_gpio(BLINK_GPIO);
29 /* Set the GPIO as a push/pull output */
30 gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
31 while(1) {
32 /* Blink off (output low) */
33 gpio_set_level(BLINK_GPIO, 0);
34 vTaskDelay(1000 / portTICK_PERIOD_MS);
35 /* Blink on (output high) */
36 gpio_set_level(BLINK_GPIO, 1);
37 vTaskDelay(1000 / portTICK_PERIOD_MS);
38 }
39 }
40
41 void app_main()
42 {
43 xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
44 while(true){
45 vTaskDelay(1000);
46 }
47 }


*****************************************

I put in the vTaskDelay at line 45 because before that the second N was black hole territory.

I'll try with a simpler blink without a task, but this one should work (the program does run and the led blinks, so the hardware seems OK).

RA5040
Posts: 26
Joined: Mon Jul 30, 2018 1:20 pm

Re: OpenOCD problem

Postby RA5040 » Fri Aug 24, 2018 9:16 pm

Well, by sheer head banging against the brick wall and sore eyes I seem to have made a breakthrough of sorts.

It seems that to run gdb on the ESP32 DevKit C, it's necessary to do things in this order:

1. Make and flash the program
2. Run OpenOCD
3. Run xtensa-esp32-elf-gdb

If OpenOCD is running before flashing the program nothing works.

The Espressif documentation says that OpenOCD should be running, then the program should be flashed, then gdb should be run (https://esp-idf.readthedocs.io/en/lates ... mmand-line

So there's either a bug in the code or a bug in the documentation or a bug in my hardware (or in my head). But there is bug there somewhere and I certainly am not competent to find it or even to know who to talk to about it.

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

Re: OpenOCD problem

Postby ESP_igrr » Sat Aug 25, 2018 4:28 pm

Hi RA5040,

Not full dbg stub table 1 of 2 is not an error, it is logged at info level.

RA5040
Posts: 26
Joined: Mon Jul 30, 2018 1:20 pm

Re: OpenOCD problem

Postby RA5040 » Sat Aug 25, 2018 4:49 pm

OK, thanks .... good to know. The problem had to do with the order of running gdb/openocd, but at the time of my post I didn't know that.

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

Re: OpenOCD problem

Postby ESP_igrr » Sat Aug 25, 2018 5:05 pm

The order of starting gdb and OpenOCD should not matter, as long as OpenOCD is running at the point when you are executing "target remote ..." command in GDB.

RA5040
Posts: 26
Joined: Mon Jul 30, 2018 1:20 pm

Re: OpenOCD problem

Postby RA5040 » Sat Aug 25, 2018 5:27 pm

Well the problem is that the order does appear to matter. Try it and see. You can follow the steps I took here, if you wish: http://www.irelandupclose.com/customer/ ... _LINE.html

It's just a summary of the Espressif documentation ... which I have followed to the letter (as far as I am aware).

You should find (at least on Windows) that the debug will not work. If you then
flash
run openocd
run gdb

It should work.

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

Re: OpenOCD problem

Postby ESP_igrr » Sat Aug 25, 2018 7:40 pm

Hi RA5040,
I might have a clue where the issue is, could you please try one thing to check?
In openocd directory, in share/openocd/scripts/target/esp32.cfg, change "halt" to "reset halt" on line 78:
$TGT configure -event gdb-attach { reset halt }
Save the file, start openocd, "make flash", try to connect with GDB.
Thanks.

Who is online

Users browsing this forum: Google [Bot] and 211 guests