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

Adding a prebuilt littlefs image to merge.hex image

I am trying to use the littlefs fileystem in Zephyr to hold the configuration parameters and cloud identifier for each of our devices.  It would be really nice to build the filesystem image on the host, and then combine the image into the hex file that gets flashed by nrfjprog.  This makes it quick and easy at manufacturing.  

I've gotten the littlefs image built on my host, but I am hitting a wall on getting it flashed.  nrfjprog only accepts ihex files, and I can't find a tool to convert the littlefs image into a proper ihex file with the address offsets configured correctly (the filesystem sits in the "storage" partition, so it the hex file needs to have its start address offset).  I haven't figured out how to get objcopy or srec_cat to do this for me.  If I could then mergehex.py in the Zephyr toolchain would handle combining it with the mcuboo, spm, and app images for me.

So my questions are:

1. Does someone know of a good way to convert a binary file into a ihex file that starts at a specified address offset (thus solving my problem directly)

2. Does someone know of a tool I can use to just flash a binary file to an specified address (giving me at least some way to do this)

Thanks in advance!

  • Hello

     

    1. Does someone know of a good way to convert a binary file into a ihex file that starts at a specified address offset (thus solving my problem directly)

     I think you can use arm-none-eabi-objcopy which is part of the arm gcc installation. To convert from binary to ihex you should do something like this

    arm-none-eabi-objcopy --input-target=binary --output-target=ihex

     

    2. Does someone know of a tool I can use to just flash a binary file to an specified address (giving me at least some way to do this)

     You can just use nrfjprog with the memwr argument.

    nrfjprog --memwr <addr>

  • objcopy doesn't quite do it.  I haven't found a way to get the output ihex file to have its addresses offset to the location of the "storage" partition.

    I did find "pynrfjprog" however which has a "write" method which can take a byte array, so I have a simple python script that can write the files in for now. 

    Thank you!

Related