Skip to content

boards: nxp: frdm_mcxn947 and mcx_n9xx_evk: boot directly from QSPI flash #90409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 28, 2025

Conversation

DerekSnell
Copy link
Collaborator

The ROM bootloader has the option to boot from external QSPI flash on the FlexSPI instead of internal flash. Configures QSPI board variants to boot directly from QSPI. Secondary bootloader is no longer required. Moves the MCUboot boot_partition to QSPI flash.

Placing the MCUboot boot_partition in the QSPI flash depends on mcu-tools/mcuboot#2319

Copy link

github-actions bot commented May 23, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_nxp zephyrproject-rtos/hal_nxp@d0e49d6 zephyrproject-rtos/hal_nxp@73d478f (master) zephyrproject-rtos/hal_nxp@d0e49d63..73d478f7

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

butok
butok previously approved these changes May 26, 2025
@decsny decsny added the DNM This PR should not be merged (Do Not Merge) label May 27, 2025
@decsny
Copy link
Member

decsny commented May 27, 2025

DNM until #90566 merges, otherwise CI breaks, thanks

please update manifest

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 <derek.snell@nxp.com>
Configures QSPI board variant to boot directly from external QSPI flash
on the FlexSPI.  Secondary bootloader is no longer required.  Moves the
MCUboot boot_partition to QSPI flash.

Signed-off-by: Derek Snell <derek.snell@nxp.com>
Configures QSPI board variant to boot directly from external QSPI flash
on the FlexSPI.  Secondary bootloader is no longer required.  Moves the
MCUboot boot_partition to QSPI flash.

Signed-off-by: Derek Snell <derek.snell@nxp.com>
@DerekSnell DerekSnell removed DNM This PR should not be merged (Do Not Merge) DNM (manifest) This PR should not be merged (controlled by action-manifest) labels May 28, 2025
@DerekSnell
Copy link
Collaborator Author

#90566 merged, HAL_NXP merged, manifest updated and this PR rebased, and DNM label removed.

Copy link

@dleach02 dleach02 requested a review from butok May 28, 2025 16:28
@kartben kartben merged commit c7e36f0 into zephyrproject-rtos:main May 28, 2025
37 checks passed
@DerekSnell DerekSnell deleted the mcxn947_qspi_xip branch May 29, 2025 17:18
@DerekSnell
Copy link
Collaborator Author

I am documenting this here for those who prefer using the previous hybrid flash use-case. This PR enabled booting directly from external QSPI flash. Before this PR merged, XIP from QSPI was supported using both internal and external flash, what I call here the hybrid use-case. This hybrid method boots from internal flash with the MCUboot boot_partition. Then MCUboot enables the FlexSPI interface and configures for the external QSPI flash, and then loads the app to XIP from QSPI. However, MCUboot was reverted which broke this hybrid use-case. But the hybrid option is no longer needed, because now the QSPI board variant will boot directly from QSPI, and no longer requires MCUboot.

If the hybrid flash use-case is preferred, these steps work for me. These steps are written for the frdm_mcxn947 board. MCUboot is built and flashed in internal flash. The blinky app is built for the frdm_mcxn947//cpu0/qspi board variant and flashed to the external QSPI. These steps are based on c7e36f0 :

  1. Program the PFR to boot from internal flash. This is the default setting of the MCXN947 SOC. But if the SOC was previously programmed to boot from external QSPI flash, it needs to be programmed back. For more details, see Programming the ROM bootloader for external QSPI.
  2. In the MCUboot repo, revert mcu-tools/mcuboot@8131548
  3. Apply the attached patch mcuboot-hybrid-flash-overlay.patch.txt to the Zephyr repo. This adds mcuboot-hybrid-flash.overlay to the FRDM_MCXN947 board folder.
  4. Build and flash MCUboot and the blinky sample using the commands below:
west build -b frdm_mcxn947//cpu0 ../bootloader/mcuboot/boot/zephyr -d ../hybrid_mcb_n947 --pristine -- -DDTC_OVERLAY_FILE="../../../../zephyr/boards/nxp/frdm_mcxn947/mcuboot-hybrid-flash.overlay" 
west build -b frdm_mcxn947//cpu0/qspi samples/basic/blinky -d ../hybrid_blinky_n947 --pristine -- -DCONFIG_BOOTLOADER_MCUBOOT=y -DDTC_OVERLAY_FILE="../../boards/nxp/frdm_mcxn947/mcuboot-hybrid-flash.overlay" -DCONFIG_MCUBOOT_SIGNATURE_KEY_FILE=\"bootloader/mcuboot/root-rsa-2048.pem\" 
west flash -d ../hybrid_mcb_n947 -r jlink
west flash -d ../hybrid_blinky_n947 -r jlink

The debug console output shows MCUboot boots and loads the blinky sample:

*** Booting MCUboot v2.2.0-rc1-17-gbcd9614727ab ***
*** Using Zephyr OS build v4.1.0-4901-gc7e36f01696a ***
I: Starting bootloader
I: Image index: 0, Swap type: none
I: Bootloader chainload address offset: 0x0
I: Image version: v0.0.0
I: Jumping to the first image slot
*** Booting Zephyr OS build v4.1.0-4901-gc7e36f01696a ***
LED state: OFF
LED state: ON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants