-
Notifications
You must be signed in to change notification settings - Fork 18
Use the IAR ELF Tool to convert executable targets to their binary formats
Felipe Torrezan edited this page Oct 6, 2025
·
3 revisions
A CMake function can be used to convert executable target (*.elf or *.out) to binary formats such as Motorola S-Record (*.srec, *.mot), Intel Hexadecimal format (*.hex) and Raw Binary (*.bin).
- CMake projects using the IAR C/C++ Compilers with the IAR ILINK technology.
- Add the following
function()to the CMake project:
# Convert the ELF output to its binary formats
function(iar_elftool tgt)
add_custom_command(TARGET ${tgt}
POST_BUILD
COMMAND ${CMAKE_IAR_ELFTOOL} --silent --ihex $<TARGET_FILE:${tgt}> <TARGET_PROPERTY:${tgt},NAME>.hex
COMMAND ${CMAKE_IAR_ELFTOOL} --silent --srec $<TARGET_FILE:${tgt}> <TARGET_PROPERTY:${tgt},NAME>.srec
COMMAND ${CMAKE_IAR_ELFTOOL} --silent --bin $<TARGET_FILE:${tgt}> <TARGET_PROPERTY:${tgt},NAME>.bin
)
endfunction()- Call the
iar_elftool(<target>)function replacing<target>by the actual executable target. Example:
iar_elftool(MyTarget)-
Build the target.
-
Find
MyTarget.hex,MyTarget.srecandMyTarget.bininside the build sub-directory.
This is the cmake-tutorial wiki. Back to Wiki Home
- IAR Compiler options in a CMake project
- IAR ILINK options in a CMake project
- Language-specific target options
- Selecting build types
- Using Ninja Multi-Config
- Filing a build log
- Multi-file compilation
- Invoking IAR binary utilities
- Use the IAR ELF Tool to convert executable targets to their binary formats
- Using IAR Build Tools with CMake Presets