debug_tool = custom
PIO Unified Debugger can be configured from “platformio.ini” (Project Configuration File):
Black Magic Probe with a custom debug_port (list ports with platformio device list)
[env:debug]
platform = ...
board = ...
framework = ...
debug_tool = custom
; set here a valid port...
debug_port = /dev/cu.usbmodem7BB07991
debug_init_cmds =
target extended-remote $DEBUG_PORT
monitor swdp_scan
attach 1
set mem inaccessible-by-default off
$INIT_BREAK
$LOAD_CMD
Segger J-Link probe and ST Nucleo F446RE board in pair with J-Link GDB Server:
Note
You can use configuration below in pair with other boards, not only with ST
Nucleo F446RE. In this case, please replace STM32F446RE
with
your own device name in debug_server
option.
See full list with J-Link Supported Devices.
[env:debug_jlink]
platform = ststm32
framework = mbed
board = nucleo_f446re
debug_tool = custom
debug_server =
/full/path/to/JLinkGDBServerCL
-singlerun
-if
SWD
-select
USB
-port
2331
-device
STM32F446RE
Segger J-Link probe as debugger and uploader for a custom Teensy-based board.
If you plan to use with other board, please change device MK20DX256xxx7
to a valid identifier. See supported J-Link devices at J-LINK.
Install J-Link GDB Server
[env:jlink_debug_and_upload]
platform = teensy
framework = arduino
board = teensy31
extra_scripts = extra_script.py
upload_protocol = custom
debug_tool = custom
debug_server =
/full/path/to/JLinkGDBServerCL
-singlerun
-if
SWD
-select
USB
-port
2331
-device
MK20DX256xxx7
extra_script.py
Place this file on the same level as “platformio.ini” (Project Configuration File).
from os import makedirs
from os.path import isdir, join
Import('env')
# Optional block, only for Teensy
env.AddPostAction(
"$BUILD_DIR/firmware.hex",
env.VerboseAction(" ".join([
"sed", "-i.bak",
"s/:10040000FFFFFFFFFFFFFFFFFFFFFFFFDEF9FFFF23/:10040000FFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFD/",
"$BUILD_DIR/firmware.hex"
]), "Fixing $BUILD_DIR/firmware.hex secure flash flags"))
def _jlink_cmd_script(env, source):
build_dir = env.subst("$BUILD_DIR")
if not isdir(build_dir):
makedirs(build_dir)
script_path = join(build_dir, "upload.jlink")
commands = ["h", "loadbin %s,0x0" % source, "r", "q"]
with open(script_path, "w") as fp:
fp.write("\n".join(commands))
return script_path
env.Replace(
__jlink_cmd_script=_jlink_cmd_script,
UPLOADER="/full/path/to/JLink",
UPLOADERFLAGS=[
"-device", "MK20DX256xxx7",
"-speed", "4000",
"-if", "swd",
"-autoconnect", "1"
],
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS -CommanderScript ${__jlink_cmd_script(__env__, SOURCE)}'
)
On-board ST-Link V2/V2-1 in pair with ST-Util GDB Server:
[env:debug]
platform = ststm32
framework = mbed
board = ...
debug_tool = custom
debug_port = :4242
debug_server = $PLATFORMIO_HOME_DIR/packages/tool-stlink/bin/st-util
On-board ST-Link V2/V2-1 in pair with OpenOCD GDB Server:
[env:debug]
platform = ststm32
framework = mbed
board = ...
debug_tool = custom
debug_server =
$PLATFORMIO_HOME_DIR/packages/tool-openocd/bin/openocd
-f
$PLATFORMIO_HOME_DIR/packages/tool-openocd/scripts/board/st_nucleo_f4.cfg
Using pyOCD for CMSIS-DAP based boards
Firstly, please install pyOCD and
check that pyocd-gdbserver --version
command works.
[env:debug]
platform = ...
board = ...
framework = mbed
debug_tool = custom
debug_server = pyocd-gdbserver