Program external spi flash using nrfjprog

Hi,

is it possible to write data to external spi flash using nrfjprog? This would be on a custom board, which has nRF9160 with extra external SPI flash (not QSPI)?

Kind regards,

Luc

Parents Reply Children
  • Hi,

     

    If you have a .hex file that has the correct offset, you can program it directly with nrfjprog and it will automatically figure out that it is in the QSPI XIP area:

    nrfjprog --program <qspi.hex> --verify -f nrf53

     

    Or if you want to read:

    nrfjprog --readqspi readout.hex -f nrf53

     

    Note that the XIP area differs on nRF52840 (0x1200_0000) and nRF5340 (0x1000_0000):

    https://docs.nordicsemi.com/bundle/ps_nrf52840/page/memory.html#ariaid-title4

    https://docs.nordicsemi.com/bundle/ps_nrf5340/page/chapters/memory/appmem.html

     

    Please note that the "-f nrf53" (or -f nrf52 if nrf52840 is targeted) is crucial when communicating over QSPI.

    If not, you will see errors similar to this:

    $ nrfjprog --memwr 0x10000000 --val 0x12345678
    Parsing parameters.
    [error] [ Client] - Encountered error -2: Command qspi_init_preconfigured executed for 47 milliseconds with result -2
    [error] [ Worker] - QSPI driver is not configured! Configure QSPI before attempting to initialize.
    ERROR: Requested operation is currently unavailable.
    ERROR: Check logs for more details.
    NOTE: For additional output, try running again with logging enabled (--log).
    NOTE: Any generated log error messages will be displayed.
    

    While with the correct family switch:

    $ nrfjprog --memwr 0x10000000 --val 0x12345678 -f nrf53
    Parsing parameters.
    [ #################### ]   0.000s | Reading external memory, 0x0004 bytes @ 0x00000000 - Done                          
    Initializing the QSPI peripheral.
    Writing.
    Uninitializing the QSPI peripheral.
    
    $ nrfjprog --memrd 0x10000000 -f nrf53
    [ #################### ]   0.000s | Reading external memory, 0x0004 bytes @ 0x00000000 - Done                          
    0x10000000: 12345678                              |xV4.|
    
    

    I see that I've misinformed you:

    Håkon Alseth said:
    nRF52840/nRF52833/nRF5340

    My apologies, nRF52833 does not have QSPI, so I will edit this and remove that reference.

     

    Kind regards,

    Håkon

  • thanks, that work nicely! Much handier for production initialisation of the external flash areas

  • Always happy to help out. Hope you have a wonderful day!

     

    Kind regards,

    Håkon

Related