Hello,
Is there any way to enable heap in simulator?
I would like to read some data from disk by using <stdio.h>'s file IO function. In the emulator I have succeeded, for example:
FILE *fp;
fp=fopen("test.dat","r");
fp returns a valid pointer and all subsequent operations are smooth.
But once I switched back to simulator, fopen() seems to defunct and it always return 0x00000000 which is a NULL pointer.
I have found a number of posts in E2E discussing fopen() issue and this one seems to suggest that for file IO operations to work heap must be enabled.
I am using linker.cmd rather than DSP/BIOS.
linker.cmd beginning said:
-stack 0x00000800 /* Stack Size */
-heap 0x00000800 /* Heap Size */MEMORY
{
L2RAM: o = 0x10810000 l = 0x00020000
DDR2: o = 0x80000000 l = 0x1000000
}
SECTIONS
{
.bss > DDR2
.cinit > DDR2
.cio > DDR2
.const > DDR2
.data > DDR2
.far > DDR2
.stack > DDR2
.switch > DDR2
.sysmem > DDR2 /*where heap and stack are placed*/
.text > DDR2
In EVM I specified heap size like this and all fopen()/fread()/fwrite() work successfully. With all files and settings intact, once I switched back to simulator, fopen() begins to return NULL.
Does simulator allow heap? How does simulator treat linker.cmd file? Does it ignore that? Or if .cmd file cannot be used, is there anyway to enable heap so that these file IO operations can be available?
Thanks,
Jim