Git Product home page Git Product logo

Comments (3)

sjasonsmith avatar sjasonsmith commented on June 12, 2024

It is definitely possible to debug on real hardware, but it typically requires a JTAG interface. The actual requirements vary by board and MCU. It is sometimes very easy, and sometimes impossible.

Some environments have debug information configured in them (or defaulted in PlatformIO), but they are going to reflect whatever a developer had used on them previously, and won't necessarily match what you have on hand.

from marlin.

sjasonsmith avatar sjasonsmith commented on June 12, 2024

There probably aren't really Marlin-specific instructions for this, but you can find information about how to configure debugging with PlatformIO to get started.

from marlin.

thisiskeithb avatar thisiskeithb commented on June 12, 2024

Here's an STM32F1 example:

Debug Marlin 2.x with VSCode & PlatformIO using an ST-Link V2 (STM32F1)

Table of Contents

Connect ST-Link V2 to SWD Pins

This will vary depending on the board.

Configure Marlin

Using your desired config settings, you will also need to:

  1. Disable USE_WATCHDOG

  2. Enable MARLIN_DEV_MODE

  3. Possibly disable DISABLE_DEBUG and/or DISABLE_JTAG depending on your board (check the board's pins file).

  4. Build Marlin

Configure & Run GDB

macOS

  1. In VSCode, open Terminal (CTRL + `) and run the following to configure OpenOCD (STM32F1):

    ~/.platformio/packages/tool-openocd/bin/openocd -d2 -s ~/.platformio/packages/tool-openocd/scripts -f interface/stlink.cfg  -f target/stm32f1x.cfg
    

    💡 See ~/.platformio/packages/tool-openocd/scripts/target for a full list of *.cfg files 💡

  2. Then open a new Terminal (CTRL + SHIFT + `) and run the following to launch GDB for debugging:

    ~/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gdb /path/to/marlin/.pio/build/YOUR_PIO_ENV/firmware.elf
    

    💡 Be sure to change the path to firmware.elf in the command above to match your build environment. 💡

  3. In the same Terminal window as Step 2, run the following command to connect GDB to the ST-Link:

    tar ext:3333
    

Windows

  1. In VSCode, open Terminal (CTRL + `) and run the following to configure OpenOCD (STM32F1):

    %USERPROFILE%\.platformio\packages\tool-openocd\bin\openocd -d2 -s %USERPROFILE%\.platformio\packages\tool-openocd\scripts -f interface\stlink.cfg  -f target\stm32f1x.cfg
    

    💡 See %USERPROFILE%\.platformio\packages\tool-openocd\scripts\target for a full list of *.cfg files 💡

  2. Then open a new Terminal (CTRL + SHIFT + `) and run the following to launch GDB for debugging:

    %USERPROFILE%\.platformio\packages\toolchain-gccarmnoneeabi\bin\arm-none-eabi-gdb C:\path\to\marlin\.pio\build\YOUR_PIO_ENV\firmware.elf
    

    💡 Be sure to change the path to firmware.elf in the command above to match your build environment. 💡

  3. In the same Terminal window as Step 2, run the following command to connect GDB to the ST-Link:

    tar ext:3333
    

Basic GDB Debugging Commands

Command Description
bt Backtrace. Print the current function stack to show where you are in the current program
bt full Backtrace, including local variables
b Break on the first line in Marlin firmware
n Step over
s Step into
c Continue
q Quit
r Restart

from marlin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.