Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

malloc problem

Altera_Forum
Honored Contributor II
771 Views

Hello 

 

I 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.
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
87 Views

have you connected at least the data_master of the NIOS to the DDR-RAM?

Altera_Forum
Honored Contributor II
87 Views

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.
Altera_Forum
Honored Contributor II
87 Views

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[65535] __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.
Altera_Forum
Honored Contributor II
87 Views

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.
Reply