This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

FatFs on mmc/sd card on a AM3359

Other Parts Discussed in Thread: AM3359

I am trying to implement the FatFs code to read and write a text file on an AM3359 Arm cortex A8 board but files are not written properly to the SD card. The SD card will mount and initialize, I can read text from files and delete files. When I create a file, the fill will show up on the SD card and will be the appropriate size, but will be unreadable on both the am3359 board and windows. Windows says the files are corrupted and will not open them. After fixing the files, Windows pops up a notification that there is something wrong with the disk and to scan it. The following message reads “the first allocation unit is not valid. The entry will be truncated”. If I create a text file on windows and simply open it and overwrite it then everything is fine. Has anyone else had any issues with implementing FatFs on this board?

 

I can provide any additional information needed.

Thank you

  • Max,

    Where are you trying to implement FATFS write support? Is it in boot loader level or kernel? If so, which is the u-boot/OS that you are using?

    What is the motive behind implementing FAT write? Which version of FAT is that you are trying? FAT12/16/32

  • Renjith,

    I am using the newest version of the starterware(AM335X_StarterWare_02_00_00_07). I am trying to implement Fat32, as it is a customer requirement. I would like to use FAT write for data logging purposes to a text file. I am using FatFS included in the Third party folder. Most of it works except when files are created. Write will work if the file has been created the sd card by a computer(windows). The problem, more specifically, is when I try to create the file with f_open. The file is created but in an unusable format.

  • Max,

    Is FAT write supported in Staterware? I'm not really familiar with Starterware. 

    But it looks like mostly the data block allocation in the FAT driver. Can you try the following experiments. 

    1. Can you create an empty text file(0 bytes) from Windows and see whether write is working fine or not?

    2. In your working case where file is created from desktop, can you try to write a huge file from StarterWare and see whether the contents are proper or not?

    3. Can you print the data blocks where data is getting written to?

  • Renjith,

    I fixed the problem. In the file close function, f_close(), is where the data is actually written to the sd card. Stepping though the code at that point would result in a successful write but simply running the code would result in random results. I added a 100 millisecond delay after the section where the actual write to the sd card occurred and that allowed for the command to successfully run without interuption. Thank you for your help.

  • Hello Max, I have the exact same problem as you and came across your post.  It's been over a year, so I hope you still receive this message and remember what you did.


    Can you tell me where exactly where you put that delay at?  And did you use a function from one of the C libraries or did you do something else?  Thanks.

  • Hi Andrew,

    I have the same problem as you and Max. I also hope you receive this message and remember what you did to solve it. Could you explain it to me?

    Thansks