Friday, May 9, 2025

MicroPython On STM32F429 Discovery

We try out MicroPython on STM32F429 Discovery kit.  We pull the MicroPython v1.25.0 source code from github.  

First `make -C mpy-cross` to build MicroPython cross compiler.

Then in ports/stm32, `make BOARD=STM32F429DISC submodules` to pull in libhydrogen, micropython-lib and stm32lib.  

We need the GNU compiler  arm-none-eabi-gcc; we use GCC version 13.3.1  from STM32CubeIDE 1.18.1.  `make BOARD=STM32F429DISC` to build.  The size of the firmware is about 320KB.  STM32F429 has 2MB Flash.

We use stlink to flash; we build stlink v1.8.0 from the source.   We need to specify the USB device ID, `export STLINK_DEVICE="0483:374b"` and `make BOARD=STM32F429DISC deploy-stlink` to download.  openocd can also be used.

Connect to the STLINK USB serial port with minicom -D /dev/ttyACM0

>>> MicroPython v1.25.0 on 2025-04-24; F429I-DISCO with STM32F429

Type "help()" for more information.

We can turn on the red LED with pyb.LED(1).on().

Connecting to the micro USB port, we get another serial device /dev/ttyACM1 and a storage device of 240KB.  There is one 112KB FAT partition on the storage device; the partition has the python scripts, 'boot.py' and 'main.py', which are executed at the start.  We can edit the files (like printing a message) and CTRL-D to restart.  We can the output.   Connecting to /dev/ttyAMC1, we also get a REPL console.  The output goes to both serial ports.

Next we want to do something with the 3-axis gyro (I3G4250D) and the 240x320 LCD (ILI9341).

No comments:

Post a Comment