EmbDev.net

Forum: ARM programming with GCC/GNU tools problem with.


Author: Sevc Dominik (sevc)
Posted on:

Rate this post
0 useful
not useful
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.

Author: Sevc Dominik (sevc)
Posted on:

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

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

Rate this post
0 useful
not useful
Search the forum for sbrk

Author: Clifford Slocombe (clifford)
Posted on:

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

Author: Harold Ritter (hlritter)
Posted on:

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

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

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

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.