stm32duino / Arduino_Core_STM32

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

J-Link support when using STM32CubeProgrammer #2452

Open jamesy0ung opened 1 month ago

jamesy0ung commented 1 month ago

STM32CubeProgrammer has support for J-Link probes, however the Arduino core only allows it to use SWD with ST-Link, DFU or UART

I'd like to be able to upload using a J-Link probe from the Arduino IDE. Thank you!

Screenshot 2024-07-18 170617

fpistm commented 1 month ago

Hi @jamesy0ung Feel free to contribute and provide a PR.

jamesy0ung commented 1 month ago

I haven't done any work on Arduino cores before, but I got the STM32CubeProgrammer CLI working by using the following flag. -c port=JLINK ap=0

I tried to modify boards.txt to add support but I can't see it in the Arduino IDE as a programmer


GenF1.menu.upload_method.jlinkMethod=STM32CubeProgrammer (J-Link)
GenF1.menu.upload_method.jlinkMethod.upload.protocol=swd
GenF1.menu.upload_method.jlinkMethod.upload.options=-c port=JLINK ap=0
GenF1.menu.upload_method.jlinkMethod.upload.tool=stm32CubeProg

Is there anything I'm missing?

fpistm commented 1 month ago

I would recommend to check the script: https://github.com/stm32duino/Arduino_Tools/blob/main/stm32CubeProg.sh

And simply add a new interface (protocol): jlink then in the script simply call it with correct option. About the fact it is not in the menu, this is an Arduino IDE issue. You have to delete the cache.

Path:

jamesy0ung commented 1 month ago

I've opened 2 PR's

One adds a case to the flashing script, and the other adds support under the STM32F1, I'll look into adding J-Link programmer support for other boards, but I don't have any other hardware to test with

fpistm commented 1 month ago

Thanks @jamesy0ung for the PR's. I will try on my side and see if it is OK for other series. I never used J-Link so have to ramp-up.