Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12604 Discussions

questions about sdram and flash

Altera_Forum
Honored Contributor II
1,202 Views

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 II
385 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.
0 Kudos
Altera_Forum
Honored Contributor II
385 Views

thanks a lot !

0 Kudos
Altera_Forum
Honored Contributor II
385 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 ?
0 Kudos
Altera_Forum
Honored Contributor II
385 Views

can somebody help me ? 

thanks!
0 Kudos
Altera_Forum
Honored Contributor II
385 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 ?
0 Kudos
Reply