retargeting printf to uart using Newlib?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

retargeting printf to uart using Newlib?

1,955件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by deeearth on Mon Sep 16 01:21:12 MST 2013
I need to use printf in my code, but i cant use semihosting as i would need to be connected to the debugger, my project will need to be standalone therefore i would need to use a  no host libary.

I've already looked at the link: http://support.code-red-tech.com/CodeRedWiki/UartPrintf and the example it says to look at.
With the RDB1768 example code I've verified i can re-target with the Redlib (nohost) and i can get the correct output over the uart, but i cant use Redlib in my final project as it doesn't support C++.

my only option is to use the NewLib when i change the libary to NewLib (nohost) i get no output at all.
has anyone else had to use NewLib in this way?

thanks
Deeearth
0 件の賞賛
返信
3 返答(返信)

1,527件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by HelloLpcXpresso on Thu Mar 26 05:54:49 MST 2015
Hello LPCSupport,

My UART/re-targeted function prints garbage on the screen. I am using newlibnano (no host) library and LPC1769 processor.

The function works well on a test code using CMSIS library, but in a different project with application firmware that does not use the built-in library functions, this prints junk characters. Any hints?

0 件の賞賛
返信

1,527件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by deeearth on Tue Sep 17 01:26:29 MST 2013
I'm using a lpc1769 and lpcxpresso 5.1.2

I tried to set a break point on the write but nothing happened when i used the Newlib nohost. (having a look at the linker map shows printf and __write are in the Discarded input section)

The UART/re-targeted __write function works correctly when using the redlib nohost

I've attached my test program which is pretty much the code_red RDB_1769 example code, ive changed the retarget to toggle the led on the board so that anyone can try it. (don't need to use the UART) currently this is set to using the redlib no host which means that the led will toggle the breakpoint should be hit.

if you change the lib to newlib then it wont be.

Update: I think I've found the problem the retarget was using __write() and not _write(), not sure if this would make a difference but when i try to debug it it now gives a:
15: Target error from Commit Flash write error could anyone comment on what this means? ive tried to power the board externally with no luck.
0 件の賞賛
返信

1,527件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Mon Sep 16 23:55:27 MST 2013
I've certainly done this in the past - that is where the information on retargeting Newlib in the FAQ you reference came from.

A couple of obvious things...

[list=1]
  [*]Does you implementation of _write() actually get called when you call printf(). ie if you set a breakpoint on your implementation, is that breakpoint hit?


  [*]Does the UART function that your implementation of _write() calls actually output text to your terminal if you call it directly?
[/list]

If the above don't help you to work out where the problem is, you will probably need to export and post a buildable simple test project that shows up the problem.

Please also ensure that you tell us what MCU you are targeting and which version of LPCXpresso you are using.

Regards,
LPCXpresso Support




0 件の賞賛
返信