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
  • Not a proper answer to what you are asking for, but it might help you out.

    Attached is three python files which I think does what you want. It supports dumping the fds data to .yaml .bin or .hex format. Note that this is just something I made for my own use, and it is not supported by anyone and it may break and stop working. You need to have pynrfjprog installed for it to work. github.com/.../pynrfjprog

    Use the command

    python fds_reader.py read --source 682354148 --dest lol.yaml
    

    To read the fds data from the kit to lol.yaml.

    The idea was to support reading the fds data from the device to a human modifiable format, change the data, and the write the new data back to the device with updated CRC, however this does not work at the moment.

    Copy these three files somewhere to be able to run the command. Note: It will only work on windows for now, to change this, just change remove the entire "auto detect devices" functionality.

    fds_device_discovery.py

    nrfmap.py

    fds_reader.py

  • @shibshab: thanks for sharing these scripts. However, I had issues running these on my PC (it gave me "no such command "read"") and decided it would be quicker for me to roll a script of my own. It looks like your scripts do quite a lot more than I need and I'll bookmark them for future reference!

Reply Children
No Data
Related