Software QSPI
Software QSPI (sQSPI) is an emulation of the Quad Serial Peripheral Interface (QSPI) using the Fast Lightweight Peripheral Processor (FLPR). The sQSPI sample demonstrates how to use Soft Peripheral QSPI to perform read, page program, and sector erase operations on the external flash memory of the development kit.
Requirements
The sample supports the following development kits with on-board SPI external flash:
The following board variants do not have DFU capabilities:
S115:
Hardware platform |
PCA |
Board target |
|---|---|---|
PCA10156 |
|
|
PCA10184 |
|
S145:
Hardware platform |
PCA |
Board target |
|---|---|---|
PCA10156 |
|
|
PCA10184 |
|
The following board variants have DFU capabilities:
S115:
Hardware platform |
PCA |
Board target |
|---|---|---|
PCA10156 |
|
|
PCA10184 |
|
S145:
Hardware platform |
PCA |
Board target |
|---|---|---|
PCA10156 |
|
|
PCA10184 |
|
Note
Other nRF54L Series DKs do not have on-board external flash memory and are out of scope for this sample.
However, the sQSPI driver itself is supported on more nRF54L Series SoCs (see VPR pin mapping for the supported SoCs and pins).
You can still use sQSPI on these boards by connecting an external flash to the supported pins of the SoC and adapting the sample configuration accordingly (pin assignments in the board-config.h file, command set, and timing parameters to match your device).
Important
Before flashing the sample, you must enable External memory using the Board Configurator app in nRF Connect for Desktop, and then write the configuration to the board. Otherwise, the on-board flash is not routed to the SoC, and the sample does not work.
Overview
The sample uses the sQSPI Soft Peripheral driver to perform read, program, and erase operations on the external flash.
The peripheral logic runs on the Fast Lightweight Peripheral Processor (FLPR), a dedicated VPR CPU based on the RISC-V architecture in the fast domain.
The application core controls it through the sQSPI driver API.
Reads and page programs use QSPI, while erase and setup commands use single SPI.
All operations target the same flash address (set by the CONFIG_SAMPLE_SQSPI_FLASH_ADDR Kconfig option).
The flash is the on-board MX25-class NOR device on the development kit.
Its SPI pins and strap pins that configure fixed hardware settings, such as write-protect and reset state at power on, are defined by the BOARD_EXTERNAL_MEMORY_* macros in the board-config.h file.
Configuration
For information on how to configure the Soft Peripheral, see Using Soft peripherals.
You can modify the following options (available in the Kconfig file at samples/softperipherals/sqspi/Kconfig):
CONFIG_SAMPLE_SQSPI_MSG- Sets the message written to the external flash on program.CONFIG_SAMPLE_SQSPI_FLASH_ADDR- Sets the external flash address targeted by read, program, and erase. Keep it a multiple of 0x1000 (4 KiB sector size) to avoid a wrapped, corrupted write.
User interface
- LED 0:
Lit when the device is initialized.
- Button 1:
Erase external memory.
- Button 2:
Read external memory.
- Button 3:
Program external memory.
Building and running
This sample can be found under samples/softperipherals/sqspi/ in the Bare Metal folder structure.
For details on how to create, configure, and program a sample, see Getting Started with the samples.
Testing
To test this sample, complete the following steps:
Enable External memory using the Board Configurator app in nRF Connect for Desktop, and then write the configuration to the board.
Compile and program the application.
Observe that the
sQSPI sample initializedmessage is printed, followed by the list of available buttons and their operations.Press Button 2 to read the on-board flash. The hex dump shows either all
0xFF(erased) or the data last written to the address.Press Button 3 to program the configured message (set by the
CONFIG_SAMPLE_SQSPI_MSGKconfig option, defaultHello World!). The log printsFlash operation complete.Press Button 2 to read again. The hex dump now starts with the message bytes, confirming the write succeeded. For the default configuration, this is
48 65 6c 6c 6f 20 57 6f 72 6c 64 21 00, which is ASCII forHello World!, followed by the string terminator.Power-cycle the board and press Button 2 to read. The same message reappears, confirming the data persists across power cycles.
Press Button 1 to erase the sector and wait for the flash’s self-timed erase operation to complete.
Power-cycle the board again and press Button 2 to read. The hex dump shows all
0xFF, confirming the erase succeeded.