diff --git a/target/stm32f746g-disco/init.c b/target/stm32f746g-disco/init.c index 270cbc9b..cc7f54d0 100644 --- a/target/stm32f746g-disco/init.c +++ b/target/stm32f746g-disco/init.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -34,13 +35,13 @@ #include #include #include -#include +#include #if WITH_LIB_MINIP #include #endif -extern uint8_t BSP_LCD_Init(uint32_t fb_address); +extern uint8_t BSP_LCD_Init(void); const sdram_config_t target_sdram_config = { .bus_width = SDRAM_BUS_WIDTH_16, @@ -61,8 +62,8 @@ void target_early_init(void) /* now that the uart gpios are configured, enable the debug uart */ stm32_debug_early_init(); - /* The lcd framebuffer starts at the base of SDRAM */ - BSP_LCD_Init(SDRAM_BASE); + /* start the lcd */ + BSP_LCD_Init(); } static uint8_t* gen_mac_address(void) diff --git a/target/stm32f746g-disco/lcd.c b/target/stm32f746g-disco/lcd.c index 3eadeefd..25b26b87 100644 --- a/target/stm32f746g-disco/lcd.c +++ b/target/stm32f746g-disco/lcd.c @@ -57,6 +57,7 @@ #include #include #include +#include #include /* @@ -345,7 +346,7 @@ static void BSP_LCD_ClockConfig(LTDC_HandleTypeDef *hltdc, void *Params) * @brief Initializes the LCD. * @retval LCD state */ -uint8_t BSP_LCD_Init(uint32_t fb_address) +uint8_t BSP_LCD_Init(void) { /* Timing Configuration */ ltdc_handle.Init.HorizontalSync = (RK043FN48H_HSYNC - 1); @@ -382,7 +383,13 @@ uint8_t BSP_LCD_Init(uint32_t fb_address) HAL_LTDC_Init(<dc_handle); - BSP_LCD_LayerDefaultInit(0, fb_address); + /* allocate the framebuffer */ + size_t fb_size_pages = PAGE_ALIGN(RK043FN48H_WIDTH * RK043FN48H_HEIGHT * 4) / PAGE_SIZE; + void *fb_address = novm_alloc_pages(fb_size_pages, NOVM_ARENA_SECONDARY); + if (!fb_address) + panic("failed to allocate framebuffer for LCD\n"); + + BSP_LCD_LayerDefaultInit(0, (uint32_t)fb_address); BSP_LCD_SelectLayer(0); /* clear framebuffer */