<?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>preparing a hex file to program in flash</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21901/preparing-a-hex-file-to-program-in-flash</link><description>Hello,
I am using nrf52832 board, with SDK 11.0.0 and s132_nrf52_2.0.0. and trying to program a 512 Bytes text file using nrfjprog (J-Link: JLinkExe) in flash.
The nrfjprog tool only allows a 4 Byte value write at a time to a an offset so I am trying</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 16 May 2017 00:40:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21901/preparing-a-hex-file-to-program-in-flash" /><item><title>RE: preparing a hex file to program in flash</title><link>https://devzone.nordicsemi.com/thread/85993?ContentTypeID=1</link><pubDate>Tue, 16 May 2017 00:40:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:845ec76f-1c54-41f1-bb0a-e1adbfe085ba</guid><dc:creator>Sal</dc:creator><description>&lt;p&gt;Thanks for your suggestion Hung. Unfortunately I do not have control over the central device.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: preparing a hex file to program in flash</title><link>https://devzone.nordicsemi.com/thread/85992?ContentTypeID=1</link><pubDate>Mon, 15 May 2017 07:59:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3bd9fdf2-18fa-4148-ae29-fd57cddebe02</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Sal, Thanks for the link, good to know the tool.&lt;/p&gt;
&lt;p&gt;If you have control on both side of the link (central + peripheral) you can hardcode the long term key (LTK) and re-use it when they connect. Just like what happens &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v3.0.0/group___b_l_e___g_a_p___c_e_n_t_r_a_l___e_n_c___m_s_c.html?cp=2_3_0_1_2_2_1_3_5_3"&gt;here&lt;/a&gt; on the central and &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v3.0.0/group___b_l_e___g_a_p___p_e_r_i_p_h___e_n_c___m_s_c.html?cp=2_3_0_1_2_2_1_3_8_5"&gt;here&lt;/a&gt; on the peripheral.&lt;/p&gt;
&lt;p&gt;However, this way of using hardcoded key is not very safe. Anyone who has physical access to your device can try to read the key (even if you block them from accessing the debug port, it&amp;#39;s possible to physically manipulate the chip and read the flash directly) or if you do DFU, they can read the DFU package that includes the key.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: preparing a hex file to program in flash</title><link>https://devzone.nordicsemi.com/thread/85990?ContentTypeID=1</link><pubDate>Fri, 12 May 2017 17:59:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:742266bb-96bd-404b-aa97-80d8bec8a651</guid><dc:creator>Sal</dc:creator><description>&lt;p&gt;Hi Hung,
Thank you for your help. The text file contains openssl key pair, base64 format. I used a hex converter to encode in hex (&lt;a href="http://tomeko.net/online_tools/base64.php)"&gt;tomeko.net/.../base64.php)&lt;/a&gt;. Then used the jlink loadbin command to load the file to an offset on the flash. After reading the file, looks to be okay, although endian converted and needs to be reverted back for authentication.&lt;/p&gt;
&lt;p&gt;I am using the openssl to authenticate my peripheral device when connecting to the central. I think it is not really designed for embedded applications. Looking at your comment, on a similar post here:
&lt;a href="https://devzone.nordicsemi.com/question/49190/tutorial-on-connection-encryption/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I am also not using device manager, and wondering if it would be possible to not use bonding and only write a key on flash (I am using pstorage) along with FW+BL+SD that on connection is read (with pstorage_load()?) and could be used to authenticate connection to a central device?&lt;/p&gt;
&lt;p&gt;Many thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: preparing a hex file to program in flash</title><link>https://devzone.nordicsemi.com/thread/85991?ContentTypeID=1</link><pubDate>Tue, 09 May 2017 09:23:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67c7dc62-4713-4bf4-b1e5-d6805a161358</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Sal,
I don&amp;#39;t think it would a simple way to convert a text file to binary/hex. You need to compile it or if it&amp;#39;s simply data (or keys), you need to state the address it going to be.&lt;/p&gt;
&lt;p&gt;What I would suggest is to try to read the address you want to put the data in on the flash using nrfjprog. And then use any editor that can edit hex (notepad++ for example) and edit the hex file you get to the data you need, you then need to calculate CRC according to &lt;a href="https://en.wikipedia.org/wiki/Intel_HEX"&gt;Intel Hex format&lt;/a&gt;. There is a CRC calculator here: &lt;a href="http://www.fischl.de/hex_checksum_calculator/"&gt;www.fischl.de/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Then you can use nrfjprog to flash it back to the chip.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: preparing a hex file to program in flash</title><link>https://devzone.nordicsemi.com/thread/85989?ContentTypeID=1</link><pubDate>Mon, 08 May 2017 19:52:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d44571d-c0f6-46ca-b8c7-d4c24f41224f</guid><dc:creator>Sal</dc:creator><description>&lt;p&gt;The file contains a RSA public/private keys.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>