The platform is S32(S32 Design Studio for Power Architecture, Version 1.0 build 151127), now i can use uart send data to the serial port terminal. if i want to use "printf" with uart, how should i configure the project?
Thank you very much!
UART_SendData(&LINFlexD_X ,0xaa); /* this is ok now*/
printf ("Characters: %c %c \n", 'a', 65); /*build err here Description Resource Path Location Type
S32DS/e200_ewl/EWL_C/src/stdio/printf.c undefined reference to `__pformatter' Example_Base line 44 C/C++ Problem
*/
It already look like this: but it still report the err
.stack (NOLOAD) : ALIGN(16)
{
__HEAP = . ;
. += __HEAP_SIZE ;
__HEAP_END = . ;
_stack_end = . ;
. += __STACK_SIZE ;
_stack_addr = . ;
__SP_INIT = . ;
. += 4;
} > m_data
Secondly, i find in the uart_console_io.c file, the three include file(below) cann't be found. I think this uart_console_io.c file is not suitable for newlib
#include <ansi_parms.h>
#include "console_io.h"
#include <ewl_misra_types.h>
Hi,
use the following code for .stack section
.stack (NOLOAD) : ALIGN(16)
{
__HEAP = . ;
_end = . ;
end = . ;
. += __HEAP_SIZE ;
__HEAP_END = . ;
_stack_end = . ;
. += __STACK_SIZE ;
_stack_addr = . ;
__SP_INIT = . ;
. += 4;
} > m_data
Regards,
Martin
Thank you Martin Kovar! This works!
But i still have another problem. Since i choose the newlib, i find that the "uart_console_io.c" file doesn't work well. "uart_console_io.c" file has three include file :
#include <ansi_parms.h>
#include "console_io.h"
#include <ewl_misra_types.h>
The three file could not be found. So add the path(you can see in the pic below)
After that the project build OK. But when the program runs, i find that the printf can not send anything.
I put a breakpoint at function "__write_console", and find that the program doesnot stop at the function "__write_console".
So i guess that the printf does not call "__write_console".
Need other settings?
Hi,
sorry for delay, but I have no experience with printf function using newlib library yet. Please give me a time, I will investigate, how it works and I will write you back if it is possible to use it.
Regards,
Martin
Hi,
at first, I would like to apologize for my previous claim. EWL library supports formaters like %d or %f. There is completely different issue, which can be easily fixed.
Add the following line to the Linker flags:
-Xlinker --undefined=__pformatterFP -Xlinker --defsym=__pformatter=__pformatterFP
Now it will work correct.
Regards,
Martin
Thank you very much! It works!
I wander is there any book or document introduce about the "linker" thing of S32?
for example i do not know the exact meaning of the following two lines(list follow) and also the "-Xlinker --undefined=__pformatterFP -Xlinker --defsym=__pformatter=__pformatterFP"
.stack (NOLOAD) : ALIGN(16)
{
__HEAP = . ;
_end = . ;???????????????
end = . ;???????????????
. += __HEAP_SIZE ;
__HEAP_END = . ;
_stack_end = . ;
. += __STACK_SIZE ;
_stack_addr = . ;
__SP_INIT = . ;
. += 4;
} > m_data
Hi,
S32DS uses gcc compiler and linker and these are under GNU GPL license. So the documentation is public, please look at the following URLs.
https://sourceware.org/binutils/docs/ld/
About "-Xlinker --undefined=__pformatterFP -Xlinker --defsym=__pformatter=__pformatterFP", it is little bit complicated, but I will try to explain.
When you call printf with some formatter, for example printf("%d",0xAA), function int_t _EWL_CDECL printf from printf.c file is called. In this function, __pformatter function is called. But this __pformatter calls function from stdio_api.h, which is not correct. Correct function, which has to be called is function __pformatterFP placed in __printformat.c file.
So the linker flag says that there is undefined symbol __pformatterFP (part -Xlinker --undefined=__pformatterFP) and define symbol __pformatter as a __pformatterFP (part -Xlinker --defsym=__pformatter=__pformatterFP ). So from my point of view, symbol __pformatter is replaced by __pformatterFP. Now correct function is called and the program could be compiled.
About the end symbols, please look at the following URL:
libgloss/libnosys/sbrk.c - native_client/nacl-newlib - Git at Google
You can see that line 10 declares extern char end; /* Set by linker. */. This is the symbol which has to be add to the linker file.
I hope it helps you a little bit, but if you have any other questions, please feel free to write me back.
Regards,
Martin
Hi,
please look at the following example:
Example MPC5744P PinToggleStationery S32DS
If you have any other questions, please feel free to write me back.
Regards,
Martin
Thank you very much!
now i find a strange problem
if i write like this:
printf("Best Regards, Technical Information Center\r\n"); --->It's OK!
but if i write like this:
printf("Best Regards %d, Technical Information Center\r\n", 0xAA); ---> it reports an err
"S32DS/e200_ewl/EWL_C/src/stdio/printf.c undefined reference to `__pformatter' Example_Base line 44 C/C++ Problem"
i find even in the project"Example MPC5744P PinToggleStationery S32DS", it also reports the same err
Hi,
EWL library does contain only printf function, which accepts const char * parameter. If you want to pass any other parameters like integer, float, etc.. you have to use NewLib library. This library can be chosen while you create a project (in project wizard) or you can change it in project settings (see figure below)
Regards,
Martin
Thank you Martin Kovar ,
I have tried this
(learn form this Linker errors when using the "new" operator )
but i meet the same problem " sbrk.c:21: undefined reference to `end' "
the author say " changed the heap size and added an "end" definition at the beginning of the heap section, it works just fine."
I donot know how "added an "end" definition at the beginning of the heap section"? could you help me for that? thank you very much!
Hi,
you have to change your linke file. In your project folder direct to Project_Settings and edit section.ld
Section .stack should look like that:
.stack (NOLOAD) : ALIGN(16) | |
{ | |
__HEAP = . ; | |
. += __HEAP_SIZE ; | |
__HEAP_END = . ; | |
_stack_end = . ; | |
. += __STACK_SIZE ; | |
_stack_addr = . ; | |
__SP_INIT = . ; | |
. += 4; | |
} > m_data |
Regards,
Bernhard