STM32F4 Python Programming

Language & Programming

STM32F4 Python Programming

After the rather unsuccessful approach of installing an entire NuttX/PX4 ecosystem on an NUCLEO-F446RE, I got a very simple system running on it: MicroPython! Attaching the board via USB, it is only necessary to run the following commands to get a running python shell (in python context it is called REPL):

git clone https://github.com/micropython/micropython
cd micropython
cd mpy-cross
make
cd ../ports/stm32
make submodules
make BOARD=NUCLEO_F446RE deploy-stlink
screen /dev/ttyACM0 115200

Getting stuff blinking is just as fast as the previous commands:

import pyb
led = pyb.LED(1)
led.on()
led.off()

Let us test to send some UART data:

from machine import UART
uart = UART(6, 115200) # UART6 can be used
uart.init(115200, bits=8, parity=None, stop=1)
uart.write('abc')
uart.deinit()

Logging the data with a PicoScope 2205A MSO:

I2C did not work (yet!)


Following up on this with some Rust:
https://github.com/krenzlin/rust-stm32f446-blinky/blob/master/src/main.rs
https://dev.to/minkovsky/rusted-brains-running-rust-firmware-on-a-cortex-m-microcontroller-3had

Leave a Reply

Your email address will not be published. Required fields are marked *