<?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 determine the App RAM base address in the linker script?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21543/how-to-determine-the-app-ram-base-address-in-the-linker-script</link><description>I understand part of ram is used by the softdevice, but I see different addresses are used in different examples that use the same softdevice, namely S132. For example, 
 in ble_app_hrs/pca10040/s132/armgcc/ble_app_hrs_gcc_nrf52.ld,
RAM (rwx) : ORIGIN</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 May 2017 07:41:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21543/how-to-determine-the-app-ram-base-address-in-the-linker-script" /><item><title>RE: How to determine the App RAM base address in the linker script?</title><link>https://devzone.nordicsemi.com/thread/84588?ContentTypeID=1</link><pubDate>Tue, 02 May 2017 07:41:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5eff2eeb-715b-435c-968a-c84729290085</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;@renix: Happy to help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to determine the App RAM base address in the linker script?</title><link>https://devzone.nordicsemi.com/thread/84587?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2017 17:47:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10add08a-6c5f-4b0d-8e4a-d0191576b4fd</guid><dc:creator>Renix</dc:creator><description>&lt;p&gt;Bjørn&lt;/p&gt;
&lt;p&gt;When I set IAR RAM Start to 0x20001000, execution runs to ble_stack_init(void)
and goes into the weeds at sd_ble_enable(0);&lt;/p&gt;
&lt;p&gt;I break before sd_ble_enable(0); then ram_start = 0x20001000&lt;/p&gt;
&lt;p&gt;No debug output on UART or RTT Viewer.&lt;/p&gt;
&lt;p&gt;When I set IAR RAM Start to 0x20001FE0, execution runs to app_error.c
and sits at  while (loop); Note: loop is &amp;#39;1&amp;#39;&lt;/p&gt;
&lt;p&gt;I break at if (app_ram_base != *ram_start) inside softdevice_enable(uint32_t * ram_start)
Then ram_start = 0x20002950 app_ram_base = 0x20001FF0&lt;/p&gt;
&lt;p&gt;(So uint32_t app_ram_base = *ram_start; is why it looks like app_ram_base is always what I set it to in IAR)&lt;/p&gt;
&lt;p&gt;Debug output on UART
SDH:WARNING:RAM start should be adjusted to 0x20001ff0.
SDH:WARNING:RAM size should be adjusted to 0xe010.
:ERROR:Fatal&lt;/p&gt;
&lt;p&gt;When I set IAR RAM Start to 0x20001FF0, (as the UART printout suggests), BLE runs fine.&lt;/p&gt;
&lt;p&gt;Thanks for the explanation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to determine the App RAM base address in the linker script?</title><link>https://devzone.nordicsemi.com/thread/84586?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2017 07:13:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f665cb5e-3f35-40bc-b322-62edca7d35f4</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;@renix: No, the SoftDevice will calculate its RAM requirements based on the configuration( e.g. number of central/peripheral links, number of services/characteristics/descriptors etc) when you enable it, i.e. call sd_ble_enable(). So in IAR the start address will be 0x20000000 and then app_ram_base should return the the end address of the SoftDevice RAM region. What happens if you set the end address to 0x20001000? 0x1000 should be to little and app_ram_base should contain a larger value. A quick way to tell if you have allocated enough RAM to the SoftDevice is to check if your device is advertising, if not, then increase the end_address until it starts advertising.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to determine the App RAM base address in the linker script?</title><link>https://devzone.nordicsemi.com/thread/84584?ContentTypeID=1</link><pubDate>Thu, 27 Apr 2017 19:31:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9661d0e1-d540-4081-962e-487658a212b3</guid><dc:creator>Renix</dc:creator><description>&lt;p&gt;RK&lt;/p&gt;
&lt;p&gt;app_ram_base will only be what I set it to in the IAR IDE wright?&lt;/p&gt;
&lt;p&gt;If I set it to 0x20001FF0 then that is what app_ram_base displays.
If I set it to 0x20002FF0 then that is what app_ram_base displays.&lt;/p&gt;
&lt;p&gt;So in IAR one only adjusts the RAM start and end address, not the size&lt;/p&gt;
&lt;p&gt;So where does SD get the RAM info, if all I do is tell the linker in advance where RAM starts?&lt;/p&gt;
&lt;p&gt;Any help appreciated&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to determine the App RAM base address in the linker script?</title><link>https://devzone.nordicsemi.com/thread/84585?ContentTypeID=1</link><pubDate>Sat, 22 Apr 2017 10:25:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:241709d3-6323-40bd-86f4-8f3f3b02c8cc</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;As RK suggested there is (according to Nordic) no clear formula about Soft Device RAM allocation depending on the configuration during enable/init so you need to run it once on actual chip and get the correct value from the Soft Device. If you cannot or don&amp;#39;t want to use debugger you can use UART (or debug Trace) and print it out (&lt;a href="https://devzone.nordicsemi.com/question/112184/trouble-updating-vendor-specific-uuid-count-on-ble-stack-init/?answer=112189#post-id-112189"&gt;here are some hints and code samples if needed&lt;/a&gt;).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to determine the App RAM base address in the linker script?</title><link>https://devzone.nordicsemi.com/thread/84583?ContentTypeID=1</link><pubDate>Sat, 22 Apr 2017 01:17:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf486fb1-90c8-41f3-934f-9089375fea28</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;This is documented in the sd_ble_enable() call, although you&amp;#39;ll find in all the recent SDKs this has been abstracted away inside the standard softdevice_handler which also now contains a macro to work out what the memory usage ought to be.&lt;/p&gt;
&lt;p&gt;You basically give the sd_ble_enable() call a pointer to uint32_t which contains the address of the start of user memory, it either returns an error telling you you&amp;#39;ve not given it enough RAM or it returns ok and puts the minimum value of the app RAM base back in the pointer.&lt;/p&gt;
&lt;p&gt;So the best way is to use softdevice_handler, or just give it lots of RAM, break after the sd_ble_enable() call and note down the value, then set the linker script to that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>