<?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>Flash SoftDevice and then an app using JLink?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9695/flash-softdevice-and-then-an-app-using-jlink</link><description>Hello everyone, 
 Please forgive my continued naive questions. This is my first embedded-systems project. 
 I have been working with an nRF52 development board and SDK 0.9.1 for several weeks. I have applications talking to the USB interface. My development</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 26 Oct 2015 23:58:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9695/flash-softdevice-and-then-an-app-using-jlink" /><item><title>RE: Flash SoftDevice and then an app using JLink?</title><link>https://devzone.nordicsemi.com/thread/35872?ContentTypeID=1</link><pubDate>Mon, 26 Oct 2015 23:58:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aab44f42-c7e2-46f7-83d5-162c458de37c</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;That doesn&amp;#39;t really make sense as lots of people flash the softdevice first and the user code afterwards. Moreover, a very standard and working practice is to flash the softdevice &lt;em&gt;once&lt;/em&gt; and flash the user code constantly for each debugging iteration. That all works perfectly, rewriting the user code every time and leaving the softdevice alone. JLink just erases the pages it needs to use and then uploads the new code to them, it doesn&amp;#39;t touch flash in the rest of the chip.&lt;/p&gt;
&lt;p&gt;There could be something different about JLinkExe on Linux, but that really doesn&amp;#39;t seem likely.&lt;/p&gt;
&lt;p&gt;You should be able to see what&amp;#39;s going on by loading the files in the &amp;#39;wrong&amp;#39; order and then dumping out the memory contents back from the chip using JLink and verifying what you see.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash SoftDevice and then an app using JLink?</title><link>https://devzone.nordicsemi.com/thread/35871?ContentTypeID=1</link><pubDate>Mon, 26 Oct 2015 22:21:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e87535f4-72e2-4375-9cb4-2909e60025a3</guid><dc:creator>Ladasky</dc:creator><description>&lt;p&gt;I don&amp;#39;t know if anyone is still following this discussion, but I discovered the solution to my problem.  If the application code is flashed BEFORE the SoftDevice, everything works!  Like this:&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;J-Link&amp;gt;loadfile ble_app_template_s132.bin 0x1f000&lt;/p&gt;
&lt;p&gt;[no errors]&lt;/p&gt;
&lt;p&gt;J-Link&amp;gt;loadfile s132_nrf52_softdevice.hex 0&lt;/p&gt;
&lt;p&gt;[no errors]&lt;/p&gt;
&lt;p&gt;J-Link&amp;gt;r&lt;/p&gt;
&lt;p&gt;[no errors]&lt;/p&gt;
&lt;p&gt;J-Link&amp;gt;go&lt;/p&gt;
&lt;p&gt;[no errors]&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;This makes me wonder exactly how memory is being erased by JLink.  Is JLink&amp;#39;s default procedure to erase every memory address from the highest address needed by the program, down to 0?  When I had the order reversed, it is possible that I was just erasing the SoftDevice after loading it.&lt;/p&gt;
&lt;p&gt;My development platform is Linux-based. Until recently, nrfjprog was apparently unavailable on Linux.  I just downloaded the Linux version of nrfjprog, and I now will try it.  I was unable to use the Nordic makefiles to flash the board without nrfjprog.  Loading order may be unimportant when nrfjprog is used, because I can see in the makefile that specific ranges of memory are selected for erasure.  I do not specify the erased memory range when using JLink -- indeed, I don&amp;#39;t know whether it&amp;#39;s even possible.  Time to RTFM.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash SoftDevice and then an app using JLink?</title><link>https://devzone.nordicsemi.com/thread/35870?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2015 04:28:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91a39cf9-4752-4129-859c-c543dbf4e80d</guid><dc:creator>Ladasky</dc:creator><description>&lt;p&gt;Thanks again, RK.  I am sure that there are better ways of me getting my work done than I am currently using.  The boss wants to see Bluetooth ASAP.  I will work on building a better work environment when the time pressure is off.  Also, I don&amp;#39;t get to keep the Apple laptop, it was just lent to me for Bluetooth sensing.  Thanks anyway for offering your RKnRFGo software.  If I could get it running on my Linux development box... :^)&lt;/p&gt;
&lt;p&gt;I like your idea of building Blinky in a way that it co-habitates in memory with the SoftDevice, even though it wouldn&amp;#39;t actually activate Bluetooth.  At least I could see that the SoftDevice was handing off to the application.  I already tried doing that, so I thought, with my attempt to communicate with SEGGER RTT.  I&amp;#39;m willing to try another approach.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash SoftDevice and then an app using JLink?</title><link>https://devzone.nordicsemi.com/thread/35869?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2015 01:29:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:889326d3-f3ac-466e-b8c3-a08aa9e4d75f</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;... there&amp;#39;s a pca10038/blank subdir. Add a pca10038/s132 subdir and populate it with an armgcc directory with the s132 ld file in it. That should build a blinky at 0x1f000, try that with the softdevice, try the bare board one too, if you can get those to work then you can at least be confident in the upload process.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash SoftDevice and then an app using JLink?</title><link>https://devzone.nordicsemi.com/thread/35868?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2015 01:26:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb13be46-4f47-4e25-8fb1-543f7d85104e</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;All had to start somewhere - I began this stuff about 2 years ago and spent at least the first 3 months looking permanently dazed. Debugging with JLinkExe is not very easy, you can do it, but it&amp;#39;s just hard, so getting an environment set up, even if it takes time and it does, pays back quickly.&lt;/p&gt;
&lt;p&gt;Another idea for you - you said you have an Apple laptop - you could grab this &lt;a href="https://sourceforge.net/projects/rknrfgo/"&gt;sourceforge.net/.../&lt;/a&gt;, install JLink on the mac, copy the softdevice and code files over and use that to upload them to the board. That removes one variable from the process as rknrfgo usually puts things in the right place.&lt;/p&gt;
&lt;p&gt;Nordic usually provides a blinky which builds for a softdevice, for some reason they don&amp;#39;t for the nrf52 DK.  What you could try is going to the current blinky example ... &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash SoftDevice and then an app using JLink?</title><link>https://devzone.nordicsemi.com/thread/35867?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2015 01:09:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51cbdaa4-1d44-4d8b-87ed-fd57729237b1</guid><dc:creator>Ladasky</dc:creator><description>&lt;p&gt;Hi, RK, thanks for staying with me.  I did not modify the Nordic linker files for the applications in any way. Apps which don&amp;#39;t use a SoftDevice (at least, the ones I have looked at) are allocated memory as follows:&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;SEARCH_DIR(.)&lt;/p&gt;
&lt;p&gt;GROUP(-lgcc -lc -lnosys)&lt;/p&gt;
&lt;p&gt;MEMORY&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000&lt;/p&gt;
&lt;p&gt;RAM (rwx) :  ORIGIN = 0x20000000, LENGTH = 0x8000&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;INCLUDE &amp;quot;nrf5x_common.ld&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;And the BLE apps linker files look like this:&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;SEARCH_DIR(.)&lt;/p&gt;
&lt;p&gt;GROUP(-lgcc -lc -lnosys)&lt;/p&gt;
&lt;p&gt;MEMORY&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000&lt;/p&gt;
&lt;p&gt;RAM (rwx) :  ORIGIN = 0x20002800, LENGTH = 0x5800&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;INCLUDE &amp;quot;nrf5x_common.ld&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Concerning debugging: as I mentioned, I&amp;#39;m new to embedded systems.  I haven&amp;#39;t even needed a debugger yet, although I planned to use gdb.  I will investigate the registers as you suggested.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash SoftDevice and then an app using JLink?</title><link>https://devzone.nordicsemi.com/thread/35866?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2015 00:12:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f171e17-9287-4484-a7a8-6ec093c41393</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;As long as you compiled the code for 0x1f000, that&amp;#39;s the correct sequence for getting the softdevice and code onto the chip. Do you have a better way of debugging than RTT and JLink, even gdbserver is better than that.&lt;/p&gt;
&lt;p&gt;If not then try ```halt&lt;code&gt;,&lt;/code&gt;regs`` to see where you&amp;#39;ve ended up. Or set a breakpoint in your code using JLink.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash SoftDevice and then an app using JLink?</title><link>https://devzone.nordicsemi.com/thread/35865?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 23:34:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93f0f135-1199-43ad-b9ba-562f3c44b0d8</guid><dc:creator>Ladasky</dc:creator><description>&lt;p&gt;Here is a modestly-abbreviated transcript of my JLink session:&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;BashPrompt$ JLinkExe -device nRF52&lt;/p&gt;
&lt;p&gt;SEGGER J-Link Commander V5.02c (&amp;#39;?&amp;#39; for help)&lt;/p&gt;
&lt;p&gt;[...]&lt;/p&gt;
&lt;p&gt;Cortex-M4 identified.&lt;/p&gt;
&lt;p&gt;Target interface speed: 100 kHz&lt;/p&gt;
&lt;p&gt;J-Link&amp;gt;loadfile s132_nrf52_softdevice.hex 0 [yes, I shortened the SoftDevice file name]&lt;/p&gt;
&lt;p&gt;[no errors]&lt;/p&gt;
&lt;p&gt;J-Link&amp;gt;loadfile ble_app_template_s132.bin 0x1f000&lt;/p&gt;
&lt;p&gt;[no errors]&lt;/p&gt;
&lt;p&gt;J-Link&amp;gt;r&lt;/p&gt;
&lt;p&gt;[no errors]&lt;/p&gt;
&lt;p&gt;J-Link&amp;gt;go&lt;/p&gt;
&lt;p&gt;[no errors]&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Nothing ever happens.&lt;/p&gt;
&lt;p&gt;I have a modified ble_app_template which includes SEGGER_WriteString statements. They should print to JLinkRTTClient when main() first starts, and when it&amp;#39;s about to enter the power management loop.  Nothing prints.  My other applications which talk to JLinkRTTClient are working fine.&lt;/p&gt;
&lt;p&gt;This makes me think that the SoftDevice is never jumping to my application&amp;#39;s own code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash SoftDevice and then an app using JLink?</title><link>https://devzone.nordicsemi.com/thread/35864?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 21:53:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a1ae870-ba25-422e-b44b-0bde166e8f4a</guid><dc:creator>Ladasky</dc:creator><description>&lt;p&gt;Thanks for your reply, RK.  I believe that I flashed the S132 SoftDevice .hex file to 0x0, and the Beacon app to 0x1F000, but I&amp;#39;ve seen nothing so far.&lt;/p&gt;
&lt;p&gt;Upon doing some further reading, I can see that a &amp;quot;beacon&amp;quot; means something very specific in Bluetooth terms.  I believe that I am only interested in my nRF52 board &amp;quot;advertising&amp;quot; its existence at this stage.  I have also tried to compile and flash ble_app_template as above.  I am still not seeing anything.&lt;/p&gt;
&lt;p&gt;I am currently seeking to modify ble_app_template to show that it&amp;#39;s actually running (adding some blinking LEDs, or SEGGER RTT output to the USB port).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash SoftDevice and then an app using JLink?</title><link>https://devzone.nordicsemi.com/thread/35863?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2015 06:22:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4a51755-ed0f-4235-b8e3-42947ff9d6f0</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;The softdevice goes at 0x00000000 and your code is flashed at whatever the correct code address is for the softdevice you&amp;#39;re using, which is in the softdevice spec. It&amp;#39;s the address you built the code to run at. In the case of the S132 V1 alpha that&amp;#39;s 0x1f000. That address is in the ble_app_beacon_gcc_nrf52.ld file you used to build the code.&lt;/p&gt;
&lt;p&gt;And you have it backwards, the softdevice, which is at 0x00000000 is the code the chip starts running on boot, because that&amp;#39;s where the default vector table is. When it&amp;#39;s set itself up, it reads the vector table at 0x1f000, the defined address for your user code, and jumps to the reset_handler who&amp;#39;s address is at 0x1f004. The user code never really calls the softdevice except via SVC calls which are handled by the softdevice&amp;#39;s SVC interrupt handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>