Description
I wasn't sure whether to report this as an issue or not, so feel free to immediately close it, I just wanted to document this for others to find if they were experiencing the same issues as me.
TLDR: using the default lv_conf.h
also present in this repository, I failed to have soft-reboots working properly, but I found a solution.
The first hurdle, getting to a clean state, was fairly easily taken by implementing finalizers and using the deinit()
function. After that, I could completely tear down and rebuild my setup by manually calling the functions in REPL multiple times in a row and it would keep working.
The second problem wasn't so easy to debug: once I soft rebooted, the finalizers were called but it would always crash with a MemoryError. After a lot of scratching my head and a deep-dive into the memory allocation code of both LVGL and MicroPython I found finally that during deinit()
the LVGL code is doing calls to realloc
which are failing because the garbage collector doesn't want to hand out memory anymore. Whether this is a problem to be solved in LVGL or in MicroPython I'm not sure at this point.
The solution finally was pretty simple: stop using the LV_STDLIB_MICROPYTHON
malloc implementation 🤷
Here you can see how I solved it in my implementation:
MathyV/lvgl_esp32_mpy@e84196d
I don't know if this is the best (temporary?) solution but so far I haven't experienced any issues with it yet.
PS: after fixing this I also had issues with deinit()
of machine.SPI
in the ESP32 MicroPython implementation but that is definitely out of scope here, still, here's how I fixed it as an FYI:
MathyV/lvgl_esp32_mpy@7330fcc