Skip to content

Instantly share code, notes, and snippets.

@stepansnigirev
Last active June 28, 2025 11:54
Show Gist options
  • Save stepansnigirev/61e96e60cedfdc7bb7e115581dee2548 to your computer and use it in GitHub Desktop.
Save stepansnigirev/61e96e60cedfdc7bb7e115581dee2548 to your computer and use it in GitHub Desktop.
Micropython build for STM32F469-Discovery board

Micropython overview

Micropython works on a variety of different boards, but originally it was written to work on STM32 microcontrollers. Their PYBOARD is based on STM32.

At the moment micropython is ported to several STM32 developer boards, ESP32, linux, MacOS and even webassembly.

I started porting micropython to STM32F469-Discovery board - I want to make a pull request to the main micropython repo when we add better support of peripherals, but for now it is located here.

In this document we will work with our fork of micropython.

Compilation

Clone the repo and init all submodules:

git clone --recursive https://github.com/diybitcoinhardware/micropython

Compile the mpy-cross crosscompiler:

cd micropython
make -C mpy-cross

To compile micropython for a particular board you need to go to the corresponding port directory. It will be ports/stm32 for stm32 boards, ports/unix for unix port etc.

cd ports/stm32
make BOARD=STM32F469DISC

When compilation is complete you will end up with the firmware.elf file in the build directory.

There are different ways to upload firmware to the board. I normally convert firmware to .bin file and copy it to the STLINK:

arm-none-eabi-objcopy -O binary build-STM32F469DISC/firmware.elf upy-f469disco.bin
cp upy-f469disco.bin /Volumes/DIS_F469NI/

Now when you connect the board with a microUSB cable (native USB port of the board, not STLINK) you will see another drive mounted where you can put micropython files.

You will also see a new serial port, you can connect to it and get to micropython REPL.

Files specific to the board

In order to port micropython to the board we created a new folder: ports/stm32/boards/STM32F469DISC

The most interesting file is mpconfigboard.h. It contains a bunch of pin definintions to make USB and other peripherals working. Some of them are working, others were copy-pasted from other boards.

I also added a linker script under ports/stm32/boards/stm32f469.ld that contains memory mapping for the microcontroller.

There is a CSV file ports/stm32/boards/stm32f469_af.csv that should contain the pinout of the board, but I don't know where micropython developers are taking it from, so I just copied one from STM32F439.

Most of the files are a simple copy-paste from STM32F439 or from STM32F769 boards. I made a few small changes to it such that it works with the board, but peripherals integration is currently limited to USB board (to get to REPL and mass storage) and LEDs.

Currently there is not support of QSPI, SD card (uses SDIO) and other peripherals.

Open problems

How to enable QSPI?

STM32F769DISC might be a good example for that. They added a custom board_init.c file that configures QSPI on startup, but I was not able to upload this binary directly - if QSPI is used then it can be uploaded only using micropython bootloader MBOOT. This is another question - how to use MBOOT? I was not able to figure out.

About the micropython bootloader: https://github.com/micropython/micropython/tree/master/ports/stm32/mboot

Fix SD card support

Some magic is required here, probably just pin configuration in mpconfigboard.h. If SD card is configured correctly it should be visible from micropython (using os lib):

import os
os.listdir("/")

listdir("/") should return an array ["flash", "sdcard"].

Simple flip of the #define MICROPY_HW_ENABLE_SDCARD (0) in mpconfigboard.h didn't work - I got a bunch of errors during compilation.

Use on-board RAM

Should be large, we could use it. How?

Future

Add littlevgl support. They have an example repo - https://github.com/littlevgl/lv_micropython and micropython bindings - https://github.com/littlevgl/lv_binding_micropython

They also have a driver for f469 that I used in Specter-DIY.

Would be nice to make it work with our board in micropython.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment