<?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>How do I configure newlib printf?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/5136/how-do-i-configure-newlib-printf</link><description>Im using GCC + Eclipse with the S110 SoftDevice and the HRS example code. Everything is working well except for printf (which I&amp;#39;ve added a call to via app_trace ). I&amp;#39;ve set the ENABLE_DEBUG_LOG_SUPPORT #define. I&amp;#39;ve also called app_trace_init() . 
 I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 15 Jan 2015 08:11:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/5136/how-do-i-configure-newlib-printf" /><item><title>RE: How do I configure newlib printf?</title><link>https://devzone.nordicsemi.com/thread/18023?ContentTypeID=1</link><pubDate>Thu, 15 Jan 2015 08:11:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1faf7599-ed70-40ab-983f-787fd1c25eda</guid><dc:creator>Marcel Mulder</dc:creator><description>&lt;p&gt;I also use (&lt;a href="https://launchpad.net/gcc-arm-embedded"&gt;GCC&lt;/a&gt; but with QT Creator. I also used the GCC Makefile supplied by Nordic. They both work with app_trace().
Could you share the linker options you use?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I configure newlib printf?</title><link>https://devzone.nordicsemi.com/thread/18028?ContentTypeID=1</link><pubDate>Wed, 14 Jan 2015 23:36:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b811e0e-4194-47d1-86c2-0bc58ee8202c</guid><dc:creator>Peter</dc:creator><description>&lt;p&gt;I voted up all the other answers since they provided excellent info.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I configure newlib printf?</title><link>https://devzone.nordicsemi.com/thread/18027?ContentTypeID=1</link><pubDate>Wed, 14 Jan 2015 23:34:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50e6c8f4-1a38-43bf-806a-f0b1af3fa68e</guid><dc:creator>Peter</dc:creator><description>&lt;p&gt;Newlib &lt;code&gt;printf&lt;/code&gt; doesn&amp;#39;t need to be configured (other than making sure the items you want to use are defined as &lt;a href="https://devzone.nordicsemi.com/question/24499/how-do-i-configure-newlib-printf/?answer=24502#post-id-24502"&gt;pabigot mentioned&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;However, newlib does put some items in the &lt;code&gt;.data&lt;/code&gt; section, namely &lt;code&gt;impure_data&lt;/code&gt;. In my case, &lt;a href="https://devzone.nordicsemi.com/question/24598/should-__data_end__-and-__data_start__-be-the-same/"&gt;I had totally messed up my sections&lt;/a&gt;. &lt;code&gt;.data&lt;/code&gt; was not getting initialized, and &lt;code&gt;impure_data&lt;/code&gt; was pointing off where it shouldn&amp;#39;t. Because of this, &lt;code&gt;printf&lt;/code&gt; would crash when it tried to dereference &lt;code&gt;impure_data&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;So if your &lt;code&gt;.data&lt;/code&gt; section is not being initialized, &lt;code&gt;printf&lt;/code&gt; &lt;em&gt;will&lt;/em&gt; fail.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I configure newlib printf?</title><link>https://devzone.nordicsemi.com/thread/18026?ContentTypeID=1</link><pubDate>Wed, 14 Jan 2015 19:50:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5d84c9a-3dcb-4b8f-9791-564922745895</guid><dc:creator>cocoa</dc:creator><description>&lt;p&gt;Right, you will use JLinkRTTClient and not JLinkSWOViewer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I configure newlib printf?</title><link>https://devzone.nordicsemi.com/thread/18020?ContentTypeID=1</link><pubDate>Wed, 14 Jan 2015 19:16:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb04730f-4f22-4993-843e-d40fab4c5aef</guid><dc:creator>pabigot</dc:creator><description>&lt;p&gt;Yes.  I was unaware of the retarget.c feature since I don&amp;#39;t use anything but the CMSIS headers from the Nordic SDK.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve also run into trouble where two things (e.g. retarget.o and -lnosys) define the same symbol, especially if they both come from libraries, as the order the libraries are read by the linker becomes important.  In BSPACM I use weak symbols for the stubs to avoid some of these problems.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I configure newlib printf?</title><link>https://devzone.nordicsemi.com/thread/18019?ContentTypeID=1</link><pubDate>Wed, 14 Jan 2015 19:09:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af354e54-ad07-458f-96af-45ddeb503054</guid><dc:creator>Peter</dc:creator><description>&lt;p&gt;But doesn&amp;#39;t the nosys library just provide stubs for functions that are undefined? i.e., since &lt;code&gt;retarget.c&lt;/code&gt; defines &lt;code&gt;_read&lt;/code&gt; and &lt;code&gt;_write&lt;/code&gt;, those versions will be used instead of the stubs in nosys. I can test this by commenting out &lt;code&gt;_write&lt;/code&gt; in &lt;code&gt;retarget.c&lt;/code&gt;--when I print the symbols with &lt;code&gt;nm&lt;/code&gt;, &lt;code&gt;_write&lt;/code&gt; comes from somewhere else (nosys I assume) and &lt;code&gt;_read&lt;/code&gt; comes from &lt;code&gt;retarget.c&lt;/code&gt;. Can&amp;#39;t I let nosys define stubs for functions I don&amp;#39;t care about like &lt;code&gt;_exit&lt;/code&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I configure newlib printf?</title><link>https://devzone.nordicsemi.com/thread/18025?ContentTypeID=1</link><pubDate>Wed, 14 Jan 2015 18:53:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0dda4f1-9508-44ab-9863-5045c9d00825</guid><dc:creator>Peter</dc:creator><description>&lt;p&gt;So just to confirm: The SWV console doesn&amp;#39;t require SWO, right? Because SWO isn&amp;#39;t supported on the NRF51-DK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I configure newlib printf?</title><link>https://devzone.nordicsemi.com/thread/18022?ContentTypeID=1</link><pubDate>Wed, 14 Jan 2015 18:41:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:779c15f3-8689-44c5-9f70-7e9abe3a3e0c</guid><dc:creator>Peter</dc:creator><description>&lt;p&gt;I did add it. &lt;code&gt;_write&lt;/code&gt; and _read appear in my &lt;code&gt;.elf&lt;/code&gt; (and the debug symbols show that they come from &lt;code&gt;retarget.c&lt;/code&gt;. My app crashes before those ever get called though.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I configure newlib printf?</title><link>https://devzone.nordicsemi.com/thread/18024?ContentTypeID=1</link><pubDate>Wed, 14 Jan 2015 13:34:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c3e1b40-885a-43e8-a8fc-fbc9d9ea5ac3</guid><dc:creator>cocoa</dc:creator><description>&lt;p&gt;If you&amp;#39;re using Jlink , printf is available trough Eclipse ARM plugin in Semihosting and SWV console.&lt;/p&gt;
&lt;p&gt;Automatically added by plugin to linker : --specs=rdimon.specs -Wl,--start-group -lgcc -lc -lc -lm -lrdimon -Wl,--end-group&lt;/p&gt;
&lt;p&gt;If you need a realtime printf, use Segger RTT library, is free.&lt;/p&gt;
&lt;p&gt;-c&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I configure newlib printf?</title><link>https://devzone.nordicsemi.com/thread/18021?ContentTypeID=1</link><pubDate>Wed, 14 Jan 2015 10:10:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6007f4d4-1f36-45d1-b22e-db782ab66a76</guid><dc:creator>Marcel Mulder</dc:creator><description>&lt;p&gt;Did you add nrf51-sdk/components/libraries/uart/retarget.c to your project?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I configure newlib printf?</title><link>https://devzone.nordicsemi.com/thread/18018?ContentTypeID=1</link><pubDate>Wed, 14 Jan 2015 03:14:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1aac8db-e3b6-4097-8048-08de4be81319</guid><dc:creator>pabigot</dc:creator><description>&lt;p&gt;&lt;a href="http://pabigot.github.io/bspacm/"&gt;BSPACM&lt;/a&gt; provides some information about its &lt;a href="http://pabigot.github.io/bspacm/newlib.html"&gt;newlib interface&lt;/a&gt;.  I use printf and related stdio functions on nRF51 hardware with this solution.&lt;/p&gt;
&lt;p&gt;In short you need to provide implementations of the &lt;a href="http://pabigot.github.io/bspacm/newlib.html#newlib_sys"&gt;system functions newlib expects&lt;/a&gt;.  (Be aware that the nRF51 SDK, like many other ARM Cortex-M vendor libraries, hides a reference to -lnosys in a GROUP directive in the linker script.  You&amp;#39;ll need to get rid of that.)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>