Programming QSPI with nrfjprog for nrf5340

I am trying to program a QSPI flash with a file system.  I have confirmed that my qspi ini is correct as i can read write and erase.  I created a small file system on an usb disk and used HxD to read it to a .bin of the file system. I can then either use objcopy or JFlash to create a hex file with my file system placed passed the mcuboot partition.  The issue I have is that when I flash I just get 0's back and the verify fails. below is my testing.

Erase Write Read

nrfjprog  --log -f nRF53 --qspiini con_qspi.ini --qspieraseall
nrfjprog  --log -f nRF53 --qspiini con_qspi.ini --memwr 0x100f0000  --val 0xAAAA
nrfjprog  --log -f nRF53 --qspiini con_qspi.ini --memrd 0x100F0000  --n 100

D:\ZephyrWorkspace\ShockStream\Controller\fs>nrfjprog  --log -f nRF53 --qspiini con_qspi.ini --memwr 0x100f0000  --val 0xAAAA
Parsing parameters.
[ #################### ]   0.000s | Reading external memory, 0x0004 bytes @ 0x000F0000 - Done
Initializing the QSPI peripheral.
Writing.
Uninitializing the QSPI peripheral.

D:\ZephyrWorkspace\ShockStream\Controller\fs>nrfjprog  --log -f nRF53 --qspiini con_qspi.ini --memrd 0x100F0000  --n 100

[ #################### ]   0.000s | Reading external memory, 0x0064 bytes @ 0x000F0000 - Done
0x100F0000: 0000AAAA FFFFFFFF FFFFFFFF FFFFFFFF   |................|
0x100F0010: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
0x100F0020: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
0x100F0030: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
0x100F0040: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
0x100F0050: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
0x100F0060: FFFFFFFF 

Write Hex

D:\Nordic\toolchains\cf2149caf2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-objcopy.exe  -v -I binary -O ihex --change-addresses 0x100f0000 nor2.bin nor2.hex

nrfjprog  --log -f nRF53 --qspiini con_qspi.ini --qspieraseall
nrfjprog  -f nRF53 --coprocessor CP_APPLICATION --qspiini con_qspi.ini --program nor2.hex  --verify

D:\ZephyrWorkspace\ShockStream\Controller\fs>nrfjprog  -f nRF53 --coprocessor CP_APPLICATION --qspiini con_qspi.ini --program nor2.hex  --verify
[ #################### ] 177.071s | Program file - Done programming
[error] [ Client] - Encountered error -160: Command verify_file executed for 158239 milliseconds with result -160
[error] [  nRF53] - Failed while performing 'Verify' operation on target address 0x100F0000.
-160: Data does not match in address range [0x100F0000 - 0x108EFFFF] (XIP (QSPI))
Expected byte value 0xEB but read 0x00 at address 0x100F0000.
[error] [  nRF53] - Failed while verifying device. -160: Data does not match in address range [0x100F0000 - 0x108EFFFF] (XIP (QSPI))
Expected byte value 0xEB but read 0x00 at address 0x100F0000.
[error] [ Worker] - Data does not match in address range [0x100F0000 - 0x108EFFFF] (XIP (QSPI))
Expected byte value 0xEB but read 0x00 at address 0x100F0000.
ERROR: Write verify failed.
NOTE: For additional output, try running again with logging enabled (--log).
NOTE: Any generated log error messages will be displayed.
PS D:\ZephyrWorkspace\ShockStream\Controller\fs> .\fs.bat

D:\ZephyrWorkspace\ShockStream\Controller\fs>nrfjprog  --log -f nRF53 --qspiini con_qspi.ini --memrd 0x100F0000  --n 100

[ #################### ]   0.000s | Reading external memory, 0x0064 bytes @ 0x000F0000 - Done
0x100F0000: 00000000 00000000 00000000 00000000   |................|
0x100F0010: 00000000 00000000 00000000 00000000   |................|
0x100F0020: 00000000 00000000 00000000 00000000   |................|
0x100F0030: 00000000 00000000 00000000 00000000   |................|
0x100F0040: 00000000 00000000 00000000 00000000   |................|
0x100F0050: 00000000 00000000 00000000 00000000   |................|
0x100F0060: 00000000                              |....|

  • I tried doing the same to my zephyr.hex from the project with the same results 

  • Hi Edward,

    Could you check that the QSPI flash memory is properly erased before writing?

    nrfjprog --log -f nRF53 --qspiini con_qspi.ini --qspieraseall 

    Regards,

    Priyanka

  • I already did that it is all 0xff.  You can also see that the other bytes in the write read are 0xff

  • D:\ZephyrWorkspace\ShockStream\Controller\fs>D:\Nordic\toolchains\cf2149caf2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-objcopy.exe  -v -I binary -O ihex --change-addresses 0x100f0000 nor2.bin nor2.hex
    copy from `nor2.bin' [binary] to `nor2.hex' [ihex]
    
    D:\ZephyrWorkspace\ShockStream\Controller\fs>nrfjprog  --log -f nRF53 --qspiini con_qspi.ini    --qspieraseall
    WARNING: An operation that can take up to several minutes is being executed.
    WARNING: Please remain patient.
    Initializing the QSPI peripheral.
    Erasing.
    Uninitializing the QSPI peripheral.
    
    D:\ZephyrWorkspace\ShockStream\Controller\fs>nrfjprog  --log -f nRF53 --qspiini con_qspi.ini --memrd 0x100F0000  --n 100
    
    [ #################### ]   0.000s | Reading external memory, 0x0064 bytes @ 0x000F0000 - Done
    0x100F0000: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x100F0010: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x100F0020: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x100F0030: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x100F0040: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x100F0050: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x100F0060: FFFFFFFF                              |....|

  • Hi Edward,

    It does look puzzling. Please make sure our bin file is properly aligned, i.e. sometimes padding can help. Also, please verify that your memory layout does not overlap with any other critical regions. For further understanding, it would also be good to use a debugger t step through the initialization and programming process.

    -Priyanka

Related