STM32 [NUCLEO_F411RE] - Missing pyb.usb_mode function

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
esologic
Posts: 3
Joined: Mon Jan 13, 2020 3:33 am

STM32 [NUCLEO_F411RE] - Missing pyb.usb_mode function

Post by esologic » Mon Jan 13, 2020 3:41 am

Hi everyone!

Spent the day getting MicroPython running on my NUCLEO_F411RE dev board. Everything has gone smooth so far, and I can access the repl no problem.

I would like to enable USB MSC to drag and drop libraries and programs onto the device. Reading the docs, I think I should use the:

Code: Select all

pyb.usb_mode
Function, but when I go to use it in the repl I see:

Code: Select all

>>> import pyb 
>>> pyb.usb_mode()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'usb_mode'
Any ideas?

Thanks.

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

Re: STM32 [NUCLEO_F411RE] - Missing pyb.usb_mode function

Post by jimmo » Mon Jan 13, 2020 4:28 am

For reasons that aren't quite clear to me, many of the Nucleo 4xx boards do not have a USB port on them connected to the 4xx chip (despite the chips supporting USB).

So the MicroPython firmware for these boards disables USB support by default.

The MSC device you see when you connect it to a computer is actually the ST-Link -- the USB port on these boards is only for the ST-Link, which connects to the 411 via UART only.

You could possibly wire a USB cable to DM PA11 / DP PA12, but there's no connector on the board.

esologic
Posts: 3
Joined: Mon Jan 13, 2020 3:33 am

Re: STM32 [NUCLEO_F411RE] - Missing pyb.usb_mode function

Post by esologic » Mon Jan 13, 2020 4:34 am

Ah bummer. Makes sense, that's what googling for a few hours kind of got me thinking.
jimmo wrote:
Mon Jan 13, 2020 4:28 am
by default.
If I were to add a usb connector for this, do you know what I would have to change in compilation to enable usb support?

Hardware-wise, would I need level shifters or pullup/down resistors anywhere? Or could I directly wire in the usb connector?

Probably could look at some schematics to answer this question...

Thanks so much for the quick response.

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

Re: STM32 [NUCLEO_F411RE] - Missing pyb.usb_mode function

Post by jimmo » Mon Jan 13, 2020 4:49 am

It's mostly just a matter of adding MICROPY_HW_ENABLE_USB to ports/stm32/boards/NUCLEO_F411RE/mpconfigboard.h

The board is otherwise almost identical to the Pyboard Lite 1.0, so take a look at ports/stm32/boards/PYBLITEV10/mpconfigboard.h (and the pyblite schematics). http://micropython.org/resources/PYBLIT ... matics.pdf has exactly the wiring.

esologic
Posts: 3
Joined: Mon Jan 13, 2020 3:33 am

Re: STM32 [NUCLEO_F411RE] - Missing pyb.usb_mode function

Post by esologic » Mon Jan 13, 2020 1:02 pm

Amazing! Thank you so much. I'll report back w/how surgery goes :D .

Post Reply