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                              |....|

Parents
  • 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

  • Well since I am trying to load a file system it is a bit different but the Intel hex file I generated looks correct.  I have also tried the base of qspi at 0x10000000 with the same results.

  • so the files seems to be overwriting itself every page.  if i limit the file to the first page then it works but after that it seems to overwrite it.  It cant seem to move past the first page. below is my init and i am using the MX25L25645GZNI

    ;----------------------------------------------
    ; Deprecated, use config.toml format instead
    ;----------------------------------------------
    
    ; nrfjprog QSPI 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 = 0x2000000
    
    ; 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 = PP4IO
    
    ; Define the desired AddressMode. Valid options are BIT24 and BIT32
    AddressMode = BIT32
    
    ; 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 = 0x80
    
    ; Define SPI interface timing. Valid options are in the range of 0 to 7.
    ; This argument is only used for devices where the dll function NRFJPROG_qspi_set_rx_delay() is supported.
    RxDelay = 2
    
    ; 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
    
    ; Define the assigned pins for the QSPI peripheral. Valid options are those existing in your device
    ; For nRF53, QSPI pins are not configurable and these values are ignored.
    CSNPin = 17
    CSNPort = 0
    SCKPin = 19
    SCKPort = 0
    DIO0Pin = 13
    DIO0Port = 0
    DIO1Pin = 14
    DIO1Port = 0
    DIO2Pin = 15
    DIO2Port = 0
    DIO3Pin = 16
    DIO3Port = 0
    
    ; 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. Format is instruction code plus data to send in between optional brakets. 
    ; These instructions will be executed each time the qspi peripheral is initiated by nrfjprog. 
    ; To improve execution speed on consecutive interations with QSPI, you can run nrfjprog once with custom initialization, and then comment out the lines below.
    ; 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] 
    
    ; If retention is enabled, device RAM contents will be read and buffered during QSPI driver initialization.
    ; The buffered data will be written back to the device when unitializing the driver, restoring the original device RAM state.
    ; Enabled: RetainRAM = 1, Disabled: RetainRAM = 0
    RetainRAM = 1
    
    

  • So i have gotten it to write by adding a 32bit addressing custom command, but i cant seem to find the file system now.

  • Ok so now I can read the files from the fs project so I need to figure out the difference between the 2 projects.  I did have to add 32bit addressing to the device tree as well.

Reply Children
Related