Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
842 Views

questions about sdram and flash

1.in nios system,is there any problem if i install code in sdram and use sdram as data storage device at the same time? 

in my project, after build the software, it shows: 

Info: (test2.elf) 61 KBytes program size (code + initialized data). 

Info: 8130 KBytes free for stack + heap. 

the code + initialized data only occupy a little space. the rest of the sdram are free for stack+heap. 

if i use some space of the sdram, for example: from SDRAM_BASE+0x30000 to the end, will the stack + heap also use these space? may that cause something unpredictable happen? 

what can i do if i want to use sdram as code storage and data stroage? 

 

 

 

 

2.does a big c code need a big flash? 

i want to use max10, but the onchip flash is very limited, only 280KB in 10M08. 

if my c code in nios is big, does it needs a bigger flash? if in that case, the max 10 is less attractive
0 Kudos
5 Replies
Altera_Forum
Honored Contributor I
24 Views

1. 

You can use sdram for everything: code, data, stack, heap and data storage. 

If you need to reserve an address range for your data storage and use it with direct memory access, you must make sure it has been excluded from linkage, otherwise you risk to corrupt application data. 

So you need to instruct the linker to reserve that area, nemely specifying an empty memory section in the linker memory map.  

A better and safer option, which avoids you bothering with linker commands and settings, would be to define a generic array (i.e. int data_storage[STORAGE_SIZE] ) and then you read/write the variable rather than directly access sdram addresses.  

 

2. 

The flash memory is normally used only to load the program code upon boot. 

Then its size is at least the same as code + initialized data. 

The sdram space where stack, heap and other memory sections are mapped, needs not to be saved into flash because these areas can start with random data or they can simply be initialized with zeros or other constant values. 

In the case of your test application, the required flash size is about 61kB. Account for a bit more since the flash image needs to store the bootloader.
Altera_Forum
Honored Contributor I
24 Views

thanks a lot !

Altera_Forum
Honored Contributor I
24 Views

i think you may not be right. 

the flash should stroage both hardware and software, maybe the software size is code + initialized data, but what size of the hardware configure data ?
Altera_Forum
Honored Contributor I
24 Views

can somebody help me ? 

thanks!
Altera_Forum
Honored Contributor I
24 Views

 

--- Quote Start ---  

1. 

You can use sdram for everything: code, data, stack, heap and data storage. 

If you need to reserve an address range for your data storage and use it with direct memory access, you must make sure it has been excluded from linkage, otherwise you risk to corrupt application data. 

So you need to instruct the linker to reserve that area, nemely specifying an empty memory section in the linker memory map.  

A better and safer option, which avoids you bothering with linker commands and settings, would be to define a generic array (i.e. int data_storage[STORAGE_SIZE] ) and then you read/write the variable rather than directly access sdram addresses.  

 

2. 

The flash memory is normally used only to load the program code upon boot. 

Then its size is at least the same as code + initialized data. 

The sdram space where stack, heap and other memory sections are mapped, needs not to be saved into flash because these areas can start with random data or they can simply be initialized with zeros or other constant values. 

In the case of your test application, the required flash size is about 61kB. Account for a bit more since the flash image needs to store the bootloader. 

--- Quote End ---  

 

 

i think the "code + initialized data" is the soft project size, the size must be smaller than the memory size(on-chip memory or sdram ), it is not equal to how much space it will occupy in flash(EPCS). 

i think the flash needs to storage both sof file and elf file, the "code + initialized data" is just the elf file, what about the sof file ?
Reply