<?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>SDK 17.1.0: secure bootloader runtime failure when compiled with current gcc (11.2.0)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85677/sdk-17-1-0-secure-bootloader-runtime-failure-when-compiled-with-current-gcc-11-2-0</link><description>Hi, I have encountered the following problem, using SDK 17.1.0: 
 secure bootloader compiled with current gcc stable version (11.2.0) fails during runtime with the following error: 
 &amp;lt;info&amp;gt; app: Entering DFU mode. &amp;lt;debug&amp;gt; app: Initializing transports</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 17 Jun 2022 19:38:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85677/sdk-17-1-0-secure-bootloader-runtime-failure-when-compiled-with-current-gcc-11-2-0" /><item><title>RE: SDK 17.1.0: secure bootloader runtime failure when compiled with current gcc (11.2.0)</title><link>https://devzone.nordicsemi.com/thread/373101?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 19:38:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84267f68-d254-4a4e-9270-ab45dd228b88</guid><dc:creator>trunk</dc:creator><description>&lt;p&gt;I too had this issue. It&amp;#39;s caused by the inputs into SVCALL assembly definition not being fully defined and therefore the parameters never get placed on the stack. I found this solution from the link below which is adding this to CFLAGS or within SES. Of course, it should probably be fixed by correctly defining the inputs, but this is an acceptable fix in interim.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;c_additional_options=&amp;quot;-fno-ipa-modref&amp;quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/daniel-thompson/wasp-bootloader/commit/357b9a58160808a23af334d7aeb845d477283a99"&gt;daniel-thompson fix&lt;br /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can also isolate the optimization options just for the SVCALL as shown below. I&amp;#39;ve chosen to apply the above fix as I&amp;#39;m timid of another location running into interprocedural optimization issues with gcc 11.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define SVCALL(number, return_type, signature)          \
  _Pragma(&amp;quot;GCC diagnostic push&amp;quot;)                        \
  _Pragma(&amp;quot;GCC diagnostic ignored \&amp;quot;-Wreturn-type\&amp;quot;&amp;quot;)   \
  _Pragma(&amp;quot;GCC push_options&amp;quot;)                           \
  _Pragma(&amp;quot;GCC optimize (\&amp;quot;-fno-ipa-modref\&amp;quot;)&amp;quot;)         \
  __attribute__((naked))                                \
  __attribute__((unused))                               \
  static return_type signature                          \
  {                                                     \
    __asm(                                              \
        &amp;quot;svc %0\n&amp;quot;                                      \
        &amp;quot;bx r14&amp;quot; : : &amp;quot;I&amp;quot; (GCC_CAST_CPP number) : &amp;quot;r0&amp;quot;   \
    );                                                  \
  }                                                     \
  _Pragma(&amp;quot;GCC pop_options&amp;quot;)                            \
  _Pragma(&amp;quot;GCC diagnostic pop&amp;quot;)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 17.1.0: secure bootloader runtime failure when compiled with current gcc (11.2.0)</title><link>https://devzone.nordicsemi.com/thread/371274?ContentTypeID=1</link><pubDate>Wed, 08 Jun 2022 06:45:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9318075-2369-46db-871c-3d00b319fe9e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@kentorth: Please create a new ticket for your question. Please try using the&amp;nbsp;version that&amp;#39;s recommended for the SDK: GCC ARM Embedded 9.2020-q2.major&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 17.1.0: secure bootloader runtime failure when compiled with current gcc (11.2.0)</title><link>https://devzone.nordicsemi.com/thread/371233?ContentTypeID=1</link><pubDate>Tue, 07 Jun 2022 18:00:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21165f4d-2b72-4b5a-b9a0-0e4e09367918</guid><dc:creator>kentorth</dc:creator><description>&lt;p&gt;Hi Hung,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am currently running 10.3-2021.10 and am having the same error with SDK 17.1.0.&amp;nbsp; Are you positive it is a compiler issue?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 17.1.0: secure bootloader runtime failure when compiled with current gcc (11.2.0)</title><link>https://devzone.nordicsemi.com/thread/357867?ContentTypeID=1</link><pubDate>Mon, 14 Mar 2022 09:18:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:350f21f9-1a16-4072-9d77-276ed3c17b43</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Michael,&lt;/p&gt;
&lt;p&gt;You are right and your suggestions make a lot of sense. Normally, we would keep our SDK compatible with the latest tool chain update and try to match with the newest gcc version.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However, the nRF5 SDK is now considered legacy development platform and we have stopped releasing new major version of it since June 2020 (SDK v17.0). The resource is now focusing on nRF Connect SDK. It&amp;#39;s likely that v17 will be the last major version of the nRF5 SDK.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I hope you understand our situation and consider using the gcc version that&amp;#39;s tested with the SDK. But of course please provide your feedback to our sales representative in your country.&amp;nbsp;We always listen to you and&amp;nbsp;will try our best to help solving your problem.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 17.1.0: secure bootloader runtime failure when compiled with current gcc (11.2.0)</title><link>https://devzone.nordicsemi.com/thread/357780?ContentTypeID=1</link><pubDate>Sat, 12 Mar 2022 11:45:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5708a2a4-9bcf-4419-b444-58821f8c1932</guid><dc:creator>m5k8</dc:creator><description>&lt;p&gt;Thank you for your insight and support, prompt answer is really appreciated.&lt;/p&gt;
&lt;p&gt;Unfortunately, that&amp;#39;s the kind of answer I was expecting.&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/85677/sdk-17-1-0-secure-bootloader-runtime-failure-when-compiled-with-current-gcc-11-2-0/357667#357667"]It must be something wrong with the declaration of SVC call.[/quote]
&lt;p&gt;Probably. I didn&amp;#39;t try to debug it on my own, I thought that you are the right instance to track down the problem. You built the hardware, your wrote all the pieces of software. I must accept your decision to not dig deeper into the problem as thoughtful one. I respect your priorities.&lt;/p&gt;
&lt;p&gt;Regarding the preferred choice of the compiler, I beg to differ, please bear with me:&lt;/p&gt;
&lt;p&gt;When any software vendor is asked &amp;quot;which version of your software should be used&amp;quot;, usually the correct answer is &amp;quot;use the last stable version, it&amp;#39;s the best one as of today&amp;quot;. When I ask you, you probably will point me to the newest version of your SDK and SoftDevice.&lt;/p&gt;
&lt;p&gt;gcc current stable version is 11.2. That&amp;#39;s what gcc authors consider as the current compiler. I consider this as the most authoritative opinion. The &amp;quot;blessed&amp;quot; one. But I can understand that using fresh versions of all software is constant churn and sometimes too much.&lt;/p&gt;
&lt;p&gt;The second level of blessedness is ARM&amp;#39;s distribution of gcc. They decided to stay at one major version behind. It&amp;#39;s considerable choice, maybe they prefer to do more testing which is time consuming, maybe there are other objections to stay on the bleeding edge of current compiler technology. Even Debian stable linux distribution, known to be as the software archeology site, is already at gcc major version 10. So let&amp;#39;s assume this is the conservative choice, the least common denominator.&lt;/p&gt;
&lt;p&gt;Your choice to suggest version 9 that is two major version behind is odd. It&amp;#39;s obsolete and archival.&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/85677/sdk-17-1-0-secure-bootloader-runtime-failure-when-compiled-with-current-gcc-11-2-0/357667#357667"]The problem is that we don&amp;#39;t&amp;nbsp;test with any other gcc compiler version (and we can&amp;#39;t keep continue to test with new gcc releases)[/quote]
&lt;p&gt;Why not? OK, latest newest versions, I can agree. But using current version of ARM&amp;#39;s Embedded Toolchain should be good practice if not even mandatory, not some obsolete one. I&amp;#39;m aware that I&amp;#39;m not in the position to tell you what you should and shouldn&amp;#39;t, so please consider this as polite suggestion.&lt;/p&gt;
&lt;p&gt;Keeping to the obsolete version of compiler is problematic, at least for considerable group of your users. There are ongoing compatibility and maintenance issues. Linux ecosystem, especially development one, moves quite fast. System libraries and other dependencies break. Yes, I know, I can always compile the compiler from sources...&lt;/p&gt;
&lt;p&gt;I&amp;#39;m also using C++ in my projects, and try to follow latest language developments. Getting stuck at old compiler version is prohibitive here, I just can&amp;#39;t use the good niceties from modern C++. std::byte is a nice abstraction over uint8_t everywhere.&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s also imagine I&amp;#39;m using some substantial library from another vendor in my project, and this vendor did some mistakes and their piece of code doesn&amp;#39;t compile with your selected version of the compiler, and I&amp;#39;m expected to use some another random ancient version. Hell...&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/85677/sdk-17-1-0-secure-bootloader-runtime-failure-when-compiled-with-current-gcc-11-2-0/357667#357667"]v &lt;a href="https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads"&gt;10.3-2021.10&lt;/a&gt; the&amp;nbsp;&lt;span&gt;nrf_dfu_mbr_init_sd() function worked fine and returned 0.&lt;/span&gt;[/quote]
&lt;p&gt;So gcc 10 has a chance to work. But as you say, you don&amp;#39;t test your software with this version, only version 9. If gcc 11 doesn&amp;#39;t work, then there&amp;#39;s chance that there&amp;#39;s some code that is trying to outsmart the compiler and can introduce compiler dependent bugs, so using untested by you gcc 10 also doesn&amp;#39;t feel safe.&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/85677/sdk-17-1-0-secure-bootloader-runtime-failure-when-compiled-with-current-gcc-11-2-0/357667#357667"]you may need to attach the correct gcc version to the SDK setup[/quote]
&lt;p&gt;If your freshly released software, as of today, doesn&amp;#39;t compile and work properly using contemporary compiler version, I consider this to be a bug, the definite one. In your software, or in compiler :)&lt;/p&gt;
&lt;p&gt;So I kindly ask you to reconsider your stance, and not stay so far in the past with the compiler choice.&lt;/p&gt;
&lt;p&gt;Nevertheless, once again thank you for your prompt support! If you read anything above as harsh, English is my foreign language and I had no intention to. Just a little bit of astonishment.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 17.1.0: secure bootloader runtime failure when compiled with current gcc (11.2.0)</title><link>https://devzone.nordicsemi.com/thread/357667?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2022 13:03:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5de2615c-4a86-477d-b933-82cc16ca9aee</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Michael,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have tried here and got the same error when testing with gcc v11.2&lt;/p&gt;
&lt;p&gt;I managed to trace back the error down to the&amp;nbsp;&amp;nbsp; &amp;nbsp; err_code = nrf_dfu_mbr_init_sd(); call in&amp;nbsp;ble_stack_init(). It&amp;#39;s the function that returns error 9.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s a call to the MBR. It must be something wrong with the declaration of SVC call. I checked the source of MBR and it has no option to return error 9 from there.&lt;/p&gt;
&lt;p&gt;The problem is that we don&amp;#39;t&amp;nbsp;test with any other gcc compiler version (and we can&amp;#39;t keep continue to test with new gcc releases) except for the one comes default in the SDK. Without thorough test we can&amp;#39;t recommend to use newer gcc compiler. So we don&amp;#39;t have any other recommendation other than you may need to attach the correct gcc version to the SDK setup and make it separate from your system wide compiler.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;(FYI: At least in my test here the last version of GNU ARM Embedded Toolchain (before they merged ) v &lt;a href="https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads"&gt;10.3-2021.10&lt;/a&gt; the&amp;nbsp;&lt;span&gt;nrf_dfu_mbr_init_sd() function worked fine and returned 0. )&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>