I can't build the program with memory allocation functions thats work
correctly.
I definded _sbrk() and _sbrk_functions, but malloc returns zero-pointer,
or getting stick in after second call of _sbrk_r().
CPU - LPC2214
i tried to compile syscalls.c in pure arm mode and in thumb-interwork,
but result is same
----------------syscalls.c cut------------------------------------
extern char _end;
caddr_t _sbrk(int incr)
{
HalDebugInfo("sbrk\n");
static unsigned char *heap_end =0;
unsigned char *prev_heap_end=0;
if( heap_end == 0 ) heap_end = (caddr_t)&_end;
prev_heap_end = heap_end;
heap_end += incr;
return(caddr_t) prev_heap_end;
}
void *_sbrk_r(struct _reent* reent, ptrdiff_t incr)
{
return _sbrk(incr);
}
-----------------------------------------------------------------
Whats version of libc should i use ?
..\arm-elf\lib\interwork\libc.a // the program get stack in
after
// second _sbrk_r call
..\arm-elf\lib\thumb\interwork\libc.a // malloc always return zero
pointer
..\arm-elf\lib\be\interwork
..\arm-elf\lib\be\nofmult
Does anybody has a working code for memory functions ?
Vyachwslav Krutov wrote: > [...] > Does anybody has a working code for memory functions ? There is working code for sbrk in the newlib-lpc, source comes with WinARM in utils/newlib_lpc_src/. In other examples sbrk is implemented in the file syscalls.c (basicly code from newlib-lpc or the newlib-default-code or from Keil-Examples - it my differ a little bit). Also check if end is provided correctly in the linker-script. Martin Thomas
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
Log in with Google account
No account? Register here.