JTAG error when hitting breakpoint (blink example)

gdombi
Posts: 1
Joined: Sun Feb 25, 2018 4:59 am

JTAG error when hitting breakpoint (blink example)

Postby gdombi » Sun Feb 25, 2018 5:23 am

Hi everyone,

First time posting in this forum. I will try to provide as much information about the problem I'm having.

Problem: xtensa-esp32-elf-gdb fails setting breakpoint. Displays "Cannot access memory at address 0x0"

Hardware:
  • Olimex ARM-USB-OCD-H (version 7.0)
    NodeMCU ESP-32S revision 1.1
Software:
1. esp-idf latest from master (commit 165e3edd4949586dc90fa682f907d971fee488fc (HEAD -> master, origin/master, origin/HEAD))
2. Modified blink example:

Code: Select all

/* Blink Example

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "sdkconfig.h"

/* Can run 'make menuconfig' to choose the GPIO to blink,
   or you can edit the following line and set a number here.
*/
#define BLINK_GPIO CONFIG_BLINK_GPIO  // Use GPIO 2 for onboard LED

void stop_here() {
	printf("Aca!\n");
}

void blink_task(void *pvParameter)
{
    /* Configure the IOMUX register for pad BLINK_GPIO (some pads are
       muxed to GPIO on reset already, but some default to other
       functions and need to be switched to GPIO. Consult the
       Technical Reference for a list of pads and their default
       functions.)
    */
    gpio_pad_select_gpio(BLINK_GPIO);
    /* Set the GPIO as a push/pull output */
    gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
    while(1) {
        /* Blink off (output low) */
        gpio_set_level(BLINK_GPIO, 0);
        vTaskDelay(1000 / portTICK_PERIOD_MS);
        /* Blink on (output high) */
        gpio_set_level(BLINK_GPIO, 1);
        vTaskDelay(1000 / portTICK_PERIOD_MS);
        stop_here();
    }
}

void app_main()
{
    xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
}
OpenOCD started with: "bin/openocd -s share/openocd/scripts -f interface/ftdi/olimex-arm-usb-ocd-h.cfg -f board/esp-wroom-32.cfg". Here is the console. The second "paragraph" is the log when I run xtensa-esp32-elf-gdb.

Code: Select all

Gastons-Mac-mini:openocd-esp32 gaston$ bin/openocd -s share/openocd/scripts -f interface/ftdi/olimex-arm-usb-ocd-h.cfg -f board/esp-wroom-32.cfg
Open On-Chip Debugger 0.10.0-dev-ga859564 (2017-07-25-00:19)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 20000 kHz
force hard breakpoints
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)
Info : esp32: Debug controller was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core was reset (pwrstat=0x5F, after clear 0x0F).



Info : accepting 'gdb' connection on tcp/3333
Info : Target halted. PRO_CPU: PC=0x400D1A8E (active)    APP_CPU: PC=0x00000000
esp32: target state: halted
Info : Use core0 of target 'esp32'
Error: cpu0: esp32_fetch_all_regs (line 234): DSR (8091CC13) indicates DIR instruction generated an exception!
Info : Target halted. PRO_CPU: PC=0x400905EC (active)    APP_CPU: PC=0x400076DD
Info : Auto-detected flash size 0 KB
Info : Using flash size 0 KB
Info : Set current thread to 0x00000000, old= 0x00000000
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)
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
esp32: target state: halted
Info : esp32: Core was reset (pwrstat=0x1F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400
esp32: target state: halted
Command to debug: "xtensa-esp32-elf-gdb -x gdbinit build/blink.elf"
Here is the source for gdbinit (just modified name of function of breakpoint. I tried with app_main with same results so I created my own function just in case that was the problem)

Code: Select all

target remote :3333
mon reset halt
thb stop_here
x $a1=0
c
Output from xtensa-esp32-elf-gdb:

Code: Select all

Gastons-Mac-mini:blink gaston$ xtensa-esp32-elf-gdb -x gdbinit build/blink.elf
GNU gdb (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a) 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=x86_64-build_apple-darwin16.3.0 --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.
0x400d1a8e in esp_vApplicationIdleHook () at /Users/gaston/esp/esp-idf/components/esp32/./freertos_hooks.c:62
62	    asm("waiti 0");
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)
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: target state: halted
esp32: Core was reset (pwrstat=0x1F, after clear 0x0F).
Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400
esp32: target state: halted
Hardware assisted breakpoint 1 at 0x400d1f3b: file /Users/gaston/esp/blink/main/./blink.c, line 21.
0x0:	gdbinit:4: Error in sourced command file:
Cannot access memory at address 0x0
I also tried from Eclipse and as expected it hit the same error which made Eclipse crash with some bug and abort the debug session.

Interestingly, I noticed the LED not blinking so it seems that even though I had that error the system was halted somewhere. For curiosity I typed "c" and the console moved and it then hit MY breakpoint. Though my breakpoint is inside of a loop and gdb decided to not stop again as you can see in the logs:

Code: Select all

(gdb) c
Continuing.
Target halted. PRO_CPU: PC=0x400D1F3B (active)    APP_CPU: PC=0x400D1A8E
[New Thread 1073435336]
[New Thread 1073433948]
[New Thread 1073437992]
[New Thread 1073426836]
[New Thread 1073412716]
[New Thread 1073413468]
[Switching to Thread 1073439156]

Temporary breakpoint 1, stop_here () at /Users/gaston/esp/blink/main/./blink.c:21
21		printf("Aca!\n");
(gdb) c
Continuing.
(gdb)
Anyway, my main question is how can I fix the error?
0x0: gdbinit:4: Error in sourced command file:
Cannot access memory at address 0x0

Thanks for your help. I can post a picture of how things are wired if that would help.
Gaston

PS: I might create another post since Olimex JTAG is failing to flash the app and it seems like it was supported.

Who is online

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