Compact flash; is it hot lugable

Hi, I just started to play with compact flash. I have a small cheap reader device on the USB bus to my linux machine.

It is easy to plug and unplug the compact flash from the reader and it is also easy to plug the whole reader from the USB. I was wondering if the compact flash is actually hot pluggable?

I know the USB spec says that the USB device itself is hot pluggable.

I was also wondering if all USB devices are actually hot pluggable or have some manufactures cheated.

I realize that I still have to do the right thing in linux and unmount the device before unplugging. No device can protect me from that kind of screwup.

Al

Reply to
Alpinekid
Loading thread data ...

Normally you could not use the compact flash before you have mounted it, even if some newer linux-distributions may do that for you. So if you have to mount a device to work with it, you also have to unmount it if you want to take it away. Physically you can unplug the card, but you cannot assure that all data is written to it. So if you dont want data get lost, you dont want hot pluggable compact flash.

regards, Jens

--
Die o.a. Adresse ist OK, wird aber nicht gelesen. Für Mails an mich bitte
"usenet" durch "jens.nixdorf" ersetzen.
Reply to
Jens Nixdorf

No, it is not. Actually you can easily kill your CF card by removing it while a write operation is in progress.

This is something different. If you unplug the USB device while a write operation to CF is in progress the CF card may die all the same.

I wouldn't hold my breath here.

Indeed.

Wolfgang Denk

--
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88   Web: www.denx.de
 Click to see the full signature
Reply to
Wolfgang Denk

I think there is two issues here, mount/unmount and hotplugable.

The data loss due to unplugging before unmounting is expected and is an OS issue. The hotplugable issue is separate. If I unmount correctly that prevent any data loss due to things not being written to the filesystem. it insures that all the caches and buffers have been purged etc.

The hotplugable issue is when you physically remove th compact flash module with power on. Its a hardware thing not a OS thing.

I'm wondering if compact flash is speced to be hotplugable. I know the USB devices have a hotplugable specification.

Al

Reply to
Alpinekid

Yes, but not recommended. There are two power detection pins on CF, but it's up to the interfacing logic to properly handle it.

Sometimes it requires a proper USB bus reset sequence.

An important consideration is that the CF sockets are quite fragile. After certain number of insertions (hundreds), some of the plugs (there are 50 of them in each CF) might not make good contacts and the CF becomes useless.

Since we insert/remove many of them everyday, we have built up a great deal of CFs with bad sockets. We ususally ship them to a shop to replace the sockets after a while.

Reply to
Tech Support for IDE-CF

As the CF does some internal work after writing data to it, unplugging it shortly after any write operation might damage it. There even were reports that the card was completely unusable afterwards.

-Michael

Reply to
Michael Schnell

Theoretical youre right, but hotplugging _together_ _with_ manual mount/umount makes no sense, therefore hotplugable cf-card makes no sense, except you can assure that _never_ _ever_ any data is written to the card. Thats why even USB-Sticks with Flash-memory are not really hotpluggable.

regards, Jens

--
Die o.a. Adresse ist OK, wird aber nicht gelesen. Für Mails an mich bitte
"usenet" durch "jens.nixdorf" ersetzen.
Reply to
Jens Nixdorf

Thanks for your very helpful response.

Tech Support for IDE-CF wrote:

I'm using RH8.0; the linux kernel is 2.4.18 that came with it.

Does anyone know if it does the "proper USB bus reset" and when or under what circumstances does it do the proper bus reset?

That is good to know. Is there any wear type failure on the reader side? I guess with 50 male pins sticking up bending is a possible problem.

Where is this shop and what kind of quantities do they handle; as in how small. I wondering how to handle a case where I may have a damaged CF with a valuable picture on it or in the case where somehow my only good backup ended up on a bad CF. When they change the socket do they effect the stored data?

Al

Reply to
Alpinekid

I assuming that the time frame for this work is on the order of micro-sec or even milli-sec but not seconds or minutes.

Am I correct?

Al

Reply to
Alpinekid

O, I think it does make sense. I think that if the CF is being read in an external reader, as in reading the CF that has a picture on it from your camera, you would like to be able to plug in the CF read the picture and unplug the CF without power cycling the entire system.

Since I'm using linux it is reasonable to have a system that has been powered up for months or years. I would just plug in the CF from a camera, mount the device, offload the picture, and then umount the device and remove the CF.

The hot plugging refers to pluging the device in while the reader has power to it. Its the same as sticking a floppy in the floppy drive. If you pop it out while the little green light is on you are asking for trouble. If I unplug while the CF contains mounted devices I'm asking for trouble.

I accept your technical accurate and very strict definition of hot-plug-able. We in the engineering community always strive to make these system as simple as possible but sometimes we use words to explain things that allow connotation that we don't mean to imply. At other times description of how thing work at one level don't apply at a different level in the system.

Al

Reply to
Alpinekid

Summary

Alp> Hi,

My environment: rh8.0 that uses the linux 2.4.18 kernel A 9-in-1 usb card reader that has the "inland" logo on it, sold my microcenter in San Jose, CA. The label says it is model UCR-V10-SV-A060-M39l. The utility, usbdevice, reports is as being manufactured by the ICSI_1 corporation vendor number 0dda, product number 0102; revision number 52.7d The cf module has a label with PNY on it and is 8meg big.

In my testing I used fdisk and the mkdosfs to setup the flash. I mounted it and wrote to it. All of this works fine.

I then umounted the device and after a short while, many seconds, I would unplug and replug the CF. This seems to cause bad data to be written to the CF device.

When I leave the device alone and shutdown power off and then restart the whole system it seems to be fine. I haven't got to trying to just unplug the reader at the USB cable. that is todays project.

what I have learned so far:

The CF should be able to be hot pluggable. It has the offset power pins to give the device a chance to do the right thing.

I know that I must umount the device in the OS. I know that implies it is not really and truly hotplugable in the strictest sense but I understand the issues involved and I'm not bothered by that "legal" technicality.

I can not do the unplugging too fast. It takes time for the CF to complete the write and to flush it to the real persistent storage.

I understand that a CF does some work to actually store the data after writing. I'm assuming that this is happening in the time frame of micro seconds or even mill-seconds and not seconds.

The CF is not really designed to be plugged and unplugged a lot.

More later, Thanks for your help Al

Reply to
Alpinekid

...

Assuming no bending of the male pins, they usually last longer than the female sockets. The male pins are solid rounds, while the female sockets are flat foils. Even with prefectly aligned insertions, the sockets fail to attach to the pins after a while.

Our estimate is that the pins lasts thousand cycles and sockets lasts hundred cycles. This is no where near what they claim in CF spec, according to our experiences. But what can we do, sue the whole industry?

The shop is in San Diego. We usually send them 20 to 30 CF and sockets. They remove the old sockets and replace with the new one we provided.

If you specify in advance, they can probably extract the data first and restore it afterward.

Reply to
Tech Support for IDE-CF

I have finished testing my usb-compactflash configuration.

The test scenario was:

1) completely erase the CF by using badblocks

2) Use fdisk to partition the CF into a single partition accepting the defaults. In my case the first cylinder was 2, I still do not know why. The last cylinder was 992

3) put a dos file system on the partition using mkdosfs

4) I then used dd to make two files of the 1st 100 blocks of the CF,

50Kbytes. I used the /dev/sda and the /dev/sda1 devices. I just wanted to see how much overhead there was. The partition was offset from the start of the device by 8K, one cylinder. This must be something from the fact that it is being treated as a scsi disk drive.

5) I then calculated a MD5 secure checksum of the files.

This setup allows me to have known contents on the device and to check if any bytes change.

The test goal is to verify that I can hotplug the USB reader device. I will test the CF device itself later. Right now it is easy to just unplug the reader from the USB and then unplug the CF.

The short answer: It works .... sort-of.

I get some interesting messages in dmesg, see below. There seems to be some instability in the system somewhere. Most ofter after I have hotpluged the reader the first attempt to use the device fails. fdisk reports that it can not read the device. sometime the second attempt will work. Once I completely shutdown and restarted before I could read the device. I'm sure there is an easier way to reset the USB subsystem without power cycling. After all its not windows. I just dont know it yet.

The good news is that I have not lost any data on the CF.

I'm beginning to think that the problems I was having with hotplugging the CF itself may have been these 1st time instabilities.

Note: I have done all this without mounting the device. I'm just checking access and contents of the device. The mount/umount was just confusing the issue.

Details:

I unpluged and repluged the reader from the USB without touching the CF card itself.

when I remount the device I get the following:

[fred@butler usb]$ mount /mnt/flash /dev/sda1: Input/output error

From dmesg I get the following messages:

usb.c: USB disconnect on device 2 hub.c: USB new device connect on bus1/1, assigned device number 4 WARNING: USB Mass Storage data integrity not assured USB Mass Storage device found at 4 usb-uhci.c: interrupt, status 2, frame# 1587 SCSI disk error : host 1 channel 0 id 0 lun 0 return code = 8000002 Info fld=0x0, Current sd08:01: sense key None I/O error: dev 08:01, sector 0

The device seems to work. I can read the directory that was stored on the CF card before I unplugged and replugged the USB CF reader.

I wish I know what the WARNING really met. There seems to be some issue with timing on the first access. I do have an old kernel and distribution. Its a 2.4.18 kernel and a RH

8.0 distribution. Its so last year:-)

At any rate, thanks for letting me chat. I'll let the world know if I find any more interesting phenomenon that confuses me.

Soon I'm going to get the nerve to use one of my big CF from the camera and try to get a picture off it.

Even in the open world of Linux there is a lot of unspoken facts. Its nice to have a lot of folks to help. What do the poor folks in the windows world do for help?

The system seems to work, I just have to learn how to work it.

Al

Reply to
Alpinekid

Oy, I remember a customer around 1987 who was frothing at the mouth because ejecting a floppy disk while still Unix mounted caused file system corruption. They were apparently accustomed to the DOS way of yanking any floppy without the activity led on (yet older floppy drives locked the eject mechanism while busy or selected). Sadly, there was no software solution since only Macintosh systems have floppy disks with "soft eject" to notify the system to finish up before physically ejecting the disk. And even in the 80s, floppy drives no longer locked the eject mechanism to prevent removing an in-use disk.

Linux is rather cd-saavy like Windows and auto-detects when a CD is inserted. The eject buttion is usually disabled, but the 'eject' command auto unmounts the file system before opening the tray.

But as to other removeable media, there's no "lock/disable eject button" mechanism or even "IN USE, DO NOT TOUCH" LED to prevent removal of the still-active device.

I've plugged in and removed USB storage devices to Linux while still running (compact flash and such), but I was careful to "sync" and unmount the device before unplugging. Sadly, there was not even an LED to warm me when it was safe to unplug, only an LED for activity.

SCSI folks have more experience with such things: the drive MUST be idle and LOGICALLY DETACHED (unmounted, etc.) before physically removing.

Reply to
Jeff Jonas

That's the point: If you customize a system only for your own use, then you can plug cf-cards in and out like you want. You can also mount the brake-pedal in your car at the right side if you want to and if you always think of it. But if you do this for other people, maybe because you want to sell a system, you have to do all you can think about to avoid "risky" things. And if you want to teach the customer, forget it. If you have a door with a sign "Dont look through the keyhole", what do you think most people do?.

So my clue is: If you (or Al) wanna hotplugging cf_cards, then do it. But its not safe for customers.

regards, Jens

--
Die o.a. Adresse ist OK, wird aber nicht gelesen. Für Mails an mich bitte
"usenet" durch "jens.nixdorf" ersetzen.
Reply to
Jens Nixdorf

You have the hit on the reason that I'm learning about this right now.

There are products out there that have an ide-to-cf adapter in a 3-1/2 front panel. There are all kinds of cameras that use CF and its cousins as film. This is most likely not really a good mix. The sw mount/umount issue can be handled. Its SMOP:-) Those of us that strive to be the hacker-grade SW engineers of the world need to look at this and make sure the issues are addressed.

The real problem seems to be the limited life on the CF socket. Those darn mechanical engineers did it to us again:-) Routinely plugging and unplugging a CF is bad. I also need to look at the other trade-marked flash packaging products to see if there is one that can work.

Right now it looks like I should be recommending that we stick to cameras that have USB or 1394 connectors and leave the CFs in the cameras. This still does not solve the mount/umount problem. I also do not like powering up a $600 camera to serve as a $10 reader.

As for using CF in a PC they need to be inside the box and treated like very expensive hard drives and not removable media like floppies. CF seems to be almost useless as removable media unless they are coupled with a USB reader. I'm assuming the USB connector has been designed for more plug/unplug cycles.

Thanks for making me think more about what the real problems are.

In the spirit of free software, as in free speech, one has to learn how to use the freedoms to the advantage of society and one assumes responsibility to learn about and avoid the risks as the cost of having the freedom. A little knowledge can be dangerous.

The market opportunity comes from supplying working products to the folks that don't want to take the time to learn how to solve the problem themselves. I buy milk because I don't know how to milk a cow. If I had the time I might want to learn.

I also want to work to avoid creating a world where a few folks can control a market by keeping the people in the market ignorant. I don't mind buying good products that solve a problem that I don't have time to solve myself. I don't like to support producers that have made it illegal for me to solve the problem myself if I choose to. That just rewards bad behavior.

Long live Linux and our ability to use computers and computer technology. Al

Reply to
Alpinekid

I suppose waiting a second you should be save. But AFAIK, there are not specs available.

-Michael

Reply to
Michael Schnell

But that is the way they are used in digital cameras all day...

-Michael

Reply to
Michael Schnell

People don't usually plug and unplug CF every day, especially with a large capacity card. Most cameras come with downloading cables without removing the CF.

We have more than 20 CFs with bad sockets. Anybody else got bad CFs?

Reply to
Tech Support for IDE-CF

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.