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

Any sample for embedding binary or text file to be available as variable in the code?

ESP32 has this in the build system, I was wondering if there is any sample in nrf52 This helps in embedding private key/ certificates easily.

Parents
  • Hi 

    Would it be possible to use something like this to convert the binary file to a C array?

    Then you can easily reference the data from the code. 

    The tool I linked to above will make the array const, which ensures it is put in flash and not in RAM. 

    Another method is to convert the binary to a hex file, and have Segger Embedded Studio load the hex file when you flash the code. 

    Best regards
    Torbjørn

  • Hi Torbjorn,

    I have a similar inquiry so I thought I could reply in here.

    My use case is that I have several identical custom nRF boards that must be configured differently (i.e. internal device id, etc.). Currently, the values are hardcoded so I end up with multiple firmware. How could I implement it in a hex file that could be loaded via SES and have my firmware locate it and extract the values?

    I looked at the FDS implementation and it looked like it is just what I needed but I can't get my head around how could I create the hex file that the FDS could understand and at what address I should load it.

    If you could point me to the examples that I could use as guide, it would be much appreciated.

    Best regards,

    Carlos

  • Hi Carlos

    In general I recommend opening new tickets, otherwise there is a risk whoever was assigned to the case originally is unavailable, and you might not get a response ;)

    I think the easiest way to do this would be to run some form of command line script to generate your hex file, and then use nrfjprog to flash the hex file into your device. You just have to make sure you put the data into an address in the hex file where you don't have any code or data in your devices (at the end of the available flash area typically). 

    For creating the hex files I would recommend a Python library called IntelHex:
    https://pypi.org/project/IntelHex/

    With this library you can create and save hex files with whatever data you need. 

    Then you can call nrfjprog to have the hex file programmed into your board, directly from the Python script if you want. 

    Best regards
    Torbjørn

Reply
  • Hi Carlos

    In general I recommend opening new tickets, otherwise there is a risk whoever was assigned to the case originally is unavailable, and you might not get a response ;)

    I think the easiest way to do this would be to run some form of command line script to generate your hex file, and then use nrfjprog to flash the hex file into your device. You just have to make sure you put the data into an address in the hex file where you don't have any code or data in your devices (at the end of the available flash area typically). 

    For creating the hex files I would recommend a Python library called IntelHex:
    https://pypi.org/project/IntelHex/

    With this library you can create and save hex files with whatever data you need. 

    Then you can call nrfjprog to have the hex file programmed into your board, directly from the Python script if you want. 

    Best regards
    Torbjørn

Children
Related