zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.52k stars 6.45k forks source link

MCUboot with LVGL MIMXRT1160_EVK causes incredible lag #75702

Open RafalHalik opened 2 months ago

RafalHalik commented 2 months ago

Describe the bug I've been working with the LVGL sample in zephyr for the 1160, touch screen did need to be looked at but that's solved now. However when I decided to flash MCUboot onto the device and then load into my very basic LVGL app it seems to slow down considerably. On the screen I have a button, arc slider, btn matrix and an animation example from LVGL docs webpage. The animation is just to visually perceive the lag as the fps counter from LVGL is stuck at 33fps even though you can clearly see its much lower.

So far from my testing I've concluded that the LVGL app just as a bin flashed on works with no problems its responsive and the UART console is also responsive. Where as when a vanilla MCUboot built for mimxrt1160 is flashed onto the device then the signed image flashed, it seems to slow down to a crawl and this is not just the graphics but the UART console too. So its not just a lvgl_flush_thread issue of it being cpu starved but the whole app.

Currently I've only really noticed one difference between the regular app and the MCUboot loaded app. This being another 2 devices on the board SPI bus and a child node on the spi bus. Not sure if this is the cause of the lag but thought I'd mention it

image

Touch screen help link to helpful issue page for anyone also struggling with touch screen: (https://github.com/zephyrproject-rtos/zephyr/issues/75178#issue-2380698639)

Please also mention any information which could help others to understand the problem you're facing:

Side note: I was also looking into enabling VG_Lite to see if this helped but was not able to get the includes resolved seems to be missing the files completely in zephyr?

To Reproduce Steps to reproduce the behavior:

  1. build mcuboot and flash

    • west build -b mimxrt1160_evk/mimxrt1166/cm7
    • west flash
  2. build lvgl sample and flash

    • west build -b mimxrt1160_evk/mimxrt1166/cm7 --pristine -- -DSHIELD=rk055hdmipi4ma0
    • west sign -t imgtool -d build --no-hex -- --version 1.0.0 --pad --key /workdir/bootloader/mcuboot/root-rsa-2048.pem
    • west flash -f build/zephyr/zephyr.signed.bin
  3. Open putty terminal or minicom to observe UART lag also display for lag.

Expected behaviour App will load and start however this will take a while and the app with also be very slow.

Impact Because of this developing using MCUboot and LVGL for the graphics library is no feasible as even with a basic app its far to slow to be useful. So a showstopper.

Extra code for animation

  static void anim_x_cb(void * var, int32_t v)
  {
      lv_obj_set_x(var, v);
  }

  static void anim_size_cb(void * var, int32_t v)
  {
      lv_obj_set_size(var, v, v);
  }

  void lv_example_anim_2(void)
  {
    lv_obj_t * obj = lv_obj_create(lv_scr_act());
    lv_obj_set_style_bg_color(obj, lv_palette_main(LV_PALETTE_RED), 0);
    lv_obj_set_style_radius(obj, LV_RADIUS_CIRCLE, 0);

    lv_obj_align(obj, LV_ALIGN_LEFT_MID, 10, 100);

   lv_anim_t a;
   lv_anim_init(&a);
   lv_anim_set_var(&a, obj);
   lv_anim_set_values(&a, 10, 50);
   lv_anim_set_time(&a, 1000);
   lv_anim_set_playback_delay(&a, 100);
   lv_anim_set_playback_time(&a, 300);
   lv_anim_set_repeat_delay(&a, 500);
   lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
   lv_anim_set_path_cb(&a, lv_anim_path_ease_in_out);

   lv_anim_set_exec_cb(&a, anim_size_cb);
   lv_anim_start(&a);
   lv_anim_set_exec_cb(&a, anim_x_cb);
   lv_anim_set_values(&a, 10, 240);
   lv_anim_start(&a);
   }       

prj.conf file for my lvgl project

 CONFIG_MAIN_STACK_SIZE=2048
 CONFIG_DISPLAY=y
 CONFIG_DISPLAY_LOG_LEVEL_ERR=y     
 CONFIG_UART_CONSOLE=y
 CONFIG_UART_INTERRUPT_DRIVEN=y
 CONFIG_GPIO=y
 CONFIG_INPUT_GT911=y
 CONFIG_INPUT_GT911_INTERRUPT=n
 CONFIG_INPUT=y
 CONFIG_SERIAL=y
 CONFIG_LOG=y
 CONFIG_SHELL=y
 CONFIG_DMA=y
 CONFIG_MCUX_ELCDIF_PXP=y
 CONFIG_I2C=y
 CONFIG_I2C_SHELL=y
 CONFIG_LVGL=y
 CONFIG_LV_Z_MEM_POOL_SIZE=56384
 CONFIG_LV_Z_SHELL=y
 CONFIG_LV_USE_PERF_MONITOR=y
 CONFIG_LV_MEM_CUSTOM=y
 CONFIG_LV_USE_LOG=y
 CONFIG_LV_USE_LABEL=y
 CONFIG_LV_USE_BTN=y
 CONFIG_LV_USE_ARC=y
 CONFIG_LV_USE_IMG=y
 CONFIG_LV_USE_GPU_NXP_PXP=n
 CONFIG_LV_FONT_MONTSERRAT_14=y
 CONFIG_LV_USE_GPU_NXP_VG_LITE=n
 CONFIG_LV_Z_POINTER_INPUT=y
 CONFIG_BOOTLOADER_MCUBOOT=y

Environment (please complete the following information):

dleach02 commented 2 months ago

@RafalHalik for clarity, what did you build in step 1 west build command:

  1. build mcuboot and flash

    • west build -b mimxrt1160_evk/mimxrt1166/cm7
    • west flash
RafalHalik commented 2 months ago

Hey, @dleach02 I built mcuboot. this can be found in bootloader/mcuboot/boot/zephyr Hope this helps.