[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.
Lupine
Posts: 8
Joined: Thu Aug 24, 2017 8:12 pm

[NUCLEO-F401RE] procedure to upload the MicroPython image

Post by Lupine » 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

User avatar
dhylands
Posts: 2956
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 » Sat Aug 26, 2017 6:05 am

The simplest way to program the Nucleo-F401RE is to use the ST-Link interface that's included on the board. The pyboard is normally programmed using DFU, but the Nucleo-F401RE board doesn't expose the USB on the 401 chip. The USB connector present on the board is for the ST-Link processor.

Lupine
Posts: 8
Joined: Thu Aug 24, 2017 8:12 pm

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

Post by Lupine » Mon Aug 28, 2017 9:44 pm

Hi,
many thanks for your feedback.
I also thought this was the simplest way to load the MicroPython interpreter on the board.
The problem is that in the official download page (http://micropython.org/download) I found only a DFU release (section: Firmware for other boards) that, if I'm not wrong, I cannot load it via ST-Link.
Where can I find the same binary file to load it on the board (without the need to compile source files for the moment)?
Moreover, after uploading the micropython image, I guess the REPL interface is also available on ST-link (virtual com port)?
Is it correct?

Thanks in advance for your support...

Regards

User avatar
dhylands
Posts: 2956
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 » 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.

Lupine
Posts: 8
Joined: Thu Aug 24, 2017 8:12 pm

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

Post by Lupine » Tue Aug 29, 2017 7:54 pm

Hi Dave,
thanks a lot for your support.
I downloaded the elf file you have kindly shared but it seems to be too large to be loaded on my NUCLEO-F401RE.
The elf file size, downloaded on the disk, is 582 KB (596.475 bytes) that does not appear to be available on the STM32 target device (so I get the "insufficient space" error message from WIN 10 OS).
Could you please check if there is an error or the file can be reduced?

Thanks in advance...

Regards

mwm
Posts: 36
Joined: Wed Aug 09, 2017 3:52 pm

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

Post by mwm » Tue Aug 29, 2017 11:54 pm

Are you trying to copy the file to the mbed device? That won't work, and gets the space message you are reporting. The mbed storage is on the st-link, not the STM32F, and the file is too big for that. You'll have to use the st-link protocol, which doesn't store the file on the st-link.

User avatar
dhylands
Posts: 2956
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 » Wed Aug 30, 2017 6:36 am

Just to claridfy, I programmed the elf image on my NUCLEO board using the following command:

Code: Select all

make BOARD=NUCLEO_F401RE deploy-stlink
which uses the command:

Code: Select all

st-flash write build-NUCLEO_F401RE/firmware0.bin 0x08000000
and

Code: Select all

st-flash --reset write build-NUCLEO_F401RE/firmware1.bin 0x08020000
The .bin files can be found in this directory: https://www.dropbox.com/sh/48f4pyubzqau ... yvENa?dl=0

I use linux, so I'm not sure of the exact procedure to use st-flash under windows. This page has some instructions, but I'm not sure if they work: https://github.com/texane/stlink/blob/m ... utorial.md

Lupine
Posts: 8
Joined: Thu Aug 24, 2017 8:12 pm

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

Post by Lupine » Wed Aug 30, 2017 9:20 pm

Hi,
many thanks for the feedback!
I was able to upload the firmware.hex file that you shared through the STM32 ST-LINK utility software
and finally got the REPL prompt via putty!

Code: Select all

>>> MicroPython v1.9.2-21-g8388ec4-dirty on 2017-08-29; NUCLEO-F401RE with STM32F401xE
Type "help()" for more information.
>>>
Now I can start to do some trials and get acquainted with the micrpyton language.
I would like to put on the system for the source code compilation also for other \ board platforms.
If I wanted to retrieve\set up a machine with Ubuntu, could you please suggest a procedure to install all the tool-chain needed to compile and load image on the board?
Moreover, for the future releases, it would be possible to release the image file also in .hex (or .bin) format (which is much more usable) for the other boards and not just dfu file (sorry but I'm not sure this is the right place for that request)?

Regards

User avatar
dhylands
Posts: 2956
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 » Wed Aug 30, 2017 11:25 pm

The README has links to a toolchain:
https://github.com/micropython/micropyt ... tm-version

You basically unpack the tarball and add the bin directory into your PATH.

This page has some additional udev setup that I find useful:
https://github.com/micropython/micropyt ... -Discovery

Lupine
Posts: 8
Joined: Thu Aug 24, 2017 8:12 pm

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

Post by Lupine » Wed Sep 06, 2017 8:21 pm

Hi,
let me come back to the following request:
Lupine wrote: .
.
Moreover, for the future releases, it would be possible to release the image file also in .hex (or .bin) format (which is much more usable) for the other boards and not just dfu file (sorry but I'm not sure this is the right place for that request)?
Since it would be useful, in my opinion, to have a "reference release" for Nucleo boards (even if not officially supported) in a more easily programmable format (instead of dfu), could you please help me to carry on this kind of "change request" for next releases ?
Are there any chances that it can be accepted?

Thanks in advance!
Regards

Post Reply