HelloI am using Quarts and Nios 9.1 versions. In my board I have external (altmemddr) and on-chip (inside Cyclone III) memory. In the system library properties all memory (including rwdata, heap and stack) is defined to use an on-chip memory. But in my applicaion I am tring to allocate part of the variables to the ddr: EXTERN unsigned char *CisSheetQueue __attribute__ ((section(".altmemddr.rwdata"))); // Locate this array in DDR Later on I am trying to allocate 64K of this memory: CisSheetQueue = malloc(CIS_SHEET_QUEUE*sizeof(unsigned char)); But this size is not allocated and limited only to ~6K. During the compilation of nios there is an info message 16Kbytes free for stack + heap. How I can use and allocate a large size (64K) speciphically in DDR? Thank you for the help.
That isn't how malloc() and linker sections work.You can either put your heap in altmemddr and use malloc(), or you can statically allocate your array and use the section attribute (as you have attempted) to place that array in altmemddr.
I don't want to put a heap on altmemddr as I want that all variables will be handled in fast way (as it is done on the on-chip memory).I have tried to allocate an array in this way: unsigned char CisSheetQueue __attribute__ ((section(".altmemddr.rwdata"))); // Locate this array in DDR But in this way the code (that burned to the flash memory) is jumping from 120K to 280K. And I have a limited space to program this code to the specific sector of the flash.
The increase in code size is likely due to the .cinit to initialize the data.Instead of doing it this way, just do it with a pointer and a linker region: modify your linker script to create a region to hold your "CisSheetQueue" and then:
unsigned char *pCisSheetQueue = (unsigned char *)the_address_of_the_region_you_just_created;If I recall, you can manage the linker script regions through the BSP editor.