Background: We use NRF52 chip along with SDK 12.1.0. Since we have a few components of firmware (i.e. secure DFU settings, secure DFU , application, Softdevice) that go into the FLASH memory which each have an image file associated with, I am trying to combine all into a single .hex file to make it easier for our production facility to upload firmware on each device.
Tools used: IAR Embedded to build the project, mergehex from nrf tools to combine the hex files.
Problem: As I was trying to merge the hex files I would get the following error from mergehex:
ERROR: The hex files cannot be merged since there are conflicts.
(as a side note, it's unfortunate that mergehex doesn't give any information about where the conflict was, so I had to do a bit of digging with some other hex tools to find where the conflict was).
I found out that both the application and the secure DFU are trying to include the UICR into the hex output file. This is a result of having nrf_dfu_settings.c file in both the application and secure DFU projects.
This is the line which enforces UICR placement:
__root const uint32_t m_uicr_mbr_params_page_address @ NRF_UICR_MBR_PARAMS_PAGE_ADDRESS = NRF_MBR_PARAMS_PAGE_ADDRESS;
One possible solution to this #ifdef this line so that it gets included only in the secure DFU project not the application.
#ifdef SDFU_PROJ
__root const uint32_t m_uicr_mbr_params_page_address @ NRF_UICR_MBR_PARAMS_PAGE_ADDRESS = NRF_MBR_PARAMS_PAGE_ADDRESS;
#endif