Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
489 views

Debugging With DAPLink + OpenOCD + STM32CubeIDE

This document describes the steps to set up STM32CubeIDE to use an external OpenOCD installation with a DAPLink debugger. It involves creating an external tool configuration for OpenOCD, a debug configuration for GDB, and a launch group to run the program and start debugging. Connecting the DAPLink to the board, checking it works with OpenOCD, creating a project, and following the listed steps will allow debugging the project with STM32CubeIDE.

Uploaded by

shanrei
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
489 views

Debugging With DAPLink + OpenOCD + STM32CubeIDE

This document describes the steps to set up STM32CubeIDE to use an external OpenOCD installation with a DAPLink debugger. It involves creating an external tool configuration for OpenOCD, a debug configuration for GDB, and a launch group to run the program and start debugging. Connecting the DAPLink to the board, checking it works with OpenOCD, creating a project, and following the listed steps will allow debugging the project with STM32CubeIDE.

Uploaded by

shanrei
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Debugging with DAPLink + OpenOCD +

STM32CubeIDE
Visit https://jrcrulida.wordpress.com/2023/07/02/debugging-with-daplink-openocd-stm32cubeide/
for a more updated version of this post.

This post describes the steps in setting up STM32CubeIDE to use DAPLink and
an external OpenOCD installation.
CAVEAT(S):

1. A custom “Launch Group” must be created for every project that will use
the external OpenOCD debugger.
2. I am using Windows but I am assuming that this would work in Linux and
other operating systems as well; the path slashes just needs to be
adjusted.
3. I am also assuming the following:
○ OpenOCD is already extracted/installed somewhere in the computer
and added in the PATH variable,
○ DAPLink drivers are installed (if needed), and
○ STM32CubeIDE is installed.

PRELIMINARY STEPS:

1. Connect the appropriate wires from the DAPLink debugger to the target
board. In this post, I am using a NUCLEO-F411RE with the embedded
ST-Link cut off.
2. Plug in in the DAPLink debugger to the computer. Check the “Device
Manager” for the corresponding COM port for the debugger.
3. DAPLink is supported by OpenOCD. To check if everything is working so
far, open up a terminal and enter the following:

openocd -f interface/cmsis-dap.cfg -f
target/<your_target>.cfg

If all is good, a similar as the next figure should appear:

4. Exit OpenOCD. Then create a project in STM32CubeIDE and configure the


peripherals of the board/chip accordingly. In this post, I am using a
NUCLEO-F411RE with the embedded ST-Link V2-1 cut off.
PART 1. SETTING THE EXTERNAL TOOLS CONFIGURATIONS:

1. In the STM32CubeIDE, go to Menu toolbar then click Run -> External


Tools -> External Tools Configurations like the following figure.

2. In the External Tools Configuration dialog, right-click on Program and click


New Configuration

3. Create a new configuration and give it a name that’s relevant to the project.
Since I am targeting an STM32F411RE microcontroller, I’ll name this
DAPLink_F411RE. In the Location field, enter the full path to the
OpenOCD executable. In the Working Directory field, enter the path to
where the OpenOCD scripts are located. In the Arguments, enter the
following arguments and replace <your_target>.cfg with the
appropriate target config file for your board or chip:
-f interface/cmsis-dap.cfg -f target/<your_target>.cfg .

See the following figure for examples. Then click Apply, then Close.

PART 2. CREATING A DEBUG CONFIGURATION:

1. Making sure that the active project is selected, go to the Menu toolbar,
then click Run -> Debug Configurations.
2. In the Debug Configurations Dialog, right-click GDB Hardware Debugging
and click New Configuration as shown in the following figure.
3. Choose an appropriate name for the debug configuration, then click
Apply…BUT NOT CLOSE IT YET.
4. Go to the Debugger tab. Clear the entry in the “GDB Command:” field.
Next, click on the “Variables…” button and select
gnu_tools_for_stm32_compiler_path. After that, append the following to
the newly inserted variable “\arm-none-eabi-gdb.exe”. Set the JTAG
Device to OpenOCD (via socket) and the GDB Connection String to
localhost:3333. Click Apply. The following figure shows how it should look
like (the important parts are in red).

5. Go to the Startup tab. Check “Reset and Delay (seconds): 0“. Check
“Set breakpoint at:” and type main in its field. Leave the rest as is. Then
click Apply.
6. Go to the Source tab. Leave it as it is.
7. Go to the Common tab. Select Shared file: in the Save As option and
leave the default entry. Check the Debug option in the Display in
favorites menu as shown in the following image. Then click Apply and
then click Close.

PART 3. CREATE A LAUNCH GROUP.

A launch group is created to automate the running of the program followed by the
debug operation. It is important to note that Steps 2 and 3 in this section needs
to be done in order so that when the launch group is activated, the Run
configuration is executed before the Debug configuration.
1. Go to Menu toolbar, then click Run -> Debug Configurations. Right-click
on Launch Group then create a New Configuration as shown in the
following image.

2. Choose an appropriate name for the configuration, then click Apply.


3. Next, an OpenOCD server needs to be launched first before launching a
debug session. Click on Add and select the launch Program that
corresponds to the project that was configured in PART 1. Make sure of
the following.
○ Set the Launch mode to Run
○ Set Post launch action to None
○ Check Adopt launch if already running.
Click OK

4. Next, Click on Add and select the GDB Hardware Debugging


configuration that corresponds to the project that was configured in PART
2. Make sure of the following.
○ Set the Launch mode to Debug
○ Set Post launch action to None
○ Check Adopt launch if already running.
Click OK

5. Once this is done, you should get something similar to the following figure.
Then click Apply, then click Close.

PART 4. START THE DEBUGGING PROCESS

1. The Launch Group that was created in PART 3 might or might not show
when the arrow next to the Play icon is clicked. If it is not showing, go to to
Menu toolbar, then click Run -> Debug Configurations. The launch group
should appear the next time you click the arrow next to the Play icon.
2. Go to the Launch Group section and select the launch group created in
PART 3, then click Debug. If all goes well, you will see something similar
to the following image.

3. NOTE: If you run into an error that says “Error address 0x20000000
already has watchpoint 1“, stop the debugging then go to Menu toolbar,
then click Run -> Remove All Breakpoints.

PART 5. CONCLUSION

The open-source DAPLink debugger has been around for a few years and it is a
great tool if you want to a cheap debugger that also has UART functionality. It
works.

OTHER RESOURCES:

● https://usamodelkina.ru/23338-otladka-stm32-s-pomoschju-daplink-v-stm3
2cubeide.html
● https://www.galliumio.com/1531/debugging-with-stm32cubeide/
● https://www.cxybb.com/article/lone5moon/120092024
● https://openocd.org/
● https://openocd.org/doc-release/html/index.html

You might also like