problem with.

OP
Sevc Dominik wrote:
> Hi all.
> I need read number value from string , if use atol or atoi then all is
> OK but if vant use atof then show error. why??
>
> any sugestion.
>
> regards.

compiler show:

Linking: main.elf
arm-elf-gcc -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2
-DROM_RUN -DVECTORS_IN_RAM -D__WinARM__  -Os -Wall -Wcast-align
-Wimplicit  -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type
-Wshadow -Wunused -Wa,-adhlns=Startup.lst  -I../../Common_WinARM/inc
-Wcast-qual -MD -MP -MF .dep/main.elf.d Startup.o  swi_handler.o   irq.o
target.o cnc1.o adc.o rprintf.o serial.o pwm.o axes.o timers.o
mainfuntion.o cmd.o      --output main.elf -nostartfiles
-Wl,-Map=main.map,--cref -lc  -lm -lc -lgcc
-T../../Common_WinARM/LPC2138-ROM.ld
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): undefined reference to `_sbrk_r'
mallocr.c:(.text+0x388): undefined reference to `_sbrk_r'
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): undefined reference to `_sbrk_r'
mallocr.c:(.text+0x3c): undefined reference to `_sbrk_r'
mallocr.c:(.text+0x48): undefined reference to `_sbrk_r'
collect2: ld returned 1 exit status
make: *** [main.elf] Error 1

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

regards
sbrk_r is one of the Newlib syscall stubs. You have to provide that to
glue the library to your platform and environment. It is used to support
dynamic memory allocation.

You might I suppose also consider using sscanf() to parse the string
data.

Clifford
I had this problem using sprintf(), another sys call. Here was the
solution:

at the end of your linker script file (xxxx.cmd) is a line that should
look like this:

  _end = .;    /* global symbol marking the end of application RAM */

All you need to do is add the following line directly under the above
line.

        PROVIDE(end = .);


It should look like this:

  _end = .;    /* global symbol marking the end of application RAM */
  PROVIDE(end = .);

> Linking: main.elf
> arm-elf-gcc -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2
> -DROM_RUN -DVECTORS_IN_RAM -D__WinARM__  -Os -Wall -Wcast-align
> -Wimplicit  -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type
> -Wshadow -Wunused -Wa,-adhlns=Startup.lst  -I../../Common_WinARM/inc
> -Wcast-qual -MD -MP -MF .dep/main.elf.d Startup.o  swi_handler.o   irq.o
> target.o cnc1.o adc.o rprintf.o serial.o pwm.o axes.o timers.o
> mainfuntion.o cmd.o      --output main.elf -nostartfiles
> -Wl,-Map=main.map,--cref -lc  -lm -lc -lgcc
> -T../../Common_WinARM/LPC2138-ROM.ld
> 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): undefined reference to `_sbrk_r'
> mallocr.c:(.text+0x388): undefined reference to `_sbrk_r'
> 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): undefined reference to `_sbrk_r'
> mallocr.c:(.text+0x3c): undefined reference to `_sbrk_r'
> mallocr.c:(.text+0x48): undefined reference to `_sbrk_r'
> collect2: ld returned 1 exit status
> make: *** [main.elf] Error 1
>
>> Process Exit Code: 2
>> Time Taken: 00:04
>
> regards
Moderator
Just a side-note (again)

Harold Ritter wrote:
> I had this problem using sprintf(), another sys call.

sprintf is not a system-call (in terms of newlib-syscalls) but when
using this  newlib libc function dynamic memory allocation/heap-space is
needed and since this relies on the sbrk syscall the "symptoms" are
similar.

> Here was the
> solution:
>
> at the end of your linker script file (xxxx.cmd) is a line that should
> look like this:
>
>   _end = .;    /* global symbol marking the end of application RAM */
>
> All you need to do is add the following line directly under the above
> line.
>
>         PROVIDE(end = .);
>
>
> It should look like this:
>
>   _end = .;    /* global symbol marking the end of application RAM */
>   PROVIDE(end = .);

This solves issues when the linker can not find the "end"-symbol. But as
far as I can see the OP's problem is one step "before" this: the
sbrk-syscall object code is missing. Yes, the mentioned end-symbol has
to be present too since this defines the "start-address" of the heap
which is later used by sbrk. Since the newlib in WinARM is configured to
not provide syscalls and for reentrant-syscalls one has to provide
_sbrk_r either "self written" or from another source/library does not
really matter. There should be serveral examples implementations in the
WinARM package (see examples/, utils/newlib_lpc_src and
utils/useful_from_newlib) also interesting: libsysbase from devkitarm.

Reply

A question of your own? This thread is over 18 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.