Error with lv_bindings/lvgl/src/lv_misc/lv_printf.c

SDL can only be used on systems with OS (Linux, Windows, OSX, Android, etc.) that support multimedia.
I don’t think this applies to your stm32 boards.

To display anything you would need a display driver. Please have a look at the docs.

Officially, supported drivers are:

  • ILI9341 (and similar displays) driver for ESP32
  • Linux Frame Buffer ( /dev/fb0 )
  • SDL unix drivers (display and mouse)

You can use these as a reference for developing your display driver.

Hi @amirgon,

It took me several days to read and partly understood the content of the doc you had given me.

I also did some research and reading in lib/lv_bindings/driver and indeed, as u said, the current lvgl only supports esp32, SDL, and linux. As I walked through lib/lv_bindings/driver/esp32, there are several files: ili9341.py and modILI9341.c or xpt2046.py and modxpt2046.c (I did some research and ILI9341 and xpt2046 are screen modules). I guess these are the files I base on to write driver for the screen of my board.

I also see espidf.c and .h . I guess i dont need this. And modrtch.c i don’t need this too due to my screen is not a resistive touch driver.

Am I going in a correct path?

Thank you, Huy.

Also, Do I need to look anywhere else in lv_bindings to support the screen of my board?

I think you are in the correct path.

The first thing you need to decide is whether you want to develop a pure micropython display driver or a C display driver.
As a reference, ili9341.py is a pure python display driver and modILI9341.c is a C display driver.

I believe STM32F4 Discovery already has a C lvgl driver (non micropython) but I’m not sure for which display hardware exactly, and whether it is up to date.
@embeddedt /@kisvegabor - could you give more information about existing STM32F4 Discovery display drivers?

So as the first step, please try to run lvgl C code (without Micropython) on your stm32 and display hardware and make sure you have a working lvgl C display driver.

The next step would be to use this driver with micropython.
In order to use a C display driver in micropython, it would need the following changes:

  • Parameters should be set on runtime not compile time. For example, when you set SPI ports on C driver you usually use #define to declare them, so they are set during compile time.
    On a micropython driver on the other hand, you need to receive port numbers as function arguments that can be set on runtime.
  • Provide API to micropython and bind it as a micropython module. More details on micropython-usermod, adding-module and micropython docs. I can help you with that when you get to it.

The existing drivers for STM32 discovery boards are provided as components of the pre-made projects. They are built to work with the STM32Cube infrastructure. Significant work is probably necessary to adapt them to MicroPython.

The standalone drivers in the lv_drivers repository are not dependent on Cube and may be easier to work with, but only if your chipset is already supported.

Otherwise, you would need to make a new driver.

Hi @amirgon,

The first thing you need to decide is whether you want to develop a pure micropython display driver or a C display driver. Files are written in C language and then they are translated into Micropython modules. Also I have just started this project for 2 months. So I am a bit confused which one to choose.

As I suggested, try to run lvgl C code (without Micropython) on your stm32 and display hardware and make sure you have a working lvgl C display driver .

After you have lvgl running with your display, I’ll explain what you need to do in order to use it with micropython.

As @embeddedt suggested, start with a driver from lv_drivers, which matches (or as close to) your hardware.

Hi @embeddedt,

Thanks for your response

So you mean that there exists an already-made display driver for STM32 discovery boards? and this driver is written in C so that I could use it via STM32Cube? Where can i find this driver?

As i read through the link of Github you gave, there are several drivers for some display modules. But mine display module (MB1314) is not supported. So i guess i have to write a new driver.

Hi @amirgon,

I got your idea.
Currently, as I responded to @embeddedt, my display module is not supported yet.

By “matches” and “close”, you mean the same size, shape, resolution, type of screen, frequency,… etc like mine.my module is MB1314:

By “close” I mean displays with the same controller or almost the same controller, such as ILI9488 and ILI9341. Their initialization is different, but commands are the same.

I’m not familiar with MB1314. I suggest you search the internet and ST resources for a driver example.

For example, a quick search on GitHub for RM67162 (which is the controller of MB1314 according to your datasheet) brings multiple results:

Hi @amirgon,

As you talk about the lvgl C code, I realize that our team did that before at the very beginning of this project. As we upgraded the the library of STM32L4 for the Github repo of lv_micropython from1.8 to 1.14, we come across this rar file from this link:

Inside the link, there is not only the upgraded 1.14 library, but also some examples for us to interact with the screen: (As you download and extract the file), it is in: STM32Cube_FW_L4_V1.14.0/Projects/32L4R9IDISC/Examples.

Is that the thing you mentioned and suggested me to do? If so, yes we can turn on the screen and interact with it. (the demonstration is STemWin).

Turning the screen on and interacting with it would be the first step.
The second step is to use it with lvgl (C code)
The third step is to bind it to lv_micropython.

I got your idea. I will start the second step and update as i finish it.

However, there are some difficulties as the screen on the only board i have was broken. I got a display module of STM32L4R9I Eval. Meanwhile, my board is STM32L4R9I Discovery. Our team is trying to modify the module to run it on the Disco board.

I update as soon as possible.

There are LittlevGL drivers for STM32 discovery boards that use STM32Cube. I’m not sure how difficult they would be to integrate with MicroPython, but they would certainly be more work than a bare-metal driver with no dependencies.

To find them I suggest searching for the name of your chip here. In that example I searched for “stm32f429” and got the STM32F429-DISCO project. I believe there is also one for F469.

Hi @embeddedt

I appreciate your reponse. Although there is no material for my chip (STM32L4 series), the STM32F429 is a good reference to me. Thank you very much

Hi @amirgon,

I did the second step as you suggested to me. I followed this link to use LittlevGL in C:

I used STM32CubeMX to configurate the board (STM32L4R9I) and Keil C uVision to program it.

However, as I built the project, I met this errors:

I was a bit confused. For example, in the file lv_conf.h, I set LV_COLOR_DEPTH as suggested number but the error in this file still appeared.

So @amirgon and @embeddedt, how may I address this issue?

Are you sure that that lv_conf.h file is actually be included? It might be worth double-checking that.

Hi @embeddedt,

As instructed in the link, I put the lv_conf.h next to lvgl and in the project folder.

Or do you mean that I also need to write "#include “lv_conf.h” " in some file?

I am also a bit confused about the line " Include lvgl/lvgl.h where you need to use LittlevGL related functions.". I put "#include “…/lvgl/lvgl.h” " in main.c file. Is that the right thing to do?

Hi @embeddedt and @amirgon

I used Keil C uVision and STM32CubeMX in stead of recommended applications:

Does that affect the process?

It’s a bit hard for me to know your exact project setup, particularly since you’re creating it from scratch.

What I can suggest is that you check whether that lv_conf.h file is actually being included properly (an #error directive added to its first line should tell you that quickly).