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

Embedding firmware for external MCU in firmware image

I have another MCU on the same board as the Nordic 52832. The firmware update image for the MCU is about 50kb in size, so instead of adding a parallel DFU for the MCU through Bluetooth I figured I could just embed the firmware in the Nordic firmware. What is the best way to store this data in the firmware image so it isn't loaded into RAM but can be read directly from flash as required? I'm guessing if I store it in an array it will be loaded into RAM.

Parents Reply Children
  • I understand that it is not a normal task, and I did search before asking but found nothing. But guidance on how this can roughly be achieved can lead me in the right direction. I’m not asking for it done for me, just how it could be done. So far I’m not sure how I would be able to get the address and length of the data. I guess I would need to store the data at a fixed place in flash specified in the hex file. The length could be stored in the data. But I am asking because perhaps there is another way. I see ARM have a bin2hex tool so I guess I could merge the data into the firmware hex directly using that? And then just use nrfutil to generate zip normally?

  • Yes you can use bin2hex to convert to hex file.

    When you have the .bin file (can be from hex2bin or from nrfutil) you will have the size of the .bin file equal to the size of the actual image. 

    Note that unlike .hex file, in .bin file there is no concept as address. Bin file is simply binary, the actual image data, no address. 

    The challenge is just to create a hex file that contains the 2 images. I haven't done this but I do think that it should be possible using the 2 .bin files, combine them and convert them back to .hex.

    In your code, to detect where the image started you can make a pattern that mark the start of your firmware for example 100 bytes of 0xAA continuously. (in my DFU master code, I simply going backward and look for first byte which is not 0xFF as the marking of the end of the image, please have a look in find_image_size() ). But it's the best if you can modify the bootloader to write to a place in bootloader setting to mark where the image is and the size of the image. 

Related