<?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>How to set nrf51 Read Back Protection using OpenOCD?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19538/how-to-set-nrf51-read-back-protection-using-openocd</link><description>Looking for the OpenOCD equivalent of &amp;quot;&amp;quot;nrfjprog --rbp all&amp;quot; 
 Looking at the commands for OpenOCD they have a &amp;quot;flash protect&amp;quot; command, but it doesn&amp;#39;t appear that&amp;#39;s quite the same thing (requests regions of flash). 
 Any assistance for a OpenOCD newbie</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 14 Feb 2017 23:49:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19538/how-to-set-nrf51-read-back-protection-using-openocd" /><item><title>RE: How to set nrf51 Read Back Protection using OpenOCD?</title><link>https://devzone.nordicsemi.com/thread/75945?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2017 23:49:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0723c37c-49d0-4ead-991e-670ca141f327</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;You can use the &lt;a href="http://embeddedsoftdev.blogspot.ca/p/idap-link.html"&gt;IDAP-Link&lt;/a&gt;. It will do all that for without needing to do any concatenation of hex and multiboards in parallel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set nrf51 Read Back Protection using OpenOCD?</title><link>https://devzone.nordicsemi.com/thread/75944?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2017 22:55:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:354c8a94-31ff-41e4-938b-6d66ec01f333</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Hello Jerod,&lt;/p&gt;
&lt;p&gt;Indeed you cannot program that HEX file separately, programmer will complain that chip isn&amp;#39;t erased. You need to do the same as with SoftDevice and Application: concatenate the thing into one blob and program it at once. I&amp;#39;m using PyOCD on Windows, will try to get some example tomorrow... but honestly, this is rather question to OpenOCD community (= how to flash three binaries at once or how to write particular flash byte/word after chip is programmed). You can also seak help at @hnhoan &amp;#39;s &lt;a href="http://embeddedsoftdev.blogspot.cz/p/idap-link.html"&gt;blog&lt;/a&gt;, he seems to be using ST-Link and OpenOCD on nRF5x chips routinely.&lt;/p&gt;
&lt;p&gt;Cheers Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set nrf51 Read Back Protection using OpenOCD?</title><link>https://devzone.nordicsemi.com/thread/75942?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2017 20:40:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1d79553-4a92-4d78-9411-6682f4abdd9c</guid><dc:creator>Jerod</dc:creator><description>&lt;p&gt;Still not able to get us to a state of read back protected files.&lt;/p&gt;
&lt;p&gt;Using OpenOCD, one cannot write your hex file after SoftDevice and Program are written.&lt;/p&gt;
&lt;p&gt;Here is the command and output:&lt;/p&gt;
&lt;p&gt;D:\OpenOCD\bin&amp;gt;openocd.exe -f ../scripts/interface/stlink-v2.cfg -f &amp;quot;C:\Program Files\GNU ARM Eclipse\OpenOCD\0.10.0-201701241841\scripts\target\nrf51.cfg&amp;quot; -s ..\share\openocd\scripts -c &amp;quot;init&amp;quot; -c &amp;quot;halt&amp;quot; -c &amp;quot;nrf51 mass_erase 0&amp;quot;  -c &amp;quot;program sd.hex verify&amp;quot; -c &amp;quot;program myprogram.hex verify&amp;quot; -c &amp;quot;program nrf51822_UICR_lock.hex verify&amp;quot; -c &amp;quot;reset&amp;quot; -c &amp;quot;exit&amp;quot;&lt;/p&gt;
&lt;code&gt;
Open On-Chip Debugger 0.9.0 (2016-09-01) [https://github.com/sysprogs/openocd]
&lt;p&gt;Licensed under GNU GPL v2&lt;/p&gt;
&lt;p&gt;For bug reports, read&lt;/p&gt;
&lt;p&gt;&lt;a href="http://openocd.org/doc/doxygen/bugs.html"&gt;openocd.org/.../bugs.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Info : auto-selecting first available session transport &amp;quot;hla_swd&amp;quot;. To override use &amp;#39;transport select &amp;#39;.&lt;/p&gt;
&lt;p&gt;Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD&lt;/p&gt;
&lt;p&gt;adapter speed: 1000 kHz&lt;/p&gt;
&lt;p&gt;Info : Unable to match requested speed 1000 kHz, using 950 kHz&lt;/p&gt;
&lt;p&gt;Info : Unable to match requested speed 1000 kHz, using 950 kHz&lt;/p&gt;
&lt;p&gt;Info : clock speed 950 kHz&lt;/p&gt;
&lt;p&gt;Info : STLINK v2 JTAG v23 API v2 SWIM v4 VID 0x0483 PID 0x3748&lt;/p&gt;
&lt;p&gt;Info : using stlink api v2&lt;/p&gt;
&lt;p&gt;Info : Target voltage: 3.172668&lt;/p&gt;
&lt;p&gt;Info : nrf51.cpu: hardware has 4 breakpoints, 2 watchpoints&lt;/p&gt;
&lt;p&gt;Info : nRF51822-QFAA(build code: E0) 256kB Flash&lt;/p&gt;
&lt;p&gt;nrf51.cpu: target state: halted&lt;/p&gt;
&lt;p&gt;target halted due to debug-request, current mode: Thread xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc&lt;/p&gt;
&lt;p&gt;** Programming Started **&lt;/p&gt;
&lt;p&gt;auto erase enabled&lt;/p&gt;
&lt;p&gt;Info : Padding image section 0 with 2112 bytes&lt;/p&gt;
&lt;p&gt;Warn : using fast async flash loader. This is currently supported&lt;/p&gt;
&lt;p&gt;Warn : only with ST-Link and CMSIS-DAP. If you have issues, add&lt;/p&gt;
&lt;p&gt;Warn : &amp;quot;set WORKAREASIZE 0&amp;quot; before sourcing nrf51.cfg to disable it&lt;/p&gt;
&lt;p&gt;nrf51.cpu: target state: halted&lt;/p&gt;
&lt;p&gt;target halted due to breakpoint, current mode: Thread&lt;/p&gt;
&lt;p&gt;xPSR: 0x61000000 pc: 0x2000001e msp: 0xfffffffc&lt;/p&gt;
&lt;p&gt;wrote 93184 bytes from file sd.hex in 4.006389s (22.714 KiB/s)&lt;/p&gt;
&lt;p&gt;** Programming Finished **&lt;/p&gt;
&lt;p&gt;** Verify Started **&lt;/p&gt;
&lt;p&gt;nrf51.cpu: target state: halted&lt;/p&gt;
&lt;p&gt;target halted due to breakpoint, current mode: Thread&lt;/p&gt;
&lt;p&gt;xPSR: 0x61000000 pc: 0x2000002e msp: 0xfffffffc&lt;/p&gt;
&lt;p&gt;nrf51.cpu: target state: halted&lt;/p&gt;
&lt;p&gt;target halted due to breakpoint, current mode: Thread&lt;/p&gt;
&lt;p&gt;xPSR: 0x61000000 pc: 0x2000002e msp: 0xfffffffc&lt;/p&gt;
&lt;p&gt;verified 90328 bytes in 0.636024s (138.691 KiB/s)&lt;/p&gt;
&lt;p&gt;** Verified OK **&lt;/p&gt;
&lt;p&gt;nrf51.cpu: target state: halted&lt;/p&gt;
&lt;p&gt;target halted due to debug-request, current mode: Thread&lt;/p&gt;
&lt;p&gt;xPSR: 0xc1000000 pc: 0x000006d0 msp: 0x000007c0&lt;/p&gt;
&lt;p&gt;** Programming Started **&lt;/p&gt;
&lt;p&gt;auto erase enabled&lt;/p&gt;
&lt;p&gt;Warn : using fast async flash loader. This is currently supported&lt;/p&gt;
&lt;p&gt;Warn : only with ST-Link and CMSIS-DAP. If you have issues, add&lt;/p&gt;
&lt;p&gt;Warn : &amp;quot;set WORKAREASIZE 0&amp;quot; before sourcing nrf51.cfg to disable it&lt;/p&gt;
&lt;p&gt;nrf51.cpu: target state: halted&lt;/p&gt;
&lt;p&gt;target halted due to breakpoint, current mode: Thread&lt;/p&gt;
&lt;p&gt;xPSR: 0x61000000 pc: 0x2000001e msp: 0x000007c0&lt;/p&gt;
&lt;p&gt;Warn : Adding extra erase range, 00000000 to 0x00000013&lt;/p&gt;
&lt;p&gt;Warn : using fast async flash loader. This is currently supported&lt;/p&gt;
&lt;p&gt;Warn : only with ST-Link and CMSIS-DAP. If you have issues, add&lt;/p&gt;
&lt;p&gt;Warn : &amp;quot;set WORKAREASIZE 0&amp;quot; before sourcing nrf51.cfg to disable it&lt;/p&gt;
&lt;p&gt;nrf51.cpu: target state: halted&lt;/p&gt;
&lt;p&gt;target halted due to breakpoint, current mode: Thread&lt;/p&gt;
&lt;p&gt;xPSR: 0x61000000 pc: 0x2000001e msp: 0x000007c0&lt;/p&gt;
&lt;p&gt;wrote 14572 bytes from file myprogram.hex in 0.822974s (17.292 KiB/s)&lt;/p&gt;
&lt;p&gt;** Programming Finished **&lt;/p&gt;
&lt;p&gt;** Verify Started **&lt;/p&gt;
&lt;p&gt;nrf51.cpu: target state: halted&lt;/p&gt;
&lt;p&gt;target halted due to breakpoint, current mode: Thread&lt;/p&gt;
&lt;p&gt;xPSR: 0x61000000 pc: 0x2000002e msp: 0x000007c0&lt;/p&gt;
&lt;p&gt;verified 14252 bytes in 0.143640s (96.895 KiB/s)&lt;/p&gt;
&lt;p&gt;** Verified OK **&lt;/p&gt;
&lt;p&gt;nrf51.cpu: target state: halted&lt;/p&gt;
&lt;p&gt;target halted due to debug-request, current mode: Thread&lt;/p&gt;
&lt;p&gt;xPSR: 0xc1000000 pc: 0x000006d0 msp: 0x000007c0&lt;/p&gt;
&lt;p&gt;** Programming Started **&lt;/p&gt;
&lt;p&gt;auto erase enabled&lt;/p&gt;
&lt;p&gt;Error: The chip was not pre-programmed with SoftDevice stack and UICR cannot be erased
separately. Please issue mass erase before trying to write to this region&lt;/p&gt;
&lt;p&gt;Error: failed erasing sectors 0 to 0&lt;/p&gt;
&lt;p&gt;embedded:startup.tcl:454: Error: ** Programming Failed **&lt;/p&gt;
&lt;p&gt;in procedure &amp;#39;program&amp;#39;&lt;/p&gt;
&lt;p&gt;in procedure &amp;#39;program_error&amp;#39; called at file &amp;quot;embedded:startup.tcl&amp;quot;, line 510&lt;/p&gt;
&lt;p&gt;at file &amp;quot;embedded:startup.tcl&amp;quot;, line 454&lt;/p&gt;
&lt;/code&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set nrf51 Read Back Protection using OpenOCD?</title><link>https://devzone.nordicsemi.com/thread/75943?ContentTypeID=1</link><pubDate>Fri, 10 Feb 2017 08:49:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cce472e1-9ec5-4ba8-89aa-007d5eb1e46a</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;I&amp;#39;m adding HEX file to my answer which should solve your problem. I suppose you can flash HEX with OpenODC (e.g. by using &amp;quot;&lt;code&gt;-i&lt;/code&gt;&amp;quot; option in &amp;quot;&lt;code&gt;flash_nrf51822.py&lt;/code&gt;&amp;quot;).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set nrf51 Read Back Protection using OpenOCD?</title><link>https://devzone.nordicsemi.com/thread/75941?ContentTypeID=1</link><pubDate>Fri, 10 Feb 2017 03:07:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94d0d710-72a0-4e46-ab1b-e26d2e904f66</guid><dc:creator>Jerod</dc:creator><description>&lt;p&gt;Technically, the question hasn&amp;#39;t been answered; still looking for the way to do this in OpenOCD. I will hunt down the proper command(s) and post here before closing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set nrf51 Read Back Protection using OpenOCD?</title><link>https://devzone.nordicsemi.com/thread/75939?ContentTypeID=1</link><pubDate>Thu, 09 Feb 2017 09:40:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:220647d9-0a27-43a6-a4d1-5b5e5551043d</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Cool. Are you able to use single word write in OpenOCD and verify that it works? Could you then close the case or give me a feedback what&amp;#39;s missing? Thx&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set nrf51 Read Back Protection using OpenOCD?</title><link>https://devzone.nordicsemi.com/thread/75940?ContentTypeID=1</link><pubDate>Thu, 09 Feb 2017 00:36:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3dbd99a9-a08b-4b7d-b557-12918d30926f</guid><dc:creator>Jerod</dc:creator><description>&lt;p&gt;Thanks. I was unaware of the security hole!  I was trying to learn a little more about OpenOCD and nrf support to see how the two work together -- as the majority of guides seem to stick to the basic, wipe, program, reset capabilities.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set nrf51 Read Back Protection using OpenOCD?</title><link>https://devzone.nordicsemi.com/thread/75938?ContentTypeID=1</link><pubDate>Wed, 08 Feb 2017 08:30:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfb92af9-72cc-4b8b-834c-6eea9ef8806f</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Hi Jerod,&lt;/p&gt;
&lt;p&gt;Simply write &lt;code&gt;0xFFFF00FF&lt;/code&gt; to &lt;code&gt;UICR-&amp;gt;RBCONF&lt;/code&gt; register which resides on address &lt;code&gt;0x100010004&lt;/code&gt;. To be precise you should read it out and mask with that value (to preserve &lt;code&gt;PR0&lt;/code&gt; register part on the least significant byte of the register in case it is used). Also make sure what endian OpenOCD use to code raw 32-bit hexadecimal values when writing to the memory. In the end reset the target and memory should be protected.&lt;/p&gt;
&lt;p&gt;Btw. you can easily do this from within the FW code to be sure that you don&amp;#39;t forget this in production and also note that nRF51 has major security hole in read-back protection and debugging interface so doing &lt;code&gt;RBALL&lt;/code&gt; is rather cosmetic thing which saves you against people who cannot use Google search.&lt;/p&gt;
&lt;p&gt;Cheers Jan&lt;/p&gt;
&lt;h2&gt;Edit 10-Feb-2017&lt;/h2&gt;
&lt;p&gt;Here is HEX file which writes &lt;code&gt;RBALL&lt;/code&gt; to &lt;code&gt;UICR-&amp;gt;RBCONF&lt;/code&gt; on any nRF51 variant. It can be flashed by any tool including OpenOCD. Can be stripped down to single register write (with little bit of work with GCC tools or similar) but normally it isn&amp;#39;t needed.&lt;/p&gt;
&lt;p&gt;Cheers Jan&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/nrf51822_5F00_UICR_5F00_lock.hex"&gt;nrf51822_UICR_lock.hex&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>