About latest micropython(1.21) on lvgl/lv_micropython

Greetings!

Thank you for your micropython bindings, even it doesn’t seem to be very mainstream.
I would greatly appreciate knowing more about the schedule, humbly asking for information on the timeframe.

It is actively being worked on. MicroPythons build system underwent some pretty extensive changes to it and it has caused a great deal of grief. We are also trying to address uniformity issues across the different MCUs, namely the display drivers. We are trying to make it so the binding is not so intertwined into the build system. It’s a tough nut to crack and it is being worked on.

I did have a good day today working on it. Got quite a bit accomplished. We are getting together on a video conference call in the next couple of days to hopefully hammer out a final direction and figure out who needs to do what. We will know more once that takes place. so hold tight a few more days and we can get you a better ides on when it will be available.

1 Like

Always thanks for a such great work.

I’m very appreciative that you’ve picked up the baton on this project !!!

I’ve downloaded your repo and attempted to do a build.
python make.py esp32 -mpy_cross -submodules -clean BOARD=ESP32_GENERIC MICROPY_BOARD_VARIANT=SPIRAM
Had errors… Am I too anxious ???

make[3]: Leaving directory '/workspaces/v2-lvupy-1.21/lv_binding_micropython/micropython/ports/esp32/build-ESP32_GENERIC'
make[2]: Leaving directory '/workspaces/v2-lvupy-1.21/lv_binding_micropython/micropython/ports/esp32/build-ESP32_GENERIC'
make[1]: Leaving directory '/workspaces/v2-lvupy-1.21/lv_binding_micropython/micropython/ports/esp32/build-ESP32_GENERIC'
-e See https://github.com/micropython/micropython/wiki/Build-Troubleshooting
make: Leaving directory '/workspaces/v2-lvupy-1.21/lv_binding_micropython/micropython/ports/esp32'
/workspaces/v2-lvupy-1.21/esp-idf/tools/check_python_dependencies.py:12: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources
Including User C Module(s) from ../../../../micropython.cmake
Found User C Module(s): usermod_lcd_bus, usermod_lvgl, lvgl_interface
/home/codespace/.espressif/tools/xtensa-esp32-elf/esp-2022r1-11.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/bin/ld: CMakeFiles/micropython.elf.dir/workspaces/v2-lvupy-1.21/lv_binding_micropython/driver/esp32/lcd_bus/modlcd_bus.c.obj:(.rodata+0x1c): undefined reference to `mp_lcd_i80_bus_type'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/micropython.elf.dir/build.make:3593: micropython.elf] Error 1
make[2]: *** [CMakeFiles/Makefile2:2210: CMakeFiles/micropython.elf.dir/all] Error 2
make[1]: *** [Makefile:130: all] Error 2
make failed with exit code 2, output of the command is in the /workspaces/v2-lvupy-1.21/lv_binding_micropython/micropython/ports/esp32/build-ESP32_GENERIC/log/idf_py_stderr_output_9078 and /workspaces/v2-lvupy-1.21/lv_binding_micropython/micropython/ports/esp32/build-ESP32_GENERIC/log/idf_py_stdout_output_9078
make: *** [Makefile:62: all] Error 1
@SL2021-Dev ➜ /workspaces/v2-lvupy-1.21/lv_binding_micropython (MicroPython_1.21.0_Update) $ 

Hope you had a great Thanksgiving !!

Said I was working on it, not that it is finished. LOL. I am able to get LVGL to compile properly with it. Still trying to hammer out a kink in the bus drivers for the ESP32. Not sure why I am getting the error that I am getting and I have not found any information that helps to sort the problem out. Still trying different things. Once I get the last 2 problems (which are actually the same error) I know it will compile the rest of the way. I will manage to get it hammered out I am sure. Last night I tried going about it a different way and that was a failure and caused more problems that I am pretty sure are not going to be easier to solve so I am going to go back to the way I was originally doing it.

Saw your discussion over at…
https://forum.lvgl.io/t/standalone-binary-mpy-module-for-lvgl-so-we-can-just-use-it-in-micropython/13518/81

I hope you guys can hammer out this modular idea which I think is great.
Another issue I have is the problem with the final .bin size
which is exceeding, in my case a 4MB flash area split in half for OTA
means I only have 2MB to work with.
My current build is…
image
not including my code.
I would like to remove alot of widgets.
I’ve tried turning various widgets off in lvconfig.h but build crashes.
It’s a massive try and error to get rid of those unessay modules.
Micropython also needs a huge reduction… it keeps growing, v1.21 7% increase from last.

I got the compilation problem sorted out. The GC issue I was having is also corrected.

Now remember it is going to compile twice the first go around, this is because of it having to size the partitions properly. A clean needs to be done between the 2 runs because of cmake caching things. I will do some more digging to see if I am able to update the partitions file that gets stored in the cmake cache or even if one is stored in the cmake cache. I have not dove that deep into it yet. That is going to be my next hurdle.

I have not tested this on an ESP32 yet. There is a high probability that it is not going to run, I am holding my breath on that one.

The partitions get sized based on an error that the idf produces so if LVGL will fit no resizing gets done. I will more than likely change that behavior due to space constraints. Currently I am sizing the partition so it is a hair above the size that is needed. The hair part meaning that the partition size needs to be evenly divisible by 4096. so there is going to be some left over space and that is outside of my control. It is the way the idf does things, it’s not my choice.

I pushed the updates to the repo so it should compile if you do a pull.

@SL2021-Dev

Your problem is your are using OTA updates. There really is no reason to do this. You can perform OTA updates of your python code. There is no need to be able to flash the firmware over the air. It uses up way to much space to do that. This is one of the reasons why compiling your python code into the firmware is not good to do because the only way to update it OTA is by doing a firmware OTA which takes up twice as much space.

I am sure you can find an already written MicroPython library that will handle updating your python source files. I wrote one at one point, not sure where I have it stashed tho. It is probably on my old computer.

RE: OTA
There are currently about 1,500 units out in the field that needs to be updated from…
micropython 1.17.0 to hopefully 1.21.0. to be able to add new features, fix some issues and also stay current.
The original units were built with ota partitions even though we never used them, but have been updating main.py and other files via http requests from our server and downloading.

Second attempt at building 1.21.0 repo…
I am missing somethig… I apologize but I’m just having a lot on my plate right now.

So i did a pull
ran…

python make.py esp32 -mpy_cross -submodules -clean BOARD=ESP32_GENERIC MICROPY_BOARD_VARIANT=SPIRAM

got…

Including User C Module(s) from ../../../../micropython.cmake
Found User C Module(s): usermod_lcd_bus, usermod_lvgl, lvgl_interface
/home/codespace/.espressif/tools/xtensa-esp32-elf/esp-2022r1-11.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/bin/ld: CMakeFiles/micropython.elf.dir/workspaces/v2-lvupy-1.21/lv_binding_micropython/driver/esp32/lcd_bus/modlcd_bus.c.obj:(.rodata+0x1c): undefined reference to `mp_lcd_i80_bus_type'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/micropython.elf.dir/build.make:3593: micropython.elf] Error 1
make[2]: *** [CMakeFiles/Makefile2:2210: CMakeFiles/micropython.elf.dir/all] Error 2
make[1]: *** [Makefile:130: all] Error 2
make failed with exit code 2, output of the command is in the /workspaces/v2-lvupy-1.21/lv_binding_micropython/micropython/ports/esp32/build-ESP32_GENERIC/log/idf_py_stderr_output_74427 and /workspaces/v2-lvupy-1.21/lv_binding_micropython/micropython/ports/esp32/build-ESP32_GENERIC/log/idf_py_stdout_output_74427
make: *** [Makefile:62: all] Error 1

now ran … (“A clean needs to be done between the 2 runs”)

python make.py esp32 -clean BOARD=ESP32_GENERIC MICROPY_BOARD_VARIANT=SPIRAM

got…

make[1]: Leaving directory '/workspaces/v2-lvupy-1.21/lv_binding_micropython/micropython/ports/esp32/build-ESP32_GENERIC'
-e See https://github.com/micropython/micropython/wiki/Build-Troubleshooting
make: Leaving directory '/workspaces/v2-lvupy-1.21/lv_binding_micropython/micropython/ports/esp32'
/workspaces/v2-lvupy-1.21/esp-idf/tools/check_python_dependencies.py:12: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources
Including User C Module(s) from ../../../../micropython.cmake
Found User C Module(s): usermod_lcd_bus, usermod_lvgl, lvgl_interface
/home/codespace/.espressif/tools/xtensa-esp32-elf/esp-2022r1-11.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/bin/ld: CMakeFiles/micropython.elf.dir/workspaces/v2-lvupy-1.21/lv_binding_micropython/driver/esp32/lcd_bus/modlcd_bus.c.obj:(.rodata+0x1c): undefined reference to `mp_lcd_i80_bus_type'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/micropython.elf.dir/build.make:3593: micropython.elf] Error 1
make[2]: *** [CMakeFiles/Makefile2:2210: CMakeFiles/micropython.elf.dir/all] Error 2
make[1]: *** [Makefile:130: all] Error 2
make failed with exit code 2, output of the command is in the /workspaces/v2-lvupy-1.21/lv_binding_micropython/micropython/ports/esp32/build-ESP32_GENERIC/log/idf_py_stderr_output_109249 and /workspaces/v2-lvupy-1.21/lv_binding_micropython/micropython/ports/esp32/build-ESP32_GENERIC/log/idf_py_stdout_output_109249
make: *** [Makefile:62: all] Error 1

OK so this is the process.

git clone https://github.com/espressif/esp-idf
cd esp-idf
git checkout v5.0.2
git submodule update --init --recursive
./install.sh all
. ./export.sh

cd ..
git clone https://github.com/kdschlosser/lv_binding_micropython
cd lv_binding_micropython
git checkout MicroPython_1.21.0_Update
git submodule update --init --recursive

python make.py esp32 -mpy_cross -submodules -clean BOARD=ESP32_GENERIC MICROPY_BOARD_VARIANT=SPIRAM

That should be all that you need to do. Now if you already have the ESP-IDF downloaded you are going to need do a recursive remove of the .espressif folder. You will not need to clone it again if you already have it. Just checkout the correct version. You should be able to do a git pull while in the lv_binding_micropython folder and it will pull down the most recent changes that have been made.

So reinstalled your repo…
and the build just stoped ?


I’m using code spaces and I don’t know if I have any kind of resource restrictions.

I had IDF allread installed by…

git clone -b v5.0.2 --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
./install.sh
source export.sh
cd ..

So riped out IDF and reinstall per your instructions… same outcome

are you using anything like docker by chance?

you missed something.

git submodule update --init --recursive

you forgot the “all” on the end of the install command

./install.sh all

No Docker

Removed original IDF and reinstalled per your instructions…

git clone https://github.com/espressif/esp-idf
cd esp-idf
git checkout v5.0.2
git submodule update --init --recursive
./install.sh all
. ./export.sh

It builds to ~ 16 to 17% and stops ???
I am using GitHub Codespaces and have no issiues in other lv_micropython build projects.
Is this method caching the .obj in to memory?
I get no warings of terminial issues.
Strange

Have you tried to let it sit there a while and see if it eventually errors or continues?
I know that is asking the dumb question but have to ask it.

Probably a minute or two which seems like eternity when building these binaries.
I’ll try it again and give it a lot more time !!!


As a reference my other builds never take more than ~ two minutes.
image

In my case it is successfully compiled.

micropython.bin binary size 0x27d8d0 bytes. Smallest app partition is 0x27e000 bytes. 0x730 bytes (0%) free.
Warning: The smallest app partition is nearly full (0% free space left)!

Project build complete. To flash, run this command:
/.espressif/python_env/idf5.0_py3.11_env/bin/python ../../../../esp-idf/components/esptool_py/esptool/esptool.py -p (PORT) -b 460800 --before default_reset --after hard_reset --chip esp32  write_flash --flash_mode dio --flash_size 4MB --flash_freq 40m 0x1000 build-ESP32_GENERIC/bootloader/bootloader.bin 0x8000 build-ESP32_GENERIC/partition_table/partition-table.bin 0x10000 build-ESP32_GENERIC/micropython.bin
or run 'idf.py -p (PORT) flash'
bootloader  @0x001000    23056  (    5616 remaining)
partitions  @0x008000     3072  (    1024 remaining)
application @0x010000  2611408  (    1840 remaining)
total                  2676944

Mac os sonoma 14.1.1 , Python 3.11.6
Chip is ESP32-PICO-V3-02 (revision v3.0)

After flashing the firmware.bin, there is

E (1024) i2s(legacy): CONFLICT! The new i2s driver can't work along with the legacy i2s driver

So I disabled I2S on mpconfigboard, compile again, it works.

MicroPython v1.21.0-dirty on 2023-11-30; Generic ESP32 module with ESP32
Type "help()" for more information.
>>> import lvgl as lv
>>> lv.layer_
layer_bottom    layer_sys       layer_top
>>> 

Great thanks for this. :slight_smile: