Forum Discussion
Altera_Forum
Honored Contributor
12 years ago --- Quote Start --- how to find the correct address where i can write some data into EPCS flash. --- Quote End --- The "correct" address is to start where locations are not used :) That location depends on how you have configured your FPGA image. For example, if you turn compression on for generation of the EPCS programming image, the number of flash locations is smaller than if compression is off. However, if using compression, the "correct" location in flash for your data will change. Page 12 of the SRunner application note (AN418) indicates that the image length in flash is located where there is all 0xFF values. However, the last 36 bytes are part of the flash image, so you cannot overwrite those. My recommendation; Starting with Flash that you've just written a configuration image to (but never written custom data to): 1) Start at the end of flash 2) Loop backwards comparing data to 0xFF 3) When you get a mismatch, go forward 36-bytes of 0xFF 4) Round up to the nearest 256-byte page 5) Write a 'magic' code, i.e., a series of header bytes 6) Start using that as your personal flash area. The next time you go to look at the flash, you can start searching from the end going backwards in 256-byte blocks looking for your magic header. Rather than doing steps 1-6 above, your code would actually just search for the header on 256-byte blocks, and then when it finds data that is not 0xFF and not the header, it would know that you have never written custom data to the flash, so it could jump forward 256-bytes, where the data is 0xFF, and start from step 2/3, i.e., go and find the end of the configuration image. The Quartus programmer erase EPCS flash (at least when operating in AS mode), so you'll lose your data when you program a new configuration image. Cheers, Dave