Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21611 Discussions

Storing user data in EPCS64

Altera_Forum
Honored Contributor II
1,748 Views

I am using EPCS64 configuration device in my project along with cyclone 3 fpga. 

I want to store some data at run time in unused space of EPCS64(left over space after configuration data) as I am not using any other flash in my design. 

when I tried to write in some location as specified in Nios II Software Developer's Handbook using functions  

 

--alt_write_flash( alt_flash_fd* fd,int offset,const void* src_addr,int length) and 

 

--alt_read_flash( alt_flash_fd* fd,int offset,void* dest_addr,int length ) 

 

flash configuration data is getting corrupted. 

 

Please can anybody tell me how to write user data in EPCS64 without corrupting configuration data.(i,e at what address location I have to write in EPCS64?)  

 

Also please tell me at what address space EPCS64(8 MB) gets mapped to in 32 bit address space. 

0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
717 Views

Configuration data is stored at the lower epcs addresses. The higher address depends from the configuration data itself and you can retrieve from the .sof file. 

If you don't need to change the user data (I mean you only need to write it and never erasing) you can write directly from the first epcs free address. If you need to change user data, you must start at the beginning of next epcs block, otherwise you are erasing the last part of configuration data, too.
0 Kudos
Altera_Forum
Honored Contributor II
717 Views

I've used the last blocks of the EPCS memory for user data. 

 

The address of the EPCS controller comes from SOPC builder and from your BSP's system.h include file (i.e. it varies in every system). But if you use alt_flash_open_dev(), you don't have to know the address of the EPCS controller in but Avalon bus. 

 

Here's some example what I've used: 

 

# define BOARD_DATA_BLOCK_FROM_END 1 /* Last block for my own use */ alt_flash_dev *pFlash; flash_region *flash_info_ptr; int number_of_regions; unsigned int addr; pFlash = alt_flash_open_dev( EPCS_CONTROLLER_NAME ); if ( pFlash ) { alt_get_flash_info( pFlash, &flash_info_ptr, &number_of_regions ); //printf( "Flash offset=0x%X, region_size=0x%X, number_of_block=%d, block_size=0x%X\n", // flash_info_ptr->offset, // flash_info_ptr->region_size, // flash_info_ptr->number_of_blocks, // flash_info_ptr->block_size ); //printf( "Flash number_of_regions=%d\n", number_of_regions ); addr = (flash_info_ptr->number_of_blocks-BOARD_DATA_BLOCK_FROM_END) * flash_info_ptr->block_size; alt_read_flash( pFlash, addr, &g_BoardData, sizeof(g_BoardData) ); alt_flash_close_dev( pFlash ); // Verify tag ... if ( (g_BoardData.MagicTag & 0xFFFF0000) != (BOARD_DATA_TAG_V1 & 0xFFFF0000) ) { // Bad tag, ignore data and clear buffer memset( &g_BoardData, 0, sizeof(g_BoardData) ); } }
0 Kudos
Altera_Forum
Honored Contributor II
717 Views

thanks to cris and jari... 

Now I am able to write and read to epcs64 without disturbing config data... 

 

thanks a lot... 

 

but still i have one doubt..where exactly 8MB memory address's (of epcs64) mapped to 32 address space of processor...? 

 

I agree that we dont have to bother about address space of flash(epcs64)if we r making use those api's. 

 

Please let me know....
0 Kudos
Altera_Forum
Honored Contributor II
717 Views

It's a serial/SPI flash. It isn't mapped into memory. You have to use the APIs to access it.

0 Kudos
Reply