diff --git a/include/arch/arm/cortex_m/scripts/linker.ld b/include/arch/arm/cortex_m/scripts/linker.ld index a3441286a8b..8a0852fc862 100644 --- a/include/arch/arm/cortex_m/scripts/linker.ld +++ b/include/arch/arm/cortex_m/scripts/linker.ld @@ -36,10 +36,6 @@ #define _DATA_IN_ROM #endif -#if !defined(SKIP_TO_KINETIS_FLASH_CONFIG) - #define SKIP_TO_KINETIS_FLASH_CONFIG -#endif - #if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) #define ROM_ADDR RAM_ADDR #else @@ -177,10 +173,11 @@ SECTIONS KEEP(*(.openocd_dbg)) KEEP(*(".openocd_dbg.*")) - /* Kinetis has to write 16 bytes at 0x400 */ - SKIP_TO_KINETIS_FLASH_CONFIG +#ifdef CONFIG_KINETIS_FLASH_CONFIG + . = CONFIG_KINETIS_FLASH_CONFIG_OFFSET; KEEP(*(.kinetis_flash_config)) KEEP(*(".kinetis_flash_config.*")) +#endif _vector_end = .; } GROUP_LINK_IN(ROMABLE_REGION) diff --git a/soc/arm/nxp_kinetis/Kconfig b/soc/arm/nxp_kinetis/Kconfig index b4e64768f95..8b14baf92a8 100644 --- a/soc/arm/nxp_kinetis/Kconfig +++ b/soc/arm/nxp_kinetis/Kconfig @@ -107,4 +107,21 @@ config MCG_FRDIV kHz. endif # HAS_MCG + +config KINETIS_FLASH_CONFIG + bool "Kinetis flash configuration field" + default y if XIP && !BOOTLOADER_MCUBOOT + help + Include the 16-byte flash configuration field that stores default + protection settings (loaded on reset) and security information that + allows the MCU to restrict access to the FTFx module. + +if KINETIS_FLASH_CONFIG + +config KINETIS_FLASH_CONFIG_OFFSET + hex "Kinetis flash configuration field offset" + default 0x400 + +endif # KINETIS_FLASH_CONFIG + endif # SOC_FAMILY_KINETIS diff --git a/soc/arm/nxp_kinetis/k6x/linker.ld b/soc/arm/nxp_kinetis/k6x/linker.ld index 1c956e8fb64..ed49c1db411 100644 --- a/soc/arm/nxp_kinetis/k6x/linker.ld +++ b/soc/arm/nxp_kinetis/k6x/linker.ld @@ -11,21 +11,4 @@ * This is the linker script for both standard images and XIP images. */ -#include - -/* - * K64F Flash configuration fields - * These are 16 bytes, which must be loaded to address 0x400, and include - * default protection and security settings. - * They are loaded at reset to various Flash Memory module (FTFE) registers. - */ - -/* - * No need to account for this when running a RAM-only image since that - * security feature resides in ROM. - */ -#if defined(CONFIG_XIP) - #define SKIP_TO_KINETIS_FLASH_CONFIG . = 0x400; -#endif - #include diff --git a/soc/arm/nxp_kinetis/k8x/linker.ld b/soc/arm/nxp_kinetis/k8x/linker.ld index b4f50859436..ed49c1db411 100644 --- a/soc/arm/nxp_kinetis/k8x/linker.ld +++ b/soc/arm/nxp_kinetis/k8x/linker.ld @@ -11,22 +11,4 @@ * This is the linker script for both standard images and XIP images. */ -#include - -/* - * K8x Flash configuration fields - * These are 16 bytes, which must be loaded to flash at offset 0x400, and - * include default protection and security settings. - * They are loaded at reset to various Flash Memory module (FTFA) registers. - */ - -/* - * No need to account for this when running a RAM-only image since that - * security feature resides in ROM. There is also no need to account for this - * when building an image to be chainloaded by MCUboot. - */ -#if defined(CONFIG_XIP) && !defined(CONFIG_BOOTLOADER_MCUBOOT) - #define SKIP_TO_KINETIS_FLASH_CONFIG . = 0x400; -#endif - #include diff --git a/soc/arm/nxp_kinetis/ke1xf/linker.ld b/soc/arm/nxp_kinetis/ke1xf/linker.ld index e3580d4954d..ed49c1db411 100644 --- a/soc/arm/nxp_kinetis/ke1xf/linker.ld +++ b/soc/arm/nxp_kinetis/ke1xf/linker.ld @@ -11,21 +11,4 @@ * This is the linker script for both standard images and XIP images. */ -#include - -/* - * KE1xF Flash configuration fields - * These are 16 bytes, which must be loaded to address 0x400, and include - * default protection and security settings. - * They are loaded at reset to various Flash Memory module (FTFE) registers. - */ - -/* - * No need to account for this when running a RAM-only image since that - * security feature resides in ROM. - */ -#if defined(CONFIG_XIP) - #define SKIP_TO_KINETIS_FLASH_CONFIG . = 0x400; -#endif - #include diff --git a/soc/arm/nxp_kinetis/kl2x/linker.ld b/soc/arm/nxp_kinetis/kl2x/linker.ld index 712ecdf140e..ed49c1db411 100644 --- a/soc/arm/nxp_kinetis/kl2x/linker.ld +++ b/soc/arm/nxp_kinetis/kl2x/linker.ld @@ -11,21 +11,4 @@ * This is the linker script for both standard images and XIP images. */ -#include - -/* - * KL25Z Flash configuration fields - * These are 16 bytes, which must be loaded to address 0x400, and include - * default protection and security settings. - * They are loaded at reset to various Flash Memory module (FTFE) registers. - */ - -/* - * No need to account for this when running a RAM-only image since that - * security feature resides in ROM. - */ -#if defined(CONFIG_XIP) - #define SKIP_TO_KINETIS_FLASH_CONFIG . = 0x400; -#endif - #include diff --git a/soc/arm/nxp_kinetis/kwx/linker.ld b/soc/arm/nxp_kinetis/kwx/linker.ld index 383c0ab830d..ed49c1db411 100644 --- a/soc/arm/nxp_kinetis/kwx/linker.ld +++ b/soc/arm/nxp_kinetis/kwx/linker.ld @@ -11,21 +11,4 @@ * This is the linker script for both standard images and XIP images. */ -#include - -/* - * KW41Z Flash configuration fields - * These are 16 bytes, which must be loaded to address 0x400, and include - * default protection and security settings. - * They are loaded at reset to various Flash Memory module (FTFE) registers. - */ - -/* - * No need to account for this when running a RAM-only image since that - * security feature resides in ROM. - */ -#if defined(CONFIG_XIP) - #define SKIP_TO_KINETIS_FLASH_CONFIG . = 0x400; -#endif - #include