Hi,
I'm working on a custom board based on nRF52840 and a 2.9" ePaper display (SSD1680) connected via SPI using the mipi-dbi-spi interface.
I'm using nRF Connect SDK v3.0.0 (Zephyr) and LVGL for graphics rendering.
In the devicetree, the display is marked with zephyr,deferred-init because I only power the display later from main():
.overlay:
&spi1 {
compatible = "nordic,nrf-spi";
status = "okay";
cs-gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
pinctrl-0 = <&spi1_default>;
pinctrl-1 = <&spi1_sleep>;
pinctrl-names = "default", "sleep";
};
&spi1_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 20)>,
<NRF_PSEL(SPIM_MOSI, 0, 17)>; //SDA
// <NRF_PSEL(SPIM_MISO, 0, 8)>;
};
};
&spi1_sleep {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 20)>,
<NRF_PSEL(SPIM_MOSI, 0, 17)>; //SDA
// <NRF_PSEL(SPIM_MISO, 0, 8)>;
};
};
/ {
mipi_dbi_waveshare_epaper_gdeh029a1 {
compatible = "zephyr,mipi-dbi-spi";
spi-dev = <&spi1>;
dc-gpios = <&gpio0 24 GPIO_ACTIVE_HIGH>;
reset-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
#address-cells = <1>;
#size-cells = <0>;
// write-only;
ssd16xx_waveshare_epaper_gdeh029a1: ssd16xxfb@0 {
compatible = "gooddisplay,gdey0213b74", "solomon,ssd1680";
mipi-max-frequency = <1000000>;
reg = <0>;
width = <296>;
height = <128>;
busy-gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>;
tssv = <0x80>;
zephyr,deferred-init;
full {
border-waveform = <0x05>;
};
partial {
border-waveform = <0x3c>;
};
};
};
};
/ {
chosen {
nvs-storage = &storage_partition;
zephyr,console = &cdc_acm_uart0;
zephyr,display = &ssd16xx_waveshare_epaper_gdeh029a1;
};
};prj.conf:
CONFIG_DISPLAY=y CONFIG_SSD16XX=y # Enable SPI CONFIG_SPI=y CONFIG_SPI_NRFX=y CONFIG_MAIN_STACK_SIZE=16384 CONFIG_HEAP_MEM_POOL_SIZE=2048 CONFIG_LVGL=y CONFIG_LV_Z_MEM_POOL_SIZE=16384 CONFIG_LV_Z_AUTO_INIT=n CONFIG_LV_USE_LOG=y CONFIG_LV_USE_LABEL=y CONFIG_LV_COLOR_DEPTH_1=y CONFIG_LV_USE_LABEL=y CONFIG_LV_LOG_LEVEL_TRACE=y CONFIG_LV_Z_SHELL=y CONFIG_LV_USE_MONKEY=y CONFIG_LV_FONT_MONTSERRAT_14=y
K_THREAD_STACK_DEFINE(lvgl_stack_area, 32768);
static struct k_thread lvgl_stack_data;
static lv_obj_t *hello_world_label;
static const struct device *display_dev;
void view_lvgl()
{
gpio_pin_set_dt(&out, 1);
k_msleep(1000);
display_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
device_init(display_dev);
while (!device_is_ready(display_dev))
{
printk("Device not ready");
k_msleep(100);
}
hello_world_label = lv_label_create(lv_scr_act());
lv_label_set_text(hello_world_label, "Hello world!");
lv_obj_align(hello_world_label, LV_ALIGN_CENTER, 0, 0);
lv_task_handler();
display_blanking_off(display_dev);
while (1)
{
lv_task_handler();
printk("view_lvgl loop\n");
k_msleep(1000);
}
}However, after calling:
hello_world_label = lv_label_create(lv_scr_act());
I get a NULL pointer, and any further use causes a crash (lv_scr_act() returns NULL, and lv_label_create() returns NULL).
I assume this happens because no LVGL display was registered, due to the deferred init.
If I remove zephyr,deferred-init, then the display is not initialized at all.
Now I see fast blinking and part of the screen is filled with garbage when initializing.

Here is the initialization after power is applied.

-
How should I trigger full LVGL registration after enabling the display device at runtime?
-
Can I manually re-init the display driver (e.g., force call
lv_disp_drv_register()or trigger the driverinit()after power is applied)? -
Is there a known working method to combine
zephyr,deferred-init+ LVGL for late-powered displays (e.g., ePaper)?
Any advice would be very helpful. Thank you in advance!
*** Booting nRF Connect SDK v3.0.2-89ba1294ac9b ***
*** Using Zephyr OS v4.0.99-f791c49f492c ***
[00:00:00.002,868] [1;31m<err> lvgl: Display device not ready.[0m
USB CDC ready. Type something...
[00:00:00.108,947] [0m<inf> fs_nvs: 8 Sectors of 4096 bytes[0m
[00:00:00.108,947] [0m<inf> fs_nvs: alloc wra: 0, f30[0m
[00:00:00.108,947] [0m<inf> fs_nvs: data wra: 0, 2c8[0m
[00:00:00.109,344] [0m<inf> bt_sdc_hci_driver: SoftDevice Controller build revision:
89 9a 50 8a 95 01 9c 58 fc 39 d2 c1 10 04 ee 02 |..P....X .9......
64 ce 25 be |d.%. [0m
[00:00:00.112,121] [0m<inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)[0m
[00:00:00.112,152] [0m<inf> bt_hci_core: HW Variant: nRF52x (0x0002)[0m
[00:00:00.112,182] [0m<inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 137.20634 Build 2617349514[0m
[00:00:00.112,426] [0m<i
view_lvgl loop
