How to build and run MicroPython on STM32F7-Disco board

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
Posts: 6
Joined: Sat Nov 05, 2016 6:23 pm

How to build and run MicroPython on STM32F7-Disco board

Post by JF002 » Sat Nov 05, 2016 7:11 pm


I recently discovered the MicroPython project, and I wanted to give it a try. After some research, I found out that MicroPython is ported to the STM32F7 microcontroller, and the STM32F7-Disco board. Nice, I have one laying around!

I did not find complete documentation about building and running MicroPython on this board, but after some tries and errors, I managed to build and run it on my board! Here is what I did.

First, my setup : I mainly work on Windows 10, but I have a Debian virtual machine (VirtualBox).
I used the Debian virtual machine as most of the documentation about building MicroPython is related to Linux (and that's a very good point!).

First, get the source using git:
$ git clone
This will download the source to the directory ./micropython

You can build the Unix version of MicroPython if you want. For that, you need to install some dependancies:
$ apt-get install build-essential libffi-dev pkg-config

Then go into the Unix folder:
$ cd micropython/unix

And build MicroPython for Unix:
$ make

You can then run the interpreter :
$ ./micropython

Now, let's build MicroPython for our STM32F7DISCO board. We need a toolchain (compiler and other tools) to cross-compile micropython. Indeed, my computer is running a 64bits Intel Processor, and we need to build MicroPython to run on an ARM Cortex M7 microcontroller.
There is a package in Debian named 'gcc-arm-none-eabi' which should do the job, except that this is an old version (4.8) of GCC that has no knowledge of the Cortex-M7 architecture.
We'll need to find another compiler. I found useful information about this on this page :

First, download the toolchain (GCC ARM Embedded) : You'll want the 'Linux installation tarball'.
Download it and uncompress it on your local hard-drive.
As this toolchain is built for 32bits Linux and as I use a 64bits Debian, I needed to install extra packages :
$ apt-get -y install lib32z1 lib32ncurses5

Then, go to the micropython directory and start the compilation:
$ cd ~/micropython
$ cd stmhal
$ make BOARD=STM32F7DISC CROSS_COMPILE=<Path where you uncompressed the toolchain>/bin/arm-none-eabi-

This will build Micropython into the folder build-STM32F7DISC. Just look for the files firmware.dfu, firmware.hex,...

Next, we need to flash the board with this binary file. It is easily done using the STLINK USB interface of the board.
I did this step in Windows, as I never used the STLINK on Linux.
Download STLINK drivers and utility from this page :

Connect a mini-USB cable between the board and your computer. Windows should detect the STLINK interface and a new COM port (it'll be used as the REPL port once the firmware will be uploaded).
Start the STM32 ST-Link Utility, and open (File->Open File) the file 'firmware.hex' that was created before.
Screenshot :
Then, connect to the target (Target->Connect) and upload the file (Target->Program).
Screenshot :

I use Putty as a serial terminal (just open a connection on COMx, 115200 bauds). After the uploading of the firmware, the board reset and... the Python interpreter appeard on the screen!
Screenshot :
How is that possible? MicroPython is configured to use the UART1 of the µC as the REPL port. It is connected to the STLINK device on the board, and the USB interface of the STLINK exposes this UART as a USB-serial port to Windows.

And I've just discovered that the micro-USB port on the right of the STLINK port is seen by windows as a USB storage, which is used by MicroPython to store your .py files.

Now, I'm ready to play with MicroPython :-)
Pictures : and

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

Re: How to build and run MicroPython on STM32F7-Disco board

Post by dhylands » Sun Nov 06, 2016 2:03 am

The normal build instructions for micropython are found on the main file in the github repository: ... tm-version

If you put arm-none-eabi-gcc into your PATH then you don't need to use CROSS_COMPILE

The remaining instructions can be found here: ... -Discovery

Since those instructions were written there is now a deploy-stlink rule which will program any of the STM32 boards that have the builtin stlink hardware.
You'll need to install stlink (under linux) from: to use the deploy-stlink target.

Posts: 6
Joined: Sat Nov 05, 2016 6:23 pm

Re: How to build and run MicroPython on STM32F7-Disco board

Post by JF002 » Sun Nov 06, 2016 4:08 pm

You're right, all the information were already available...
But I spent some time to put them together, and I thought it would be useful for anyone who wants to start micropython on is STM32F4 disco board :)

Btw, thanks for the links!

Posts: 1
Joined: Sun Jan 08, 2017 11:40 am

Re: How to build and run MicroPython on STM32F7-Disco board

Post by aronno » Wed Jan 18, 2017 6:04 pm

Thanks very much for the post. I just applied your steps and success. I want to add a note that, I inserted a Micro SDCard when powering up the board, The board did not respond. Then I removed the Micro SDCard and repower the board. Then the board started to respond and MicroPython prompt appeared on both port.

Posts: 6
Joined: Mon Dec 15, 2014 3:11 am

Re: How to build and run MicroPython on STM32F7-Disco board

Post by blipton » Sat Jan 20, 2018 5:48 am

Is this only for the STM32F769 DISCovery board? The other STM32F7 based boards (ex. STM32F746G-DISCO, NUCLEO-F746ZG) would require additional work?

BTW, does micropython support an interactive shell via the SWD console? Keil's uVision has a debug (printf) console but seems to require a compatible debugger.. not sure if the cheapy $3 st-link v2 will work! ... print-Ly1m

[Update] Regarding SWV and St-Link, it seems according to this, that it should work: ... -for-stm32

Post Reply