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

possible mergehex issue (v10.12.1) ?

Found a potential "weirdness" with the mergehex utilty.  When merging hex files containing code, dont seem to have an issue.  Recently I was using mergehex create a full programming image containing MBR, Softdevice, App, custom Bootloader and UICR.  The UICR file .hex I am using only specifies the changed locations in UICR memory, so the changed data is 4 or 8 bytes long in several places in the UICR.  When the UICR.hex  file was joined with other files to create the image,  the 4 or 8 byte UICR locations seem to be padded out the 16 bytes with the padded bytes being zeros or seemingly random values.  This showed up as an issue when the image was programmed into an nrf52840 and was protected, even though the protection was not set in the UICR.  Address 0x10001208 was set to zero because the UICR file had data at 0x10001200 and 0x10001204..  I solved the issue be creating a new UICR file that was padded with 0xFFs and inserted the actual data into that so mergehex does get to do it own thing as the entire UICR is specified.  The 0xFFs will not change any values, but only the specified values will change.  Seems to have solved the issue but mergehex should be fixed to eliminate this unexpected behavior. 

Related