MMC msdos fs corrupt when files copied in shell

Chris Johns chrisj at
Tue Jan 6 06:40:30 UTC 2009

Gene Smith wrote:
> Starting with a cleanly formatted fat16 MMC containing some random txt 
> files, if I try to copy them to new files using the shell cp command, 
> they seem to work but when put on a pc (linux or windows) the new files 
> are always corrupted and there are additional files present with random 
> names that were never copied.
> Also, when I first mount the cleanly formatted fat16 MMC (or fat32) and 
> do ls in the shell I see a couple of random spurious files listed. This 
> is before I do any copies. If I try to ls those files, the shell says 
> they don't exist.

These files may be the volume name or something similar. I suspect ls is 
listing them but you cannot open them.

> Also if I unmount and re-mount the MMC with the shell I see the copied 
> new files corrupted when cat'ing in the shell. I have varied my MMC 
> clock speed from 400Khz to 25Mhz with the same result (just copies 
> faster at higher clock rate). I intend to run at 12.5Mhz (below the max 
> 20Mhz MMC speed).
> I see no errors occurring with SYSLOG (DEBUG is defined in 
> spi-sd-card.c). So not sure what the problem is. Can others copy files 
> around on a SD/MMC with the shell and obtain good results?

What happens if you mount a disk with a tree of files ? Can you see the files ?

What happens if you unmount and remount the disk without making a change ?

Can you then make a directory then unmount then remount the disk ?

Finally what happens if you copy the tree using the cp command ?

What is the bdbuf configuration ?

> I still need to try the mount and copies with c library calls in some 
> test code independent of the shell.

The shell code should be fine. Most of these commands are taken from FreeBSD.


More information about the users mailing list