<?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>Generating just the application hex file</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72072/generating-just-the-application-hex-file</link><description>Hi, 
 I am currently working on generating a dfu over serial uart by testing with the ble_app_blinky example given in the SDK 15.2.0. Currently the ble_app_blinky hex file contains both application and the softdevice. I want to be able to generate the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Feb 2021 22:18:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72072/generating-just-the-application-hex-file" /><item><title>RE: Generating just the application hex file</title><link>https://devzone.nordicsemi.com/thread/296664?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 22:18:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:079bab0f-c6bf-4d1a-81d9-d04580f5e5a1</guid><dc:creator>amarin</dc:creator><description>&lt;p&gt;Thank you so much! This really helps!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generating just the application hex file</title><link>https://devzone.nordicsemi.com/thread/296617?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 15:54:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3cf569b5-8b8e-4202-b887-f358b05a9228</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If you build the project yourself, then the generated hex file is the application only. That is probably the easiest solution.&lt;/p&gt;
&lt;p&gt;Alternatively, it is possible to locate within the hex file where the data for the application is located, and remove everything else. The rest of this answer describes how to do that.&lt;/p&gt;
&lt;p&gt;The hex file is a text file in the &lt;a href="https://en.wikipedia.org/wiki/Intel_HEX"&gt;Intel HEX format&lt;/a&gt;, and removing the SoftDevice can be done using any text editor if you know what you are doing.&lt;/p&gt;
&lt;p&gt;E.g. in nRF5_SDK_15.3.0_59ac345\examples\ble_peripheral\ble_app_blinky\hex\ble_app_blinky_pca10040_s132.hex, the first two lines are:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;:020000040000FA&lt;/code&gt;&lt;br /&gt;&lt;code&gt;:1000000000040020810A000015070000610A0000BA&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Splitting it up to better show the individual parts of those lines, they become:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;:02 0000 04 0000 FA&lt;/code&gt;&lt;br /&gt;&lt;code&gt;:10 0000 00 00040020810A000015070000610A0000 BA&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Everything is hexadecimal values.&lt;/p&gt;
&lt;p&gt;You can ignore most of the values. The important parts from those lines are:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;:## #### 04 0000 ##&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The record type &lt;code&gt;04&lt;/code&gt; means this is &amp;quot;Extended Segment Address&amp;quot;. The value (in this case &lt;code&gt;0000&lt;/code&gt;) should be added in front of any data addresses on the following lines.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;:## 0000 00 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ##&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This is address &lt;code&gt;0000&lt;/code&gt;, record type &amp;quot;Data&amp;quot; (&lt;code&gt;00&lt;/code&gt;). The full address is &lt;code&gt;00000000&lt;/code&gt;, as we need to put the extended segment address in front. The hexadecimal sequence (written as &lt;code&gt;xx..xx&lt;/code&gt; above) is placed at this address.&lt;/p&gt;
&lt;p&gt;So, as long as you know the start and end address of the SoftDevice, you can locate the &amp;quot;Data&amp;quot; lines for that data and remove it. The SoftDevice is always starting at address 0, and the size is described in the release notes (which you find under &amp;lt;sdk root folder&amp;gt;\components\softdevice\&amp;lt;softdevice variant&amp;gt;\doc\, where &amp;lt;softdevice variant&amp;gt; is e.g. s132 or s140.&lt;/p&gt;
&lt;p&gt;Following the example from above, using the s132 SoftDevice v6.1.1, we see from the SoftDevice release notes that it takes &lt;code&gt;0x26000&lt;/code&gt; bytes. This means removing the &amp;quot;data&amp;quot; lines from line 1 through line 9416 of the hex file (last line to remove is &lt;code&gt;:105140002A8608019F0916CB327F0B6CF410C00031&lt;/code&gt;). Note that we need to keep line 8115, which reads &lt;code&gt;:020000040002F8&lt;/code&gt;, as it sets the extended segment address to &lt;code&gt;0002&lt;/code&gt;. That is needed because the application start on address &lt;code&gt;00026000&lt;/code&gt;. Also note that in this case the last SoftDevice data line has (full) address &lt;code&gt;00025140&lt;/code&gt;, and there is a gap in address space before the first application data line with (full) address &lt;code&gt;00026000&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;There may be some other bytes also described in the hex file, for instance in the UICR area of flash. Particularly for DFU related hex files. Then you may have to remove lines related to that as well.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>