LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Writing files to MultiMedia Card (MMC) using USB reader/writer (https://www.linuxquestions.org/questions/linux-general-1/writing-files-to-multimedia-card-mmc-using-usb-reader-writer-261475/)

sebyte 12-01-2004 05:37 PM

Writing files to MultiMedia Card (MMC) using USB reader/writer
 
Hi all,

First of all apologies if this is not the right forum for this question.

I have a 4-in-1 USB CompactFlash/MemoryStick/SmartMedia/MultiMedia card reader/writer which works like a dream. Installation is simply a case of making sure the necessary kernel modules are loaded at boot-time (or added with insmod) and writing /etc/fstab entries that correspond to the first partition of each drive. Cards can then be mounted/unmounted and read/written to with ease.

Recently however, I have been trying to write some mp3s to an MMC card for use in my mobile phone and have discovered an interesting problem. Reading from the card (and writing to disk) is fine but writing to the card (from disk) only appears to work. When I try to read the file back from the card (i.e., play the mp3 I've just written) I discover that the file is corrupted. Neither my computer nor my phone can play the mp3 without jumps and kicks and sometimes the file won't play at all. I am using the 'cp' command to write the file and I have noticed that the actual 'writing' activity only occurs when I unmount the card.

My question is this: Should I be using a different command to write to the card? 'dd' perhaps with no conversion?

AHMATIA.

sebyte

ahh 12-01-2004 05:45 PM

That is how it works.

The kernel doesn't write to disk immediately, but waits till theres not much else going on.

When you unmount a drive the kernel will write any data pending to the drive. If you remove the card without unmounting it the kernel may not have written everything to it so the files will be incomplete, hence them being unplayable.

cp is the correct command - just make sure you always unmount before removing the card.

sebyte 12-01-2004 05:51 PM

Ahh (great nick)... Thanks for your interest but I have been unmounting and waiting till all USB light flicker activity has ceased before removing the card. My mp3s are still corrupted for some reason....

sebyte

ahh 12-01-2004 06:00 PM

Sorry it didn't help.

I can only suggest maybe a bad card or reader.

sebyte 12-02-2004 04:55 PM

Not at all. Thanks for trying. It's good to know that the 'write while unmounting' behaviour is as it should be.

I don't think it can be a bad card reader and I don't really see how it can be a bad card. Let me explain.

Earlier, I was sent an mp3 file via Bluetooth (mobile phone to mobile phone) and saved it on the card. Listening to it, it sounded fine. I mounted the card and copied the file to disk and it still sounded fine. This must mean that both the card reader and the card are working, at least in one direction, and I know that the SmartMedia card reader/writer works perfectly in both directions so I am going to assume the problem lies elsewhere.

I decided to 'format' the card using the phone's 'Format' option, and try once more to write something from disk-to-card. No joy. Listening to the mp3 on the card (using a Linux app) the jumping around was worse than ever and snatches of one song could even be heard in the middle of another!!! Obviously a corrupt filesystem I thought. (I think this particular card may be destined for the bin :-)

I don't know if you're familiar with the GNU 'shred' command? Well I decided to shred /dev/sdc1 and recreate a FAT32 filesystem using GNU parted. I've never done either before but so what! I'm beyond caring about whether the card works in the phone.

The shredding produced a fantastic long listing, a snippet of which is below:
Code:

# ls -al /media/usb/MultiMedia
.
.
.
ls: /media/usb/multimedia/Ú\224ø/%h3ñ.\236d\214: No such file or directory
ls: /media/usb/multimedia/üu^U«»i\226Ê.ò[Ì: Input/output error
ls: /media/usb/multimedia/æ^XÝ^L<\206f\203.Ú¬\203: Input/output error
ls: /media/usb/multimedia/Õ\225oÁßúm].^W($: Input/output error
ls: /media/usb/multimedia/Ù8Äã±w6\207.h\215h: Input/output error
ls: /media/usb/multimedia/^X^Fs6sn^\r.á^S7: Input/output error
ls: /media/usb/multimedia/Ç/^^^[å\236]\206.Ë\2069: No such file or directory
total 260947414
-r-xr--r--  1 sebyte adm  3243540796 Nov 29  2013 ?ðö?Ðs`?.?og
-rwxr--r--  1 sebyte adm  1949152665 Dec 20  1966 ?fh?7ò\Ì.?v?
-r-xr--r--  1 sebyte adm  460952644 Nov 25  1908 ?±æ?e?ç».+&?
-r-xr--r--  1 sebyte adm  2037877161 Jan 22  2028 ?pÁnxo?Ò.;×Î
-r-xr--r--  1 sebyte adm  1758548868 Dec 18  1927 ?v$êÂmzæ.°Ùh
-r-xr--r--  1 sebyte adm  1242620917 Jan 17  2035 ?íÙ??¬?ú.¨q?
-r-xr--r--  1 sebyte adm  185799554 Oct 31  1995 ?. Ö)
-r-xr--r--  1 sebyte adm  1775995598 Feb 13  1952 ?«Ómo{\q.Ãgx
.
.
.

And this went on for pages and pages! I had to issue a keyboard interrupt.

I've no idea what I've done and no idea if GNU parted will come to the rescue but I'll keep you posted!

sebyte

P.S. If I have a question it's probably this: Is parted the right command to format the card and is FAT32 likely to be the right filesystem to use?

ahh 12-02-2004 05:06 PM

FAT32 would be the right format, but I have never formatted a card in Linux.

If you know where the card is, e.g. /dev/sda1 or whatever, maybe fdisk will format it.

sebyte 12-02-2004 05:23 PM

fdisk....

Good point.


All times are GMT -5. The time now is 07:18 AM.