I call the malloc() funcion in a little routine like this
#######################################
/*******************************************************************************
* Function Name : main
* Description : Main program.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
int main(void)
{
#ifdef DEBUG
debug();
#endif
ioInit();
uart1Init();
printf1("Hello!\n\r");
/* Infinite loop */
pnt = (u8*)malloc(8);
while (1)
{
}
}
#######################################
when i compile this, the linker show this message:
#######################################
Building C:\Lavoro\DDB\malloc\Malloc.rapp
Running : LD
\"C:\Programmi\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -mcpu=cortex-m3 -mthumb -Wl,-T -Xlinker "./obj\Malloc.elf.ld" -u _start -Wl,-static -Wl,--gc-sections -nostartfiles -Wl,-Map -Xlinker "./lst\Malloc.map"
c:/programmi/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.2.3/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text+0xc): undefined reference to `_sbrk'
collect2: ld returned 1 exit status
Build failed
#######################################
where is the problem? How you can solve? :(
Thank You
|
As it's to do with GCC and not Raisonance specifically, try looking here:
http://www.luminarymicro.com/component/option,com_joomlaboard/Itemid,92/func,view/id,2256/catid,6/
You should also consider whether dynamic allocation is really necessary - or if it wouldn't be simpler and/or safer just to use static allocation.
Dynamic allocation raises a number of issues that often make it best avoided in embedded systems...
Hi,
You can consider to write your own malloc function that allocate memory form the table initialized in C. It will be save because you do not need to touch starting files.
I have never done this before but it should be relatively easy.