Comments (3)
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.
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.
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:
-
Disable
USE_WATCHDOG
-
Enable
MARLIN_DEV_MODE
-
Possibly disable
DISABLE_DEBUG
and/orDISABLE_JTAG
depending on your board (check the board's pins file). -
Build Marlin
Configure & Run GDB
macOS
-
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 💡 -
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. 💡 -
In the same Terminal window as Step 2, run the following command to connect GDB to the ST-Link:
tar ext:3333
Windows
-
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 💡 -
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. 💡 -
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)
- [FR] Linuxcnc and Fanuc compatibility HOT 6
- [BUG] MKS TinyBee Occasionally Fails to Execute G-code. HOT 7
- [BUG]#error Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN requires the Z_MIN_PIN to be defined." HOT 2
- [FR] M23 with long name HOT 2
- [BUG]2.1.2.2 Unable to Compile HOT 1
- [FR] G34 doesn't respect the X-axis twist compensation
- [BUG] M20 L skips folders if names are just numbers HOT 1
- [BUG] Unable to boot with any compiled commit after 2024-03-28 on the Ender 3 V2 Neo with an SKR3 HOT 3
- [BUG] Axis freeze/crash when FT_MOTION is turned ON HOT 3
- [BUG] 2.1.2.2 severely impacts reliability of BLtouch sensor on Mega2560 8-Bit boards HOT 8
- [BUG] REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SD not working HOT 1
- [BUG] Weird MPCTEMP behavior HOT 2
- [BUG] No axes move with FT_MOTION HOT 7
- [BUG] New encoder logic & debounce (#26723) bricks HOT 3
- [FR] Single pin for LCD BTN EN1, EN2, and ENC HOT 2
- [BUG] MPCTEMP and 12864 LCD error (GD32/Maple) HOT 2
- [BUG] Deploy/Stow wrong behaviour with a magnetic mounted probe
- [BUG] (Z Offset Don't Move) HOT 1
- [BUG] FT Motion causes endstops to not trigger properly HOT 1
- [BUG] Weird MPCTEMP behavior HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marlin.