zephyr: lvgl: Using sw_rotate with SSD1306 shield causes memory fault
Describe the bug
Using the new sw_rotate feature from LVGL with the ssd1306_128x64 shield causes a memory fault.
The issue seems to be related to the draw_buf_rotate...() functions not accounting for the possibility that a custom set_px_cb (such as lvgl_set_px_cb_mono() function maybe packing the data as bits instead of full bytes. This results in out of bounds array accesses in the rotation functions and causes data corruption in other (likely display related) areas of memory.
To Reproduce Steps to reproduce the behavior:
- Edit modules/lib/gui/lvgl/zephyr/lvgl.c adding the following lines immediately after the call to
lv_disp_drv_init(&disp_drv);inlvgl_init():
disp_drv.sw_rotate = 1;
disp_drv.rotated = LV_DISP_ROT_90;
- Build the LVGL display sample for a supported board that also supports the
ssd1306_128x64shield. I am using a Nordic development kit and the Zephyr based nRF Connect SDK, so my build command is:
west build zephyr/samples/subsys/display/lvgl -b nrf5340dk_nrf5340_cpuapp -- -DSHIELD=ssd1306_128x64
- Flash the built code to the board (with and SSD1306 shield attached)
- Observer the failure (memfault shown on the console output, or obvious rebooting causing display to flash)
Expected behavior Normal display of the LVGL display sample rotated on the display by 90 degrees (a.k.a. portrait mode instead of landscape)
Impact This is a major impact to my current project as we need to use the display in portrait mode and the SSD1306 display controller does not seem to support 90 degree rotation in HW.
Logs and console output
No real information to capture/add here. It’s a standard memfault report in the console output. The actual fault happens for me on exit from draw_buf_rotate_90_sqr() but is due to the data corruption caused during the execution of that function.
Environment (please complete the following information):
- OS: Windows
- Toolchain: Zephyr SDK
- v3.0.99-ncs1 (via the nRF Connect SDK from Nordic)
Additional context Needed to create an samples/subsys/display/lvgl/boards/nrf5340dk_nrf5340_cpuapp.overlay file with the following snippet for the sample to work with the nRF5340 dev kit.
&arduino_i2c {
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
zephyr,concat-buf-size = <1025>;
};
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (2 by maintainers)
@richesonk the fix will have to make its way into the zephyr fork too so let’s keep it open until that happens.