Try out LVGL Pro - A complete toolkit to build, test, share, and ship UIs efficiently!
LVGL
Tutorial

MicroPython with LVGL on STM32F746 Discovery

Step-by-step guide to running LVGL's MicroPython binding on the STM32F746 Discovery board with display and touch support.

Gabor Kiss-VamosiGabor Kiss-Vamosi2 min read

This tutorial shows you how to get started with MicroPython and LVGL on the STM32F746 Discovery board. You'll learn how to build the firmware, flash it to the board, and initialize the display and touch screen.

Get MicroPython#

The fork of the original MicroPython repository with LVGL is available at https://github.com/lvgl/lv_micropython.

Simply clone it with git:

git clone --recurse-submodules https://github.com/micropython/micropython.git
sh

These libraries also need to be installed:

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

Build for STM32F746 Discovery#

Prepare MicroPython for cross-compiling:

cd lv_micropython
make -C mpy-cross
sh

Build the STM32 port and flash the board:

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

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

picocom /dev/ttyACM0 -b 115200
sh

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 is good, copy this line by line:

import lvgl as lv
lv.init()
 
import lvstm32 as st
st.lvstm32()
 
import rk043fn48h as rk
rk.init()
 
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.init()
disp_drv.buffer = disp_buf1
disp_drv.flush_cb = rk.flush
disp_drv.hor_res = 480
disp_drv.ver_res = 272
disp_drv.register()
 
indev_drv = lv.indev_drv_t()
indev_drv.init()
indev_drv.type = lv.INDEV_TYPE.POINTER
indev_drv.read_cb = rk.ts_read
indev_drv.register()
python

Test LVGL#

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

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

About the author

Gabor Kiss-Vamosi
Gabor Kiss-Vamosi

CEO & Creator of LVGL

Founder and lead developer of LVGL, the open-source embedded graphics library used in millions of devices worldwide.

Meet the people behind the blog

Discover the talented writers sharing their knowledge about LVGL

View Authors

Subscribe to our newsletter to not miss any news about LVGL. We will send maximum of 2 mails per month.

LVGL

LVGL is the most popular free and open source embedded graphics library targeting any MCU, MPU and display type to build beautiful UIs.

We also do services like UI design, implementation and consulting.

© 2026 LVGL. All rights reserved.
YouTubeGitHubLinkedIn