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++
12745 Discussions

Store SW-Program and Data on CFI-Flash

Altera_Forum
Honored Contributor II
1,298 Views

HI there! 

 

I am running a Nios II - system on a DE0-board from Terasic. The flash programmer has successfully programmed the software into my flash memory. I am currently trying to save (non volatile) data on the Flash-memory (i.e. data input from UART). Since I want to share the flash memory for program AND data, how do I know at what address I can start saving user data, in order to not conflict with the Program Data? 

 

I've tried to find similar posts here on the forum without luck, also read the chapter about Using Flash Devices in the Nios II Software Developer's Handbook. 

 

Cheers, 

mr_embedded
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
610 Views

If you know which is the maximum dimension of the data stored in flash and you can estimate the size it can reach in future, place the data before the program so you can avoid checking the size of the program everytime you modify it. Or, if you can better estimate the size of the program, do it reversed. 

I think you can not find this information in handbooks since it strictly depends on your design constraints.
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

gabrigob thanks for your reply. Good for me to know there is no macro for mallocs then. Next step: How do I know where the flash Programmer places the program data? I.e. from and to what addresses? Can I specify where to put it? 

 

Regards, 

mr_embedded
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

This step is more likely to be documented in handbooks. 

If you invoke the flash programmer manually from command line it depends on the parameters you set. If you use it from nios2 SBT or IDE it will depend on the BSP configuration. 

As an advice, try getting a look at this pdf 

http://www.altera.com/literature/hb/nios2/n2sw_nii52015.pdf 

in particular at page 39 and following: these pages talk about the possible configurations of software (flash, internal memory, etc etc) and as far as I remember it will link you to other manuals that are about the single tool. Hope this helps.
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

gabrigob, 

Thanks once again. I took a look at that document and you were very right :) It was helpful and also linked me to other documents. 

 

Altera provides example boot loaders for CFI and EPCS memory in the Nios II EDS,  

precompiled to Motorola S-record Files (.srec). You can use one of these example boot  

loaders, or provide your own. " 

 

Cheers, 

mr_embedded
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

If you want to save data in flash you need to understand how the flash devices work - and their limitations - and then format your data appropriately. 

For 'nor' flash (I believe nand is similar but can have bad sectors) the only way to change a '0' to a '1' is to erase a complete flash sector (which might be 128k bytes), individual bits can be changed from '1' to '0' (usually as a word write). 

Erases are very slow (significant fraction of a second), writes are relatively slow. It is also likely that no other memory cycles can be issued to the flash 

while a write/erase is in progress. 

You also need to limit erases to avoid wearing out the devices.
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

dsl, 

I appreciate your explanation it also made me understand I probably have to learn more about how the flash technology works. I am used to working with embedded flash/EEPROM on microcontrollers, you dont really have to be that educated then ;) 

 

cheers, 

mr_embedded
0 Kudos
Reply