LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 12-01-2004, 06:37 PM   #1
sebyte
LQ Newbie
 
Registered: Jan 2004
Location: London
Distribution: Debian
Posts: 15

Rep: Reputation: 0
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
 
Old 12-01-2004, 06:45 PM   #2
ahh
Member
 
Registered: May 2004
Location: UK
Distribution: Gentoo
Posts: 293

Rep: Reputation: 31
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.
 
Old 12-01-2004, 06:51 PM   #3
sebyte
LQ Newbie
 
Registered: Jan 2004
Location: London
Distribution: Debian
Posts: 15

Original Poster
Rep: Reputation: 0
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
 
Old 12-01-2004, 07:00 PM   #4
ahh
Member
 
Registered: May 2004
Location: UK
Distribution: Gentoo
Posts: 293

Rep: Reputation: 31
Sorry it didn't help.

I can only suggest maybe a bad card or reader.
 
Old 12-02-2004, 05:55 PM   #5
sebyte
LQ Newbie
 
Registered: Jan 2004
Location: London
Distribution: Debian
Posts: 15

Original Poster
Rep: Reputation: 0
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^Ui\226.[: Input/output error
ls: /media/usb/multimedia/^X^L<\206f\203.ڬ\203: Input/output error
ls: /media/usb/multimedia/\225om].^W($: Input/output error
ls: /media/usb/multimedia/8w6\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 ?pnxo?.;
-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?
 
Old 12-02-2004, 06:06 PM   #6
ahh
Member
 
Registered: May 2004
Location: UK
Distribution: Gentoo
Posts: 293

Rep: Reputation: 31
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.
 
Old 12-02-2004, 06:23 PM   #7
sebyte
LQ Newbie
 
Registered: Jan 2004
Location: London
Distribution: Debian
Posts: 15

Original Poster
Rep: Reputation: 0
fdisk....

Good point.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
USB card reader/writer troubles triona Linux - Hardware 8 12-21-2004 06:46 AM
USB MMC Card reader doesn't work on Mandrake 10.0 brggle Mandriva 5 08-24-2004 01:32 PM
TwinMOS USB MMC card reader juan18 Linux - Hardware 0 06-13-2004 03:45 AM
USB MMC Card reader g4c9z Linux - Hardware 0 06-12-2004 06:25 PM
PQI USB flash card (SM) reader/writer freezes Knoppix linux dead! stukennedyuk Linux - Hardware 4 03-19-2004 08:58 AM


All times are GMT -5. The time now is 04:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration