EmbDev.net

Forum: ARM programming with GCC/GNU tools sprintf


Author: Harold Ritter (hlritter)
Posted on:

Rate this post
0 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!

Author: Mhel Marcelo (mhel)
Posted on:

Rate this post
0 useful
not useful
somewhere in this
http://forum.sparkfun.com/viewtopic.php?t=5390&pos...
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!

Author: Harold Ritter (hlritter)
Posted on:

Rate this post
0 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&pos...
> 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!

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.