Forum Discussion
Altera_Forum
Honored Contributor
16 years agoWriting to EPCS sectors
Hello, all,
I have been struggling with this and I hope someone can shead some light. My project has a 3C25 along with a EPCS16 device. I would like to write some data to the EPCS16 somewhere around sector 20. Every time I try to write I end up with data being written to sector 0. I should also mention that I am using the block erase, write_block and read epcs functions I noticed that the alt_epcs_flash_write_block function in the in the altera_avalon_epcs_flash_controller.c has the following comments: /* Write, assuming that someone has kindly erased the appropriate * sector(s). * Note: "block_offset" is the base of the current erase block. * "data_offset" is the absolute address (from the 0-base of this * device's memory) of the beginning of the write-destination. * This device has no need for "block_offset", but it's included for * function type compatibility. */ I am concerned about the part of the comment that says the device has no need for block offset. Like I said I want to erase and write to sector 20. alt_epcs_flash_write_block(alt_flash_dev* flash_info, int block_offset, int data_offset, const void* data, int length) I am setting the int block_offset to 20. Thanks for any suggestions. JTA12 Replies
- Altera_Forum
Honored Contributor
Hey jta1,
"erase block" is different than "sector/block". There are frequently only 1 or 2 erase blocks on most any flash device, whereas the number of sectors depends upon the sector size (commonly 128k or 64k) and overall size of the flash. In your case, I think you should set the "block_offset" to 0 and the data_offset to 20*sector_size....0x280000 (128k sector_size), 0x140000 (64k sector_size). I don't recall exactly what the sector size is for an EPCS 16 device, but I'm pretty sure you can look it up :-) Cheers, and Good luck! - slacker - Altera_Forum
Honored Contributor
Slacker,
Thanks for the quick reply. I am now able to read and write sector 20. Thanks again, JTA