-
Notifications
You must be signed in to change notification settings - Fork 1
Setting up debugging in different IDEs
Since MioLink (like the BlackMagic Probe on which it is based) works directly with GDB commands, the configuration for debugging will be similar across all IDEs.
The basic set of commands for the SWD interface:
set mem inaccessible-by-default off
monitor tpwr enable
monitor frequency 1M
monitor swdp_scan
att 1
The basic set of commands for the JTAG interface:
set mem inaccessible-by-default off
monitor tpwr enable
monitor frequency 1M
monitor jtag_scan
att 1
The purpose of the commands is as follows:
-
set mem inaccessible-by-default off
– allows viewing, for example, MCU peripheral registers; -
monitor tpwr enable
– enables 3.3V power supply from the debugger to the Vtref pin.
If this feature is not needed and the Vtref pin is powered externally, usemonitor tpwr disable
instead; -
monitor frequency 1M
– sets the interface frequency to 1MHz.
This command supports values in Hz, kHz, and MHz.
Examples of valid values: 100000 (100kHz), 250k (250kHz), 4M (4MHz); -
monitor swdp_scan
/monitor jtag_scan
– initiates a target scan on the SWD/JTAG interface. -
att 1
– connects to the target with the specified index.
Here, the argument 1 is the index of the target in the output of theswdp_scan
/jtag_scan
command:
(gdb) monitor swdp_scan
Target voltage: 3.3V
Available Targets:
No. Att Driver
1 STM32F1 L/M density M3
If you have multiple targets (e.g., in a JTAG chain), specify the index of the desired target.
NOTE: If you want to work with the target via the JTAG interface, but JTAG is disabled in the target's current firmware, you will need to connect the target's NRST pin to the probe and add monitor connect_rst enable
to the list of commands before monitor jtag_scan
.
- Open the command line;
- Run GDB and specify the .elf file:
arm-none-eabi-gdb MioLink_testing_f103.elf
- Connect to the MioLink:
target extended-remote COM9
NOTE: On Windows, useCOMx
format for ports 0-9 and\\.\COMx
for ports starting from the 10 (where x - is the port number).
Example:(gdb) target extended-remote \\.\COM10
- Use the commands from the list above, for example:
(gdb) target extended-remote COM9
`C:\Development\MCU\MioLink\test_board\MioLink_testing_f103\Debug\MioLink_testing_f103.elf' has changed; re-reading symbols.
Remote debugging using COM9
(gdb) set mem inaccessible-by-default off
(gdb) monitor tpwr enable
Enabling target power
(gdb) monitor frequency 1M
Debug iface frequency set to 1000000Hz
(gdb) monitor swdp_scan
Target voltage: 3.3V
Available Targets:
No. Att Driver
1 STM32F1 L/M density M3
(gdb) att 1
Attaching to program: C:\Development\MCU\MioLink\test_board\MioLink_testing_f103\Debug\MioLink_testing_f103.elf, Remote target
HAL_GetTick () at ../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:305
305 {
(gdb)
- Work as you would with a regular GDB server.
Unfortunately, as of now (October 2024), CLion does not support extended-remote
, making it impossible to set up debugging in CLion without resorting to dirty hacks with .gdbinit.
If that doesn’t scare you and you know what you're doing, you can find more information here.
- Install cortex-debug extension;
- Create (or modify)
launch.json
file in.vscode
folder; - Add the debug configuration:
{
"version": "0.2.0",
"configurations": [
{
"name": "BMP Debug",
"type": "cortex-debug",
"servertype": "bmp",
"request": "launch",
"cwd": "${workspaceRoot}",
"executable": "<path to .elf executable>",
"interface": "swd",
"device": "<target device>",
"BMPGDBSerialPort": "<probe serial port>",
"powerOverBMP": "<enable or disable>",
"runToEntryPoint": "main",
"svdFile": "<path to .svd file>"
}
]
}
Options description:
Option | Description |
---|---|
executable | Path to your .elf executable, e.g. ${workspaceRoot}/build/MioLink_testing_f103.elf .For CMake applications, you can use ${command:cmake.launchTargetPath}
|
device | Target device, e.g. STM32F103
|
BMPGDBSerialPort | Black Magic Probe serial port, COMx for Windows (\\.\COMx for ports starting from the 10),/dev/ttyACMx for Linux and /dev/cu.usbmodemX for Mac OS |
powerOverBMP | Set to enable to power the target from the probe or disable if the target is self-powered |
svdFile | optional, specify the path to .svd file (registers description), e.g. STM32F103.svd
|
Full configuration example for a CMake-based project for STM32F103 which is powered from the BMP:
{
"version": "0.2.0",
"configurations": [
{
"name": "BMP Debug",
"type": "cortex-debug",
"servertype": "bmp",
"request": "launch",
"cwd": "${workspaceRoot}",
"executable": "${command:cmake.launchTargetPath}",
"interface": "swd",
"device": "STM32F103",
"BMPGDBSerialPort": "/dev/cu.usbmodem1201",
"powerOverBMP": "enable",
"runToEntryPoint": "main",
"svdFile": "STM32F103.svd"
}
]
}
- Go to Run -> Debug Configurations;
- In GDB Hardware Debugging, add new configuration:
- In the Debugger tab, specify the GDB command you are using, in my case:
arm-none-eabi-gdb
,
the debugger type:Black Magic Probe
(orGeneric Serial
, it doesn't matter),
and the COM port number for MioLink’s GDB interface:
- In the Startup tab, in the Initialization Commands input field, copy the basic set of commands from the list above (edited to fit your project, of course):
- If you want the execution to stop at the main function, enable "Set breakpoint at:" in the Run Commands section below, enter
main
in the input field, and enable "Resume" below:
- That’s it! To save the configuration, click Apply, and click Debug to start the debugging process.
This page contains only basic information on how to get started with MioLink.
For more details, please refer to the Black Magic Probe documentation.