It is possible to build lvgl for raspberry pi PICO? I cloned dev-8.0 branch and triying to build but looks that lvgl library is not included for this platform.
As I know, micropython-lvgl can be built for ESP32 platforms that, as PICO, have a build system based on cmake, so it should be easy to adapt.
But such idf_build_x are just available under esp build system. Maybe I can find these commands on esp-idf and copy to rp2 cmake…
If someone can help, cause I never work with cmake and I dont know how to do it
CMakeLists.txt (11.7 KB)
I added the required sources to the CMakeLists.txt and get the built fw with but looks that something still wrong cause it dosnt boot up (I cant see the device on my COM ports)
To generate lv_mpy.c I still dont know how to call gen_mpy.py so I take it from stm32 build.
But the code for esp32 version is something like that (form lv_bindings/mkrules.cmake)
Thank you @amirgon. I included such file, removed few esp32 stuff and now wrappers are generated properly and handled in qstr generation.
I dont know why, but compilations crashed cause some functions from lv_mp.c where unused and I bypassed the error simply adding a gcc pragma on gen_mpy.py generator.
Now I can get a firmware image, still cant boot-up, but I think It should work soon.
So I have all sources compiled, wrappers generated and LVGL handle in root pointers. Is there any other thing that Im missing?
ok, finally I got my fw image. The procedure should be easy if you have previous experience with cmake. I attached the most important modified files, mpconfigport.h and CMakeLists.txt
After build with lv_bindings dev-8.0 branch I create a simple screen with a button and dump the fb to the stdout, to verify that really works, and everything was ok. Then I had problems adding a label inside button (maybe the API change a little bit on this version I dont know) but also I saw some crazy behavior checking allocated memory with gc.mem_alloc() so finally I decide to move to lvgl v7 (dev branch) and now LVGL v7 is working ok on raspberry pi pico.
I think that someone with more experience on cmake can easily review these files and add to the dev branch. CMakeLists.txt (12.0 KB) mpconfigport.h (10.6 KB)
On v7 works ok. On v8, without label works and I can see a correct button drawn on framebuffer, but with the label, code is halted before flush callback.
Yes, I called gc.collect()…Now Im wondering, maybe it wasnt a problem with gc. I used thonny and call few times to gc.mem_alloc() from terminal and got results that I didnt expected. I tried to reproduce again but now looks normal so maybe the “crazy” values I saw where related to the “automatic variable inpection” feature that thonny ide has. ( Thonny IDE adds some code to every REPL command to visualize variables on the ide, like a light debugger)
Here I executed above script and then (without reset) called few times to gc funtions. The values returned from gc.mem_free() move from 70k, 100k, 100k, 25k…its not what you should expect
Yes, any ILI9xxx with an SPI interface cause PICO hasent too many pins. But I will write on python side, so it dosent affect to LVGL build.
I like how v8 looks, and today I came back to v7 cause that “gc problems”. Tomorrow I will check again better to understand if its really a problem or not…but another problem with v8 is that API has too many changes so I need to learn again how todo too many things, even python demos dosent works or API doc is not available…
This code works just fine for me in on v8.
Maybe something is not up to date on your workspace?
After checking out dev-v8 branch of lv_micropython, did you remember to run git submodule update --recursive?
Maybe some problem related to Thonny?
Actually @uraich did a lot of work on Python examples for LVGL v8.
These examples will eventually be part of the official docs, but you can already see them on GitHub:
(Note that src/* files has been modified to avoid compilation errors with some snprintf “%d” that should be “%ld” )
Then I tried the example from @uraich repo lv_example_btn_1.py and still dosent works. (But works if I remove the labels)
I wonder that maybe something related with fonts, but check that default montserrat fonts are enabled on lv_conf.h…so I dont know what is happening here. Also cause I dont have rp2 debug IDE I dont know what is happening on background…
This image shows on the top cell the micropython code with lv_example_btn_1.py that is executed on raspberry pico and on bottom cell the PC code to visualize the framebuffer(that is dumped via REPL). I can see two buttons on the screen, but if I uncomment the labels, the code dosent work…
I hope I can solve the problem with labels cause with @uraich examples will be easy use lvgl v8
First step for solving this is identifying where the problem is.
It could be related to LVGL C code when built for Ri PICO
It could be related to Micropython or the LVGL binding code between Micropython and LVGL
Let’s see if it’s related to Micropython or to LVGL.
I suggest trying to reproduce the same problem without Micropython:
Create a small C program that builds with the same LVGL workspace that you use for Micropython (including your changes to LVGL code, including lv_conf.h) but without Micropython itself.
In that C program just create a button and a label in C and let’s see if it works correctly or not.
You could also compile the unix port of micropython first and try the program there. If it works correctly there, then the problem is in the RPi port. If not, then something is wrong in the way you create your micropython binary.
You are right. I build unix port and test it and worked OK, so problem should be on rp2 port (upy, biddings or somewhere)
Im new on rp2 so I need some time to build a C project and add LVGL sources. I also can debug the current .elf file that I have, but I also need time to get required setup (ide, pico probe…)
Meanwhile I enabled LVGL log traces and now behavior is different(also I came back to snprintf("%d") that linux port requires and then add (int) castings on rp2 port snprintfs). I can add the label, but text is blank and is tooo long… log btn.txt (21.0 KB)