LVGL's Micropython binding on STM32F746 Discovery

This post summarizes how to get started with Micropython and LVGL on STM32F746 Discovery

Get the Micropython

The fork of the original Micropython repository with LVGL is available at

Simply clone it with git:

git clone --recurse-submodules

These libraries also need to be installed:

sudo apt-get install build-essential libreadline-dev libffi-dev git pkg-config python

Build for STM32F746 Discovery

Prepare Myropython for Cross compiling:

cd lv_micropython
make -C mpy-cross

Build the STM32 port and flash the board:

cd ports/stm32
make -j8  BOARD=STM32F7DISC MICROPY_PY_LVGL=1 deploy-stlink

When flashed, reset the board and connect to the boards serial port. Here picocom is used but other applications work as well.

picocom /dev/ttyACM0 -b 115200

Initialize the display and touch screen

When the terminal is active test if Micropython is really running. For example type 3 + 4 and it should print the result.

If all good copy this line by line:

import lvgl as lv

import lvstm32 as st

import rk043fn48h as rk

disp_buf1 = lv.disp_buf_t()
buf1_1 = bytes(480 * 80)
disp_buf1.init(buf1_1, None, len(buf1_1) // 4)
disp_drv = lv.disp_drv_t()
disp_drv.buffer = disp_buf1
disp_drv.flush_cb = rk.flush
disp_drv.hor_res = 480
disp_drv.ver_res = 272

indev_drv = lv.indev_drv_t()
indev_drv.type = lv.INDEV_TYPE.POINTER
indev_drv.read_cb = rk.ts_read


Just create a button to see the display and touch is working:

btn1 = btn.create(lv.scr_act())