I have done something similar with a 2Mbyte SPI FLASH and an EEPROM to keep track of positions in the FLASH. I use a block of 16 bytes as the smallest unit in the FLASH. Every log entry can have a different length and can contain a different number of blocks. I use a log header for every log entry which contains the block number (pointer) of the previous log header and the number of blocks for this log entry. This way I can traverse the log entries easily for reading, both forwards and backwards. In the EEPROM I save the next free block number and the block number to the last written block (to go backwards from the end when reading). I always write sequentially from the beginning to the end. For me, the oldest logs are more important than newer logs so I stop writing when the FLASH is full. I could implement a circular buffer if the newer logs are more important than older logs and then I would also need to save the block number to the first (earliest) log header in the EEPROM. I use Microchips SPI FLASH routines from the TCPIP stack and these only erases a page when the first byte in a page is written to so they expect the FLASH to be written to sequentially, one or several bytes at a time. If I would use a circular buffer I would have to keep track of when a page is erased before written to and if the erased page already contains log data the block number for the first log has to be adjusted to the first log header in the next page. /Ruben >=20 > Em 22/12/2013 16:05, Andre Abelian escreveu: > > all, thanks for your replay, > > > > my question was about a method to write and read back data and keep tra= ck of > > it. I am not sure why do I need to know the page size? I can write even= single > > byte when it comes to erase I will erase all after download all. I am u= sing > > SST25VF032 and it is not important to save space at all. mostly the fla= sh will > > be empty any way. > > > > thanks > > > > AA > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Ruben J=F6nsson AB Liros Electronic Box 9124 200 39 Malm=F6 Sweden Tel +46 40142078 ruben@rjjournal.net =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .