Undefined InitializeUART, ReadUARTN, WriteUARTN

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Undefined InitializeUART, ReadUARTN, WriteUARTN

6,184 Views
dan_quist
Contributor III

I'm setting up a new C++ project for a Coldfire MCF52110.

 

Everything builds fine until I start including code from the EWL_C++ library - I then get three linker errors.

 

Undefined InitializeUART Referenced from __init_uart_console

Undefined ReadUARTNReferenced from __read_console

Undefined WriteUARTNReferenced from __write_console

 

I don't understand why these keep popping up, especially because the files that are getting referenced are getting compiled out using the _EWL_CONSOLE_SUPPORT define.

 

I've tried rebuilding the EWL project several times, that doesn't seem to help either.

 

I don't need or want console support. How do I get rid of these linker errors?

 

Dan

Labels (1)
10 Replies

3,920 Views
abhishekpatil
Contributor I

Hi

I am trying to port some stack on the MPC5675K and am using eclipse cdt and my code has lot of printf's and am getting this errors you mentioned above is their any other solution for this other than build->settings->librarian.

i have given the path of the .a file it askes in LDFLAGS but ists not finding, I also added the path in environment variable,

The code is as below,

LDFLAGS = "-lr C:/Freescale/PA_Support/ewl -lr C:/Freescale/PowerPC_EABI_Support -lr C:/Freescale/PowerPC_EABI_Tools";

The error goes as below,

mwldeppc.exe: undefined: 'InitializeUART'

mwldeppc.exe: Referenced from '__init_uart_console' in

mwldeppc.exe: libc_E200z650_VLE_SPFP_Only.a

mwldeppc.exe: undefined: 'ReadUARTN'

mwldeppc.exe: Referenced from '__read_console' in

mwldeppc.exe: libc_E200z650_VLE_SPFP_Only.a

mwldeppc.exe: undefined: 'WriteUARTN'

mwldeppc.exe: Referenced from '__write_console' in

mwldeppc.exe: libc_E200z650_VLE_SPFP_Only.a

mwldeppc.exe: undefined: '_ExitProcess'

Errors caused tool to abort.

mwldeppc.exe: Referenced from 'exit' in libc_E200z650_VLE_SPFP_Only.a

mwldeppc.exe: undefined: '_ExitProcess'

mwldeppc.exe: Referenced from 'abort' in libc_E200z650_VLE_SPFP_Only.a

mwldeppc.exe: alert: Link failed.

0 Kudos
Reply

3,920 Views
mohammedzakari1
Contributor I

Hi Abhishek,

Hows going on this issue? if you got the solution can you share the steps please, I am facing the same issue,

I am using CW 5.9.0 , powerPC platform. Below are the error... Need help

 

Link Error : undefined: 'InitializeUART'
Referenced from '__init_uart_console' in MSL_C.PPCEABI.bare.E.UC.a

Link Error : undefined: 'ReadUARTN'
Referenced from '__read_console' in MSL_C.PPCEABI.bare.E.UC.a

Link Error : undefined: 'WriteUARTN'
Referenced from '__write_console' in MSL_C.PPCEABI.bare.E.UC.a

 

Appreciated the help.

 

Thanks,

-Mohammed

0 Kudos
Reply

3,920 Views
FridgeFreezer
Senior Contributor I

Should it help anyone, I just had this problem crop up in my code when I included "assert.h" as I am not using any of the stdio libs. Replacing it with a simple one-liner definition of assert() fixed it.

0 Kudos
Reply

3,920 Views
TomE
Specialist II

Search for "__init_uart_console" and see if the previous posts answer your question.

Tom

0 Kudos
Reply

3,920 Views
dan_quist
Contributor III

I spent over an hour searching, including that phrase. I can't find a single post that answers this question.

0 Kudos
Reply

3,920 Views
Monica
Senior Contributor III

Hello Dan, how is the project going, any breakthroughs?

Please keep us posted, we'd like to know! :smileywink:

Best regards,

Monica

0 Kudos
Reply

3,920 Views
admin
Specialist II

Hey All,

I came across this issue too and found a couple of solutions that worked for me.  Not sure if this topic is still open.  But anyway, here's my input.

The traditional solution to this issue in the past has been to define the low-level UART functions *before* the standard library functions.  I.e., __read_console, __write_console, and __close_console (see [ewl]/sys/console_io.h) would overwrite the functions of the same name found in the EWL_C library.  This also required an "Initialize UART" function to set up the UART settings; i.e., baud, pins, etc.  While this solution worked perfectly fine in a *C* project, I discovered some nuances and annoyances when transferring the same working code from a *C* project to a *C++* project. 

To overcome this, I discovered a MUCH easier solution, that requires *no* UART set up at all.  With the latest release of Codewarrior (version 10.4...must be the one with *out* code size restriction), there's a feature that let's users specify the Console window/tab for I/O!  When a creating a new project, all the user has to do is specify the "Developer Console" option instead of the "UART" one under the I/O options.  For existing projects, the I/O options can always be changed after the fact by going to the Project Properties (Alt+Enter)  --> C/C++ Build --> Librarian:

* ewl_c / ewl_c++ --> this requires the UART code to be defined.

* ewl_c_hosted / ewl_c++_hosted --> no UART code required.  stdio will route to the developer's console.  no need to open some third-party terminal window and enter COM port settings.  (really cool!)

* ewl_c_no_io / ewl_c++_no_io  --> disable console I/O altogether?  Well, kind of...stdio functions won't be compiled, so all calls to stdio functions will have to be omitted; i.e., #define DBG_PRINT 0 or similar.

I realize that this feature (semihosting) might have been available before, but the latest version of codewarrior (10.4) makes it much more noticeable and easier to use.   Some users may have an issue with the slightly slower baud rate, but I don't think this is a huge deal.

Lastly, as a word of caution...be careful with those scanf's and printf's...

I hope this helps,

Rich

3,920 Views
bowerymarc
Contributor V

wouldn't that mean your app would only run attached to the debugger?

0 Kudos
Reply

3,920 Views
venkatachalapat
Contributor II

Thanks Rich, your effort helped me a lot, for some reason I would like to use traditional terminal than console, anybody has the source code for these functions which i can use while eliminating the above errors (K21 device)

initializeUART(), ReadUARTN(), WriteUARTN()

thanks

tvc

3,920 Views
TomE
Specialist II

> I spent over an hour searching,

It would have helped if you'd mentioned your previous research.

The problem is with the Development Environment setup rather than with using the CPU, which is what this forum is (mainly) for. So one of the Tools/Development forums may get you a better audience.

I know you've been down this path, and may have dismissed all of these, but just in case...

Something must still be pulling in those "__xxxx_console" functions for them to then want the other definitions. Are you using MQX? This post mentions "bare metal printf()" and "a bunch of code you pulled in from elsewhere" which might be related to your problem as it might describe whatever "EWL" is:

twrmp55125 linker error with printf

There's often problems compiling code written for an older CW or MQX with newer versions. These things don't support "mix and match" or older versions of code (and there often aren't newer versions):

Error Undefined InitializeUART

Tom

0 Kudos
Reply