Hey there,
I'm currently trying to port MicroPython onto a custom board with a STM32L471 µC. I already ported MicroPython to a custom board without an USB interface before. But that was with a STM32F407 and the difference is, that the L471 has no built-in USB connectivity.
So my question is, if anyone has ever done a port to a STM32 microcontroller without USB OGT / USB device communication.
I already tried to get rid of the many USB references within the source files but the firmware I got still does not work.
Does anyone have an idea how to approach this?
Thanks in advance!
[STM32L471] Port for STM32 without USB connectivity
Re: [STM32L471] Port for STM32 without USB connectivity
Hi,
There are a few different boards that don't have USB -- for example the NUCLEO_F091RC is one I've used.
I'm fairly sure that you don't have to do anything other than
in mpconfigboard.h. (Or just don't set it at all).
Which board definition did you start from? I notice that the NUCLEO_L432 board definition also doesn't enable USB support. (Even though the STM32L432KC does have a USB peripheral).
There are a few different boards that don't have USB -- for example the NUCLEO_F091RC is one I've used.
I'm fairly sure that you don't have to do anything other than
Code: Select all
#define MICROPY_HW_USB_FS (0)
Which board definition did you start from? I notice that the NUCLEO_L432 board definition also doesn't enable USB support. (Even though the STM32L432KC does have a USB peripheral).
Re: [STM32L471] Port for STM32 without USB connectivity
Code: Select all
#define MICROPY_HW_USB_FS (0)
I started from the STM32L476DISC. The datasheets of L471VG and L476RG look the same when you look at the memory mappings and the alternative functions (except LCD and USB support within the AFs of the L476). So the linker file of the "l476xg" should work and also the .csv-file for the AFs should work if you remove the AFs for LCD and OTG USB.
Also I configured mpconfigboard.h and pins.csv.
I noticed that there is no port for any µCs from the "Access line" as ST calls them. Thats why I'm asking if it's even possible to run MicroPython on one of those.
Re: [STM32L471] Port for STM32 without USB connectivity
I'm unsure why you had to remove any references other than in mpconfigboard.h (I assume you already set MICROPY_HW_ENABLE_USB to zero (in addition to MICROPY_HW_USB_FS), which should cover everything).
Does your board also have external spiflash, or have you already removed all the additional config from the STM32L476DISC definition for the spiflash init.
When you say the firmware doesn't work, can you provide more information? I'm guessing you don't see a REPL on the UART. How is MICROPY_HW_UART_REPL configured? What if you do something simpler like edit main.c to toggle one of the pins a few times?
How are you programming the board? USB DFU or SWD via stlink or other? Can you attach a debugger?
From my (admittedly somewhat limited experience, e.g. porting to L0), if you can get it to compile, most of the variations in the the families shows up as compile errors against the HAL (e.g. different register names etc).
Re: [STM32L471] Port for STM32 without USB connectivity
You also need to remove
and define a REPL UART.
Use mpconfigboard.h from the NUCLEO_L432KC port as a starting point. I did the L452 port based on the L432. It doesn't have USB enabled (no connector on NUCLEO board) and it compiles error free for L451 by just changing the MCU in mpconfigboard.h. No source code changes were necessary.
Code: Select all
#define MICROPY_HW_ENABLE_USB (1)
Use mpconfigboard.h from the NUCLEO_L432KC port as a starting point. I did the L452 port based on the L432. It doesn't have USB enabled (no connector on NUCLEO board) and it compiles error free for L451 by just changing the MCU in mpconfigboard.h. No source code changes were necessary.