<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Post build step building a Zephyr application</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/90917/post-build-step-building-a-zephyr-application</link><description>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.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 15 Aug 2022 15:45:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/90917/post-build-step-building-a-zephyr-application" /><item><title>RE: Post build step building a Zephyr application</title><link>https://devzone.nordicsemi.com/thread/381625?ContentTypeID=1</link><pubDate>Mon, 15 Aug 2022 15:45:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa8a98ce-5d54-472d-ba85-b7af2dc45570</guid><dc:creator>kpreiss</dc:creator><description>&lt;p&gt;Hi Einar,&lt;br /&gt;&lt;br /&gt;Thank you for pointing me in the right direction.&amp;nbsp; I&amp;#39;m not proficient in CMake so it&amp;#39;s been a bit of a struggle.&amp;nbsp; We have created a freestanding Zephyr project and have our own board file defined.&amp;nbsp; In the CMakeLists.txt file in the board directory I added....&lt;br /&gt;&lt;br /&gt;# Include post build instructions from build folder.&lt;br /&gt;include(${APPLICATION_CONFIG_DIR}/postbuild.cmake)&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Where APPLICATION_CONFIG_DIR is the folder where the application CMakeLists.txt file exists.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then, in my application folder I created the postbuild.cmake file with the following contents...&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;set(CMAKE_SREC_TOOL &amp;quot;../../FileTools&amp;quot;)&lt;/p&gt;
&lt;p&gt;# Add post-build step after final zephyr application is created.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;set_property(GLOBAL APPEND PROPERTY extra_post_build_commands&lt;br /&gt; COMMAND &amp;quot;${APPLICATION_CONFIG_DIR}/../createappbin.bat&amp;quot; &amp;quot;${CMAKE_SREC_TOOL}&amp;quot;&lt;br /&gt; )&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This runs AFTER the final zephyr elf file is created.&amp;nbsp; Putting the post build commands in a separate cmake file provides the flexibility of customizing the post build steps by application, not by board.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Post build step building a Zephyr application</title><link>https://devzone.nordicsemi.com/thread/381465?ContentTypeID=1</link><pubDate>Mon, 15 Aug 2022 06:57:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6777e4c3-c3d5-416b-8836-653ef6ef7667</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;There are quite a few example of it, I suggest you search for &amp;quot;&lt;span&gt;&lt;code&gt;extra_post_build_commands&lt;/code&gt;&amp;quot; in the SDK code base an&lt;/span&gt;d look at some of the the CMakeLists.txt files that use it.&lt;/p&gt;
&lt;p&gt;A more or less random example is from zephyr\boards\arm\faze\CMakeLists.txt:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;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}
  )&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Post build step building a Zephyr application</title><link>https://devzone.nordicsemi.com/thread/381395?ContentTypeID=1</link><pubDate>Fri, 12 Aug 2022 13:57:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a061851-c237-4829-b846-0500861421d5</guid><dc:creator>kpreiss</dc:creator><description>&lt;p&gt;No, I have not looked into this.&amp;nbsp; Are there any examples of using this with a Zephyr build?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Post build step building a Zephyr application</title><link>https://devzone.nordicsemi.com/thread/381363?ContentTypeID=1</link><pubDate>Fri, 12 Aug 2022 12:46:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6310bf8-8efe-4152-b5bd-d2ca3b65ce3f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have you looked at&amp;nbsp;&lt;code&gt;extra_post_build_commands&lt;/code&gt;? That is the closest I can think of.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>