nRF5 SDK v16.0.0
Compiling and running an example from the QSPI using XiP
This information applies to the nRF52840 SoC only.

The QSPI peripheral can work in two modes:

This getting started guide describes how to configure a QSPI device, program it, and start the Blinky application.

Prerequisites

You must first test the setup of your toolchain. To do so, compile, program, and run a very simple example that does not use a SoftDevice, for example the Blinky SysTick Example.

Use the PCA10056 board in version 0.10.0 or higher.

Make sure that you have all the required tools installed and that the board is connected to your computer. See Getting started page (for nRF52840) or Setting up the development kit (for nRF52832) for more information.

Procedure

This procedure requires programming your development kit with two examples. You must download the Blinky application to the QSPI memory and the main memory must be programmed with the bootloader application.

  1. Open the Blinky SysTick Example directory and then open the pca10056_qspi\blank\armgcc directory.
  2. Run the command
    make flash
    to compile and flash the QSPI memory device with the Blinky application.
  3. Open the QSPI bootloader Example directory.
  4. Compile the bootloader code and flash the board using one of the provided toolchains in the pca10056 directory.

Alternatively, you can compile the application using make and use the nrfjprog tool to program the device:

  1. Find the compiled HEX file and program the QSPI memory flash using nrfjprog command:
    nrfjprog --family NRF52 --program nrf52840_xxaa.hex --qspichiperase
  2. Verify the previous step with the command:
    nrfjprog --family NRF52 --verify nrf52840_xxaa.hex
    "Verified OK." message should be displayed.

After completing these steps, LEDs will be blinking on your development kit. In case of problems, see Troubleshooting.

Preparing an application to work with QSPI XiP

The code is executed from QSPI memory a few times slower than the code executed from internal flash. For this reason, avoid using frequency-related solutions in code, for example delay loops based on dummy instructions. They will be inaccurate.

  1. Move the flash in your application linker script to adress 0x12000000. To do this in GCC projects:
    1. Open the *.ld file.
    2. Find the line:
      FLASH (rx) : ORIGIN = 0x0, LENGTH...
    3. Change the line to the following:
      FLASH (rx) : ORIGIN = 0x12000000, LENGTH...
    4. Recompile your application.
    5. Program and verify the application in QSPI memory device using the command from section Procedure.
  1. Reconfigure a Keil project in project options. Then, program the HEX file and verify it using the command from section Procedure. Keil does not navitely support programming of a QSPI memory device.
gs_qspi_config_keil.png
Keil configuration for a QSPI XiP application
  1. Reconfigure an IAR project in project options, as shown below. Then, program the output HEX file and verify it using the command from section Procedure. IAR does not navitely support programming of a QSPI memory device.
gs_qspi_config_iar_int_vect.png
IAR vector table configuration for a QSPI XiP application
gs_qspi_config_iar_mem_regions.png
IAR memory regions configuration for a QSPI XiP application

Preparing the bootloader

Bootloader is an important part of the QSPI XiP solution. It configures the QSPI peripheral, the memory device, and jumps to the 0x12000000 address. To create your own bootloader, you can use the QSPI bootloader Example as a reference design.

Troubleshooting

Check the following table for the list of known issues and available workarounds.

Issue Workaround
The application cannot be downloaded to external memory device. Check connection, length of lines, and device family code. This getting started guide and examples use the configuration for full speed mode for the MX25R6435F device. For other devices, you must change the QSPI configuration in nrfjprog file QspiDefault.ini in the nrfjprog installation directory or prepare your own one.
The application can be downloaded to the external memory device but verification fails. There might be a problem with connection between the memory device and the MCU. Check the connections. If the problem still exists, try slowing down the download process. You can also use a simpler mode to access the memory device. To do this, open the QspiDefault.ini file in the nrfjprog installation directory(or prepare your own one) and use a safer configuration. For example:
ReadMode = FASTREAD WriteMode = PP Frequency = M2
The configuration presented here is the slowest but also the safest one.
The application can be downloaded and is verified but nothing has happened. Check whether you moved the flash address to 0x12000000 in your application linker script. The issue can be also related to data distortion. Try slowing down the memory device in the bootloader sdk_config file. Find QSPI_CONFIG_FREQUENCY and set it to 15.
Debugging the QSPI application. You can debug your QSPI application like a flash one. Remember not to load application code to the SoC in a debug session.

Documentation feedback | Developer Zone | Subscribe | Updated