problem with.

OP #1173535
Rate this post
useful
not useful
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
#1173538
Rate this post
useful
not useful
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 #1173539
Rate this post
useful
not useful
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

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now