Micropyhton Method to program an STM32 connected

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
o_eoin
Posts: 3
Joined: Thu Dec 02, 2021 4:34 pm

Micropyhton Method to program an STM32 connected

Post by o_eoin » Thu Dec 02, 2021 4:39 pm

I have a PCB with an STM32H7 that runs micropyhton, there is a second STM32 on the PCB and I would like to be able to program from the H7 processor running MP. I have access to the second STM32 over the native UART bootloader and the SWD pins.

In Linux for example I use a tool called stm32flash that programs an STM32 over UART + BOOT+RST using the factory ROM bootloader of the STM32.

Does anybody know if there is a solution for this in Micropython? The options are native STM bootloader over UART or some kind of bit-bashing on the SWD pins.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Micropyhton Method to program an STM32 connected

Post by dhylands » Thu Dec 02, 2021 11:43 pm

The source code for stm32flash can be found here: https://github.com/stm32duino/stm32flash

This code is intended for the host and has way more functionality than you need, so you'd need to extract/modify it to do what you want.

The bootloader protocol is described in this document: https://www.st.com/resource/en/applicat ... ronics.pdf and it's simple enough you can probably just implement what you need in micropython.

o_eoin
Posts: 3
Joined: Thu Dec 02, 2021 4:34 pm

Re: Micropyhton Method to program an STM32 connected

Post by o_eoin » Fri Dec 03, 2021 8:22 am

I use this already like I said, but how can I do it from micropython?

o_eoin
Posts: 3
Joined: Thu Dec 02, 2021 4:34 pm

Re: Micropyhton Method to program an STM32 connected

Post by o_eoin » Fri Dec 03, 2021 8:27 am

Is there an existing Micropython module or library that can do this? I do not know how to compile C into micropython

Post Reply