Skip to content

Latest commit

 

History

History
71 lines (47 loc) · 2.79 KB

HOW_TO_DEBUG.md

File metadata and controls

71 lines (47 loc) · 2.79 KB

How to use the PlatformIO Debugger

using the PlatformIO debugger is a great way to debug your code. It allows you to set breakpoints, step through your code, and inspect variables. This document will show you how to setup your Project for use with the PlatformIO debugger and the HC32F460.

Warning

please note that debugging support is a fairly experimental feature for the HC32F460 platform. while most things should work okay, there may be some issues.

Limitations

please note that the HC32F460 platform is currently somewhat limited in terms of debugging support.

things that work / don't work:

Status Feature Notes
🟡 Breakpoints can only use software breakpoints, so max. 6 breakpoints are available
🟢 Step Over / Into / Out
🟢 Variable inspection variable inspection tends to be kind of slow
🟡 Watchpoints only 4 watchpoints are available
🟢 Call stack inspection
🟡 Peripheral register inspection some registers of the Cortex-M4 core seem to be missing
🟢 CPU register inspection
🟢 Memory inspection
🟢 Disassembly view if you're into that kind of thing

🟢 = works 🟡 = works, but with limitations (see notes) 🔴 = not working

Prerequisites

to debug the HC32F460, you will need the following:

  • a HC32F460 based board
  • a SWD debug probe (see supported debug probes)
  • a PlatformIO compatible IDE (e.g. VSCode)

Preparing your Project

to prepare your project for debugging, you will need to make a few changes to your platformio.ini file.

1. Enable Debugging

either set the build_type to debug or add -g3 to the board_build.flags.common option:

[env:my_env]
# ...
build_type = debug
# ... OR ...
board_build.flags.common = -g3

2. Select the Debug Probe

add the debug_tool option to your environment and set it to the debug probe you're using:

[env:my_env]
# ...
debug_tool = cmsis-dap # or jlink

Debugging your Code

to debug your code, please refer to the official PlatformIO documentation on how to use the debugger.