<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPCXpresso IDE中的主题 Re: LpcXpresso and Redlib  vprintf() problems</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549216#M10876</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by OldManVimes on Thu Mar 27 13:08:02 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's my version that works. It may give you a hint. I use it in combination with the CR_INTEGER_PRINTF pre-processor symbol though, since I do not need floating point support for printf() and related functions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that __sys_write is not used when the pre-processor symbol CR_PRINTF_CHAR is defined (possibly only in combination with CR_INTEGER_PRINTF), so make sure you do not use that one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that DEBUG_CONSOLE is one of my project flags and is not related to RedLib.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
/*
 * __sys_write is overridden here. It is part of the RedLib "C"
 * library and used by printf() and related functions to write
 * to some output. We send everything to the console, provided
 * that it has been enabled with DEBUG_CONSOLE.
 * Note that this trick requires the -Xlinker --allow-multiple-definition
 * flag when linking the binary.
 * If the debug console is disabled, __sys_write defaults to a
 * stub (inside the nohost RedLib library version) that does very little.
 */
#ifdef DEBUG_CONSOLE
int __sys_write(int iFileHandle, char *pcBuffer, int iLength)
{
if (iLength &amp;gt; 0)
{
serialChannelWrite(DEBUG_CHANNEL, (uint8_t*)pcBuffer, iLength);
if ((pcBuffer[iLength - 1] != '\r') &amp;amp;&amp;amp; (pcBuffer[iLength - 1] != '\n'))
{
serialChannelWrite(DEBUG_CHANNEL, (uint8_t*)"\n\r", 2);
}
}
return (iLength);
}
#endif
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 01:57:09 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T01:57:09Z</dc:date>
    <item>
      <title>LpcXpresso and Redlib  vprintf() problems</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549214#M10874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by micronpn on Thu Mar 27 09:39:55 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I am testing and comparing the same project built with Redlib, Newlib and Newlib-Nano. During the tests related to stdio I found that vprintf() doesn't work as I expected if the project is compiled using Redlib.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think to have correctly designed __sys_write to redirect the output to the UART, same redirection, with different function name, worked with the 2 newlibs (_write in their case).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any trick related to it or is it a known problem? &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:57:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549214#M10874</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: LpcXpresso and Redlib  vprintf() problems</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549215#M10875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lpcxpresso-support on Thu Mar 27 12:45:36 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;It would help to get a bit more information here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does your vprintf() call work correctly when linking with Redlib and using standard semihosted output, rather than trying to redirect to UART?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does your implementation of __sys_write() actually get called when you call vprintf(). ie if you set a breakpoint on your implementation, is that breakpoint hit?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please can you tell us what MCU you are targeting and which version of LPCXpresso you are using?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And also, please zip up and post the map file from your build to take a look at.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPCXpresso Support&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:57:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549215#M10875</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: LpcXpresso and Redlib  vprintf() problems</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549216#M10876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by OldManVimes on Thu Mar 27 13:08:02 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's my version that works. It may give you a hint. I use it in combination with the CR_INTEGER_PRINTF pre-processor symbol though, since I do not need floating point support for printf() and related functions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that __sys_write is not used when the pre-processor symbol CR_PRINTF_CHAR is defined (possibly only in combination with CR_INTEGER_PRINTF), so make sure you do not use that one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that DEBUG_CONSOLE is one of my project flags and is not related to RedLib.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
/*
 * __sys_write is overridden here. It is part of the RedLib "C"
 * library and used by printf() and related functions to write
 * to some output. We send everything to the console, provided
 * that it has been enabled with DEBUG_CONSOLE.
 * Note that this trick requires the -Xlinker --allow-multiple-definition
 * flag when linking the binary.
 * If the debug console is disabled, __sys_write defaults to a
 * stub (inside the nohost RedLib library version) that does very little.
 */
#ifdef DEBUG_CONSOLE
int __sys_write(int iFileHandle, char *pcBuffer, int iLength)
{
if (iLength &amp;gt; 0)
{
serialChannelWrite(DEBUG_CHANNEL, (uint8_t*)pcBuffer, iLength);
if ((pcBuffer[iLength - 1] != '\r') &amp;amp;&amp;amp; (pcBuffer[iLength - 1] != '\n'))
{
serialChannelWrite(DEBUG_CHANNEL, (uint8_t*)"\n\r", 2);
}
}
return (iLength);
}
#endif
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:57:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549216#M10876</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: LpcXpresso and Redlib  vprintf() problems</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549217#M10877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by micronpn on Thu Mar 27 14:27:13 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to change what I said before because I made an example program that works.&amp;nbsp; I created a new project to send you; instead, the project where vprintf doesn't work was done with a previous release of LpcXpresso, today I add this feature and it doesn't work The example project is a copy and paste of the relevant parts of the project where vprintf doesn't work so... may be related to a linker file or other things because the project wasn't create using LpcXpresso 7.0.2?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Attached there is my example project that works (I put all the files needed to compile and debug instead that the library to link).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:57:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549217#M10877</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: LpcXpresso and Redlib  vprintf() problems</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549218#M10878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lpcxpresso-support on Fri Mar 28 04:57:01 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;@micronpn.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your project works fine here for me, using LPCXpresso 7.0.2 and running on an RDB1768 board. I see the output from the call to vprintf routine output via your _sys_write() routine to the UART in the terminal window on my PC as expected. And just to double check, I can set a breakpoint on your __sys_write(), which gets hit for each character being output.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So explain what your problem is!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPCXpresso Support&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:57:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549218#M10878</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: LpcXpresso and Redlib  vprintf() problems</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549219#M10879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lpcxpresso-support on Fri Mar 28 05:03:37 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: OldManVimes&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Note that __sys_write is not used when the pre-processor symbol CR_PRINTF_CHAR is defined (possibly only in combination with CR_INTEGER_PRINTF), so make sure you do not use that one.&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;__sys_write() should still be used in this case. Can you provide an example where it doesn't??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt; * Note that this trick requires the -Xlinker --allow-multiple-definition&lt;BR /&gt; * flag when linking the binary.&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You should not need this option.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPCXpresso Support&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:57:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549219#M10879</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: LpcXpresso and Redlib  vprintf() problems</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549220#M10880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by OldManVimes on Sat Mar 29 03:27:24 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi support,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are correct. I stand corrected on both issues. Thanks for the update. I've adapted my build settings and code comments accordingly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:57:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LpcXpresso-and-Redlib-vprintf-problems/m-p/549220#M10880</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:57:12Z</dc:date>
    </item>
  </channel>
</rss>

