From 23264c4b3a6b9f079a81d4d96f2e40e2c89e3314 Mon Sep 17 00:00:00 2001 From: Daniel DeGrasse Date: Wed, 16 Aug 2023 18:16:49 -0500 Subject: [PATCH] soc: arm: nxp_imx: introduce ROM ramloader feature The iMX RT bootrom allows the user to load images into RAM regions from flash by providing a correctly configured boot header. In particular, if the boot header contains a load address within RAM, the bootroom will automatically copy the image to the load address before executing it Introduce CONFIG_NXP_IMX_RT_ROM_RAMLOADER to enable this feature. This Kconfig will shift the LMA of a image built to run in a RAM region to reside in the default FlexSPI boot region, which allows the image to be loaded to the FlexSPI region using west. This is intended to simplify development of applications executing from RAM on iMX RT based systems. Signed-off-by: Daniel DeGrasse --- soc/arm/nxp_imx/rt/Kconfig.soc | 17 +++++++++++++++++ soc/arm/nxp_imx/rt5xx/Kconfig.soc | 19 +++++++++++++++++++ soc/arm/nxp_imx/rt6xx/Kconfig.soc | 17 +++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/soc/arm/nxp_imx/rt/Kconfig.soc b/soc/arm/nxp_imx/rt/Kconfig.soc index 23fb53ca344..253e316548e 100644 --- a/soc/arm/nxp_imx/rt/Kconfig.soc +++ b/soc/arm/nxp_imx/rt/Kconfig.soc @@ -795,6 +795,23 @@ config NXP_IMX_EXTERNAL_SDRAM an MPU region will be defined to disable cached access to the SDRAM memory space. +config NXP_IMX_RT_ROM_RAMLOADER + depends on !FLASH_MCUX_FLEXSPI_XIP && NXP_IMX_RT_BOOT_HEADER + # Required so that debugger will load image to correct offset + select BUILD_OUTPUT_HEX + bool "Create output image that IMX RT ROM can load from FlexSPI to ram" + help + Builds an output image that the IMX RT BootROM can load from the + FlexSPI boot device into RAM region. The image will be loaded + from FLEXSPI into the region specified by `zephyr,flash` node. + +# Setup LMA adjustment if using the RAMLOADER feature of ROM +FLASH_CHOSEN := zephyr,flash +FLASH_BASE := $(dt_chosen_reg_addr_hex,$(FLASH_CHOSEN)) +FLEXSPI_BASE := $(dt_node_reg_addr_hex,/soc/spi@402a8000,1) +config BUILD_OUTPUT_ADJUST_LMA + default "$(FLEXSPI_BASE) - $(FLASH_BASE)" if NXP_IMX_RT_ROM_RAMLOADER + config SECOND_CORE_MCUX bool "Dual core operation on the RT11xx series" depends on SOC_SERIES_IMX_RT11XX diff --git a/soc/arm/nxp_imx/rt5xx/Kconfig.soc b/soc/arm/nxp_imx/rt5xx/Kconfig.soc index f41c63d104b..2c82c533de9 100644 --- a/soc/arm/nxp_imx/rt5xx/Kconfig.soc +++ b/soc/arm/nxp_imx/rt5xx/Kconfig.soc @@ -101,8 +101,27 @@ config IMAGE_VECTOR_TABLE_OFFSET the application entry point and device configuration data. The boot ROM requires a fixed IVT offset for each type of boot device. +config NXP_IMX_RT_ROM_RAMLOADER + depends on !FLASH_MCUX_FLEXSPI_XIP + # Required so that debugger will load image to correct offset + select BUILD_OUTPUT_HEX + bool "Create output image that IMX RT ROM can load from FlexSPI to ram" + help + Builds an output image that the IMX RT BootROM can load from the + FlexSPI boot device into RAM region. The image will be loaded + from FLEXSPI0 into the region specified by `zephyr,flash` node. + +# Setup LMA adjustment if using the RAMLOADER feature of ROM +FLASH_CHOSEN := zephyr,flash +FLASH_BASE := $(dt_chosen_reg_addr_hex,$(FLASH_CHOSEN)) +FLEXSPI_BASE := $(dt_node_reg_addr_hex,/soc/spi@134000,1) +config BUILD_OUTPUT_ADJUST_LMA + default "$(FLEXSPI_BASE) - $(FLASH_BASE)" if NXP_IMX_RT_ROM_RAMLOADER + endif # NXP_IMX_RT5XX_BOOT_HEADER + + config IMXRT5XX_CODE_CACHE bool "Code cache" default y diff --git a/soc/arm/nxp_imx/rt6xx/Kconfig.soc b/soc/arm/nxp_imx/rt6xx/Kconfig.soc index b94e98b7384..e2222ab3214 100644 --- a/soc/arm/nxp_imx/rt6xx/Kconfig.soc +++ b/soc/arm/nxp_imx/rt6xx/Kconfig.soc @@ -107,6 +107,23 @@ config IMAGE_VECTOR_TABLE_OFFSET the application entry point and device configuration data. The boot ROM requires a fixed IVT offset for each type of boot device. +config NXP_IMX_RT_ROM_RAMLOADER + depends on !FLASH_MCUX_FLEXSPI_XIP + # Required so that debugger will load image to correct offset + select BUILD_OUTPUT_HEX + bool "Create output image that IMX RT ROM can load from FlexSPI to ram" + help + Builds an output image that the IMX RT BootROM can load from the + FlexSPI boot device into RAM region. The image will be loaded + from FLEXSPI into the region specified by `zephyr,flash` node. + +# Setup LMA adjustment if using the RAMLOADER feature of ROM +FLASH_CHOSEN := zephyr,flash +FLASH_BASE := $(dt_chosen_reg_addr_hex,$(FLASH_CHOSEN)) +FLEXSPI_BASE := $(dt_node_reg_addr_hex,/soc/spi@134000,1) +config BUILD_OUTPUT_ADJUST_LMA + default "$(FLEXSPI_BASE) - $(FLASH_BASE)" if NXP_IMX_RT_ROM_RAMLOADER + endif # NXP_IMX_RT6XX_BOOT_HEADER config IMXRT6XX_CODE_CACHE