Skip to content
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

Add support for flash controller with XIP on i.MX RT series #33701

Merged
merged 5 commits into from
Apr 15, 2021

Conversation

pdgendt
Copy link
Collaborator

@pdgendt pdgendt commented Mar 25, 2021

This change allows writing to the flash while running in XIP mode, and enables mcuboot or NVS settings to be used on i.MX RT socs with a single flash chip.
The bootloader application itself should contain the IVT/DCD in the header, but the chainable application doesn't.
The ROM_START_OFFSET defaults to 0x400 otherwise the linker alignment isn't taken into account.

It is required when running with XIP to enable code relocation, because accessing the flash needs to run in RAM.

Tested on i.MX RT1064 internal flash

Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution!

drivers/flash/CMakeLists.txt Outdated Show resolved Hide resolved
drivers/flash/flash_mcux_flexspi.c Outdated Show resolved Hide resolved
drivers/flash/flash_mcux_flexspi_nor.c Outdated Show resolved Hide resolved
drivers/flash/flash_mcux_flexspi_nor.c Outdated Show resolved Hide resolved
dts/arm/nxp/nxp_rt1064.dtsi Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Mar 26, 2021

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff
hal_nxp zephyrproject-rtos/hal_nxp@4560b0a zephyrproject-rtos/hal_nxp@27a464e (master) zephyrproject-rtos/[email protected]

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

Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With some hacky changes to move the storage partition, I was able to confirm that samples/subsys/fs/littlefs can now work on the mimxrt1064_evk internal flash:

diff --git a/boards/arm/mimxrt1064_evk/mimxrt1064_evk.dts b/boards/arm/mimxrt1064_evk/mimxrt1064_evk.dts
index 13e0399c7d..03c86766c9 100644
--- a/boards/arm/mimxrt1064_evk/mimxrt1064_evk.dts
+++ b/boards/arm/mimxrt1064_evk/mimxrt1064_evk.dts
@@ -152,14 +152,30 @@ arduino_i2c: &lpi2c1 {};
                        #address-cells = <1>;
                        #size-cells = <1>;
 
-                       storage_partition: partition@0 {
-                               label = "storage";
+                       partition@0 {
                                reg = <0x00000000 DT_SIZE_M(8)>;
                        };
                };
        };
 };
 
+&flexspi2 {
+       status = "okay";
+};
+
+&w25q32jvwj0 {
+       partitions {
+               compatible = "fixed-partitions";
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               storage_partition: partition@14000 {
+                       label = "storage";
+                       reg = <0x00014000 DT_SIZE_K(32)>;
+               };
+       };
+};
+
 &lpuart1 {
        status = "okay";
        current-speed = <115200>;

drivers/flash/flash_mcux_flexspi.c Outdated Show resolved Hide resolved
dts/arm/nxp/nxp_rt1064.dtsi Outdated Show resolved Hide resolved
@MaureenHelm MaureenHelm added this to the v2.6.0 milestone Mar 30, 2021
@MaureenHelm
Copy link
Member

Please rebase

@pdgendt pdgendt requested a review from gmarull as a code owner April 7, 2021 07:57
@pdgendt pdgendt force-pushed the flexspi-nor-xip branch 4 times, most recently from 5be15af to 9d3aa70 Compare April 7, 2021 08:50
@pdgendt pdgendt requested a review from MaureenHelm April 7, 2021 19:00
@pdgendt pdgendt force-pushed the flexspi-nor-xip branch 4 times, most recently from aafd2f3 to 0252785 Compare April 8, 2021 19:49
drivers/memc/memc_mcux_flexspi.c Show resolved Hide resolved
dts/arm/nxp/nxp_rt1064.dtsi Outdated Show resolved Hide resolved
This change allows writing to the flash while running in XIP mode,
and enables mcuboot or NVS settings to be used on i.MX RT socs.

Signed-off-by: Pieter De Gendt <[email protected]>
The bootloader application itself should contain the IVT/DCD
in the header, but the chainable application doesn't.

The ROM_START_OFFSET defaults to 0x400 otherwise the linker
alignment isn't taken into account.

Signed-off-by: Pieter De Gendt <[email protected]>
This allows signing the binary for use with mcuboot

Signed-off-by: Pieter De Gendt <[email protected]>
This fixes a bug in the write function of the MCUX FlexSPI flash driver
if the length of the data is larger than a single page.

Signed-off-by: Pieter De Gendt <[email protected]>
@github-actions github-actions bot removed the DNM This PR should not be merged (Do Not Merge) label Apr 15, 2021
drivers/flash/flash_mcux_flexspi_nor.c Outdated Show resolved Hide resolved
drivers/flash/Kconfig.mcux Show resolved Hide resolved
This feature prevents issues when trying to write data to the flash
device that is located on or addressed at the same flash device.

An example is the mcuboot logic that writes a magic number to
the secondary partition header.

Signed-off-by: Pieter De Gendt <[email protected]>
@MaureenHelm MaureenHelm merged commit 3ee5f42 into zephyrproject-rtos:master Apr 15, 2021
@pdgendt pdgendt deleted the flexspi-nor-xip branch July 12, 2021 15:18
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