This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Read and write specific flash pages from a computer

I want to read and write certain pages from the NRF52 flash via nrfjprog. The goal is to debug an issue with the peer manager by saving the FDS flash contents to disk. I would also want to restore the contents of the FDS flash from the previous saved file. I’ll also be inspecting the flash contents with a hex reader (such as HxD).

First attempt I tried was nrfjprog.exe --family NRF52 --memrd 0x6F000 --n 0x4000 > output.bin. However, this captures all of the output (including the human readable formatting) which is not what I’m after. I just want the raw binary data that is in the flash from 0x6F000 to 0x73000.

Second attempt I tried was nrfjprog.exe --family NRF52 --readcode output.bin. However, I’m not sure about the data format from readcode. For example, the hex values at offset 0x6F0000x6F008 are completely different from what I see in the Memory window while debugging in Keil. I’m expecting DE C0 AD DE FF 01 1E F1 FF, which is what I see in Keil’s Memory window.

  1. Is nrfjprog capable of reading specific pages of flash, saving this to a file on a computer, and also flashing the contents of this saved file back to specific pages of flash?
  2. If nrfjprog isn’t capable of doing this, is there another tool that can (while using a jlink debugger?).

Note I’ve also tried nRFgo Studio but I haven’t found out how read/write specific regions of flash.

Edit: I'm using nrfjprog version 9.3.1 with JLinkARM.dll version 6.18c

Parents
  • I've solved my problem with a custom python script and thought others might find it useful. The script can be downloaded here: jflashrw.py

    Reading FDS: jflashrw.py read --start 0x6F000 --length 0x4000 --file fds.bin

    Writing FDS: jflashrw.py write --start 0x6F000 --length 0x4000 --file fds.bin

    Change the start address and the length as appropriate for your project (mine has a bootloader that starts at 0x73000 and has four pages for FDS). This script can also be used to read/write other parts of flash.

Reply
  • I've solved my problem with a custom python script and thought others might find it useful. The script can be downloaded here: jflashrw.py

    Reading FDS: jflashrw.py read --start 0x6F000 --length 0x4000 --file fds.bin

    Writing FDS: jflashrw.py write --start 0x6F000 --length 0x4000 --file fds.bin

    Change the start address and the length as appropriate for your project (mine has a bootloader that starts at 0x73000 and has four pages for FDS). This script can also be used to read/write other parts of flash.

Children
No Data
Related