PlatformIO Community

'Cannot access memory at address 0x10100' while debugging ESP8266 w/ gdbstub

i’m trying to debug my sketch on ESP8266 with gdbstub since this seems to be the only available solution aside the serial outputs.

I’ve started according the information on esp8266 & gdb. the sample sketch worked fine with the following platformio.ini config:

platform = espressif8266
board = d1_mini_pro
framework = arduino
upload_speed = 460800
build_flags =

and starting gdb from cmd line.

However when i do the same procedure - obviously not the same code :wink: - i get the following error while trying to attach to USB:

(gdb) target remote /dev/ttyUSB0
Remote debugging using /dev/ttyUSB0
0x00010100 in ?? ()
Cannot access memory at address 0x10100

below is my platformio.ini:

default_envs = d1_mini_pro

lib_deps =
	adafruit/Adafruit GFX Library @ ^1.10.7
	adafruit/Adafruit ST7735 and ST7789 Library @ ^1.7.1
	adafruit/Adafruit BusIO @ ^1.7.3
	bblanchon/ArduinoJson @ ^6.17.3
	bblanchon/StreamUtils @ ^1.6.1
	paulstoffregen/Time @ ^1.6

platform = espressif8266
framework = arduino
board = d1_mini_pro
upload_speed = 921600
build_flags =

Any hints to the right direction would be appreciated :slight_smile:

Welp that doesn’t look good. According to the reverse-engineered memory map, there’s nothing there. Internal mask-ROM code is at 40000000h of length 10000h, instruction RAM at 40100000h, then SPI flash is at 40200000h, variable length. This is the only places where it should ever execute code. 0x00010100 seems to to me that either the current instruction pointer hasn’t been read out correctly or some other weird fault is occuring.

You mean ~/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-gdb not gdb right?

Are you testing with that exact sketch?

Exactly, I got the same reference table from another post in the forum. It was exactly my thought, something weird is going on; but what :thinking: ?

I was using the ~/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/xtensa-lx106-elf-gdb;
but with ~/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-gdb the results is the same - just checked.

Yes, this one works just fine:

#include <GDBStub.h>

void setup() {

void loop() {
  static uint32_t cnt = 0;
  Serial.printf("%d\n", cnt++);

Do you think it might have to do with the number of included libraries? or the my code is so faulty that nothing works?

Because the simple sketch works on the same board, my own sketch doesn’t…

btw, thank you for the help :slight_smile:

What is the most minimal sketch with which it doesn’t anymore? The gdbstub also accesses Serial so one has to be careful. I find it very interesting that the sketch can do a Serial.printf() at all, with other gdbstubs like avr-stub that’s not possible. At the very least, no other library should read from the serial, I guess.

i already had started to minimize my sketch to a point where i found the issue - created an issue on ArduinoJson that as it seems was my fault :man_facepalming:

regarding the Serial out, indeed i was thinking the same, but the original sketch contained it, so i gave a try - interestingly it works for now for simple outputs :man_shrugging:

Thank you once again for your help and hints :slight_smile: