I'm trying to debug my code on an ESP8266 with GDB, but can't get it to connect.
ESP8266 code (gdb.ino):
#include <GDBStub.h>
void setup() {
Serial.begin( 115200 );
gdbstub_init();
pinMode( LED_BUILTIN, OUTPUT );
}
unsigned long m_last;
unsigned long m_delay = 1000;
bool state = false;
void loop() {
m_last = millis();
digitalWrite( LED_BUILTIN, state );
while ( millis() < ( m_last + m_delay ) )
yield();
state = !state;
}
Commands I use to start debug session:
~/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/xtensa-lx106-elf-gdb
GNU gdb (GDB) 8.2.50.20190202-git
Copyright (C) 2019 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-linux-gnu --target=xtensa-lx106-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".
(gdb) set remote hardware-breakpoint-limit 1
(gdb) set remote hardware-watchpoint-limit 1
(gdb) set remote interrupt-on-connect on
(gdb) set remote kill-packet off
(gdb) set remote symbol-lookup-packet off
(gdb) set remote verbose-resume-packet off
(gdb) mem 0x20000000 0x3fefffff ro cache
(gdb) mem 0x3ff00000 0x3fffffff rw
(gdb) mem 0x40000000 0x400fffff ro cache
(gdb) mem 0x40100000 0x4013ffff rw cache
(gdb) mem 0x40140000 0x5fffffff ro cache
(gdb) mem 0x60000000 0x60001fff rw
(gdb) set serial baud 115200
(gdb) file /tmp/arduino/sketches/D9ED6FC0207E66B7EA29DCF94067011B/gdb.ino.elf
Reading symbols from /tmp/arduino/sketches/D9ED6FC0207E66B7EA29DCF94067011B/gdb.ino.elf...
(gdb) target remote /dev/ttyUSB0
Remote debugging using /dev/ttyUSB0
Ignoring packet error, continuing...
warning: unrecognized item "timeout" in "qSupported" response
Ignoring packet error, continuing...
Remote replied unexpectedly to 'vMustReplyEmpty': timeout
(gdb)
OS is KDE neon, which is based on Ubuntu 24.04.
usb port looks to be correct:
stat /dev/ttyUSB0
File: /dev/ttyUSB0
Size: 0 Blocks: 0 IO Block: 4096 character special file
Device: 0,5 Inode: 1211 Links: 1 Device type: 188,0
Access: (0660/crw-rw----) Uid: ( 0/ root) Gid: ( 20/ dialout)
Access: 2024-12-04 22:29:13.000000000 -0600
Modify: 2024-12-04 22:29:21.000000000 -0600
Change: 2024-12-04 21:07:07.773703612 -0600
Birth: 2024-12-04 21:06:25.384596812 -0600
It's the same port used with Arduino IDE, and access is fine from within Arduino IDE. I closed the Arduino IDE app entirely before starting GDB. But still no success.
Anyone know what the issue may be?