This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

QSPI for nrf5340-DK, examples and API functions

I am working with the module nrf5340-DK. I am searching for an example to use the QSPI with the onboard external memory, could you share an example? and the other question is where is the API I must use to control the QSPI.

  • I have checked the link.

      This link has filesystem options, we are searching for something more simple. In this link, we have also a link to a library Here but when I try to search this library in the zephyr folder I do not find it.

    Could you help us with one example for nrf5340 where only read and write some bytes, we can continue after that.

  • MarcosDNordic said:
    In this link, we have also a link to a library Here but when I try to search this library in the zephyr folder I do not find it.

     What version of NCS do you have? I have NCS v1.5.0 and I found it here: C:\Users\<user name>\ncs\v1.5.0\zephyr\drivers\flash\nrf_qspi_nor.c. 

    MarcosDNordic said:
    Could you help us with one example for nrf5340 where only read and write some bytes, we can continue after that

    I think the sample C:\Users\<user name>\ncs\v1.5.0\zephyr\samples\drivers\spi_flash\src\main.c is a perfect fit. It does not use a file system, just pure flash write and read calls.

    If the board nrf5340dk_nrf5340_cpuapp is used, the configurations in zephyr\samples\drivers\spi_flash\boards\nrf5340dk_nrf5340_cpuapp.conf will get automatically applied, which will make the driver nrf_qspi_nor.c get used under the hood. E.g. when flash_read() is called, the function qspi_nor_read() will get called under the hood. You don't need to worry about configuring the hardware, since qspi and the onboard flash is already set by default in the board file: zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340_cpuapp_common.dts

    Best regards,

    Simon

  • 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_IO0, 0, 13)>,
                        <NRF_PSEL(QSPI_IO1, 0, 14)>,
                        <NRF_PSEL(QSPI_IO2, 0, 15)>,
                        <NRF_PSEL(QSPI_IO3, 0, 16)>,
                        <NRF_PSEL(QSPI_SCK, 0, 17)>,
                        <NRF_PSEL(QSPI_CSN, 0, 18)>;
                nordic,drive-mode = <NRF_DRIVE_H0H1>;
                   
            };
        };

        qspi_sleep: qspi_sleep {
            group1 {
                psels = <NRF_PSEL(QSPI_IO0, 0, 13)>,
                        <NRF_PSEL(QSPI_IO1, 0, 14)>,
                        <NRF_PSEL(QSPI_IO2, 0, 15)>,
                        <NRF_PSEL(QSPI_IO3, 0, 16)>,
                        <NRF_PSEL(QSPI_SCK, 0, 17)>;
                low-power-enable;
                       
            };
            group2 {
                psels = <NRF_PSEL(QSPI_CSN, 0, 18)>;
                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.
  • Hello,

    I recommend that you create a new ticket for your issue, as this thread is quite old. Please include all your details in the new ticket, including the SDK version, complete logs, and overlay file.

    Kind regards,

    Abhijith

Related