cancel
Showing results for 
Search instead for 
Did you mean: 

Cmsis-DAP debugger in STM32CubeIDE

atleasttwocharacterslong
Associate III

Hello, i have a DapLink debugger and wanted to use it with stm32, i also am pretty new to stm32, so don't be mad when i mess up some terms. I don't want to buy an STLink yet since i wanna see if i am going to like stm32 debugging/programming. Some context:MCU:STM32H723ZGT6, debugger: DapLink Mini, OS:Ubuntu desktop 24.10.Also, yes i know that this board is overkill but i thought, go big or go home, if i am gonna try stm32 i better make it count.

40 REPLIES 40

True - but I wasn't talking about that.

Unless it's something that specifically needs to be a screenshot, it's generally better to copy & paste the text - with appropriate formatting, as required.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

...dont know, what your editor shows at 191 --- no AP_NUM

i see:

AScha3_0-1737990413075.png

btw i have no idea, what this means... (backup file , then edit ...maybe as sudo)

i would just try to remove the > if { $ ...    < and the else also.

just remains there:

target create $_CHIPNAME.ap2 mem_ap -dap $_CHIPNAME.dap -ap-num 0 swo create $_CHIPNAME.swo -dap $_CHIPNAME.dap -ap-num 0 -baseaddr 0xE00E3000 tpiu create $_CHIPNAME.tpiu -dap $_CHIPNAME.dap -ap-num 0 -baseaddr 0xE00F5000

and see, what happens.

 

 

If you feel a post has answered your question, please click "Accept as Solution".
atleasttwocharacterslong
Associate III

oh, i was viewing openocd files instead of the ide ones

 

after patching out the AP_NUM

atleasttwocharacterslong_0-1737991629102.png

 

...dont know... i would try instead :

target create $_CHIPNAME.ap2 mem_ap -dap $_CHIPNAME.dap -ap-num 2 swo create $_CHIPNAME.swo -dap $_CHIPNAME.dap -ap-num 2 -baseaddr 0xE00E3000 tpiu create $_CHIPNAME.tpiu -dap $_CHIPNAME.dap -ap-num 2 -baseaddr 0xE00F5000

 

If you feel a post has answered your question, please click "Accept as Solution".
VolkerS
Associate
ckocagil
Associate

I found the steps to upload and debug with a cheap daplink. See my post on imgur (https://imgur.com/a/how-to-use-daplink-cmsis-dap-with-stm32cubeide-OrpcsvX) - or I'll copy paste its contents below:

---

How to use daplink (cmsis-dap) with STM32CubeIDE


ckocagil_5-1745353772389.png
You can use a cheap and standard cmsis-dap device to flash and debug stm32 projects within the cube ide. Let's start with a fresh project.
 
 
 
 
 
ckocagil_6-1745353942962.png
I hook up the dap with 4 wires (vcc, gnd, swdio, swclk) and no reset wire. For this to work without having to constantly manually reset the device, I go to SYS and change Debug mode to Serial Wire. Save and generate code. Build.
 
 
 
 
 
ckocagil_8-1745353989610.png
Next, we create a file daplink.cfg in the project root. The file should contain:
source [find interface/cmsis-dap.cfg] adapter speed 1000 transport select swd source [find target/stm32f1x.cfg] reset_config none
 
 
 
 
 
ckocagil_10-1745354083720.png
Now go to Run -> Debug Configurations and create a debug config. Make sure the C/C++ Application field contains our elf file.
 
 
 
 
 
ckocagil_3-1745353712160.png
The crucial part: on the Debugger tab, we change the probe to OpenOCD, select User Defined script, and use our daplink.cfg.
 
Click Apply to save our debug config and that should be all. You're now ready to run or debug your code.
 
QUIRKS: For some reason, ST's openocd scripts leave the mcu paused after detaching the dap. This means every time you Run your code or detach a Debug session, your mcu will need a manual reset.
 
My workaround for this is to add the following line at the end of daplink.cfg:
 
lappend pre_shutdown_commands { resume }

 

Hi, @ckocagil ,

i tried with daplink.cfg script to connect an old blue-pill (with STM32F103C6 cpu) and yes, its working fine !

Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : CMSIS-DAP: SWD supported Info : CMSIS-DAP: Atomic commands supported Info : CMSIS-DAP: Test domain timer supported Info : CMSIS-DAP: FW Version = 2.1.0 Info : CMSIS-DAP: Serial# = 070000011a5a5bb6000000000001ceeca5a5a5a597969908 Info : CMSIS-DAP: Interface Initialised (SWD) Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1 Info : CMSIS-DAP: Interface ready Info : clock speed 4000 kHz Info : SWD DPIDR 0x1ba01477 Info : [STM32F103C6Tx.cpu] Cortex-M3 r1p1 processor detected Info : [STM32F103C6Tx.cpu] target has 6 breakpoints, 4 watchpoints Info : [STM32F103C6Tx.cpu] Examination succeed Info : starting gdb server for STM32F103C6Tx.cpu on 3333 Info : Listening on port 3333 for gdb connections Info : accepting 'gdb' connection on tcp/3333 Info : device id = 0x10006412 Info : flash size = 32 KiB Warn : GDB connection 1 on target STM32F103C6Tx.cpu not halted undefined debug reason 8 (UNDEFINED) - target needs reset Info : accepting 'gdb' connection on tcp/3333 Warn : GDB connection 2 on target STM32F103C6Tx.cpu not halted undefined debug reason 8 (UNDEFINED) - target needs reset [STM32F103C6Tx.cpu] halted due to breakpoint, current mode: Thread xPSR: 0x01000000 pc: 0x080004a4 msp: 0x20002800

So i can use my -until now useless- cmsis-dap debug probe also .

Great !

(But usually using st-link V2 or V3  , its just nice, to have a working alternative debug probe. )

If you feel a post has answered your question, please click "Accept as Solution".

Why is the topic you guys split it into showing up as read only? Also actually in debug configurations you can set blackmagic probe as a gdb server, so do not tell me it is not supported. Which means st clearly has no issues with it, they even seem to support it. Also i do not want to buy an st-link because i want one tool for all cortex-m devices, and not one tool for ST's STM32, one for TI's msp or whatever and so on.

I am writing here because i cannot in the new one.

oh never mind, just noticed why it is locked