Hi,
We are using the nRF Connect SDK and building a Zephyr standalone application. Is there a way to add a post build step to the application CMakeLists.txt file which will run AFTER the zephyr.hex is generated?
Thanks.
Hi,
We are using the nRF Connect SDK and building a Zephyr standalone application. Is there a way to add a post build step to the application CMakeLists.txt file which will run AFTER the zephyr.hex is generated?
Thanks.
Hi,
Have you looked at extra_post_build_commands
? That is the closest I can think of.
No, I have not looked into this. Are there any examples of using this with a Zephyr build?
There are quite a few example of it, I suggest you search for "extra_post_build_commands
" in the SDK code base and look at some of the the CMakeLists.txt files that use it.
A more or less random example is from zephyr\boards\arm\faze\CMakeLists.txt:
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands # Insert checksum (verified by the bootloader) into the zephyr.bin # and zephyr.hex images. COMMAND lpc_checksum -f hex ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_HEX_NAME} COMMAND lpc_checksum -f bin ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_BIN_NAME} )
Hi Einar,
Thank you for pointing me in the right direction. I'm not proficient in CMake so it's been a bit of a struggle. We have created a freestanding Zephyr project and have our own board file defined. In the CMakeLists.txt file in the board directory I added....
# Include post build instructions from build folder.
include(${APPLICATION_CONFIG_DIR}/postbuild.cmake)
Where APPLICATION_CONFIG_DIR is the folder where the application CMakeLists.txt file exists.
Then, in my application folder I created the postbuild.cmake file with the following contents...
set(CMAKE_SREC_TOOL "../../FileTools")
# Add post-build step after final zephyr application is created.
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
COMMAND "${APPLICATION_CONFIG_DIR}/../createappbin.bat" "${CMAKE_SREC_TOOL}"
)
This runs AFTER the final zephyr elf file is created. Putting the post build commands in a separate cmake file provides the flexibility of customizing the post build steps by application, not by board.
Hi Einar,
Thank you for pointing me in the right direction. I'm not proficient in CMake so it's been a bit of a struggle. We have created a freestanding Zephyr project and have our own board file defined. In the CMakeLists.txt file in the board directory I added....
# Include post build instructions from build folder.
include(${APPLICATION_CONFIG_DIR}/postbuild.cmake)
Where APPLICATION_CONFIG_DIR is the folder where the application CMakeLists.txt file exists.
Then, in my application folder I created the postbuild.cmake file with the following contents...
set(CMAKE_SREC_TOOL "../../FileTools")
# Add post-build step after final zephyr application is created.
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
COMMAND "${APPLICATION_CONFIG_DIR}/../createappbin.bat" "${CMAKE_SREC_TOOL}"
)
This runs AFTER the final zephyr elf file is created. Putting the post build commands in a separate cmake file provides the flexibility of customizing the post build steps by application, not by board.