<?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>Adjust firmware image by padding with FFs</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51984/adjust-firmware-image-by-padding-with-ffs</link><description>Hi, 
 I am sending firmware image using my DFU master. The image needs to be divided into data objects each of 4096 bytes and then those again into 244 byte BLE packets. So for ease of computation I wanted to adjust the image by padding with zeros so</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 27 Sep 2019 06:55:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51984/adjust-firmware-image-by-padding-with-ffs" /><item><title>RE: Adjust firmware image by padding with FFs</title><link>https://devzone.nordicsemi.com/thread/212180?ContentTypeID=1</link><pubDate>Fri, 27 Sep 2019 06:55:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ffbae08b-a57b-4003-b404-90d6cd8b888e</guid><dc:creator>bscdb</dc:creator><description>&lt;p&gt;Cool Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adjust firmware image by padding with FFs</title><link>https://devzone.nordicsemi.com/thread/212179?ContentTypeID=1</link><pubDate>Fri, 27 Sep 2019 06:53:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad72a618-34ec-41e7-9d68-4ff8b57e8cef</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;It&amp;#39;s safe to just use one hex for production. It does not bypass any security during normal boot. You can still have crc/signature boot validation of the app image.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adjust firmware image by padding with FFs</title><link>https://devzone.nordicsemi.com/thread/212178?ContentTypeID=1</link><pubDate>Fri, 27 Sep 2019 06:49:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b452c83-93e9-44dc-aaac-5b2b4135b350</guid><dc:creator>bscdb</dc:creator><description>&lt;p&gt;Yes I&amp;#39;ve used it. I thought that merging the settings page was only to enable debugging of the app firmware, meaning I thought it was to deliberately escape checks &amp;amp; allow loading the app firmware. Is my understanding wrong? Is it safe to use just one hex for production?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adjust firmware image by padding with FFs</title><link>https://devzone.nordicsemi.com/thread/212176?ContentTypeID=1</link><pubDate>Fri, 27 Sep 2019 06:45:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5483d57b-6ab4-41c5-9bc3-e109226ce1b2</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Have you tried the merge tool I linked to above? You also need to merge the bootloader settings page as noted in &amp;#39;appendix&amp;#39; 1 of this blog post:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/getting-started-with-nordics-secure-dfu-bootloader"&gt;https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/getting-started-with-nordics-secure-dfu-bootloader&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adjust firmware image by padding with FFs</title><link>https://devzone.nordicsemi.com/thread/212149?ContentTypeID=1</link><pubDate>Thu, 26 Sep 2019 23:47:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c28e2093-2a10-445a-bf68-48a120be18f9</guid><dc:creator>bscdb</dc:creator><description>&lt;p&gt;This is working.&lt;/p&gt;
&lt;p&gt;Because of this line -&amp;nbsp;ih_padding.puts(end_addr, &amp;quot;1&amp;quot;)&lt;/p&gt;
&lt;p&gt;I&amp;#39;m seeing 31 (ascii hex) written on the padding.hex file.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you also help me merge all the hex into one file, basically merging softdevice + bootloader + firmware?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adjust firmware image by padding with FFs</title><link>https://devzone.nordicsemi.com/thread/209457?ContentTypeID=1</link><pubDate>Thu, 12 Sep 2019 13:53:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d3c89a5-904e-4d22-93da-88884edd3789</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;It&amp;#39;s difficult to give exact steps since I&amp;#39;ve never done this. But did you try to use &amp;#39;0&amp;#39; instead of FFs for padding?&amp;nbsp;I guess that should prevent nrfutil from discarding it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve also made a quick attempt to create a python script that produces a &amp;quot;padding.hex&amp;quot; which you&amp;nbsp;can merge (&lt;a title="Merging files with mergehex" href="https://infocenter.nordicsemi.com/topic/ug_nrf5x_cltools/UG/cltools/nrf5x_mergehex.html?cp=6_1_2"&gt;Merging files with mergehex&lt;/a&gt;) with the application hex file before generating the DFU package.&amp;nbsp;It appears to be working correctly here, but please verify it on your side if you end up using it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-b56bdb67483f416db52b87bc5e551d28/padding.py"&gt;devzone.nordicsemi.com/.../padding.py&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Testing the script:&lt;/p&gt;
&lt;p&gt;1. Make sure you have the intelhex module installed in Python. Then pass the hex file&amp;nbsp;as an argument to padding.py: padding.py &amp;lt;application&amp;gt;.hex&lt;/p&gt;
&lt;p&gt;2. This should generate a new hex file named padding.hex that you can append to the application file&amp;nbsp;with mergehex: merghex -m &amp;lt;application&amp;gt;.hex padding.hex -o merged.hex&lt;/p&gt;
&lt;p&gt;3. Now to verify that&amp;nbsp;this doesn&amp;#39;t alter your program code or data. 1. l&lt;span style="font-family:inherit;"&gt;oad the merged hex file with nrfjprog: nrfjprog --program merged.hex --chiperase. 2. read back the data again : nrfjprog --memrd 0x0 --n &amp;lt;size of flash in bytes&amp;gt; &amp;gt; flash_content_w_padding.txt&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;4.Repeat step 3 but with the original application.hex and dump the flash content to a new text file&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;5. Compare the two text files with a diff tool, etc to verify that they&amp;#39;re identical except for the padding at the end.&lt;/span&gt;&lt;/p&gt;
[quote user="bop123"] My guess is the page size is 4096 bytes. [/quote]
&lt;p&gt;That is correct, they&amp;#39;re 4096 bytes for&amp;nbsp;all 52 variants.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adjust firmware image by padding with FFs</title><link>https://devzone.nordicsemi.com/thread/209213?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2019 14:05:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b6390fd-8028-4876-9e98-687f0fc5c515</guid><dc:creator>bscdb</dc:creator><description>&lt;p&gt;Could you please elaborate with exact steps? My guess is the page size is 4096 bytes. I adjusted my app.hex accordingly but when creating FW.zip, it automatically discards all those FFs. Obviously padding app.bin did not work. My DFU master sends the app.bin &amp;amp; app.dat from FW.zip.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adjust firmware image by padding with FFs</title><link>https://devzone.nordicsemi.com/thread/209187?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2019 13:11:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd594d6d-fcfa-4587-bd6c-11c89f2e6bb7</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;As you said, DFU hash validation will fail if you add padding after creating you&amp;#39;ve created the init packet. However, nrfutil should work with *.bin files. So you can use the padded binary file when you generate the packet. I guess that&amp;#39;s the easiest approach. Another option is to add padding to the hex file to ensure that the data always end at a page-aligned address.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>