<?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>nRF9160: Assigning variables to RAM slots</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/62604/nrf9160-assigning-variables-to-ram-slots</link><description>Hi, 
 In one module of an application I would like to statically declare a large buffer in SRAM: static uint8_t largeBuffer[65536]; 
 The application fails to link with the following error: 
 /opt/toolchains/zephyr-sdk-0.11.1/arm-zephyr-eabi/bin/../lib</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 01 Jul 2020 11:37:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/62604/nrf9160-assigning-variables-to-ram-slots" /><item><title>RE: nRF9160: Assigning variables to RAM slots</title><link>https://devzone.nordicsemi.com/thread/257804?ContentTypeID=1</link><pubDate>Wed, 01 Jul 2020 11:37:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:417f1274-40c4-4a58-8b78-59e3987b79d0</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Jonathan,&lt;/p&gt;
&lt;p&gt;Please check the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.0/nrf/include/spm.html#configuration" rel="noopener noreferrer" target="_blank"&gt;Secure Partition Manager documentation&lt;/a&gt;, by default, it provides certain &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.0/nrf/include/secure_services.html#lib-secure-services" rel="noopener noreferrer" target="_blank"&gt;Secure Services to the non-secure FW&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The default &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.0/kconfig/CONFIG_PM_PARTITION_SIZE_SPM.html" rel="noopener noreferrer" target="_blank"&gt;flash space set aside for SPM&lt;/a&gt;&amp;nbsp;needs to match the requirements set by &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.0/nrf/scripts/partition_manager/partition_manager.html" rel="noopener noreferrer" target="_blank"&gt;the Partition Manager.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Anyway,&amp;nbsp; please check out the PR,&amp;nbsp;&lt;a title="https://github.com/nordicplayground/fw-nrfconnect-nrf/pull/2080" href="https://github.com/NordicPlayground/fw-nrfconnect-nrf/pull/2080" rel="noopener noreferrer" target="_blank"&gt;https://github.com/NordicPlayground/fw-nrfconnect-nrf/pull/2080&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This gives the possibility to freely configure SRAM and could be of interest.&lt;/p&gt;
&lt;div&gt;That PR extends the partition_manager to also manage the SRAM.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;Note, when building a project, you should get a report about the flash and RAM usage of each image. Those should probably give you an indication of the lower limit.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;hr /&gt;&lt;span&gt;Note: &lt;br /&gt;The BSDLib is compiled to use a fixed region in RAM:&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfxlib/bsdlib/doc/ug_bsdlib_porting_os.html#memory"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfxlib/bsdlib/doc/ug_bsdlib_porting_os.html#memory&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160: Assigning variables to RAM slots</title><link>https://devzone.nordicsemi.com/thread/257184?ContentTypeID=1</link><pubDate>Fri, 26 Jun 2020 15:10:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9db1284-ff88-48ba-ab2e-51d285647e9f</guid><dc:creator>DeltaXP</dc:creator><description>&lt;p&gt;Hi H&amp;aring;kon,&lt;/p&gt;
&lt;p&gt;The latest version of the BSD lib (0.7.3) of NCS (1.3.0) seems to support user application specified location and size for bsd library memory:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.0/nrfxlib/bsdlib/doc/api.html#_CPPv417bsd_init_params_t"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.0/nrfxlib/bsdlib/doc/api.html#_CPPv417bsd_init_params_t&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am not sure yet how to approach this, but my initial thoughts are to reduce the secure region size of 64kB. What is the reason for such a large memory allocation to the SPM? My understanding is the SPM configures peripherals and memory regions for secure and non-secure then launches the non-secure application. Are there any secure services/functions that are continuing to run or be callable? If so, does bsd lib depend on them?&lt;/p&gt;
&lt;p&gt;If the secure region of RAM can be reduced to something minimal or zero, then allocate 256kB to the non-secure user application and set up a static array of 49,184 bytes and pass that to&amp;nbsp;&lt;span&gt;bsd_init function. Then the linker can figure out how to organize the RAM for another 64kB array for this particular application&amp;#39;s required buffer.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-Jonathan&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160: Assigning variables to RAM slots</title><link>https://devzone.nordicsemi.com/thread/255476?ContentTypeID=1</link><pubDate>Wed, 17 Jun 2020 10:36:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c33c165d-e099-4f64-84ef-ca39c4e7556c</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Paul,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The SPU peripheral can setup RAM blocks for secure or non-secure in 8 kB chunks, so the region will have to be rounded up to the nearest block:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/spu.html?cp=2_0_0_5_14_2#ram_access_control"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf9160/spu.html?cp=2_0_0_5_14_2#ram_access_control&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The partition configuration can be found here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/master/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_partition_conf.dts#L40-L58"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/master/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_partition_conf.dts#L40-L58&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As you mention, you can technically move one 8 kB block of reserved RAM to the non-secure application, per the documentation. Not sure why we haven&amp;#39;t done this yet. I&amp;#39;ll create an internal ticket on this matter.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you need as much as 64 kB extra RAM, adjusting the above will not satisfy that need, unfortunately.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160: Assigning variables to RAM slots</title><link>https://devzone.nordicsemi.com/thread/255314?ContentTypeID=1</link><pubDate>Tue, 16 Jun 2020 14:50:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83b4b63d-6708-491a-948d-5e3ff38ce301</guid><dc:creator>paul.lander</dc:creator><description>&lt;p&gt;Hi H&amp;aring;kon,&lt;/p&gt;
&lt;p&gt;In the &lt;a href="http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfxlib/bsdlib/doc/ug_bsdlib_porting_os.html#memory"&gt;NRFX LIB documentation&lt;/a&gt; it says in the discussion of porting the BSD library that the application in the non-secure partition can use the upper 128 KB of SRAM, plus 2 areas of the lower 128KB (0x2000 0000 - 0x2000 FFFF (64 KB) and 8,160 bytes in the 7th block, above the BSD library). I assumed that SRAM blocks would be assignable by some means, either in a project configuration or declaratively in code.&lt;/p&gt;
&lt;p&gt;Could you please give some guidance&amp;nbsp;on interpretation&amp;nbsp;of the SRAM map?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Paul&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160: Assigning variables to RAM slots</title><link>https://devzone.nordicsemi.com/thread/255288?ContentTypeID=1</link><pubDate>Tue, 16 Jun 2020 13:46:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60360288-7cba-49f1-bc5f-cd3bb279907b</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]For the nRF9160, is there a reference for how to assign variables to SRAM slots, allowing modules to manage their own encapsulated static data?[/quote]
&lt;p&gt;The non-secure region has 128 kB flash available to the application. Based on the output from the linker, you are overflowing the region with ~62kB:&amp;nbsp;&lt;/p&gt;
[quote user=""]/opt/toolchains/zephyr-sdk-0.11.1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/9.2.0/../../../../arm-zephyr-eabi/bin/ld: region `SRAM&amp;#39; overflowed by 62972 bytes[/quote]
&lt;p&gt;Placing it in another region will not help here, as you&amp;#39;re using up all the RAM.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>