<?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>pstorage - pstorage_block_identifier_get() and GCC flags -Os -O0 -flto</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17533/pstorage---pstorage_block_identifier_get-and-gcc-flags--os--o0--flto</link><description>Hello! 
 I have encountered an interesting issue: 
 When I use compiler flags (GCC CFLAGS) -Os or -O0 together with -flto the pstorage function pstorage_block_identifier_get() fails with error NRF_ERROR_INVALID_PARAM . 
 If I remove the -flto or if</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 11 Nov 2016 09:32:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17533/pstorage---pstorage_block_identifier_get-and-gcc-flags--os--o0--flto" /><item><title>RE: pstorage - pstorage_block_identifier_get() and GCC flags -Os -O0 -flto</title><link>https://devzone.nordicsemi.com/thread/67411?ContentTypeID=1</link><pubDate>Fri, 11 Nov 2016 09:32:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03172b36-2c23-4b37-8369-2e91902bdf3e</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;If I remember correctly the macro checks the element of an array which probably gets corrupted when using those optimizations.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage - pstorage_block_identifier_get() and GCC flags -Os -O0 -flto</title><link>https://devzone.nordicsemi.com/thread/67410?ContentTypeID=1</link><pubDate>Fri, 11 Nov 2016 07:59:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d38ae9d-17c5-498d-8d86-4dcbd2eaa475</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Tanasis: MODULE_ID_RANGE_CHECK(ID) return error invalid param when the id exceeds PSTORAGE_NUM_OF_PAGES. Have you made sure you update the number of pstorage pages according to your usage ?&lt;/p&gt;
&lt;p&gt;If you test with unmodified example with the above flags would you have any issue ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage - pstorage_block_identifier_get() and GCC flags -Os -O0 -flto</title><link>https://devzone.nordicsemi.com/thread/67409?ContentTypeID=1</link><pubDate>Thu, 10 Nov 2016 10:33:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:429380f1-dfdf-46ea-a545-acfac5d8e742</guid><dc:creator>Tanasis!</dc:creator><description>&lt;p&gt;Hello. @Hung: The error was coming from MODULE_ID_RANGE_CHECK(ID).
@emdi: Thanks for the answer. Especially the remark about -Os and -flto.
(GCC version is 6.2.2)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage - pstorage_block_identifier_get() and GCC flags -Os -O0 -flto</title><link>https://devzone.nordicsemi.com/thread/67408?ContentTypeID=1</link><pubDate>Mon, 07 Nov 2016 12:53:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:311f67a8-6d8f-4889-b318-fa2a8bc65a02</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;-flto is a &lt;em&gt;link&lt;/em&gt; time optimization in GCC that enables the linker to perfom optimization as if all function bodies were actually in one single file. If you are very constrained with flash, this option can help reduce the ROM size of you project.&lt;/p&gt;
&lt;p&gt;-Os performs a &lt;em&gt;compile&lt;/em&gt; time optimization, which favors size.&lt;/p&gt;
&lt;p&gt;The SDK is tested using -O3, so strictly speaking -O3 is the safest :)
Combining -Os and -flto is a very aggressive optimization and can have side effects.&lt;/p&gt;
&lt;p&gt;My guess is that the variable m_app_table in pstorage.c is not properly initialized at startup.
It may help to try to manually zero it during initialization.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage - pstorage_block_identifier_get() and GCC flags -Os -O0 -flto</title><link>https://devzone.nordicsemi.com/thread/67407?ContentTypeID=1</link><pubDate>Mon, 07 Nov 2016 11:23:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9cda7182-0154-4aeb-a7fd-aa256b23a552</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Tanasis: I tried here with a SDK v9.0 example and the flags you mentioned but didn&amp;#39; t have the error.
Have you tried to step into the pstorage_block_identifier_get() and check what caused NRF_ERROR_INVALID_PARAM ?&lt;/p&gt;
&lt;p&gt;I would suggest to test after a full erase of the chip.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>