cancel
Showing results for 
Search instead for 
Did you mean: 

Programming secondary chip using SWD interface

Ofer
Associate III

Hi

I have a chip in main board that can be programmed using SWD interface.

  1. Can I use the SWD of the STM32F407 to program another chip (and not just for programming and debugging the STM32) ?
  2. If so - Are there any HAL functions ?

Thanks

15 REPLIES 15
S.Ma
Principal

Embedding debug probe function is far from simple. Typically bootoader enables reflashing through uart, i2c, spi. Application code on target for in application programming is another way. HAL doesn't provide SWD serial function.

Peter BENSCH
ST Employee

That would be a kind of daisy chain, but no, unfortunately this is not possible with SWD and there are no functions for it.

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi Peter, I'm not sure you understood me correctly.

I'm not trying to program from PC to the STM32 and from then to the other chip.

I'm trying to control the STM32 to program the other chip directly with no other host.

Thanks

Ofer
Associate III

Hi

I'm sure it is not a simple task, but I might be doing it if it technically possible.

I see in the reference manual: https://www.st.com/resource/en/reference_manual/dm00031020-stm32f405-415-stm32f407-417-stm32f427-437-and-stm32f429-439-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf

page 1695 a list of registers that may help me doing this task.

Is someone ever did it ?

Daisy chain or not, it's not supported. The SWD pins are only for programming that device.

You can certainly emulate the SWD protocol using other pins (or even the SWD pins), but that's not a realistic solution and certainly isn't supported in HAL.

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

The way people typically program down-stream MCU is via an NRST, BOOT0 and USART pins using the System Loader (See AN2606)

Or via your own loader protocol if that is easier, or more convenient.

Perhaps look over the IAP examples, this will be orders of magnitude simpler than implementing SWD/JTAG on ARM MCU and pushing loaders, code, etc. For the latter case, perhaps look at ARM's documentation for debugger writers/developers.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

The SWD protocol on the MCU side is implemented in hardware. It's not designed to host other devices, and is not inherently a software/firmware based method. ie combinational/synchronous logic clocking into the 10's of MHz

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III

The ST-LINK debugger itself is a STM32 so it should be possible; you are free to learn the protocol and try.

As TDK wrote, this is not the most pragmatic path.

Andrew Neil
Evangelist III

"Can I use the SWD of the STM32F407 to program another chip"

No. The SWD in the microcontroller is a "slave" - it can't be a "master" to another microcontroller.

Have you looked at CMSIS DAP ?

https://os.mbed.com/handbook/CMSIS-DAP