项目作者: resetnow

项目描述 :
ESP8266 debugging tool
高级语言: C
项目地址: git://github.com/resetnow/esp-gdbstub.git
创建时间: 2016-09-01T08:34:08Z
项目社区:https://github.com/resetnow/esp-gdbstub

开源协议:Other

下载


esp-gdbstub

Intro

ESP8266 debugging tool intended to be used with esp-open-rtos. Based on Espressif/esp-gdbstub.

Usage

  1. Build requires premake5 and xtensa-lx106-elf toolchain. Make sure both are in your PATH.
  2. Configure with premake5 gmake. The following options are supported:

    • --with-eor=/path/to/esp-open-rtos: this option is required. It should point to an actual esp-open-rtos location.
    • --with-threads: enable RTOS task debugging. As for now, there is very basic support of threads, you will be able
      to see multiple tasks when a breakpoint is hit, but GDB will most likely crash shorlty after. This option also has
      a performance impact because a lot of data will be transferred through serial connection — consider increasing
      the baudrate.

      When thread support is enabled, you need to add the following definitions to CFLAGS of your project before compiling
      FreeRTOS libs:

      1. EXTRA_CFLAGS+=-DportREMOVE_STATIC_QUALIFIER -DINCLUDE_pcTaskGetTaskName=1
      2. # The line above should go before including common.mk

      Run make clean after switching the state of this flag.

  3. Run make
  4. Add library to your project:

    1. PROGRAM=blink
    2. # Order is important!
    3. EXTRA_CFLAGS+=-I../../../esp-gdbstub/include
    4. EXTRA_LDFLAGS+=-L../../../esp-gdbstub/lib
    5. include ../../common.mk
    6. LIBS+=esp-gdbstub
    7. PROGRAM_CFLAGS+=-O0
  5. Call gdbstub_init() after configuring UART speed.

Optimization, stack trace resolving and GDB

It has been observed that GDB may crash when user requests step over source in a file compiled with optimization turned on. I haven’t figured out why exactly this happens, but it has something to do with stack frame resolving. Turning optimization off for the whole project would impact performance and code size — that’s why only PROGRAM_CFLAGS is modified.

Eclipse CDT setup

To use Eclipse CDT for debugging, open Eclipse, create a new project and create a debug configuration for C/C++ Remote Application.

You need to set the following options:

  1. Main → Application: Firmware ELF
  2. Debugger: Uncheck “Stop on startup at: main”
  3. Debugger → Main: select GDB binary and .gdbinit file provided with esp-gdbstub
  4. Debugger → Connection → Type: Serial
  5. Debugger → Connection → Speed: 115200

Note that upon launching the debug session gdb will send “continue” command if the target is paused at gdbstub_do_break. If you want to stop right after debug session launch, place gdbstub_do_break macro twice in your code.

Notes

  • Using software breakpoints (‘br’) only works on code that’s in RAM. Code in flash can only have a hardware breakpoint (‘hbr’). If you know where you want to break before downloading the program to the target, you can use gdbstub_do_break() macro as much as you want.
  • Due to hardware limitations, only one hardware breakpount and one hardware watchpoint are available.