AnsweredAssumed Answered

KEIL Flash-FS on STM32F103 applied to I2C EEPROM - cannot read a file - SOLVED!

Question asked by ColdWeather on Nov 13, 2011
SOLVED: my fault, was writing two bytes less than needed.

Hello, PPL!

I've already put the quiestion to KEIL forum, but hope, someone here would help me faster.

I got:

- STM32F103RC (Cortex-M3),
- SD-Card on SPI,
- I2C EEPROM M24128 (16KB, page size 64 bytes),
- Flash-FS V4.21.

Flash-FS works with the SD-Card properly.

I modified a FS_SPI_FlashPrg.c from the KEIL examples to access an I2C EEPROM. Taking the article into consideration I described in FS_SPI_FlashDev.h the storage as 8 virtual sectors (blocks) of 2KB each. The EraseSector procedure takes care of writing 0xFF to every 64 Byte long EEPROM page building a virtual sector.

It works so far that I can format via fformat("S0:") and write a file via f=fopen("S0:\\filename.txt", "w") followed by fputs("Test", f) (with fclose(f) afterwards, of course). Both return success, on the dump of the EEPROM the "\filename.txt" string and after some bytes the string "Test" can be seen. At the top of the EEPROM address space masks of the allocation information seem to be present, too, as described in a short help to EFS.

The problem is: while f=fopen("S0:\\filename.txt", "r") returns success, the following fgets(s, sizeof(s), f) (or fread(...) I tried) returns always NULL. Besides, ffind(...) gets like:

\filename.txt 0, 01-01-1980 12:00:00

Total: 0 Free: 0.

Well, the EFS is not FAT, no information about time stamp is stored, but the file size...

Any idea?