Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updating numbered headings

...

For the full list of driver parameters available in the device tree, refer to https://docs.zephyrproject.org/latest/build/dts/api/bindings/mtd/jedec%2Cspi-nor.html#std-dtcompatible-jedec-spi-nor

3.

...

2. Support for QSPI Flash

Note that the jedec,spi-nor driver runs on top of the SPI driver, so the DSPI and QSPI features are not supported by this solution. For some Nordic chips (nRF5340 in particular), there is a nordic,qspi-nor driver that supports operating in QSPI mode, with its own set of flash parameters. nordic,qspi-nor is not affected by SPI_NOR_SFDP, all required parameters need to be supplied in the device tree node.

3.

...

3. Software APIs

There are several API levels that allow access to SPI Flash.

3.

...

3.1. Low Level Flash Access

This level can be used to access SPI Flash as a raw Flash device.

...

There are also the zephyr/samples/drivers/jesd216 and zephyr/samples/drivers/spi_flash demos that demonstrate use of low-level API.

3.

...

3.2. Flash Partitioning

Zephyr additionally has API’s that can be used to partition SPI Flash. The goal is to provide a facility to split a single Flash device into several named areas to be used independently and preventing out-of-bounds access.

...

The zephyr/samples/subsys/fs/littlefs sample illustrates use of a fixed partition to create a file system over it. mcuboot is another useful example.

3.

...

3.3. High-Level Non-Volatile API

There are several high-level storage API’s provided by Zephyr that can be used over Flash (or a Flash area):

...

In the nrf-app application use the CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL, CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL, and CONFIG_PM_PARTITION_REGION_NVS_STORAGE_EXTERNAL to relocate corresponding partition to SPI Flash.

3.

...

4. Zephyr Shell Commands

The nrf-app application comes preconfigured to use SPI Flash, with support for the relevant Zephyr shell commands enabled. The following shell commands are available:

...

  1. Run a generic erase/write/read/compare test:

    Code Block
    uart:~$ flash test gd25wb256e3ir@1 0 0x4000 1
    Erase OK.
    Write OK.
    Verified OK.
    Erase-Write-Verify test done.
  2. Run read and write measurements:

    Code Block
    uart:~$ flash erase gd25wb256e3ir@1 0 0x4000
    Erase success.
    uart:~$ flash write_test gd25wb256e3ir@1 0 0x4000 1
    Loop #1 done in 53 ticks.
    Total: 53ms, Per loop: ~53ms, Speed: ~301.9KiBps
    uart:~$ flash read_test gd25wb256e3ir@1 0 0x4000 1
    Loop #1 done in 16ms.
    Total: 16ms, Per loop: ~16ms, Speed: ~1000.0KiBps

3.

...

5. Configuring for a Different SPI Flash Device

This chapter explains how to configure a different Flash device. Specifically, the GD25WB256E Flash device installed on the Thingy-9151-Lite platform is used as an example.

3.

...

5.1. Get JEDEC info

First step when setting a new SPI Flash is to obtain information about it. To do so, we need to create a minimally required description of the Flash. Let’s start with the following overlay:

...

Code Block
/* Deactivate predefined flash node for SPI flash installed on DK */
&gd25wb256 {
        status = "disable";
};

&arduino_spi {
/* Insert node for new device */
        newspi: newdevice@1 {
                compatible = "jedec,spi-nor";
                status = "ok";
                reg = <1>;
                spi-max-frequency = <8000000>;
                jedec-id = [c8 65 19];
                size = <268435456>;
                has-dpd;
                t-enter-dpd = <3000>;
                t-exit-dpd = <40000>;
                sfdp-bfp = [ 
                        e5 20 f3 ff  ff ff ff 0f  44 eb 08 6b  08 3b 42 bb
                        ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
                        10 d8 00 ff  44 7a c9 fe  83 67 26 62  ec 82 18 44
                        7a 75 7a 75  04 c4 d5 5c  00 06 74 00  08 50 00 01
                        ]; 
        };
};

/* Use new device in choosen and aliases */
/ {
       chosen {
                nordic,pm-ext-flash = &newspi;
       };

       aliases {
                spi-flash0 = &newspi;
                ext-flash = &newspi;
       };
};

3.

...

5.2. Configuring for different SPI flash device with QSPI support on nRF5340 (nordic,qspi-nor)

The nRF5340 MCU includes a QSPI controller that allows to use faster flash devices in dual and quad SPI mode.

...