EmbDev.net

Forum: ARM programming with GCC/GNU tools WinArm and sprintf


Author: Timo (Guest)
Posted on:

Rate this post
0 useful
not useful
Hi,

How can i use sprintf function with WinArm gcc compiler. When i try use
the sprintf function , comes next error:

Linking: main.elf
arm-elf-gcc -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2
-DROM_RUN  -Os -Wall -Wcast-align -Wcast-qual -Wimplicit
-Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow
-Wunused -Wa,-adhlns=crt0.lst  -I../Common_WinARM/inc -MD -MP -MF
.dep/main.elf.d crt0.o  ../Common_WinARM/src/Startup.o
../Common_WinARM/src/swi_handler.o  ../Common_WinARM/src/irq.o
../Common_WinARM/src/target.o ../Common_WinARM/src/timer.o main.o
efsl_time_LPC.o extint.o adc.o spi.o  humi.o write_sd.o      --output
main.elf -nostartfiles -Wl,-Map=main.map,--cref -lc -lnewlib-lpc -lm -lc
-lgcc   -lefsl -L../../ -TLPC2138-ROM.ld
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
Warning: c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_close_r.o) does
not support interworking, whereas main.elf does
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
Warning: c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_fstat_r.o) does
not support interworking, whereas main.elf does
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
Warning: c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_lseek_r.o) does
not support interworking, whereas main.elf does
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
Warning: c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_read_r.o) does
not support interworking, whereas main.elf does
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
Warning: c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_sbrk_r.o) does
not support interworking, whereas main.elf does
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
Warning: c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_write_r.o) does
not support interworking, whereas main.elf does
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
Warning: c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_ioctl_r.o) does
not support interworking, whereas main.elf does
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_sbrk_r.o)(_sbrk_r):
warning: interworking not enabled.
  first occurrence:
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(freer.o):
thumb call to arm
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(freer.o):
In function `_malloc_trim_r':
mallocr.c:(.text+0x2c): warning: internal error: dangerous error
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_sbrk_r.o)(_sbrk_r):
warning: interworking not enabled.
  first occurrence:
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(freer.o):
thumb call to arm
mallocr.c:(.text+0x3c): warning: internal error: dangerous error
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_sbrk_r.o)(_sbrk_r):
warning: interworking not enabled.
  first occurrence:
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(freer.o):
thumb call to arm
mallocr.c:(.text+0x48): warning: internal error: dangerous error
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_fstat_r.o)(_fstat_r):
warning: interworking not enabled.
  first occurrence:
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(makebuf.o):
thumb call to arm
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(makebuf.o):
In function `__smakebuf':
makebuf.c:(.text+0x1c): warning: internal error: dangerous error
makebuf.c:(.text+0xb2): undefined reference to `isatty'
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_sbrk_r.o)(_sbrk_r):
warning: interworking not enabled.
  first occurrence:
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(mallocr.o):
thumb call to arm
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(mallocr.o):
In function `_malloc_r':
mallocr.c:(.text+0x2e8): warning: internal error: dangerous error
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_sbrk_r.o)(_sbrk_r):
warning: interworking not enabled.
  first occurrence:
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(mallocr.o):
thumb call to arm
mallocr.c:(.text+0x388): warning: internal error: dangerous error
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_close_r.o)(_close_r):
warning: interworking not enabled.
  first occurrence:
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(stdio.o):
thumb call to arm
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(stdio.o):
In function `__sclose':
stdio.c:(.text+0xc): warning: internal error: dangerous error
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_lseek_r.o)(_lseek_r):
warning: interworking not enabled.
  first occurrence:
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(stdio.o):
thumb call to arm
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(stdio.o):
In function `__sseek':
stdio.c:(.text+0x2a): warning: internal error: dangerous error
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_lseek_r.o)(_lseek_r):
warning: interworking not enabled.
  first occurrence:
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(stdio.o):
thumb call to arm
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(stdio.o):
In function `__swrite':
stdio.c:(.text+0x6e): warning: internal error: dangerous error
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_write_r.o)(_write_r):
warning: interworking not enabled.
  first occurrence:
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(stdio.o):
thumb call to arm
stdio.c:(.text+0x86): warning: internal error: dangerous error
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_read_r.o)(_read_r):
warning: interworking not enabled.
  first occurrence:
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(stdio.o):
thumb call to arm
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(stdio.o):
In function `__sread':
stdio.c:(.text+0xaa): warning: internal error: dangerous error
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_close_r.o): In function
`_close_r':
_close_r.c:(.text+0x38): undefined reference to `device_table'
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_read_r.o): In function
`_read_r':
_read_r.c:(.text+0xa0): undefined reference to `device_table'
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_write_r.o): In function
`_write_r':
_write_r.c:(.text+0xe8): undefined reference to `device_table'
c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_ioctl_r.o): In function
`_ioctl_r':
_ioctl_r.c:(.text+0x48): undefined reference to `device_table'
collect2: ld returned 1 exit status
make.exe: *** [main.elf] Error 1

> Process Exit Code: 2
> Time Taken: 00:06

Thanx Timo

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
Timo wrote:

> Linking: main.elf
> arm-elf-gcc -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2
[...]
> main.elf -nostartfiles -Wl,-Map=main.map,--cref -lc -lnewlib-lpc -lm -lc
> -lgcc   -lefsl -L../../ -TLPC2138-ROM.ld
[...]
> c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
> Warning: c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_close_r.o) does
> not support interworking, whereas main.elf does
[...]

The precompiled newlib-lpc library (libnewlib-lpc.a) in the
WinARM-package 6/06 does not support interwork. You can compile your own
with interwork-support:
- add thumb-interwork switch to the compiler-parameters in
WinARM\utils\newlib_lpc*_src\makefile
- rebuild the lib (make lib)
- copy the ".a-file" to a location where the linker searches for
libraries

Hope this helps,
Martin Thomas

Author: Timo (Guest)
Posted on:

Rate this post
0 useful
not useful
Martin Thomas wrote:
> Timo wrote:
>
>> Linking: main.elf
>> arm-elf-gcc -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2
> [...]
>> main.elf -nostartfiles -Wl,-Map=main.map,--cref -lc -lnewlib-lpc -lm -lc
>> -lgcc   -lefsl -L../../ -TLPC2138-ROM.ld
> [...]
>> c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:
>> Warning: c:\winarm\arm-elf\bin\../lib\libnewlib-lpc.a(_close_r.o) does
>> not support interworking, whereas main.elf does
> [...]
>
> The precompiled newlib-lpc library (libnewlib-lpc.a) in the
> WinARM-package 6/06 does not support interwork. You can compile your own
> with interwork-support:
> - add thumb-interwork switch to the compiler-parameters in
> WinARM\utils\newlib_lpc*_src\makefile
> - rebuild the lib (make lib)
> - copy the ".a-file" to a location where the linker searches for
> libraries
>
> Hope this helps,
> Martin Thomas

Hi Martin,

Can you clarify me how the process goes. I'am so new with the makefiles.

Timo

Author: Francesco Cuzzocrea (Company: BLT Italia SRL) (the_cuf)
Posted on:

Rate this post
0 useful
not useful
Hi Martin
I have the same problem and I'm new to winarm. I translated a code 
written for Keil to winarm, but using the newlib I have some problem. In 
first it seems that the newlib aren't  written for my processor 
(LPC2378).  Moreover I attempt to compile with the thumb-interwork 
switch, but I had some problems :  Where I should activate the switch in 
the makefile ?  Moreover, before compiling with the switch I attempt to 
compile the library "as is", that is I entered into the directory 
(C:\Programmi\WinARM\utils\newlib_lpc_rel5a_src) with a dos shell and 
write ARMmake (I renomined the make.exe because of conflicts with the 
Borland C++ Builder installed on my PC).  The result is:

C:\Programmi\WinARM\utils\newlib_lpc_rel5a_src>armmake
Touch  Version 4.2  Copyright (c) 1998 Borland International

arm-elf-ar cr libnewlib-lpc.a _close_r.o
arm-elf-ar cr libnewlib-lpc.a _fstat_r.o
arm-elf-ar cr libnewlib-lpc.a _ioctl_r.o
arm-elf-ar cr libnewlib-lpc.a _lseek_r.o
arm-elf-ar cr libnewlib-lpc.a _open_r.o
arm-elf-ar cr libnewlib-lpc.a _read_r.o
arm-elf-ar cr libnewlib-lpc.a _sbrk_r.o
arm-elf-ar cr libnewlib-lpc.a sys_dev.o
arm-elf-ar cr libnewlib-lpc.a sys_mam.o
arm-elf-ar cr libnewlib-lpc.a sys_pll.o
arm-elf-ar cr libnewlib-lpc.a sys_time.o
arm-elf-ar cr libnewlib-lpc.a sys_vic.o
arm-elf-ar cr libnewlib-lpc.a sys_vpb.o
arm-elf-ar cr libnewlib-lpc.a uart0_poll.o
/usr/bin/sed: -e expression #1, char 61: unterminated `s' command
arm-elf-ld -v -otest2.prg -L.  crt0.o test2.o _close_r.o _fstat_r.o 
_ioctl_r.o _
lseek_r.o _open_r.o _read_r.o _sbrk_r.o sys_dev.o sys_mam.o sys_pll.o 
sys_time.o
 sys_vic.o sys_vpb.o uart0_poll.o uart0_int.o uart1_poll.o uart1_int.o 
_write_r.
o interrupt_sup.o uart0_ishell.o uart1_ishell.o -Tlpc210x.ld
GNU ld version 060606 20060606
arm-elf-ld: cannot find -lgcc
armmake: *** [test2.prg] Error 1

C:\Programmi\WinARM\utils\newlib_lpc_rel5a_src>

As you can see it seems that the makefile starts the Borland Touch.  I 
can't find the point in the makefile in order to correct this.
Where I can find a step by step tutorial ?  For a programmer that comes 
from Keil it's very difficult to start with WinARM.
Thanks in advance for help.

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Francesco Cuzzocrea wrote:
> Hi Martin
> I have the same problem and I'm new to winarm. I translated a code
> written for Keil to winarm, but using the newlib I have some problem. In
> first it seems that the newlib aren't  written for my processor
> (LPC2378).

I guess you mean newlib-lpc not newlib. The newlib is a "generic" libc 
and newlib-lpc is an "add-on" to fill newlib's stubs to interface with 
the LPC-hardware. newlib-lpc is made be Aeolus
Yes, I guess the newlib-lpc is not written for the LPC23xx/24xx. These 
parts use a different vector-controller which needes a slightly 
different setup.

> Moreover I attempt to compile with the thumb-interwork
> switch, but I had some problems :  Where I should activate the switch in
> the makefile ?  Moreover, before compiling with the switch I attempt to
> compile the library "as is", that is I entered into the directory
> (C:\Programmi\WinARM\utils\newlib_lpc_rel5a_src) with a dos shell and
> write ARMmake (I renomined the make.exe because of conflicts with the
> Borland C++ Builder installed on my PC).  The result is:
>
> C:\Programmi\WinARM\utils\newlib_lpc_rel5a_src>armmake
> Touch  Version 4.2  Copyright (c) 1998 Borland International

Borland? Does not look good. GNU shell utils should be used (MinGW, 
cygwin etc).

> /usr/bin/sed: -e expression #1, char 61: unterminated `s' command

hmm. This does not look that good. Please check source-archive of WinARM 
again. There should be another makefile which I used to build 
newlib-lpc.

> arm-elf-ld -v -otest2.prg -L.  crt0.o test2.o _close_r.o _fstat_r.o
> _ioctl_r.o _
> lseek_r.o _open_r.o _read_r.o _sbrk_r.o sys_dev.o sys_mam.o sys_pll.o
> sys_time.o
>  sys_vic.o sys_vpb.o uart0_poll.o uart0_int.o uart1_poll.o uart1_int.o
> _write_r.
> o interrupt_sup.o uart0_ishell.o uart1_ishell.o -Tlpc210x.ld
> GNU ld version 060606 20060606
> arm-elf-ld: cannot find -lgcc

not good. Maybe because of fixed path-names in the original makefile 
from Aeolus. Try to find the other makefile and use it for another test.

> As you can see it seems that the makefile starts the Borland Touch.  I
> can't find the point in the makefile in order to correct this.
> Where I can find a step by step tutorial ?  For a programmer that comes
> from Keil it's very difficult to start with WinARM.

Yes esp. the handling how stdio is attached to the hardware is a little 
different but the concept is the same. Please note that stdio-functions 
from the newlib need more memory than the ones from Keil's libc. If you 
just need sprintf without floating-point-support it might be a good idea 
to look for an alternate implementation which does not depend on 
newlib/newlib-lpc. IRC there is some code for a sprintf-replacement in 
the examples of the TNKernel source-package.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.