FPGARelated.com
Forums

Malloc on PowerPC on VirtexII pro

Started by Tibo November 7, 2005
hi, 

I'm using a PPC405 on a Virtex2 pro. I try to allocate memory
with malloc() function. It compiles without any problem but malloc
returns NULL => no memory is allocated. I set the heap size at 0x0800 in
docm. I set need_xil_malloc to false since xil_malloc seems to be used
only for MicroBlaze. 

What's wrong ? 

Thanks for answer. 

Tibo 

ISE 7.1 / EDK 7.1 / SDK with no kernel 
Tibo wrote:

> I'm using a PPC405 on a Virtex2 pro. I try to allocate memory > with malloc() function. It compiles without any problem but malloc > returns NULL => no memory is allocated. I set the heap size at 0x0800 in > docm. I set need_xil_malloc to false since xil_malloc seems to be used > only for MicroBlaze. > > ISE 7.1 / EDK 7.1 / SDK with no kernel
Are you using a custom linker script? The STACK_SIZE and HEAP_SIZE variables are only used by the linker script. If you add --verbose to the -Wl linker options (Applications/Compiler Options/Advanced) the linker script will be output when you compile. This is also a good way to get the default linker script to read and modify. If your memory space is contiguous, (ie. it just has a start address, followed by text, followed by data, followed by bss) you should probably just be using the default linker script. If you need to use a custom linker script you need to read the default linker script to see what it does with HEAP_SIZE, and modify your custom linker script. Alan Nishioka alan@nishioka.com
How much memory are you trying to allocate? 0x800 is only 2KB.
Instead of using heap that small it might be better to allocate static 
data structures anyway.

- Peter


Tibo wrote:
> hi, > > I'm using a PPC405 on a Virtex2 pro. I try to allocate memory > with malloc() function. It compiles without any problem but malloc > returns NULL => no memory is allocated. I set the heap size at 0x0800 in > docm. I set need_xil_malloc to false since xil_malloc seems to be used > only for MicroBlaze. > > What's wrong ? > > Thanks for answer. > > Tibo > > ISE 7.1 / EDK 7.1 / SDK with no kernel