[STM32L471] Port for STM32 without USB connectivity

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
danny_h
Posts: 8
Joined: Wed Apr 03, 2019 8:10 am

[STM32L471] Port for STM32 without USB connectivity

Post by danny_h » Tue Jul 16, 2019 11:46 am

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!

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: [STM32L471] Port for STM32 without USB connectivity

Post by jimmo » Tue Jul 16, 2019 12:29 pm

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

Code: Select all

#define MICROPY_HW_USB_FS (0)
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).

danny_h
Posts: 8
Joined: Wed Apr 03, 2019 8:10 am

Re: [STM32L471] Port for STM32 without USB connectivity

Post by danny_h » Wed Jul 17, 2019 11:00 am

Code: Select all

#define MICROPY_HW_USB_FS (0)
This was the first thing I tried.

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.

Image

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.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: [STM32L471] Port for STM32 without USB connectivity

Post by jimmo » Wed Jul 17, 2019 11:38 am

danny_h wrote:
Tue Jul 16, 2019 11:46 am
I already tried to get rid of the many USB references within the source files ...
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).
danny_h wrote:
Wed Jul 17, 2019 11:00 am
I started from the STM32L476DISC.
Does your board also have external spiflash, or have you already removed all the additional config from the STM32L476DISC definition for the spiflash init.
danny_h wrote:
Tue Jul 16, 2019 11:46 am
but the firmware I got still does not work.
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?
danny_h wrote:
Wed Jul 17, 2019 11:00 am
Thats why I'm asking if it's even possible to run MicroPython on one of those.
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).

chrismas9
Posts: 152
Joined: Wed Jun 25, 2014 10:07 am

Re: [STM32L471] Port for STM32 without USB connectivity

Post by chrismas9 » Wed Jul 17, 2019 12:20 pm

You also need to remove

Code: Select all

#define MICROPY_HW_ENABLE_USB (1)
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.

Post Reply