2021-10-18 07:00 AM
Hi
I have a chip in main board that can be programmed using SWD interface.
Thanks
2021-10-18 07:08 AM
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.
2021-10-18 07:12 AM
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
2021-10-18 08:56 AM
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
2021-10-18 09:02 AM
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 ?
2021-10-18 09:22 AM
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.
2021-10-18 09:37 AM
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.
2021-10-18 09:40 AM
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
2021-10-18 10:29 AM
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.
2021-10-18 03:19 PM
"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 ?