1
Vote

Corrupted files (sometimes)

description

Here's an issue I've ran into.

I have a FRAM (FM25H20) chip with TinyFS, and a couple of files on it. On of the files, "preset0.txt.", gets appended by "0" all the time after MCU restart. Originally, it is 3291 bytes long, but when I read it after restart, it is expanded to 4038 bytes; original content is preserved, just a bunch of zeroes are added to the end. The interesting part is that it does not get corrupted if I write/read it and do not restart the MCU. Like this:
  1. I restart the chip.
  2. I read "preset0.txt" -> it is corrupted.
  3. I remove the zeroes and write the file back.
  4. I read "preset0.txt" again -> it is ok.
  5. I restart the chip, and file is damaged again.
I suspect the Mount() function does something wrong, as it is called once after MCU reset.

I don't have any issues with other files, and, actually, there are no problems on other chips. This one must have some special arrangement of files. Probably, after format, it would behave ok. But I want to catch the bug. What more could I do to help fixing it?

file attachments

comments

taylorza wrote Nov 6, 2013 at 12:02 PM

Would it be possible for you to get the content of the F-RAM chip dumped to a file? I would then be able to load that into a memory buffer and debug the Mount routine based on the current content of your device. Assuming of course that you do not have any sensitive data on the file system.

Stabilitronas wrote Nov 11, 2013 at 11:21 AM

There it is. Sector size 1024, cluster size 256.

taylorza wrote Nov 16, 2013 at 6:23 PM

Thank you for the FRAM dump, the dump seems a little strange, the file does not start with a valid sector, the first sector is at 1020 bytes which seems strange, I would have expected it to be at 0, 1024, 2048 etc. Can you confirm that you are starting to write to the FRAM memory starting at address 0 or do you start at some other offset? I need to know so that I can configure my emulator to run with the same metrics as your device.

Stabilitronas wrote Nov 19, 2013 at 1:59 PM

Oooops, there was a mistake in my dumping procedure. Attaching the correct file.

Stabilitronas wrote Dec 16, 2013 at 7:01 PM

Any news? Have you been able to reproduce it?

Actually, I noticed the problem on several other devices. So there indeed is a bug somewhere...

taylorza wrote Dec 26, 2013 at 8:50 PM

Sorry I took so long to get back to you, I only saw your last comment last night. I have managed to load the new file system dump and I see the file that you are referring to. What I am not yet able to do is reproduce the problem and understand when it occurs. I will be putting more time into this to try identify the scenario that causes the issue.

If you have any reproducible test cases that results in the problem I would appreciate the insight. But I will keep trying... And if I do not get back to you, keep pinging me, I definitely want to get to the bottom of this.

Thank!