-
Notifications
You must be signed in to change notification settings - Fork 16
Convert the ELF output to bin
Felipe Torrezan edited this page Apr 13, 2024
·
2 revisions
A CMake function can be used to convert an executable (*.elf
or *.out
) to the binary format (*.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 .bin
function(iar_elf_tool_hex TARGET)
add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_IAR_ELFTOOL} --silent --bin $<TARGET_FILE:${TARGET}> $<IF:$<BOOL:$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>>,$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>,$<TARGET_PROPERTY:${TARGET},NAME>>.bin)
endfunction()
- Call the
iar_elf_tool_bin(<target>)
function replacing<target>
by the actual executable target. Example:
iar_elf_tool_bin(MyTarget)
-
Build the target.
-
Find
MyTarget.bin
inside the build subdirectory.
Note
${CMAKE_IAR_ELFTOOL}
is automatically detected by CMake
This is the cmake-tutorial wiki. Back to Wiki Home
- Setting language-specific target options
- Selecting build types
- Using Ninja Multi-Config
- Filing a build log
- Multi-file compilation
- Invoking IAR binary utilities