<?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>linker script and HardFault</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42865/linker-script-and-hardfault</link><description>Hi all! 
 I want to use the BLE stack by Nordic. I figured out that S132 is the appropriate HEX image for nRF52832. I can burn the softdevice into flash with nrjftool. 
 An application should also run and provide BLE features later. There are multiple</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 28 Jan 2019 13:10:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42865/linker-script-and-hardfault" /><item><title>RE: linker script and HardFault</title><link>https://devzone.nordicsemi.com/thread/168236?ContentTypeID=1</link><pubDate>Mon, 28 Jan 2019 13:10:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4a7ae06-dc56-4c5b-b0a2-4f4af9c68caa</guid><dc:creator>Tamas Selmeci</dc:creator><description>&lt;p&gt;Thanks for this, I&amp;#39;ve increased the RAM origin address by 0x1000. I hope this&amp;#39;ll be enough for the SoftDevice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: linker script and HardFault</title><link>https://devzone.nordicsemi.com/thread/168198?ContentTypeID=1</link><pubDate>Mon, 28 Jan 2019 11:54:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:121c7664-ebc1-4c71-a1c4-b8664a1e1d57</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Glad you found it, I didn&amp;#39;t get your reply before making a comment.&lt;/p&gt;
&lt;p&gt;Good luck with further development.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: linker script and HardFault</title><link>https://devzone.nordicsemi.com/thread/168197?ContentTypeID=1</link><pubDate>Mon, 28 Jan 2019 11:52:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49b0c2ec-22a9-40bf-b978-d11684f32904</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;The flash address is correct for S132 V6.1.0. The ram address should not have any impact on the starting of the application. If it is wrong, then you might experience a memory corruption very quickly. Are you sure that the value you have set for the RAM start address is correct? It seems quite low (i.e. the lowest possible value), and it could be that you application is starting but gets a corrupted memory very quickly. If you are using a number of features in the SoftDevice, then the RAM start address should be higher.&lt;/p&gt;
&lt;p&gt;For example, take a look at the linker script for the &lt;strong&gt;ble_app_blinky&lt;/strong&gt; example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;MEMORY
{
  FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000
  RAM (rwx) :  ORIGIN = 0x200022b8, LENGTH = 0xdd48
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The blinky example uses for example RTC0, TIMER0, Radio, ECB, and LF clock, which all requires the SoftDevice.&lt;/p&gt;
&lt;p&gt;Therefore the RAM start address is set much higher than the lowest value.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: linker script and HardFault</title><link>https://devzone.nordicsemi.com/thread/168192?ContentTypeID=1</link><pubDate>Mon, 28 Jan 2019 10:45:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14757804-fd63-46c9-ba59-a71ba4cd2b95</guid><dc:creator>Tamas Selmeci</dc:creator><description>&lt;p&gt;I&amp;#39;ve got it. My compile flags are bit different than the flags in the SDK, but in general this doesn&amp;#39;t cause any issue, except for a linker flag:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;-Wl,--start-group&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;After uncommenting this (and using the proper linker file above) the app began working.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: linker script and HardFault</title><link>https://devzone.nordicsemi.com/thread/168153?ContentTypeID=1</link><pubDate>Mon, 28 Jan 2019 08:33:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3047f8d-e26c-420f-9eb8-e7119e93fc26</guid><dc:creator>Tamas Selmeci</dc:creator><description>&lt;p&gt;No success. I&amp;#39;ve created a hybrid linker file with the correct flash and RAM addresses/sizes, but my app still doesn&amp;#39;t work. If the very same app is linked with the linker file without extra sections, it&amp;#39;s okay.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the correct linker file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* Linker script to configure memory regions. */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
  FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000
  RAM (rwx) :  ORIGIN = 0x20001628, LENGTH = 0xe9d8
}

SECTIONS
{
}

SECTIONS
{
  . = ALIGN(4);
  .mem_section_dummy_ram :
  {
  }

} INSERT AFTER .data;

SECTIONS
{
  .mem_section_dummy_rom :
  {
  }

} INSERT AFTER .text

INCLUDE &amp;quot;nrf_common.ld&amp;quot;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And here&amp;#39;s the wrong. As you can see, I&amp;#39;ve just added the extra sections, but it caused some troubles.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* Linker script to configure memory regions. */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
  FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000
  RAM (rwx) :  ORIGIN = 0x20001628, LENGTH = 0xe9d8
}

SECTIONS
{
}

SECTIONS
{
  . = ALIGN(4);
  .mem_section_dummy_ram :
  {
  }
  .cli_sorted_cmd_ptrs :
  {
    PROVIDE(__start_cli_sorted_cmd_ptrs = .);
    KEEP(*(.cli_sorted_cmd_ptrs))
    PROVIDE(__stop_cli_sorted_cmd_ptrs = .);
  } &amp;gt; RAM
  .fs_data :
  {
    PROVIDE(__start_fs_data = .);
    KEEP(*(.fs_data))
    PROVIDE(__stop_fs_data = .);
  } &amp;gt; RAM
  .log_dynamic_data :
  {
    PROVIDE(__start_log_dynamic_data = .);
    KEEP(*(SORT(.log_dynamic_data*)))
    PROVIDE(__stop_log_dynamic_data = .);
  } &amp;gt; RAM
  .log_filter_data :
  {
    PROVIDE(__start_log_filter_data = .);
    KEEP(*(SORT(.log_filter_data*)))
    PROVIDE(__stop_log_filter_data = .);
  } &amp;gt; RAM

} INSERT AFTER .data;

SECTIONS
{
  .mem_section_dummy_rom :
  {
  }
  .sdh_ant_observers :
  {
    PROVIDE(__start_sdh_ant_observers = .);
    KEEP(*(SORT(.sdh_ant_observers*)))
    PROVIDE(__stop_sdh_ant_observers = .);
  } &amp;gt; FLASH
  .sdh_ble_observers :
  {
    PROVIDE(__start_sdh_ble_observers = .);
    KEEP(*(SORT(.sdh_ble_observers*)))
    PROVIDE(__stop_sdh_ble_observers = .);
  } &amp;gt; FLASH
  .sdh_soc_observers :
  {
    PROVIDE(__start_sdh_soc_observers = .);
    KEEP(*(SORT(.sdh_soc_observers*)))
    PROVIDE(__stop_sdh_soc_observers = .);
  } &amp;gt; FLASH
  .sdh_stack_observers :
  {
    PROVIDE(__start_sdh_stack_observers = .);
    KEEP(*(SORT(.sdh_stack_observers*)))
    PROVIDE(__stop_sdh_stack_observers = .);
  } &amp;gt; FLASH
  .sdh_req_observers :
  {
    PROVIDE(__start_sdh_req_observers = .);
    KEEP(*(SORT(.sdh_req_observers*)))
    PROVIDE(__stop_sdh_req_observers = .);
  } &amp;gt; FLASH
  .sdh_state_observers :
  {
    PROVIDE(__start_sdh_state_observers = .);
    KEEP(*(SORT(.sdh_state_observers*)))
    PROVIDE(__stop_sdh_state_observers = .);
  } &amp;gt; FLASH
    .nrf_queue :
  {
    PROVIDE(__start_nrf_queue = .);
    KEEP(*(.nrf_queue))
    PROVIDE(__stop_nrf_queue = .);
  } &amp;gt; FLASH
    .nrf_balloc :
  {
    PROVIDE(__start_nrf_balloc = .);
    KEEP(*(.nrf_balloc))
    PROVIDE(__stop_nrf_balloc = .);
  } &amp;gt; FLASH
    .cli_command :
  {
    PROVIDE(__start_cli_command = .);
    KEEP(*(.cli_command))
    PROVIDE(__stop_cli_command = .);
  } &amp;gt; FLASH
  .crypto_data :
  {
    PROVIDE(__start_crypto_data = .);
    KEEP(*(SORT(.crypto_data*)))
    PROVIDE(__stop_crypto_data = .);
  } &amp;gt; FLASH
  .pwr_mgmt_data :
  {
    PROVIDE(__start_pwr_mgmt_data = .);
    KEEP(*(SORT(.pwr_mgmt_data*)))
    PROVIDE(__stop_pwr_mgmt_data = .);
  } &amp;gt; FLASH
  .log_const_data :
  {
    PROVIDE(__start_log_const_data = .);
    KEEP(*(SORT(.log_const_data*)))
    PROVIDE(__stop_log_const_data = .);
  } &amp;gt; FLASH
  .log_backends :
  {
    PROVIDE(__start_log_backends = .);
    KEEP(*(SORT(.log_backends*)))
    PROVIDE(__stop_log_backends = .);
  } &amp;gt; FLASH

} INSERT AFTER .text

INCLUDE &amp;quot;nrf_common.ld&amp;quot;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll check whether my compile flags are correct. Perhaps another SDK version would also suit...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: linker script and HardFault</title><link>https://devzone.nordicsemi.com/thread/167540?ContentTypeID=1</link><pubDate>Thu, 24 Jan 2019 07:34:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3acf471c-2cfb-45df-80e7-47a9bd46f99a</guid><dc:creator>Tamas Selmeci</dc:creator><description>&lt;p&gt;Good idea. I&amp;#39;ll try all your recommendations on the next week (I&amp;#39;m out of office at the moment) and reflect.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: linker script and HardFault</title><link>https://devzone.nordicsemi.com/thread/167454?ContentTypeID=1</link><pubDate>Wed, 23 Jan 2019 17:30:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63fabe0e-179b-4c94-91cb-d4ec031101dc</guid><dc:creator>wpaul</dc:creator><description>&lt;p&gt;Make sure you adjust the length too. (It should be 512KB - 0x26000, i.e. 0x5A000.)&lt;/p&gt;
&lt;p&gt;I would use the debugger to set a breakpoint at 0x26000 and then launch the target and see if it gets there. This will at least tell you if the start-up code is doing the right thing. If the breakpoint doesn&amp;#39;t trigger, then something is going wrong before even reaching your application. If the breakpoint does trigger, then dump what&amp;#39;s at 0x26000 to see if it looks like valid code and try single-stepping to see where it goes wrong.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: linker script and HardFault</title><link>https://devzone.nordicsemi.com/thread/167281?ContentTypeID=1</link><pubDate>Wed, 23 Jan 2019 07:51:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8a0f10d-9596-4df7-8497-f2d40e087acd</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;You could take a look at the &lt;a href="https://devzone.nordicsemi.com/tutorials/b/getting-started/posts/adjustment-of-ram-and-flash-memory"&gt;tutorial for adjustment of RAM and Flash memory&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: linker script and HardFault</title><link>https://devzone.nordicsemi.com/thread/167278?ContentTypeID=1</link><pubDate>Wed, 23 Jan 2019 07:38:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b21f3923-2c68-47cd-8656-76f3d13c4a63</guid><dc:creator>Tamas Selmeci</dc:creator><description>&lt;p&gt;Thanks for the answer, it&amp;#39;s all clear to me. I&amp;#39;ve already figured out that the app start address is different in the mentioned linker files and created a new linker file with the correct start address (0x26000), but it again failed to execute correctly. Maybe I did something wrong, I&amp;#39;ll give it a next try and share the results here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: linker script and HardFault</title><link>https://devzone.nordicsemi.com/thread/167196?ContentTypeID=1</link><pubDate>Tue, 22 Jan 2019 18:43:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9be53bae-a2ff-4a84-a9ed-dd7b2eaea586</guid><dc:creator>wpaul</dc:creator><description>&lt;p&gt;If you&amp;#39;re using a custom application with no SoftDevice (and no bootloader), then your application code is expected to be placed at address 0x0 in the flash.&lt;/p&gt;
&lt;p&gt;But when using the S132 SoftDevice, the MBR and SoftDevice take up a portion of the flash starting from address 0, and user application code is expected to start at a specific offset in flash _after_ the SoftDevice. The exact offset varies slightly depending on the SoftDevice release, but it&amp;#39;s always documented in the SoftDevice release notes. It also has to be included in the linker script when linking your application code.&lt;/p&gt;
&lt;p&gt;In the first script file you mention, it says this:&lt;/p&gt;
&lt;p&gt;MEMORY&lt;br /&gt;{&lt;br /&gt; FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000&lt;br /&gt; RAM (rwx) : ORIGIN = 0x200014b8, LENGTH = 0xeb48&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;But in the second it says this:&lt;/p&gt;
&lt;p&gt;MEMORY&lt;br /&gt;{&lt;br /&gt; FLASH (rx) : ORIGIN = 0x2d000, LENGTH = 0x53000&lt;br /&gt; RAM (rwx) : ORIGIN = 0x20001f30, LENGTH = 0xe0d0&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;I happen to know that 0x26000 is the correct application offset address for the S132 SoftDevice (and coincidentally also for the S140 SoftDevice). The start-up code in the MBR, which is the first thing to run when you boot the CPU, expects the application code to be located at 0x26000, so after a little bit of set-up it will try to jump there. If you use the second script, your application won&amp;#39;t be there: it will be at 0x2d000 instead. So when the CPU branches to 0x26000 there will be just 0xFF bytes there, and the CPU will interpret them as illegal instructions and you&amp;#39;ll end up in the HardFault handler.&lt;/p&gt;
&lt;p&gt;The RAM definition is also important, because some of the RAM must also be reserved for use by the SoftDevice once it&amp;#39;s been enabled. Exactly how much RAM has to be reserved depends a little bit on exactly what BLE features you use, and other things like how many simultaneous connections you want to support. Some of the SoftDevice APIs will return an error if you don&amp;#39;t reserve enough RAM -- they also indicate how much RAM should be available which tells you how to adjust things.&lt;/p&gt;
&lt;p&gt;So if you want to use the second script with the SoftDevice, you have to adjust the FLASH and RAM definitions accordingly. You can try just copying the entries from the first script into the second one and see if that at least gets your application to start up.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>