<?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 to redirect printf to UART when using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/43790/how-to-redirect-printf-to-uart-when-using-segger-embedded-studio</link><description>The Segger Compiler is integrated with JLINK debugging software 
 Printf statements, when compiled, direct to the studio debugger terminal 
 How can I create code where they are directed to the UART? 
 Project options allow configuration of printf and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 20 Feb 2019 14:36:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/43790/how-to-redirect-printf-to-uart-when-using-segger-embedded-studio" /><item><title>RE: How to redirect printf to UART when using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/172143?ContentTypeID=1</link><pubDate>Wed, 20 Feb 2019 14:36:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3473f47-9da9-43b1-a86d-d3ec9ea30859</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="northernLight"]&lt;p&gt;&lt;/p&gt;&lt;p&gt;Thankyou for your time on this.&lt;/p&gt;&lt;p&gt;I believe these only configure NRF_LOG instructions, not direct printf commands&lt;/p&gt;&lt;p&gt;When using NRF_LOG_INFO commands with RTT set and UART unset I get data to the debug terminal in SES&lt;/p&gt;&lt;p&gt;But with the same code with RTT unset and UART set I get no output&amp;nbsp;to my serial monitor window&lt;/p&gt;&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is not what happend with the &lt;strong&gt;sdk_config.h file&lt;/strong&gt; I gave you?&lt;/p&gt;
[quote user="northernLight"]What is the function of&amp;nbsp;retarget.c?&amp;nbsp; Does it affect the destination for standard output?[/quote]
&lt;p&gt;&amp;nbsp;It is an implementation of functions in &lt;strong&gt;stdio.h&lt;/strong&gt;.&lt;/p&gt;
[quote user="northernLight"]How do I&lt;span&gt;&amp;nbsp;incorporate flash_placement.xml in the compiler configuration?&lt;/span&gt;[/quote]
&lt;p&gt;&amp;nbsp;Follow &lt;a href="https://www.nordicsemi.com/DocLib/Content/User_Guides/gsg_ses/latest/UG/gsg/import_ses"&gt;step 7&lt;/a&gt; on this guide.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to redirect printf to UART when using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/172074?ContentTypeID=1</link><pubDate>Wed, 20 Feb 2019 10:36:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37294ffa-a361-4225-aab5-060bdb126cc4</guid><dc:creator>northernLight</dc:creator><description>&lt;p&gt;Andreas&lt;/p&gt;
&lt;p&gt;Thankyou for your time on this.&lt;/p&gt;
&lt;p&gt;I believe these only configure NRF_LOG instructions, not direct printf commands&lt;/p&gt;
&lt;p&gt;When using NRF_LOG_INFO commands with RTT set and UART unset I get data to the debug terminal in SES&lt;/p&gt;
&lt;p&gt;But with the same code with RTT unset and UART set I get no output&amp;nbsp;to my serial monitor window&lt;/p&gt;
&lt;p&gt;:-(&lt;/p&gt;
&lt;p&gt;What is the function of&amp;nbsp;retarget.c?&amp;nbsp; Does it affect the destination for standard output?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am using the sdk_config for the peripheral/uart example from SDK 12.3.&amp;nbsp; I&amp;#39;ll try the file you propose.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How do I&lt;span&gt;&amp;nbsp;incorporate flash_placement.xml in the compiler configuration?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Many thanks&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Rob&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to redirect printf to UART when using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/172065?ContentTypeID=1</link><pubDate>Wed, 20 Feb 2019 10:05:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9cd6ee9a-1cee-4a9e-910d-9c5d71d17f52</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi Rob.&lt;/p&gt;
&lt;p&gt;The startup files are code which are run before main starts, you can call it a bootstrapping of the system, so you are correct in that they are &amp;quot;in effect the boot file&amp;quot;.&lt;/p&gt;
&lt;p&gt;[quote user="northernLight"][/quote]&lt;/p&gt;
&lt;p&gt;As a recap of the problem I am trying to solve:&amp;nbsp; I would like to redirect printf (or stop its current redirection) so that the compiled code operates without Segger Studio, just with a UART connection&lt;/p&gt;
&lt;p&gt;Does stdio.h&amp;nbsp;define&amp;nbsp;the standard output destination for putchar()?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I don&amp;#39;t think you should have to add anything to the code, you should only need the correct configuration in &lt;strong&gt;sdk_config.h&lt;/strong&gt; and include the file &lt;strong&gt;retarget.c&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Can you try with my configuration: &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-5178d1d1a1c349459ad0d732d4860b54/sdk_5F00_config.h"&gt;devzone.nordicsemi.com/.../sdk_5F00_config.h&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I think the vital thing is that you have defined this as 1:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// &amp;lt;e&amp;gt; NRF_LOG_BACKEND_SERIAL_USES_UART - If enabled data is printed over UART
//==========================================================
#ifndef NRF_LOG_BACKEND_SERIAL_USES_UART
#define NRF_LOG_BACKEND_SERIAL_USES_UART 1
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And this as 0:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// &amp;lt;e&amp;gt; NRF_LOG_BACKEND_SERIAL_USES_RTT - If enabled data is printed using RTT
//==========================================================
#ifndef NRF_LOG_BACKEND_SERIAL_USES_RTT
#define NRF_LOG_BACKEND_SERIAL_USES_RTT 0
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As you can see here from the configuration wizard:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-5178d1d1a1c349459ad0d732d4860b54/pastedimage1550657053299v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Hope this works for you.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to redirect printf to UART when using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/172052?ContentTypeID=1</link><pubDate>Wed, 20 Feb 2019 09:21:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8133444f-78cc-4d64-b463-99c4c1f55ec7</guid><dc:creator>northernLight</dc:creator><description>&lt;p&gt;As a recap of the problem I am trying to solve:&amp;nbsp; I would like to redirect printf (or stop its current redirection) so that the compiled code operates without Segger Studio, just with a UART connection&lt;/p&gt;
&lt;p&gt;Does stdio.h&amp;nbsp;define&amp;nbsp;the standard output destination for putchar()?&lt;/p&gt;
&lt;p&gt;Rob&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to redirect printf to UART when using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/172049?ContentTypeID=1</link><pubDate>Wed, 20 Feb 2019 09:12:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3184af88-662f-4737-b248-7ee467c04cd5</guid><dc:creator>northernLight</dc:creator><description>&lt;p&gt;As a check&amp;nbsp;I reverted to the original files and the build completed&lt;/p&gt;
&lt;p&gt;Thanks again for helping with this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For my education what is the broad purpose of these start-up files?&amp;nbsp; They seem to be the first instructions that the processor executes on power-up.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are they in effect the boot file?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Rob&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to redirect printf to UART when using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/172048?ContentTypeID=1</link><pubDate>Wed, 20 Feb 2019 09:06:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39f27c8c-babc-41d2-a158-08790b302265</guid><dc:creator>northernLight</dc:creator><description>&lt;p&gt;Andreas,&lt;/p&gt;
&lt;p&gt;Many thanks. I am unsure what to do with the&amp;nbsp;flash_placement.xml.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I included the *.s files in the build and excluded the old ones:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/Internal-files.JPG" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But I get the following build errors:&lt;/p&gt;
&lt;p&gt;Building &amp;lsquo;twi_master_using_app_twi_pca10028_sdk12&amp;rsquo; from solution &amp;lsquo;twi_master_using_app_twi_pca10028_sdk12&amp;rsquo; in configuration &amp;lsquo;nrf51422_xxac&amp;rsquo;&lt;br /&gt;1&amp;gt; Assembling &amp;lsquo;ses_nrf51_startup.s&amp;rsquo;&lt;br /&gt;2&amp;gt; Assembling &amp;lsquo;thumb_crt0.s&amp;rsquo;&lt;br /&gt;1&amp;gt; Linking twi_master_using_app_twi_pca10028_sdk12.elf&lt;br /&gt;1&amp;gt; &lt;br /&gt;1&amp;gt; Diagnostics:&lt;br /&gt;1&amp;gt; remark: increasing alignment of section .vectors from 1 to 2 because it contains executable instructions&lt;br /&gt;1&amp;gt; error: undefined symbol: __SEGGER_init_copy&lt;br /&gt;1&amp;gt; error: undefined symbol: __SEGGER_init_zero&lt;br /&gt;1&amp;gt; error: undefined symbol: __SRAM_segment_end__&lt;br /&gt;1&amp;gt; error: undefined symbol: __bss_end__&lt;br /&gt;1&amp;gt; error: undefined symbol: __bss_start__&lt;br /&gt;1&amp;gt; error: undefined symbol: __ctors_load_start__&lt;br /&gt;1&amp;gt; error: undefined symbol: __data_end__&lt;br /&gt;1&amp;gt; error: undefined symbol: __data_load_start__&lt;br /&gt;1&amp;gt; error: undefined symbol: __data_start__&lt;br /&gt;1&amp;gt; error: undefined symbol: __dtors_load_start__&lt;br /&gt;1&amp;gt; error: undefined symbol: __fast_end__&lt;br /&gt;1&amp;gt; error: undefined symbol: __fast_load_start__&lt;br /&gt;1&amp;gt; error: undefined symbol: __fast_start__&lt;br /&gt;1&amp;gt; error: undefined symbol: __rodata_end__&lt;br /&gt;1&amp;gt; error: undefined symbol: __rodata_load_start__&lt;br /&gt;1&amp;gt; error: undefined symbol: __rodata_start__&lt;br /&gt;1&amp;gt; error: undefined symbol: __stack_process_end__&lt;br /&gt;1&amp;gt; error: undefined symbol: __stack_process_start__&lt;br /&gt;1&amp;gt; error: undefined symbol: __text_end__&lt;br /&gt;1&amp;gt; error: undefined symbol: __text_load_start__&lt;br /&gt;1&amp;gt; error: undefined symbol: __text_start__&lt;br /&gt;Build failed&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It seems I should keep&amp;nbsp;the Segger_thumb?&lt;/p&gt;
&lt;p&gt;But then I get errors:&lt;/p&gt;
&lt;p&gt;Building &amp;lsquo;twi_master_using_app_twi_pca10028_sdk12&amp;rsquo; from solution &amp;lsquo;twi_master_using_app_twi_pca10028_sdk12&amp;rsquo; in configuration &amp;lsquo;nrf51422_xxac&amp;rsquo;&lt;br /&gt;2&amp;gt; Assembling &amp;lsquo;SEGGER_THUMB_Startup.s&amp;rsquo;&lt;br /&gt;1&amp;gt; Linking twi_master_using_app_twi_pca10028_sdk12.elf&lt;br /&gt;1&amp;gt; &lt;br /&gt;1&amp;gt; Diagnostics:&lt;br /&gt;1&amp;gt; error: multiply defined global symbol _start&lt;br /&gt;1&amp;gt; error: defined by thumb_crt0.o&lt;br /&gt;1&amp;gt; error: and by SEGGER_THUMB_Startup.o&lt;br /&gt;1&amp;gt; remark: increasing alignment of section .vectors from 1 to 2 because it contains executable instructions&lt;br /&gt;1&amp;gt; error: undefined symbol: __SRAM_segment_end__&lt;br /&gt;Build failed&lt;/p&gt;
&lt;p&gt;Rob&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to redirect printf to UART when using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/172041?ContentTypeID=1</link><pubDate>Wed, 20 Feb 2019 08:44:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1f7a70d-559c-4100-9c08-222b777f6a8d</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Can you use the files &lt;strong&gt;system_nrf51.c &lt;/strong&gt;and &lt;strong&gt;system_nrf51.h&lt;/strong&gt; found in&lt;em&gt; \components\toolchain&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-5178d1d1a1c349459ad0d732d4860b54/pastedimage1550651956337v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Download this zip file:&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-5178d1d1a1c349459ad0d732d4860b54/embedded_5F00_studio.zip"&gt;devzone.nordicsemi.com/.../embedded_5F00_studio.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And place it like I have on my picture, in &lt;em&gt;\components\toolchain&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Inside this file is a &lt;strong&gt;flash_placement.xml&lt;/strong&gt;, &lt;strong&gt;ses_nrf51_startup.s&lt;/strong&gt; and &lt;strong&gt;thumb_crt0.s&lt;/strong&gt; which should work.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to redirect printf to UART when using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/171865?ContentTypeID=1</link><pubDate>Tue, 19 Feb 2019 11:44:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81a2fe36-1a5a-4914-8261-b10a23d77130</guid><dc:creator>northernLight</dc:creator><description>&lt;p&gt;Hi Andreas&lt;/p&gt;
&lt;p&gt;Thanks for the prompt.&amp;nbsp; I followed the tutorial&amp;nbsp;importing the Keil project from&amp;nbsp;examples/periperals/UART/blank - target NRF51822 QFAA&lt;/p&gt;
&lt;p&gt;However I do not remember&amp;nbsp;modifying&amp;nbsp;the internal files after the import.&amp;nbsp; Which ones should I use for this SoC?&lt;/p&gt;
&lt;p&gt;The tutorial is&amp;nbsp;based upon the 52 series&lt;/p&gt;
&lt;p&gt;BW&lt;/p&gt;
&lt;p&gt;Rob&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to redirect printf to UART when using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/171800?ContentTypeID=1</link><pubDate>Tue, 19 Feb 2019 07:15:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a35f1f8-8ef5-4ee6-8de0-f5ddbfb10a9c</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi Rob.&lt;/p&gt;
&lt;p&gt;How did you exactly set up the project in Segger Embedded Studio, did you follow this &lt;a href="https://devzone.nordicsemi.com/b/blog/posts/segger-embedded-studio-a-cross-platform-ide"&gt;tutorial&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to redirect printf to UART when using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/171752?ContentTypeID=1</link><pubDate>Mon, 18 Feb 2019 22:36:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45742f1d-e7cf-41ac-8e20-385b6c8e5b7f</guid><dc:creator>northernLight</dc:creator><description>&lt;p&gt;After much checking I founder these helper instructions&amp;nbsp;(from the disassembler window)&lt;/p&gt;
&lt;p&gt;&lt;span&gt;--- SEGGER_THUMB_Startup.s -- 393 --------------------------&lt;/span&gt;&lt;br /&gt;&lt;span&gt;bx lr&lt;/span&gt;&lt;br /&gt;&lt;span&gt;HELPER __getchar&lt;/span&gt;&lt;br /&gt;&lt;span&gt;JUMPTO debug_getchar&lt;/span&gt;&lt;br /&gt;&lt;span&gt;HELPER __putchar&lt;/span&gt;&lt;br /&gt;&lt;span&gt;JUMPTO debug_putchar&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;However&amp;nbsp;removing the HELPER lines from&amp;nbsp;&lt;/span&gt;&lt;span&gt;thumb_crt0.s and crt0.s&amp;nbsp;&lt;/span&gt;&lt;span&gt;made no difference to printf nor putchar() which still direct to the debugger terminal.&amp;nbsp; Doh!!!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Point taken on the invisible powers of the optimiser.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Any ideas on what should I try next?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Rob&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to redirect printf to UART when using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/171670?ContentTypeID=1</link><pubDate>Mon, 18 Feb 2019 14:15:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f9c739a-b028-4edd-896e-6b2de8fda30c</guid><dc:creator>awneil</dc:creator><description>[quote userid="76628" url="~/f/nordic-q-a/43790/how-to-redirect-printf-to-uart-when-using-segger-embedded-studio/171652"]it does consume stack space for an unnecessary nested call[/quote]
&lt;p&gt;Does it?&lt;/p&gt;
&lt;p&gt;The optimiser may well be smart enough to avoid that ...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to redirect printf to UART when using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/171652?ContentTypeID=1</link><pubDate>Mon, 18 Feb 2019 13:48:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0aa7e50f-dbd4-4dc3-8b23-5eab46fbf37f</guid><dc:creator>northernLight</dc:creator><description>&lt;p&gt;Andreas,&lt;/p&gt;
&lt;p&gt;Thankyou for thinking about this.&amp;nbsp; I have been using the UART example in /peripherals, not the ble one.&amp;nbsp; I am compiling the example using Segger Embedded Studio which I&amp;nbsp;suspect&amp;nbsp;defines the behaviour of printf in a non-helpful way (at least to me).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;From the Segger manual:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a title="Link to Segger manual" href="https://studio.segger.com/index.htm?https://studio.segger.com/ide_property_code_help.htm"&gt;https://studio.segger.com/index.htm?https://studio.segger.com/ide_property_code_help.htm&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sending all output to the SEGGER Embedded Studio virtual terminal&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can send all output to the SEGGER Embedded Studio virtual terminal by supplying the following implementation of the&lt;b&gt;__putchar&lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;function in your code:&lt;/p&gt;
&lt;pre class="rwt-code"&gt;&lt;span class="rwt-code-control"&gt;#include&lt;/span&gt;&lt;span class="rwt-code-text"&gt; &lt;/span&gt;&lt;span class="rwt-code-operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="rwt-code-text"&gt;debugio&lt;/span&gt;&lt;span class="rwt-code-operator"&gt;.&lt;/span&gt;&lt;span class="rwt-code-text"&gt;h&lt;/span&gt;&lt;span class="rwt-code-operator"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="rwt-code-keyword"&gt;int&lt;/span&gt;&lt;span class="rwt-code-text"&gt; &lt;/span&gt;&lt;span class="rwt-code-function"&gt;__putchar&lt;/span&gt;&lt;span class="rwt-code-operator"&gt;(&lt;/span&gt;&lt;span class="rwt-code-keyword"&gt;int&lt;/span&gt;&lt;span class="rwt-code-text"&gt; &lt;/span&gt;&lt;span class="rwt-code-text"&gt;ch&lt;/span&gt;&lt;span class="rwt-code-operator"&gt;)&lt;/span&gt;
&lt;span class="rwt-code-operator"&gt;{&lt;/span&gt;
  &lt;span class="rwt-code-keyword"&gt;return&lt;/span&gt;&lt;span class="rwt-code-text"&gt; &lt;/span&gt;&lt;span class="rwt-code-function"&gt;debug_putchar&lt;/span&gt;&lt;span class="rwt-code-operator"&gt;(&lt;/span&gt;&lt;span class="rwt-code-text"&gt;ch&lt;/span&gt;&lt;span class="rwt-code-operator"&gt;);&lt;/span&gt;
&lt;span class="rwt-code-operator"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;This hands off output of the character&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;ch&lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;to the low-level debug output routine,&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;debug_putchar&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;Whilst this is an adequate implementation of&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;__putchar&lt;/b&gt;, it does consume stack space for an unnecessary nested call and associated register saving. A better way of achieving the same result is to define the low-level symbol for&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;__putchar&lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;to be equivalent to the low-level symbol for&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;debug_putchar&lt;/b&gt;. To do this, we need to instruct the linker to make the symbols equivalent.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Select the project node in the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;Project Explorer&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Display the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;Properties Window&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Enter the text&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;__putchar=debug_putchar&lt;/tt&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;into the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;Linker &amp;gt; Linker Symbol Definitions&lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;property of the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;Linker Options&lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;group.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Maybe this redirection has already been configured in the&amp;nbsp;standard install of SES.&amp;nbsp; (I am using the most recent version of SES).&amp;nbsp; I will check and come back&lt;/p&gt;
&lt;p&gt;Any thoughts?&lt;/p&gt;
&lt;p&gt;Rob&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to redirect printf to UART when using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/171561?ContentTypeID=1</link><pubDate>Mon, 18 Feb 2019 08:54:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72cbb782-b3fe-49e9-b97e-2bd57622452b</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m a bit unsure what you mean by this question.&lt;/p&gt;
&lt;p&gt;The UART example in SDK 12.3 (&lt;strong&gt;\examples\ble_peripheral\ble_app_uart&lt;/strong&gt;) have a &lt;strong&gt;printf&lt;/strong&gt; call in &lt;strong&gt;main(void)&lt;/strong&gt; which prints &lt;strong&gt;&amp;quot;UART Start!&amp;quot;&lt;/strong&gt; to &lt;strong&gt;UART.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can see it here:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-5178d1d1a1c349459ad0d732d4860b54/pastedimage1550480048532v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Can you please explain more details?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>