<?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>nRF bootloader runs into HardFault</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/10005/nrf-bootloader-runs-into-hardfault</link><description>I&amp;#39;d like to run a softdevice application with OTA support on a RIGADO BMD-200 Evaluation board . I&amp;#39;ve successfully flashed the softdevice, the app, and the rigado bootloader, with rigado&amp;#39;s program.py from the rigado bootloader-tools. 
 Now I want to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 29 Mar 2017 21:39:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/10005/nrf-bootloader-runs-into-hardfault" /><item><title>RE: nRF bootloader runs into HardFault</title><link>https://devzone.nordicsemi.com/thread/37071?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2017 21:39:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0865f121-d3e1-4d4e-9944-9ba1aa774d29</guid><dc:creator>arthare</dc:creator><description>&lt;p&gt;I was having identical symptoms to liszi, but a different fix.&lt;/p&gt;
&lt;p&gt;My setup:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;PCA10036 devkit with a 2015.40 stamp on it.&lt;/li&gt;
&lt;li&gt;Used ARM GCC toolchain to compile the blinky app from the 12.0 SDK (it was originally for PCA10040, but I changed all references to PCA10036)&lt;/li&gt;
&lt;li&gt;When I used keil to flash the devkit with the exact same blinky code, it worked.  When I used &lt;code&gt;make flash&lt;/code&gt; to do it, the thing would never boot&lt;/li&gt;
&lt;li&gt;So I debugged with jlink, stepping one instruction at a time, and found that the &lt;code&gt;bl SystemInit&lt;/code&gt; in gcc_startup_nrf52.s seemed to cause it to go to hardfault.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;My fix:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Stop using my ancient devkit.  I have a bunch of BMD-300s, so I programmed one of those and the exact same .hex that had been hardfaulting on the devkit worked.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Implied root causes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Devkit was ancient&lt;/li&gt;
&lt;li&gt;.hex was being compiled for the wrong CPU revision (seems unlikely to me, because Keil was still able to make a working .hex)&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF bootloader runs into HardFault</title><link>https://devzone.nordicsemi.com/thread/37070?ContentTypeID=1</link><pubDate>Fri, 06 Nov 2015 12:23:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96be7962-8eff-4233-9a54-4dd5d9f02abc</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Thank you for taking the time and sharing the answer, liszi.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF bootloader runs into HardFault</title><link>https://devzone.nordicsemi.com/thread/37069?ContentTypeID=1</link><pubDate>Fri, 06 Nov 2015 10:20:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7926d608-dc71-4b49-8620-24134f9f4985</guid><dc:creator>liszi</dc:creator><description>&lt;p&gt;Hi, I have a answer to my question, thanks to one of my friend:&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve a Rev A version of BMD-200 on my eval board with 16K RAM (as Einar Thorsrud assumed).  I forgot to modify the RAM size and origin in the linker script. The new RAM setup is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;RAM (rwx) :  ORIGIN = 0x20003000, LENGTH = 0x0fff.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Also there was a problem with the stack pointer. It was not initialised in the startup file, so now I do it in the begining of the Reset_Handler:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ldr   r0, =__StackTop
mov   sp, r0
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The __StackTop variable is calculated in the  gcc_nrf51_common.ld file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; __StackTop = ORIGIN(RAM) + LENGTH(RAM);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I also reduced the Stack_Size from 2048 to 800.&lt;/p&gt;
&lt;p&gt;My friend have solved the problem of BX and BLX instructions too. BX has no link, so the the PC is lost during the function call. We only need the BL instruction, because it saves the PC before the call, and it can restrore the PC after the function returns. BLX something similar to BL, but we don&amp;#39;t need that. The new main call in the startup file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.LC0:
    BL     SystemInit
    BL      _start
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now the bootloader starts. (But I have new problems to debug:)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF bootloader runs into HardFault</title><link>https://devzone.nordicsemi.com/thread/37068?ContentTypeID=1</link><pubDate>Fri, 06 Nov 2015 09:46:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df3dbbb0-0af0-478a-8151-d47cb21b039e</guid><dc:creator>liszi</dc:creator><description>&lt;p&gt;Thank you for the comment. Yes, I have an older (Rev A) version of BMD-200 on the eval kit, with 16 kB of RAM. And yes, I&amp;#39;ve made this mistake, I didn&amp;#39;t modify the RAM setup in the linker file.
One of my friends helps me to solve this problem. I going to write the solution in the answer section.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF bootloader runs into HardFault</title><link>https://devzone.nordicsemi.com/thread/37067?ContentTypeID=1</link><pubDate>Tue, 03 Nov 2015 10:14:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca84183c-3359-4321-8ccf-88fc88b94d0a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;It seems like a older version of the BMD-200 board was delivered with a older nRF51 revision, and with only 16 kB of RAM. Can you check which variant you have? If you have a revision 3 silicon with 32 kB of RAM I would expect the bootloader example from the SDK to work without any issues.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>