<?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>power_down_unused_ram() compatibility with malloc()/free()?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/109179/power_down_unused_ram-compatibility-with-malloc-free</link><description>Hello NordicDevZone, We are developing a Matter/Thread capable device based on the nRF52840. We have our development well underway and are striving for a low power solution with our battery operated device. As such, one of the last steps of our boot process</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 15 Mar 2024 08:30:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/109179/power_down_unused_ram-compatibility-with-malloc-free" /><item><title>RE: power_down_unused_ram() compatibility with malloc()/free()?</title><link>https://devzone.nordicsemi.com/thread/474019?ContentTypeID=1</link><pubDate>Fri, 15 Mar 2024 08:30:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0b47d39-0967-4a68-9810-4be582614a95</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Steve,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m happy to help out.&lt;/p&gt;
&lt;p&gt;These lower layer stuff can be a bit tricky. What I can say is that you will definitely notice quite quickly if parts of your&amp;nbsp;used RAM is powered off :-)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Let us know if you run into any issues or have questions.&lt;/p&gt;
&lt;p&gt;Hope you have a great weekend!&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: power_down_unused_ram() compatibility with malloc()/free()?</title><link>https://devzone.nordicsemi.com/thread/473976?ContentTypeID=1</link><pubDate>Thu, 14 Mar 2024 20:32:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24a0afea-8bb3-4e3a-a069-a61306064f00</guid><dc:creator>SteveKranz</dc:creator><description>&lt;p&gt;Hi H&amp;aring;kon,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Oh, ok, very cool. Thank you for the timely response. We appreciate it...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;:-)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Steve&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: power_down_unused_ram() compatibility with malloc()/free()?</title><link>https://devzone.nordicsemi.com/thread/473841?ContentTypeID=1</link><pubDate>Thu, 14 Mar 2024 11:32:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4c47738-df0f-4f63-84ec-faff3eb8ebb3</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="SteveKranz"]I still am left wondering if it is safe for applications and libraries to use malloc/free if the system has been placed in the power_down_unused_ram() mode and the CONFIG_RAM_POWER_ADJUST_ON_HEAP_RESIZE is not set. [/quote]
&lt;p&gt;The .heap will be placed within the limits, ie. _start and _end symbol. Therefore it shall not be deemed &amp;quot;unused&amp;quot;.&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: power_down_unused_ram() compatibility with malloc()/free()?</title><link>https://devzone.nordicsemi.com/thread/473740?ContentTypeID=1</link><pubDate>Thu, 14 Mar 2024 00:23:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:070ab553-96c5-466d-8175-30ff96324264</guid><dc:creator>SteveKranz</dc:creator><description>&lt;p&gt;Hi H&amp;aring;kon,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Hmmmm? I still am left wondering if it is safe for applications and libraries to use malloc/free if the system has been placed in the power_down_unused_ram() mode and the CONFIG_RAM_POWER_ADJUST_ON_HEAP_RESIZE is not set. Maybe I missed it in your reply, but I still can&amp;#39;t say for sure. Can you confirm?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks in advance!&lt;/p&gt;
&lt;p&gt;Steve.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: power_down_unused_ram() compatibility with malloc()/free()?</title><link>https://devzone.nordicsemi.com/thread/473691?ContentTypeID=1</link><pubDate>Wed, 13 Mar 2024 14:43:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afaceade-55f0-4b14-8f5c-807a7279174d</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=""]CONFIG_RAM_POWER_ADJUST_ON_HEAP_RESIZE&lt;br /&gt;&lt;br /&gt;My concern is that our system does not set this and we are wondering if we should. We were planning to use the malloc()/free() calls, and we have no idea if the underlying matter/thread layers also use malloc()/free(). Are we running the risk that something will break if malloc()/free() are used in a system that has been placed in the power_down_unused_ram(). Maybe power_down_unused_ram() isn’t a set-it-and-forget-it function? I notice that both of the following functions exist:&lt;br /&gt;&lt;br /&gt;power_down_unused_ram()&lt;br /&gt;power_up_unused_ram()&lt;br /&gt;&lt;br /&gt;Another way to ask my question is: Under what conditions would we need to call power_up_unused_ram()?[/quote]
&lt;p&gt;in matter projects, the heap size is set up by the matter stack itself, more specifically in this module:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-connectedhomeip/blob/v2.6.0-rc2/src/platform/Zephyr/SysHeapMalloc.cpp#L41"&gt;https://github.com/nrfconnect/sdk-connectedhomeip/blob/v2.6.0-rc2/src/platform/Zephyr/SysHeapMalloc.cpp#L41&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you do not enable CONFIG_RAM_POWER_ADJUST_ON_HEAP_RESIZE, it will adjust the RAM blocks based on the RAM start and RAM end symbols:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.5.2/lib/ram_pwrdn/ram_pwrdn.c#L195-L203"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v2.5.2/lib/ram_pwrdn/ram_pwrdn.c#L195-L203&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]Another way to ask my question is: Under what conditions would we need to call power_up_unused_ram()?[/quote]
&lt;p&gt;Provided that you never use the RAM, you shouldn&amp;#39;t need to power up the segments. This is provided as a dynamic feature, in cases where you need to use previously unused segments of 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>