Need to rename merged_domains.hex file after the build is done for NRF5340

Hi,

I have an NRF5340 application based on zephyr which produces a combined merged_domains.hex file.

I need to add a post build command after the "merge_domains.hex" file is generated to rename the "merge_domains.hex" file to "WECG_MODULE_revision_num.hex" . I have the cMakeLists.txt code as mentioned below.

set(REVISION_NUMBER "00_01_01")  #revision number
set(HEX_FILE_NAME "${CMAKE_BINARY_DIR}/zephyr/WECG_MODULE_${REVISION_NUMBER}.hex")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/zephyr/merged_domains.hex ${HEX_FILE_NAME}
)
I need to know in which CMakeLists.txt file can I add the above code?
Thanks and regards,
Ajit S J
Parents
  • Hi Ajit S J,

    I haven't been able to figure out a solution to your question yet. Usually, changes to CMake should be done in the application CMakeLists.txt. However, in this case, even though the custom command is set for POST_BUILD, it is run before linking and thus fail due to the absence of the .hex file.

    I suppose you probably have a CI/CD system. Is it possible to do the file naming outside of the build step instead?

    Best regards,

    Hieu

  • Hi Hieu,

    Thanks for your reply. We do not have a CI/CD system in place.

    Could you please let me know which script does the below mentioned steps of "Generating zephyr/merged_domains.hex". I can try to modify that script to rename the "merged_domains.hex" file?

    [442/444] Linking C executable zephyr\zephyr.elf
    Memory region Used Size Region Size %age Used
    FLASH: 310784 B 1 MB 29.64%
    RAM: 312400 B 512 KB 59.59%
    IDT_LIST: 0 GB 2 KB 0.00%
    [443/444] Generating zephyr/merged.hex
    [444/444] Generating zephyr/merged_domains.hex

    Thanks and regards,

    Ajit S J

Reply
  • Hi Hieu,

    Thanks for your reply. We do not have a CI/CD system in place.

    Could you please let me know which script does the below mentioned steps of "Generating zephyr/merged_domains.hex". I can try to modify that script to rename the "merged_domains.hex" file?

    [442/444] Linking C executable zephyr\zephyr.elf
    Memory region Used Size Region Size %age Used
    FLASH: 310784 B 1 MB 29.64%
    RAM: 312400 B 512 KB 59.59%
    IDT_LIST: 0 GB 2 KB 0.00%
    [443/444] Generating zephyr/merged.hex
    [444/444] Generating zephyr/merged_domains.hex

    Thanks and regards,

    Ajit S J

Children
No Data
Related