From 905512438e6539ed799101a838315594bdc64dc7 Mon Sep 17 00:00:00 2001 From: Daniel DeGrasse Date: Mon, 21 Aug 2023 15:39:01 -0500 Subject: [PATCH] soc: arm: nxp_imx: update iMX RT boot header to handle CONFIG_XIP=n Update iMX RT boot header to support CONFIG_XIP=n, when the image is not linked into the flash space. Also, update the boot header to correctly calculate the flash used size within the boot data header. This field is used by the iMX boot ROM to determine how much data to copy when running from RAM, so using the correct size fixes an issue where the ROM would copy more data than needed. Signed-off-by: Daniel DeGrasse --- soc/arm/nxp_imx/rt/soc_rt10xx.c | 7 ++++++- soc/arm/nxp_imx/rt/soc_rt11xx.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/soc/arm/nxp_imx/rt/soc_rt10xx.c b/soc/arm/nxp_imx/rt/soc_rt10xx.c index e61eb871441..ba22a633a50 100644 --- a/soc/arm/nxp_imx/rt/soc_rt10xx.c +++ b/soc/arm/nxp_imx/rt/soc_rt10xx.c @@ -92,8 +92,13 @@ const clock_video_pll_config_t videoPllConfig = { #ifdef CONFIG_NXP_IMX_RT_BOOT_HEADER const __imx_boot_data_section BOOT_DATA_T boot_data = { +#ifdef CONFIG_XIP .start = CONFIG_FLASH_BASE_ADDRESS, - .size = KB(CONFIG_FLASH_SIZE), + .size = (uint32_t)&_flash_used, +#else + .start = CONFIG_SRAM_BASE_ADDRESS, + .size = (uint32_t)&_image_ram_size, +#endif .plugin = PLUGIN_FLAG, .placeholder = 0xFFFFFFFF, }; diff --git a/soc/arm/nxp_imx/rt/soc_rt11xx.c b/soc/arm/nxp_imx/rt/soc_rt11xx.c index 5e1b34476e8..7340fd0f3ff 100644 --- a/soc/arm/nxp_imx/rt/soc_rt11xx.c +++ b/soc/arm/nxp_imx/rt/soc_rt11xx.c @@ -120,8 +120,13 @@ static const clock_video_pll_config_t videoPllConfig = { #ifdef CONFIG_NXP_IMX_RT_BOOT_HEADER const __imx_boot_data_section BOOT_DATA_T boot_data = { +#ifdef CONFIG_XIP .start = CONFIG_FLASH_BASE_ADDRESS, - .size = KB(CONFIG_FLASH_SIZE), + .size = (uint32_t)&_flash_used, +#else + .start = CONFIG_SRAM_BASE_ADDRESS, + .size = (uint32_t)&_image_ram_size, +#endif .plugin = PLUGIN_FLAG, .placeholder = 0xFFFFFFFF, };