Other Parts Discussed in Thread: HALCOGEN
I have been trying to implement the littlefs file system to the Emulated EEPROM that is present on RM57Lx to store configuration values.
The eeprom has the error correction code programmed initially with the ecc codes being generated by the linker script.
I initialize the flash bank like so and then supply callback functions to write and read data to a specific address that is handled by little fs.
Fapi_initializeFlashBanks(150); Fapi_setActiveFlashBank(Fapi_FlashBank7); Fapi_enableEepromBankSectors(0xFFFFFFFF, 0);
The read function is implemented as such:
int eeprom_read(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size) { struct lfs_context *ltxt = c->context; uint32_t addr = (ltxt->flash_sectors.u32BankStartAddress + (c->block_size * block) + off); while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady) { } Fapi_StatusType status = Fapi_doMarginRead( (uint32_t *)addr, (uint32_t *)buffer, size / 4, Fapi_NormalRead); if (status != Fapi_Status_Success) { fapiIndicateError(status); } return status; }
The program function is implemented as such:
int eeprom_prog(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, const void *buffer, lfs_size_t size) { struct lfs_context *ltxt = c->context; while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady) { ; } Fapi_StatusType status = Fapi_issueProgrammingCommand( (uint32_t *)(ltxt->flash_sectors.u32BankStartAddress + (c->block_size * block) + off), (uint8_t *) buffer, size, NULL, 0, Fapi_AutoEccGeneration); if (status != Fapi_Status_Success) { fapiIndicateError(status); } return status; }
I also format the sectors via:
int eeprom_erase(const struct lfs_config *c, lfs_block_t block) { struct lfs_context *ltxt = c->context; while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady) { ; } Fapi_StatusType status = Fapi_issueAsyncCommandWithAddress( Fapi_EraseSector, (uint32_t *)(ltxt->flash_sectors.u32BankStartAddress + (c->block_size * block))); if (status != Fapi_Status_Success) { fapiIndicateError(status); } return status; }
After programming the eeprom is erased and appears correct:
0xf0200000: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xf0200010: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xf0200020: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xf0200030: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xf0200040: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xf0200050: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xf0200060: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xf0200070: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xf0200080: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xf0200090: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xf02000a0: 0xffffffff 0xffffffff 0xffffffff 0xffffffff
However after initially creating and writing a few files:
The bit flips happen again. I would appreciate any pointers or guidance here to get the eeprom working. The bit flips appears as errors to the file system and will cause the filesystem to deem the block as unwritable, locking the filesystem.