<?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>Is there any way to reduce the consumption of ROM resources under the GCC compilation platform?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111742/is-there-any-way-to-reduce-the-consumption-of-rom-resources-under-the-gcc-compilation-platform</link><description>Due to the allocation of Flash resources, only 100KB ROM for the app , and if we use Keil, we will have about 20KB of margin for additional code development, but we have to abandon Keil for the sake of the compilation platform. 
 Is there any way to optimize</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 10 Jun 2024 07:32:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111742/is-there-any-way-to-reduce-the-consumption-of-rom-resources-under-the-gcc-compilation-platform" /><item><title>RE: Is there any way to reduce the consumption of ROM resources under the GCC compilation platform?</title><link>https://devzone.nordicsemi.com/thread/488027?ContentTypeID=1</link><pubDate>Mon, 10 Jun 2024 07:32:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d90407e8-e285-4156-b1d0-3a736b6df555</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;If you require different optimization levels, you must differentiate it either in code (#pragma directive), or adjust your makefile to allow individual optimization level on each compiled file.&lt;/p&gt;
&lt;p&gt;In both scenarios, you will need to analyze which files require speed and which will require size optimization.&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: Is there any way to reduce the consumption of ROM resources under the GCC compilation platform?</title><link>https://devzone.nordicsemi.com/thread/487987?ContentTypeID=1</link><pubDate>Sun, 09 Jun 2024 03:12:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:541e089c-4837-4245-91b5-7a38abb44442</guid><dc:creator>koala</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Are there any other alternatives? Using this approach makes my code less generic and requires extra time to think about which functions really need to be optimized separately.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is there any way to reduce the consumption of ROM resources under the GCC compilation platform?</title><link>https://devzone.nordicsemi.com/thread/487066?ContentTypeID=1</link><pubDate>Mon, 03 Jun 2024 09:41:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:611f8f8d-635a-483f-b367-ecbd785324b8</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=""]Is there any way to optimize the program&amp;#39;s ROM usage? &lt;span style="color:rgba(255, 0, 0, 1);"&gt;Our code is very timing-sensitive&lt;span style="color:rgba(0, 0, 0, 1);"&gt;, and if we change it directly from O3 to Os&lt;/span&gt;&lt;/span&gt;, we will get obvious ROM benefits, but our program execution will start to get messy.[/quote]
&lt;p&gt;If there are certain functions which require another optimization level, you can use the gcc #pragma directive to change optimization:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#pragma GCC push_options
#pragma GCC optimize (&amp;quot;O3&amp;quot;)

...functions to optimize with -O3..

#pragma GCC pop_options&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then you can keep the rest of your firmware on &amp;quot;-Os&amp;quot; to allow for a lower ROM footprint.&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>