<?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>Programming nRF52 using nrfjprog for use in Arduino</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72112/programming-nrf52-using-nrfjprog-for-use-in-arduino</link><description>I want to get started with nRF52832 in Arduino. I have a Ebyte development board with E73 module containing the NRF chip. 
 The hardware is quite similar to Adafruit NRF52 Feather. 
 But for use in Arduino with serial interface I have to program the boot</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 28 Feb 2021 16:22:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72112/programming-nrf52-using-nrfjprog-for-use-in-arduino" /><item><title>RE: Programming nRF52 using nrfjprog for use in Arduino</title><link>https://devzone.nordicsemi.com/thread/296708?ContentTypeID=1</link><pubDate>Sun, 28 Feb 2021 16:22:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef4e49db-5931-4bdc-acbb-faa99dd77be6</guid><dc:creator>Andreas52</dc:creator><description>&lt;p&gt;Solved it in the meantime. The solution is to follow the decription below and use a raspberry Pi to avoid any interface.&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;&lt;a href="http://forum.espruino.com/conversations/335722/"&gt;http://forum.espruino.com/conversations/335722/&lt;/a&gt;&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;But this description is missing the recovery for protected boards. Funny that this worked with upgraded St-Link 2.1, but nrfjprog could not program the chip after recovery. Maybe this is blocked by Segger.&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;It would be better if Nordic would support an openOCD workflow with tutorials for new users, to have an easy start and avoid initial frustration.&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;Script for openOCD to replace&amp;nbsp;nrfjprog -f NRF52 --recover :&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;# Read APPROTECTSTATUS &lt;br /&gt;# (0x0 Access port protection enabled - 0x1 APP disabled) &lt;br /&gt;nrf52832.dap apreg 1 0x0c 0x00000000&lt;br /&gt;# Write ERASEALL register&lt;br /&gt;nrf52832.dap apreg 1 0x04 0x01&lt;br /&gt;reset&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;Script for openOCD to program after recover:&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;# RPi Zero/v1 interface&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;interface bcm2835gpio&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;bcm2835gpio_peripheral_base 0x20000000&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;bcm2835gpio_speed_coeffs 113714 28&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;# RPi v2+ interface&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;# bcm2835gpio_peripheral_base 0x3F000000&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;# bcm2835gpio_speed_coeffs 146203 36&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;# Pins&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;bcm2835gpio_swd_nums 25 24&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;bcm2835gpio_srst_num 18&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;reset_config srst_only srst_push_pull&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;# Transport&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;transport select swd&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;# Target&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;set WORKAREASIZE 0&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;set CHIPNAME nrf52832&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;source [find target/nrf52.cfg]&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;reset_config srst_only srst_nogate&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;adapter_nsrst_delay 100&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;adapter_nsrst_assert_width 100&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;# Execution&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;init&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;targets&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;halt&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;nrf52832.dap apreg 1 0x04 0x01&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;flash write_image bootloader_nrf52832.hex&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;reset halt&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;targets&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;verify_image bootloader_nrf52832.hex&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;reset run&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;targets&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;exit&lt;/p&gt;
&lt;p style="margin-bottom:0cm;"&gt;# END OF SCRIPT&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>