Error when running BSP Library on STM32L4R9I Discovery

Hello everyone,

I am Huy. Currently I am working on a project "Running MicroPython on STM32L4R9I Discovery". In this project, my team wrote a display driver for the display module ST-AUO. When I tested the driver on STM32CubeIDE then load into the board, the performance is smooth and runnable. However, when I use MicroPython (on Ubuntu) to make a .hex file and flash the board, I could not write anything after the function BSP_LCD_Refresh() (I wrote on REPL). As soon as the BSP_LCD_Refresh() is called, the screen display the color I expected but then I could not insert anything in REPL. After 30 seconds or so, It automatically exit to the Terminal. 

Here is the code of my driver:

extern LTDC_HandleTypeDef hltdc_discovery;
extern DSI_HandleTypeDef hdsi_discovery;


static uint32_t *my_fb = (uint32_t*)(0x30000000UL); //GFXMMU_VIRTUALBUFFER0_BASE;

static volatile bool display_inited = false;

bool display_active(void)
{
return display_inited;
}

void LCD_init(void)
{
FMC_Bank1_R->BTCR[0] = 0x000030D2;

//Hardware initialization
BSP_PSRAM_Init();
BSP_LCD_Init();
BSP_LCD_SelectLayer(0);

HAL_DSI_ShortWrite(&hdsi_discovery, 0, DSI_DCS_SHORT_PKT_WRITE_P0, DSI_SET_DISPLAY_ON, 0x0);

BSP_LCD_Clear(0xFFFFFFFF);
display_inited = true; // to check the screen is working 
}

void LCD_refresh(void)
{
BSP_LCD_Refresh();
}

void LCD_deinit(void)
{
BSP_PSRAM_DeInit();
BSP_LCD_DeInit();
}

void my_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
{
CopyBuffer((uint32_t*)color_p, my_fb, area->x1, area->y1, lv_area_get_width(area), lv_area_get_height(area));
BSP_LCD_Refresh();
lv_disp_flush_ready(drv);
}

Currently, the team has doubt on GC and Memory conflict. 

Also, in MycroPython on Ubuntu, we dont know the way to debug the error.

So, What might be the cause of this situation and how can we debug this?

Thank you, Huy