EmbDev.net

Forum: ARM programming with GCC/GNU tools sprintf


von Harold R. (hlritter)


Rate this post
useful
not useful
I am attempting to use sprintf without success.

in main i have:

char str[80];


  sprintf(str, "sprintf test - Hex Number %02X - Decimal Number %d",
127, 0x0a);

After this line of code is run I would expect str to conatin:
  "sprintf test - Hex Number 7F - Decimal Number 10" without the quotes
ocourse.

This code does not compile. I never get to run it. Instead I get this
build error:

C:\msys\1.0\home\yagarto\newlib-build\arm-elf\newlib\libc\sys\arm/../../ 
../../../../newlib-1.14.0/newlib/libc/sys/arm/syscalls.c
undefined reference to `end'

This directory does not even exist on my hard drive!

von Mhel M. (mhel)


Rate this post
useful
not useful
somewhere in this
http://forum.sparkfun.com/viewtopic.php?t=5390&postdays=0&postorder=asc&start=15&sid=01422ee0aa76eee5510ade03e165d0e3
has the answer.
I believed Clifford mentioned it sometime ago relating to syscalls, and
pointed to the same link.

Harold Ritter wrote:
> I am attempting to use sprintf without success.
>
> in main i have:
>
> char str[80];
>
>
>   sprintf(str, "sprintf test - Hex Number %02X - Decimal Number %d",
> 127, 0x0a);
>
> After this line of code is run I would expect str to conatin:
>   "sprintf test - Hex Number 7F - Decimal Number 10" without the quotes
> ocourse.
>
> This code does not compile. I never get to run it. Instead I get this
> build error:
>
> C:\msys\1.0\home\yagarto\newlib-build\arm-elf\newlib\libc\sys\arm/../../ 
../../../../newlib-1.14.0/newlib/libc/sys/arm/syscalls.c
> undefined reference to `end'
>
> This directory does not even exist on my hard drive!

von Harold R. (hlritter)


Rate this post
useful
not useful
Mhel,

Thank you so much! Indeed the answer was there and here it is quoted
directly from Sparkfun. IT WORKS!

***********************************************************
The end is close.
The end in this case is a symbol that points to the first free word in
RAM after all global variables has been placed there. Some codelibraries
use the symbol _end and some use the symbol end (without the
underscore). It is usually defined in the linker script, in you case

demo_at91sam7_blink_flash.cmd

At the end, after the the definition of the symbol _end, add the line
PROVIDE(end = .);
This means: let the symbol 'end' point to the current position unless it
has been given a differnt value somewhere else.
[Jim] Perhaps this should standard in the linker scripts.
Code:

       _end = .;
       PROVIDE(end = .);

So actually end is the beginning of the heap.

Regards,
Magnus
*************************************************************

Thanks again Mhel and a special thanks to Magnus on sparkfun!

Harold



Mhel Marcelo wrote:
> somewhere in this
> 
http://forum.sparkfun.com/viewtopic.php?t=5390&postdays=0&postorder=asc&start=15&sid=01422ee0aa76eee5510ade03e165d0e3
> has the answer.
> I believed Clifford mentioned it sometime ago relating to syscalls, and
> pointed to the same link.
>
> Harold Ritter wrote:
>> I am attempting to use sprintf without success.
>>
>> in main i have:
>>
>> char str[80];
>>
>>
>>   sprintf(str, "sprintf test - Hex Number %02X - Decimal Number %d",
>> 127, 0x0a);
>>
>> After this line of code is run I would expect str to conatin:
>>   "sprintf test - Hex Number 7F - Decimal Number 10" without the quotes
>> ocourse.
>>
>> This code does not compile. I never get to run it. Instead I get this
>> build error:
>>
>> C:\msys\1.0\home\yagarto\newlib-build\arm-elf\newlib\libc\sys\arm/../../ 
../../../../newlib-1.14.0/newlib/libc/sys/arm/syscalls.c
>> undefined reference to `end'
>>
>> This directory does not even exist on my hard drive!

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.