stm32duino / Arduino_Core_STM32

STM32 core support for Arduino
https://github.com/stm32duino/Arduino_Core_STM32/wiki
Other
2.83k stars 975 forks source link

Add OpenOCD + CMSIS-DAP upload and debug #2437

Closed maxgerhardt closed 1 month ago

maxgerhardt commented 4 months ago

Is your feature request/improvement related to a problem? Please describe.

Some people don't have a ST-Link or a regular USB-to-UART adapter, but have a e.g. Raspberry Pi Pico, which can be easily programmed (drag and drop firmware file onto USB drive) to be a CMSIS-DAP compliant debugger and UART probe.

However, this core fails to support upload via CMSIS-DAP.

Describe the solution you'd like

Include the xPack OpenOCD package and add the upload action for every board with -f interfaces/cmsis-dap.cfg. Using OpenOCD also greatly expands the number of other usable uploaders and debugging methods (e.g., JLink).

PlatformIO can already do this perfectly fine.

Describe alternatives you've considered

  1. Use the UART upload with the Pico: Slower, plus you have to constantly switch the bootloader jumpers between 0 and 1 for bootloader or firmware run mode
  2. Make people buy an actual ST-Link: Why, when they have a perfectly capable CMSIS-DAP

Additional context

Example OpenOCD upload to STM32F1

openocd -d2 -s C:\Users\Max\.platformio\packages\tool-openocd/openocd/scripts -f interface/cmsis-dap.cfg -c "transport select swd" -f target/stm32f1x.cfg -c "program {.pio\build\genericSTM32F103C8\firmware.elf}  verify reset; shutdown;"
xPack Open On-Chip Debugger 0.12.0-01004-g9ea7f3d64-dirty (2023-01-30-15:04)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 2

swd
Info : Using CMSIS-DAPv2 interface with VID:PID=0x2e8a:0x000c, serial=E66038B713193E30
Info : CMSIS-DAP: SWD supported
Info : CMSIS-DAP: Atomic commands supported
Info : CMSIS-DAP: Test domain timer supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 0 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Info : CMSIS-DAP: Interface ready
fpistm commented 4 months ago

Hi @maxgerhardt

However, this core fails to support upload via CMSIS-DAP.

Don't understand why it fail. It is simply not supported. This is a community project feel free to contribute.