From 7c77d0ea48edf43eb9eb018b7e61e0f7e6cd8f9d Mon Sep 17 00:00:00 2001 From: Derek Snell Date: Wed, 28 May 2025 11:35:57 -0400 Subject: [PATCH] soc: nxp: MCXNx4x: enable booting from QSPI flash The ROM bootloader has the option to boot from external QSPI flash on the FlexSPI instead of internal flash. Adds CONFIG_NXP_FLEXSPI_BOOT_HEADER to include the FlexSPI boot ROM header in the image. Signed-off-by: Derek Snell --- soc/nxp/mcx/mcxn/CMakeLists.txt | 16 +++++++++++++++- soc/nxp/mcx/mcxn/Kconfig | 23 ++++++++++++++++++++++- soc/nxp/mcx/mcxn/Kconfig.defconfig | 3 ++- soc/nxp/mcx/mcxn/boot_header.ld | 10 ++++++++++ west.yml | 2 +- 5 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 soc/nxp/mcx/mcxn/boot_header.ld diff --git a/soc/nxp/mcx/mcxn/CMakeLists.txt b/soc/nxp/mcx/mcxn/CMakeLists.txt index 25f3fe564a6..e432bad982f 100644 --- a/soc/nxp/mcx/mcxn/CMakeLists.txt +++ b/soc/nxp/mcx/mcxn/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2024 NXP +# Copyright 2024-2025 NXP # # SPDX-License-Identifier: Apache-2.0 # @@ -8,6 +8,20 @@ # Flexcomm SDK driver zephyr_compile_definitions_ifdef(CONFIG_NXP_LP_FLEXCOMM LPFLEXCOMM_INIT_NOT_USED_IN_DRIVER=1) +zephyr_linker_sources_ifdef(CONFIG_NXP_FLEXSPI_BOOT_HEADER + ROM_START SORT_KEY 0 boot_header.ld) + +if(CONFIG_NXP_FLEXSPI_BOOT_HEADER) + zephyr_linker_section_configure( + SECTION .rom_start + INPUT ".flexspi_fcb" + OFFSET ${CONFIG_FLEXSPI_CONFIG_BLOCK_OFFSET} + KEEP + PRIO 10 + ) + zephyr_compile_definitions(XIP_EXTERNAL_FLASH) +endif() + zephyr_sources(soc.c) if(CONFIG_FLASH_MCUX_FLEXSPI_XIP OR CONFIG_FLASH_MCUX_FLEXSPI_NOR) diff --git a/soc/nxp/mcx/mcxn/Kconfig b/soc/nxp/mcx/mcxn/Kconfig index 2376dd43d70..0a771aafac8 100644 --- a/soc/nxp/mcx/mcxn/Kconfig +++ b/soc/nxp/mcx/mcxn/Kconfig @@ -1,4 +1,4 @@ -# Copyright 2024 NXP +# Copyright 2024-2025 NXP # SPDX-License-Identifier: Apache-2.0 config SOC_SERIES_MCXN @@ -77,6 +77,27 @@ config SECOND_CORE_MCUX_ACCESS_LEVEL enabled. endif +config NXP_FLEXSPI_BOOT_HEADER + bool "Boot header" + default y if FLASH_MCUX_FLEXSPI_XIP && !BOOTLOADER_MCUBOOT + + help + Enable data structures required by the boot ROM to boot the + application from an external flash device. + +if NXP_FLEXSPI_BOOT_HEADER + +config FLEXSPI_CONFIG_BLOCK_OFFSET + hex "FlexSPI config block offset" + default 0x400 + help + FlexSPI configuration block consists of parameters regarding specific + flash devices including read command sequence, quad mode enablement + sequence (optional), etc. The boot ROM expects FlexSPI configuration + parameter to be presented in serial nor flash. + +endif # NXP_FLEXSPI_BOOT_HEADER + rsource "../../common/Kconfig.flexspi_xip" endif # SOC_SERIES_MCXN diff --git a/soc/nxp/mcx/mcxn/Kconfig.defconfig b/soc/nxp/mcx/mcxn/Kconfig.defconfig index 24ba2e4a2ec..50d7ba40eb6 100644 --- a/soc/nxp/mcx/mcxn/Kconfig.defconfig +++ b/soc/nxp/mcx/mcxn/Kconfig.defconfig @@ -1,4 +1,4 @@ -# Copyright 2024 NXP +# Copyright 2024-2025 NXP # SPDX-License-Identifier: Apache-2.0 if SOC_SERIES_MCXN @@ -14,6 +14,7 @@ config NUM_IRQS config ROM_START_OFFSET default 0x400 if BOOTLOADER_MCUBOOT + default 0x1000 if !BOOTLOADER_MCUBOOT && FLASH_MCUX_FLEXSPI_XIP config MCUX_LPTMR_TIMER default n if (DT_HAS_NXP_OS_TIMER_ENABLED || DT_HAS_ARM_ARMV8M_SYSTICK_ENABLED) diff --git a/soc/nxp/mcx/mcxn/boot_header.ld b/soc/nxp/mcx/mcxn/boot_header.ld new file mode 100644 index 00000000000..b6633e11127 --- /dev/null +++ b/soc/nxp/mcx/mcxn/boot_header.ld @@ -0,0 +1,10 @@ +/* + * Copyright 2025 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#if defined(CONFIG_NXP_FLEXSPI_BOOT_HEADER) + . = CONFIG_FLEXSPI_CONFIG_BLOCK_OFFSET; + KEEP(*(.flexspi_fcb)) +#endif diff --git a/west.yml b/west.yml index b629c3a45c0..751176e5ddc 100644 --- a/west.yml +++ b/west.yml @@ -210,7 +210,7 @@ manifest: groups: - hal - name: hal_nxp - revision: d0e49d63ac74208e183ed47ebb4bf8d490ab63fb + revision: 73d478f7afff753c9cf60248e0c0fff4ac572ee0 path: modules/hal/nxp groups: - hal