Getting error after integrating lvgl in stm32u5 dk1 board

I am new to firmware and integrated LVGL in stm32u5 dk1 board . And my elf file size is bigger than internal flash hence using external flash for lvgl images . Also running LVGL in external psram . After running I see first screen then it goes immediately to hardfault . Not able to understand this hardfault reason . Need help here . And I checked that PSRAM and External flash is working fine . I have copied entire code at github GitHub - rohit-trustedwear/stm32dk1-code . the fault is happening at line bg_color.full = buf[0] + (buf[1] << 8); in

#if LV_COLOR_SCREEN_TRANSP
static inline void set_px_argb(uint8_t * buf, lv_color_t color, lv_opa_t opa)
{
lv_color_t bg_color;
lv_color_t res_color;
lv_opa_t bg_opa = buf[LV_IMG_PX_SIZE_ALPHA_BYTE - 1];
#if LV_COLOR_DEPTH == 8
bg_color.full = buf[0];
lv_color_mix_with_alpha(bg_color, bg_opa, color, opa, &res_color, &buf[1]);
if(buf[1] <= LV_OPA_MIN) return;
buf[0] = res_color.full;
#elif LV_COLOR_DEPTH == 16
bg_color.full = buf[0] + (buf[1] << 8);
lv_color_mix_with_alpha(bg_color, bg_opa, color, opa, &res_color, &buf[2]);
if(buf[2] <= LV_OPA_MIN) return;
buf[0] = res_color.full & 0xff;
buf[1] = res_color.full >> 8;
#elif LV_COLOR_DEPTH == 32
bg_color = *((lv_color_t *)buf);
lv_color_mix_with_alpha(bg_color, bg_opa, color, opa, &res_color, &buf[3]);
if(buf[3] <= LV_OPA_MIN) return;
buf[0] = res_color.ch.blue;
buf[1] = res_color.ch.green;
buf[2] = res_color.ch.red;
#endif
}
Below is error screenshot attched .

have big RAM and FLASH areas, why your design require PSRAM use???
Seems you memory lvgl config is ugly. Try explain what you do…

we are having many screens for smartwatch approx 50 , hence using psram to allocate all the lvgl objects in memory, it won’t fit in internal ram . And all images lies in external flash. plese see liinker script and lvgl config and main.cpp. copying below entire snapshot of memory and stack in lvgl code .

Primary use PSRAM for LVGL reduce effectivity. Secondary PSRAM seems have issue with byte access and align. Avoid LVGL use PSRAM is optimal way, i for example on ESP use PSRAM only for images png stored in flash and expanded into PSRAM cache.
How you test PSRAM ?

I agree to your point that PSRAM will be slow . So I ran the same code now in Internal SRam while images are in external octo spi flash. The UI runs but after some screen change it throws fault .

Seems you place fonts to external flash, maybe this too require byte access and … Too STM caches and MPU setup is critical, but hard to solve your big project

in order to test i just integrated a sample project of squareline studio of smartwatch and everything running on internal ram and internal flash but this is also is not running properly and crashing with fault . I have uploaded the code with sample demo of smartwatch of squareline studio at GitHub - rohit-trustedwear/stm32dk1-code , this is simple example which fits in internal ram and should work but getting same issues . I will add MPU then will update further. :unamused:

Trying same demo as copied below

but crashing during first gui rendering