Hi all.
I'm using SYS/BIOS rev 6.33 on a AM3359 ARM cpu
I need to allocate a (quite) large amount of memory (about 32 Mbytes) to log some process value in a circular queue fashion.
I've tried the poor man's solution:
#define LARGE_ARRAY_SIZE (32768) MY_DATA_TYPE large_data_array[LARGE_ARRAY_SIZE]; Where: sizeof (MY_DATA_TYPE) = 1024
Everything works fine, but the output binary file becomes 32Mbytes! No surprise, because "large_data_array" is statically declared and placed in .bss section. The application binary itself, without "large_data_array" is about 400Kbytes.
Problem is that I can't withstand such a big binary file, because it's placed (with other data, FPGA bitstreams and so on...) into a 16Mbit serial flash.
Then I moved to a dynamic allocation through malloc() function:
#define LARGE_ARRAY_SIZE (32768) large_data_array = ( MY_DATA_TYPE*)malloc( sizeof(MY_DATA_TYPE)*LARGE_ARRAY_SIZE);
Where: sizeof (MY_DATA_TYPE) = 1024
I've defined a big enough heap size in .cfg SYS/BIOS configuration file, and everything still works fine.
Problem is: the binary file is 32MBytes, so no actual dynamic allocation occurs: it seems that SYS/BIOS statically allocates a 32MBytes array and uses it for malloc() and free() operations. The .map output file confirms that a 32MBytes .object is statically placed in .bss section.
Is there any trick to prevent SYS/BIOS configuration tool to create such a big chunk of static data?
I've also tried to manually place the data in an unused ddr memory region:
large_data_array = ( MY_DATA_TYPE*)0x81000000;
But the application crashes at the very first attempt to read or write.
Any hints?