Write binary file to external QSPI flash with nrfjprog

Hi,

We need to write binary content from a binary file (.hex or .bin) to a specific area of the external flash (QSPI).

According to this topic:  NRF52840DK:use nrfjprog write a font bin file to external flash, this is similar to our issue.

I have a file called zephyr.recovery.bin.

I want to write the content of this file starting at address 0x1E98000 of the external flash.

Here are the steps I tried:

  • First, I converted the .bin file to .hex with an offset of 0x10000000 (the start of the QSPI memory space), then added my own offset: 0x1E98000.

bin2hex.py --offset 0x11E98000 zephyr.signed.bin zephyr.recovery.hex

  • Then I tried to program the file using this command:

nrfjprog --program zephyr.recovery.hex --recover --verify --log

But I got the following errors:

[ #################### ] 1.158s | Erase file - Done erasing
[error] [ Client] - Encountered error -172: Command program_file executed for 77 milliseconds with result -172
[error] [ nRF53] - Program file parsing failed, program file is invalid!
[error] [ nRF53] - Found data in XIP at address [0x11E98000 - 0x11F34559] that stretches out of XIP area.
[error] [ nRF53] - Failed while reading device information.
[error] [ Worker] - Found data in XIP at address [0x11E98000 - 0x11F34559] that stretches out of XIP area.
ERROR: The file specified is not a valid hex file, has data outside valid areas
ERROR: or does not have data in valid areas.

How should I write the content of my file to the external memory?

Thanks for your help.

Quentin L

Parents
  • Hi Quentin

    Sorry about the late reply, but I haven't been able to get to this one due to the staff shortage over the summer. To write to external memory, check out the nrfutil commands that does so available here.

    Your external flash size seems fine.

    Best regards,

    Simon

  • Thanks for your answer. We try to use the nrfutil commands. When we write our file at the beginning of the flash memory (0x10000000) and use the 24bit adresses mode ("address_mode""MODE24BIT"), it work.

    When we try to write the file at the end of the flash (0x11E98000), we need to switch to 32 bit adresses mode"address_mode": "MODE32BIT", and now it doesn't work. Our address is outside the 24 bit address range.

    We also try to write at the beginning of the flash (0x10000000) like previously but with 32 bit adresses mode and it doesn't work too. Is there an other thing to do than set the "address_mode" parameter to "MODE32BIT", if we want to use 32 bit adresses mode ?

    Here is our config file used with the nrfutil command: 

    {
    "firmware_config": {
    "peripheral": "QSPI"
    },
    "pins": {
    "sck": 17,
    "csn": 18,
    "io0": 13,
    "io1": 14,
    "io2": 15,
    "io3": 16
    },
    "flash_size": 33554432,
    "sck_frequency": 8000000,
    "address_mode": "MODE24BIT",
    "readoc": "READ4IO",
    "writeoc": "PP4IO",
    "pp_size": "PPSIZE256",
    "sck_delay": 0,
    "rx_delay": 0,
    "page_size": 4096
    }
  • Hi Quentin,

    Simon is out of office, and I will continue helping you. I have relayed your observation to our nRF Util team. We will investigate and follow-up with you next week.

    Hieu

  • Hi Quentin,

    We cannot reproduce the issue on our end, tested with nrfutil version 8.1.0 and nrfutil-device version 2.12.6. It should work with most recent versions of nRF Util though.

    Could you try with "rx_delay" : 7?

    If that doesn't work, could you make an attempt with --log-level=trace, and share with us the resulting log files found in <USERHOME>/.nrfutil/logs?

    Hieu

  • Hi, 

    thanks for your answer, we can't reproduce the issue again, it seem to work correctly with 32 bit mode and we can write our images as expected. 

    Thanks for your help !

    Quentin

Reply Children
No Data
Related