[NUCLEO-F401RE] procedure to upload the MicroPython image

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.
rino
Posts: 1
Joined: Sat Nov 03, 2018 8:54 am

Re: [NUCLEO-F401RE] procedure to upload the MicroPython image

Post by rino » Sat Nov 03, 2018 9:05 am

I just wrote an article about how to flash a Nucleo-64 STM32F401 board starting from the .dfu binary and using the ST morpho pins:

http://www.perlatecnica.it/tutorial/stm ... stm32f401/

Sorry it's in Italian

User avatar
boochow
Posts: 30
Joined: Sat Dec 16, 2017 9:36 am

Re: [NUCLEO-F401RE] procedure to upload the MicroPython image

Post by boochow » Mon Dec 03, 2018 1:26 pm

The easiest way to deploy MicroPython to Mbed-ready boards is to drag and drop a firmware binary onto Mbed filesystem folder.
I made an archive page which has firmware binaries built on December 1, 2018 from MicroPython mainline source code.

https://blog.boochow.com/micropython-fi ... bed-boards
(I have tested only 3 boards: 401RE, L432KC, and IOT01A.)

They are zipped files so you should download the file for your board then unzip it to get the binary file.
Drag and drop the binary file onto the folder which would open when you connect the board to your PC with USB.

These binary files are simply converted from ELF files using objdump like this:

Code: Select all

arm-none-eabi-objcopy -O binary build-STM32F769DISC/firmware.elf upy-f746disco.bin
What this method is inferior to the official deploy method is that this method will erase all of the internal files saved in flash memory area.
This is unavoidable because the internal filesystem block is placed between ISR and TEXT area and the format of raw binary file provides no means to skip writing the specific memory area.

nilo
Posts: 3
Joined: Tue Jan 08, 2019 12:13 am

Re: [NUCLEO-F401RE] procedure to upload the MicroPython image

Post by nilo » Tue Jan 08, 2019 7:28 pm

boochow,
thanks for creating the "bin" file for the iot1a, you make life easier.
I got the REPL working. since I just downloaded your binary files
I do not have the "boot.py" and "main.py". how do I run a script?
like writing a script inside main.py, reset the board to run the script.
any comments will be highly appreciated, sorry for bothering you I'm a newbie.

User avatar
boochow
Posts: 30
Joined: Sat Dec 16, 2017 9:36 am

Re: [NUCLEO-F401RE] procedure to upload the MicroPython image

Post by boochow » Wed Jan 09, 2019 11:55 am

@nilo the IoT1A board has two USB ports, USB-STLink on the top right corner and USB-OTG on the top center.
You can access the files through USB-OTG port only. USB-STLink port is dedicated to Mbed.

Please note that ( i ) you always have to connect the USB-STLink port to power your board and ( ii ) the USB-OTG port is a micro USB connector which is soldered in upside-down position.

nilo
Posts: 3
Joined: Tue Jan 08, 2019 12:13 am

Re: [NUCLEO-F401RE] procedure to upload the MicroPython image

Post by nilo » Mon Jan 14, 2019 6:15 pm

@boochow,
thanks a lot, everything is working now (using 2 microUSB's). This is the quickest MicroPython implementation on the IOT1A.
now I just have have to find drivers for all the sensors on this board. I got the VL53L0X drivers from desiphu working too.

blipton
Posts: 8
Joined: Mon Dec 15, 2014 3:11 am

Re: [NUCLEO-F401RE] procedure to upload the MicroPython image

Post by blipton » Mon Jan 27, 2020 4:19 pm

Sorry to bring up an old thread, but I've got a sort of similar issue.. I have a nucleo board with the built-in stlink, however, it doesn't come with 'mbed' installed, so programming via the mass-data-storage is not possible. However, since the st-link (and st-flash) utility seem to support the .bin format, I'm curious why the st-link can't be used to program the bin instead of via the dfu. The dfu seems trickier as you have to connect directly to the main cpu's usb pins, reset to the boot0 bootloader, then flash with the dfu programming software and/or stm32-versprog?

BTW, assuming I can get micropython flashed, I would then use the usb otg connector to upload py files so that it executes it automatically at power-on? How do you specify which files or order it should execute?

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

Re: [NUCLEO-F401RE] procedure to upload the MicroPython image

Post by dhylands » Mon Jan 27, 2020 4:36 pm

You should be able to use st-flash to program the NUCLEO-F401RE. The Makefile has a deploy-stlink rule which will do the appropriate flashing steps:

Code: Select all

make BOARD=NUCLEO_F401RE deploy-stlink
This assumes that you have the stlink tools installed and setup.

Delebel
Posts: 48
Joined: Thu May 25, 2017 2:21 pm
Contact:

Re: [NUCLEO-F401RE] procedure to upload the MicroPython image

Post by Delebel » Sat Jan 02, 2021 6:37 pm

Hi I've been struggling to get a clone STM32F405 board to enumerate correctly on my Win8.1 platform to use mircopython. I finally got success using the CubeProgrammer from STM and the ELF file that you put a link to in these forum thread. Now I'm a newbie and I don't have the tools or knowledge to redo the converstion job (dfu->elf) using a closer match of DFU file for my target hardware (f405rtg6). I do not want to impose on your good will but could you at least give me a bit more info on which tools I need to get such a conversions happening. It could be for a linux platform cause on the windows side I've had such frustration issue with drivers that I'm considering using Ubuntu on another machine for development work. However that is a big learning curve to tackle so if there is a path forward with windows it would be easier.
Thanks Denis
dhylands wrote:
Tue Aug 29, 2017 5:43 pm
Right - you need an ELF file to flash using st-link.

It would be possible to create a script which converts a DFU file into an ELF file, but I'm not aware of just a script actually existing right now.

The simplest way to create an ELF file is to build it from source.

I grabbed the latest source, built it and put the elf file here: https://www.dropbox.com/s/rvx6z2eri0jy9 ... e.elf?dl=1

And I tested it on my NUCLEO_F401RE and got a REPL:

Code: Select all

PYB: sync filesystems
PYB: soft reboot
MicroPython v1.9.2-21-g8388ec4-dirty on 2017-08-29; NUCLEO-F401RE with STM32F401xE
Type "help()" for more information.
>>> 
and yes it used the REPL shows up on the virtual usb serial port created by stlink.

Delebel
Posts: 48
Joined: Thu May 25, 2017 2:21 pm
Contact:

Re: [NUCLEO-F401RE] procedure to upload the MicroPython image

Post by Delebel » Sat Jan 02, 2021 7:04 pm

After looking around the forum more I believe I will try the DFU-util route so wish me luck...Later Denis
Lupine wrote:
Thu Aug 24, 2017 8:58 pm
Hi all,
I'm very interested in trying out the programming language starting to use a NUCLEO-F401RE board in my possession (even if not officially supported). The idea is to try starting from scratch by loading the latest firmware you have released and begin taking knowledge with the interactive prompt (the REPL) to execute commands.
The procedure you suggested for Windows setup (pdf file) is valid for official boards and is not 100% clear if and what is applicable to NUCLEO boards (moreover is related to Windows 8 and 8.1, while I have Windows 10).
Could you please clarify\list the main procedure steps to upload the MicroPython released image on the NUCLEO F401RE board and after get the REPL properly working (e.g. usb driver needed, board jumper setup, any other information that is useful).
My first understanding is that is not possible to use ST-LINK to program the STM32 micro on the board.

Thanks in advance for your support...

Regards

Delebel
Posts: 48
Joined: Thu May 25, 2017 2:21 pm
Contact:

Re: DFU-Util works to flash generic STM32F405 board...

Post by Delebel » Sun Jan 03, 2021 5:05 pm

Well thanks to the forums info I got to flash my board (STM32F405) with the DFU-util route. Downloaded the windows version. Got fooled initially as its a DOS box application. Found an example in the help text file and Bingo! Specifically my board enumerated as STM32 Bootloader in the control panel as opposed to the tradition Pyboard which enumerates as Dfuse so it would not show up using the DfuSedDemo.exe I had used for my original pyboard.

Thanks for being there to help out an newbie to move from C to Micropython. Now the real programming begins as getting to a python prompt is only a first step...

Regards...Denis

Post Reply