koendv / STM32duino-Semihosting

Arduino arm semihosting library
7 stars 2 forks source link

possible with st-link and platformio #1

Closed zerog2k closed 4 years ago

zerog2k commented 4 years ago

I can get swd debugging working (I think it's though openocd?) in vscode + platformio, using an st-link adapter.

I'm using

[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = arduino
lib_deps = 
    STM32duino-Semihosting
debug_tool = stlink
upload_protocol = stlink

in my platformio.ini along with the example blink sketch in this repo. I'm not sure if there are other steps required here to get this working. Wondering if anyone has ideas or pointers?

zerog2k commented 4 years ago

ok this might be related https://github.com/platformio/platformio-core/issues/3516

zerog2k commented 4 years ago

ok confirming that this works using the workarounds on https://github.com/platformio/platform-ststm32/issues/272 specifically, running separate openocd (can be run via tasks in one of the pio terminal windows as discussed in the issue), and using this config:

[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = arduino

lib_deps = 
    STM32duino-Semihosting
upload_protocol = stlink
debug_extra_cmds =
    monitor arm semihosting enable
;debug_tool = stlink    
debug_tool = custom
debug_port = :3333
koendv commented 4 years ago

Glad to hear it works.

mohalsa commented 3 years ago

I created a very simple and easy to use pre-configured project to make semihosting work for an STM32 bluepill board. Please have a look https://github.com/mohalsa/STM32_BluePill_Semihosting

koendv commented 3 years ago

On Tue, 27 Apr 2021 15:57:57 -0700 Mohammed Alsada @.***> wrote:

I created a very simple and easy to use pre-configured project to make semihosting work for an STM32 bluepill board. Please have a look https://github.com/mohalsa/STM32_BluePill_Semihosting

Thanks. Maybe add a picture that shows how the connections between STLink and blue pill are?

best,

koen

mohalsa commented 3 years ago

This is the wiring diagram. Just ignore the optional "Enable hardware reset mode" line! Also, I noticed that sometimes the debugging session becomes unreliable, glitchy and might not even work, In such cases try to connect the 5V power line from the Stlink debugger to the 5V Vcc of the bluepill and don't use the 3.3V Vcc to power the bluepill. I don't know what might be the reason, probably insufficient power or ripples etc. please do not connect them both at once, It might damage your board!

bluepill_connections_stlink

(Image credits: https://www.onetransistor.eu/2020/01/stm32-bluepill-arduino-support.html)

koendv commented 3 years ago

On Fri, 07 May 2021 01:29:52 -0700 Mohammed Alsada @.***> wrote:

This is the wiring diagram. Just ignore the optional "Enable hardware reset mode" line!

https://2.bp.blogspot.com/-7EuKacFbduI/XgywIr6yz0I/AAAAAAAAOrA/9zVT10WyGSMwQQ00K3qbeTU7fyY9tkA7QCLcBGAsYHQ/s1600/bluepill_connections_stlink.png

Good. You use openocd? https://github.com/phryniszak/strtt