how to retarget newlib printf scanf to embedded systemUART ?

wnlee@cad wnlee@cad.csie.ncku.edu.tw
Sun Aug 8 16:15:00 GMT 2004


Hi Anil,

After reading your post, I do the following steps.

0.   cd $PROJECT_DIR
1.    cp ../newlib-1.12.0/newlib/libc/sys/arm/syscalls.c
2.    cp ../newlib-1.12.0/newlib/libc/sys/arm/swi.h
3.    edit Makefile add syscalls.o
4.    make clean;make

Then, I receives the followings error messages.
I guess that I fail to overwrite newlib syscalls with the copies in my ROM
code.

arm-elf-as -mzpcs-32 -mno-fpu -gdwarf2 -o vector.o vector.s
arm-elf-objdump -p -h vector.o > vector.o.objdump
arm-elf-readelf -a vector.o > vector.o.elf
arm-elf-as -mapcs-32 -mno-fpu -gdwarf2 -o init.o init.s
arm-elf-objdump -p -h init.o > init.o.objdump
arm-elf-readelf -a init.o > init.o.elf
arm-elf-gcc -Os -Wall -g  -c -o main.o main.c
main.c: In function `main':
main.c:24: warning: implicit declaration of function `strlen'
arm-elf-objdump -p -h main.o > main.o.objdump
arm-elf-readelf -a main.o > main.o.elf
arm-elf-gcc -Os -Wall -g  -c -o uart.o uart.c
arm-elf-objdump -p -h uart.o > uart.o.objdump
arm-elf-readelf -a uart.o > uart.o.elf
arm-elf-gcc -Os -Wall -g  -c -o syscalls.o syscalls.c
syscalls.c:25: error: conflicting types for `_unlink'
/armtools/arm-elf/include/sys/unistd.h:129: error: previous declaration of
`_unlink'
syscalls.c:26: error: conflicting types for `_link'
/armtools/arm-elf/include/sys/unistd.h:125: error: previous declaration of
`_link'
syscalls.c:29: error: conflicting types for `_sbrk'
/armtools/arm-elf/include/sys/unistd.h:128: error: previous declaration of
`_sbrk'
syscalls.c:30: error: conflicting types for `_getpid'
/armtools/arm-elf/include/sys/unistd.h:124: error: previous declaration of
`_getpid'
syscalls.c:37: error: conflicting types for `_write'
/armtools/arm-elf/include/sys/unistd.h:130: error: previous declaration of
`_write'
syscalls.c:39: error: conflicting types for `_lseek'
/armtools/arm-elf/include/sys/unistd.h:126: error: previous declaration of
`_lseek'
syscalls.c:41: error: conflicting types for `_read'
/armtools/arm-elf/include/sys/unistd.h:127: error: previous declaration of
`_read'
syscalls.c:49: warning: `do_AngelSWI' declared `static' but never defined
make: *** [syscalls.o] Error 1


In order to retarget _read and _write syscalls,  should we edit the newlib
source, rebuild it,
and rebuild a new toolchain for specified target?

Or we can just modified our ROM code to retagert _read and _write syscalls?
Why I got the above error messages ?

Do you have some idea according to your succesful porting experiences? :)

Wayne




More information about the Newlib mailing list