<?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>GCC builds with FreeRTOS and newlib re-entrancy</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/62852/gcc-builds-with-freertos-and-newlib-re-entrancy</link><description>I am using NRF5 on an NRF52840 board, building under GCC. My application needs FreeRTOS and I also need to be able to use stdlib functions such as printf() from any RTOS task. With GCC you are using newlib and, for things such as printf(), newlib must</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 24 Jun 2020 15:25:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/62852/gcc-builds-with-freertos-and-newlib-re-entrancy" /><item><title>RE: GCC builds with FreeRTOS and newlib re-entrancy</title><link>https://devzone.nordicsemi.com/thread/256757?ContentTypeID=1</link><pubDate>Wed, 24 Jun 2020 15:25:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6eced018-4eda-4d9b-b34c-c951eb972d79</guid><dc:creator>RobMeades</dc:creator><description>&lt;p&gt;FYI, the construction in the attached file, a variant of Dave Nadler&amp;#39;s solution, fixed the problem for me.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/heap_5F00_useNewlib.c"&gt;devzone.nordicsemi.com/.../heap_5F00_useNewlib.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GCC builds with FreeRTOS and newlib re-entrancy</title><link>https://devzone.nordicsemi.com/thread/256345?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 08:52:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75c08a33-3de3-4c7a-aa43-7bf3c15c7c7d</guid><dc:creator>RobMeades</dc:creator><description>&lt;p&gt;Where the printf() goes to is not the problem, it&amp;#39;s the fact of calling it, or many other stdlib function, at all.&amp;nbsp;&amp;nbsp;See &lt;a href="https://sourceware.org/newlib/libc.html#Reentrancy"&gt;here&lt;/a&gt;&amp;nbsp;for a list of all the stdlib functions that WILL cause memory corruption if you call them from an RTOS task without implementing the necessary memory protection hooks for newlib.&amp;nbsp; Please don&amp;#39;t underestimate the danger of this hole, it is a very big one and you&amp;#39;ve only not noticed it because the example code you provide with RTOS included are very few in number.&lt;/p&gt;
&lt;p&gt;And it is NOT fixed by simply throwing the switch in the FreeRTOS config file, you actually have to write code to connect the two, see Dave Nadler&amp;#39;s link above where he has fixed exactly this problem on Freescale and ST: they hadn&amp;#39;t spotted it either, so you&amp;#39;re in good (? :-)) company.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GCC builds with FreeRTOS and newlib re-entrancy</title><link>https://devzone.nordicsemi.com/thread/256342?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 08:44:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a9d4054-7701-45eb-9593-047ef258845a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Rob,&lt;/p&gt;
&lt;p&gt;We normally override printf to redirect to UART instead of stdio. We do this by adding SDK\components\libraries\uart\retarget.c file to the project.&amp;nbsp;&lt;/p&gt;
[quote user=""]I also notice that NONE of the NRF5 examples that use FreeRTOS set&amp;nbsp;configUSE_NEWLIB_REENTRANT to 1 in their FreeRTOSConfig.h files, which is kind of strange when you are using newlib.[/quote]
&lt;p&gt;&amp;nbsp;We have not experimented with this config yet, also the documentation for this is very thin to get confidence to experiment with it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>