Tuesday, October 17th 2017, 1:08pm UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

geekxCoder

Beginner

Date of registration: Sep 19th 2017

Posts: 1

1

Wednesday, September 20th 2017, 6:35am

NAND flash files corruption

Hi All,

I'm working on NAND flash using emFile in FAT32 type on custom board with STM32F103VE.
It is observed that files get corrupted when system is power cycled frequently.


After corruption, device executes following condition:


Source code

1
if (0 != FS_FindFirstFile(&dir, dir_name, file_name, sizeof(file_name))){   while (1 == FS_FAT_CheckDisk(NAND_FLASH_PREFIX "0", &Big_stack, sizeof(Big_stack), 2, On_Check_Disk_Error));}  




In above condition, function FS_FindFirstFile() returns 1 which means “No entries available in the directory”.
In addition to that, function FS_FAT_CheckDisk() returns following message:
“Cluster 2 is marked as used, but not assigned to a file or directory.”



Can anybody please explain this message or provide a document which can explain it in detail?




This post has been edited 1 times, last edit by "geekxCoder" (Sep 20th 2017, 6:37am)


SEGGER - Marius

Super Moderator

Date of registration: Aug 10th 2011

Posts: 29

2

Tuesday, September 26th 2017, 5:38pm

Hello,

The error indicates that the file system has been corrupted.
More exactly, a FAT cluster is marked as in use in the allocation
table but FS_CheckDisk() cannot find any file or directory
that actually uses this cluster.

The FAT file system is not fail-safe by design and a sudden reset can easily corrupt it.
SEGGER provides a Journaling add-on that can be used to make the FAT file system fail-safe.
You will have to use this add-on to protect the structure of the file system against sudden resets.

In addition to this the hardware has to be fail-safe too. This means that from the moment the CPU
enters reset, the power supply of the NAND flash has to remain valid for a period of time long enough
to allow an ongoing program or erase operation to finish.

Best regards,
Marius