Using QSPI with external flash

Hello,

I tried to find information about using the QSPI with external flash on nrf connect SDK.

My goal can be split into two parts:

1. Use QSPI with external flash for read/write operation - to understand how to use the QSPI (device tree, drivers, etc)
2. Use QSPI XIP to achieve DFU using the extra space of the external flash.

Regarding point 1, I found partial data from questions by other community members, but it seemed they didn't base their implementation on certified nrf connect example/tutorial.
for the second point, I looked over Lesson 8 - exercise 2, but even there - it was just the basics (Yeah, I saw the links you ref in the exercise - but they are not related to what is going in the exercise), it is important to mention that most of the ref links talk about the zephyr sysbuild.

EDIT:
I will further explain my need in point 2.
I want to load into the external flash my new code, and use the mcuboot to use it as slot. (in the exercises the methods for DFU are using UART/USB/BLE etc which not fit thew idea of using external flash as partition)
how can I manage to use the flash as one of my slots and the most important how to make the mcuboot to get the code from there (swapping/scratch method)?

I would be grateful to get information of working with the QSPI <-> external flash to achieve my goals.

Thanks,
Udi

Parents
  • Hi, 

    1. Use QSPI with external flash for read/write operation - to understand how to use the QSPI (device tree, drivers, etc)

    See this sample https://github.com/nrfconnect/sdk-zephyr/tree/v3.5.99-ncs1/samples/drivers/spi_flash 

    2. Use QSPI XIP to achieve DFU using the extra space of the external flash.

    We do not have an example on how to run code from the XiP area on for nRF52840, but this course indicated how to set the flash as a secondary mcuboot.  

    The [216] QSPI: Race condition occurs in XIP errata limits the usability of XiP on the 52840.

    I want to load into the external flash my new code, and use the mcuboot to use it as slot. (in the exercises the methods for DFU are using UART/USB/BLE etc which not fit thew idea of using external flash as partition)

    As Step.8 in this course would show how to enable the mcuboot on the external flash as the second slot as the figure indicated.  

    how can I manage to use the flash as one of my slots and the most important how to make the mcuboot to get the code from there (swapping/scratch method)?

    See the Using swap-using-scratch flash algorithm doc. 

    Regards,
    Amanda H.

  • Hi I am trying to interface QSPI with NRF5340 dk board. I am getting build errors. I have used SPI-FLASH sample and it was working fine and I am trying to change the SPI-FLASH code into a modular form for QSPI.

    Here I am attaching the overlay file:

    // To get started, press Ctrl+Space to bring up the completion menu and view the available nodes.

    // You can also use the buttons in the sidebar to perform actions on nodes.
    // Actions currently available include:

    // * Enabling / disabling the node
    // * Adding the bus to a bus
    // * Removing the node
    // * Connecting ADC channels

    // For more help, browse the DeviceTree documentation at docs.zephyrproject.org/.../index.html
    // You can also visit the nRF DeviceTree extension documentation at nrfconnect.github.io/.../nrfdevicetree.html


    // &qspi {
    //     status = "okay";
    // };
    /{
        aliases {
            flash = &mx25r64;
        };
    };


    // Configuration take from nrf5340_cpuapp_commom-pinctrl.dtsi file
    &pinctrl {

        qspi_default: qspi_default {
            group1 {
                psels = <NRF_PSEL(QSPI_IO0013)>,
                        <NRF_PSEL(QSPI_IO1014)>,
                        <NRF_PSEL(QSPI_IO2015)>,
                        <NRF_PSEL(QSPI_IO3016)>,
                        <NRF_PSEL(QSPI_SCK017)>,
                        <NRF_PSEL(QSPI_CSN018)>;
                nordic,drive-mode = <NRF_DRIVE_H0H1>;
                   
            };
        };

        qspi_sleep: qspi_sleep {
            group1 {
                psels = <NRF_PSEL(QSPI_IO0013)>,
                        <NRF_PSEL(QSPI_IO1014)>,
                        <NRF_PSEL(QSPI_IO2015)>,
                        <NRF_PSEL(QSPI_IO3016)>,
                        <NRF_PSEL(QSPI_SCK017)>;
                low-power-enable;
                       
            };
            group2 {
                psels = <NRF_PSEL(QSPI_CSN018)>;
                low-power-enable;
                bias-pull-up;
            };
        };
       
    };

    // Configuration take from nrf5340_cpuapp_commom.dtsi file
    &qspi {
        status = "okay";
        pinctrl-0 = <&qspi_default>;
        pinctrl-1 = <&qspi_sleep>;
        pinctrl-names = "default""sleep";
        mx25r64: mx25r6435f@0 {
            compatible = "nordic,qspi-nor";
            reg = <0>;
            /* MX25R64 supports only pp and pp4io */
            writeoc = "pp4io";
            /* MX25R64 supports all readoc options */
            readoc = "read4io";
            sck-frequency = <8000000>;
            jedec-id = [c2 28 17];
            sfdp-bfp = [
                e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
                ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
                10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
                30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
            ];
            size = <67108864>;
            has-dpd;
            t-enter-dpd = <10000>;
            t-exit-dpd = <35000>;
        };
    };

    Here I am attaching the prj.conf :
    CONFIG_GPIO = y
    CONFIG_SPI_NOR = y
    CONFIG_SPI = n
    CONFIG_NORDIC_QSPI_NOR=y
    CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096

    CONFIG_TRUSTED_EXECUTION_SECURE=y
    CONFIG_BUILD_WITH_TFM = n
    This is the error I am getting:
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe '-Bc:\Users\TDANAM\NRF\Flash\build' -GNinja '-Sc:\Users\TDANAM\NRF\Flash'
    And I am using v2.5.2 sdk.
    Please try to help in this.
Reply
  • Hi I am trying to interface QSPI with NRF5340 dk board. I am getting build errors. I have used SPI-FLASH sample and it was working fine and I am trying to change the SPI-FLASH code into a modular form for QSPI.

    Here I am attaching the overlay file:

    // To get started, press Ctrl+Space to bring up the completion menu and view the available nodes.

    // You can also use the buttons in the sidebar to perform actions on nodes.
    // Actions currently available include:

    // * Enabling / disabling the node
    // * Adding the bus to a bus
    // * Removing the node
    // * Connecting ADC channels

    // For more help, browse the DeviceTree documentation at docs.zephyrproject.org/.../index.html
    // You can also visit the nRF DeviceTree extension documentation at nrfconnect.github.io/.../nrfdevicetree.html


    // &qspi {
    //     status = "okay";
    // };
    /{
        aliases {
            flash = &mx25r64;
        };
    };


    // Configuration take from nrf5340_cpuapp_commom-pinctrl.dtsi file
    &pinctrl {

        qspi_default: qspi_default {
            group1 {
                psels = <NRF_PSEL(QSPI_IO0013)>,
                        <NRF_PSEL(QSPI_IO1014)>,
                        <NRF_PSEL(QSPI_IO2015)>,
                        <NRF_PSEL(QSPI_IO3016)>,
                        <NRF_PSEL(QSPI_SCK017)>,
                        <NRF_PSEL(QSPI_CSN018)>;
                nordic,drive-mode = <NRF_DRIVE_H0H1>;
                   
            };
        };

        qspi_sleep: qspi_sleep {
            group1 {
                psels = <NRF_PSEL(QSPI_IO0013)>,
                        <NRF_PSEL(QSPI_IO1014)>,
                        <NRF_PSEL(QSPI_IO2015)>,
                        <NRF_PSEL(QSPI_IO3016)>,
                        <NRF_PSEL(QSPI_SCK017)>;
                low-power-enable;
                       
            };
            group2 {
                psels = <NRF_PSEL(QSPI_CSN018)>;
                low-power-enable;
                bias-pull-up;
            };
        };
       
    };

    // Configuration take from nrf5340_cpuapp_commom.dtsi file
    &qspi {
        status = "okay";
        pinctrl-0 = <&qspi_default>;
        pinctrl-1 = <&qspi_sleep>;
        pinctrl-names = "default""sleep";
        mx25r64: mx25r6435f@0 {
            compatible = "nordic,qspi-nor";
            reg = <0>;
            /* MX25R64 supports only pp and pp4io */
            writeoc = "pp4io";
            /* MX25R64 supports all readoc options */
            readoc = "read4io";
            sck-frequency = <8000000>;
            jedec-id = [c2 28 17];
            sfdp-bfp = [
                e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
                ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
                10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
                30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
            ];
            size = <67108864>;
            has-dpd;
            t-enter-dpd = <10000>;
            t-exit-dpd = <35000>;
        };
    };

    Here I am attaching the prj.conf :
    CONFIG_GPIO = y
    CONFIG_SPI_NOR = y
    CONFIG_SPI = n
    CONFIG_NORDIC_QSPI_NOR=y
    CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096

    CONFIG_TRUSTED_EXECUTION_SECURE=y
    CONFIG_BUILD_WITH_TFM = n
    This is the error I am getting:
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe '-Bc:\Users\TDANAM\NRF\Flash\build' -GNinja '-Sc:\Users\TDANAM\NRF\Flash'
    And I am using v2.5.2 sdk.
    Please try to help in this.
Children
Related