XIP problems with a custom board running nrf5340

Hi,

I'm trying to use XIP on our custom board running a nrf5340 with a different Flash memory than the one on the nrf5340-devkit.

The XIP worked on nrf5340dk, but now it's not working on the custom board. We are using a different Flash memory, W25Q64JW instead of the one on the devkit (MX25R64).

Not sure if it is the commands sent to the Flash that needs to be changed, but the commands looks pretty much the same on both flash memories.

Starting to think maybe that the problem is when trying to Flash the custom board, and specifically the external flash with the commands:

nrfjprog --qspicustominit --qspieraseall

nrfjprog --coprocessor CP_APPLICATION --sectorerase --qspisectorerase --program zephyr.hex --verify

How is the QSPI peripheral initiated with these commands?

The problem I have is that I get the following: "Usage Fault":

 ***** USAGE FAULT *****
[00:00:00.326,477] <err> os:   Attempt to execute undefined instruction
[00:00:00.326,507] <err> os: r0/a1:  0x00000000  r1/a2:  0x0000001c  r2/a3:  0x0000001b
[00:00:00.326,538] <err> os: r3/a4:  0x20001940 r12/ip:  0x10000001 r14/lr:  0x0000261f
[00:00:00.326,538] <err> os:  xpsr:  0x29000000
[00:00:00.326,568] <err> os: Faulting instruction address (r15/pc): 0x10000000

And this is the resultl when trying to flash the external flash:

nrfjprog --coprocessor CP_APPLICATION --sectorerase --qspisectorerase --program zephyr.hex --verify --log

Parsing image file.
Verifying programming.
ERROR: [  nRF53] - Data does not match in QSPI memory address range [0x00000000-0x00000060]
ERROR: [  nRF53] - QSPI memory verification failed
ERROR: [  nRF53] - Failed while verifying file zephyr.hex.
ERROR: Write verify failed.

So I don't think the code is actually flashed to the external memory.

BR

Parents Reply Children
  • I've changed jedec-id and didn't help, also updated some other properties. Still doesn't work when trying to flash the external memory.

    I'm still wondering how the flash procedure for the external flash works. It must be the nordic bootloader in ROM that handles it right? Then it shouldn't matter at flash-time how the QSPI peripheral is setup by the user in dts files?
    I read something about an init file for qspi for flashing, using:

    --qspiini <file>

    I've been using this so far and probably this is for the devkit (mx25r64 flash):

    --qspicustominit

    How to write this QSPI settings file, any examples?

    Thanks

  • PROBLEM SOLVED

    Added a custom QSPI settings file with these properties and used it with the command:

    nrfjprog --qspiini ../app/QspiSettings.ini --coprocessor CP_APPLICATION --sectorerase --qspisectorerase --program zephyr.hex --verify
    

    The added part above is "--qspiini ../app/QspiSettings.ini" which adds a custom settings file for the correct flash device.

    And this is how the file looks like:
    (I changed the following parameters to correspond to W25Q64 flash memory):

    MemSize = 8000000 (instead of 800000)
    WriteMode = PP4O (instead of PP4IO which is not supported by W25Q64)
    SckDelay = 0xA (instead of 0x80)

    And changed all pins to correct values.

    All of those parameters above was found in the data sheet of W25Q64 flash.


    ; nrfjprog.exe configuration file.
    
    [DEFAULT_CONFIGURATION]
    ; Define the capacity of the flash memory device in bytes. Set to 0 if no external memory device is present in your board.
    MemSize = 8000000
    
    ; Define the desired ReadMode. Valid options are FASTREAD, READ2O, READ2IO, READ4O and READ4IO
    ReadMode = READ4IO
    
    ; Define the desired WriteMode. Valid options are PP, PP2O, PP4O and PP4IO
    WriteMode = PP4O
    
    ; Define the desired AddressMode. Valid options are BIT24 and BIT32
    AddressMode = BIT24
    
    ; Define the desired Frequency. Valid options are M2, M4, M8, M16 and M32
    Frequency = M16
    
    ; Define the desired SPI mode. Valid options are MODE0 and MODE3
    SpiMode = MODE0
    
    ; Define the desired SckDelay. Valid options are in the range 0 to 255
    SckDelay = 0xA
    
    ; Define the desired IO level for DIO2 and DIO3 during a custom instruction. Valid options are LEVEL_HIGH and LEVEL_LOW
    CustomInstructionIO2Level = LEVEL_LOW
    CustomInstructionIO3Level = LEVEL_HIGH
    
    CSNPin = 18
    CSNPort = 0
    SCKPin = 17
    SCKPort = 0
    DIO0Pin = 13
    DIO0Port = 0
    DIO1Pin = 14
    DIO1Port = 0
    DIO2Pin = 15
    DIO2Port = 0
    DIO3Pin = 16
    DIO3Port = 0
    
    
    ; Define the assigned pins for the QSPI peripheral. Valid options are those existing in your device
    
    ; Define the Index of the Write In Progress (WIP) bit in the status register. Valid options are in the range of 0 to 7.
    WIPIndex = 0
    
    ; Define page size for commands. Valid sizes are PAGE256 and PAGE512.
    PPSize = PAGE256
    
    ; Custom instructions to send to the external memory after initialization. Only used if --qspicustominit option is given in the call to nrfjprog. Format is 
    ; instruction code plus data to send in between optional brakets. Numbers can be given in decimal, hex (starting with either 0x or 0X) and binary (starting 
    ; with either 0b or 0B) formats. The custom instructions will be executed in the order found. 
    ; This example includes two commands, first a WREN (WRite ENable) and then a WRSR (WRite Satus Register) enabling the Quad Operation and the High Performance
    ; mode for the MX25R6435F memory present in the nRF52840 DK.
    InitializationCustomInstruction =  0x06
    InitializationCustomInstruction =  0x01, [0x40, 0, 0x2]

Related