LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices



Reply
 
Search this Thread
Old 08-24-2005, 12:53 PM   #1
qwijibow
Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Rep: Reputation: 47
usb multi card reader doesnt detect newly inserted cards


EDIT

SOLVED..

use HAL (hardware abstraction layer)

once the hal daemon is running, it automatically probes USB card readers for newly inserted cards !

Igore pretty much everything in this thread !



#############################################################
Origonal post Follows.


I have an Internal Memory Card Reader. Model Trust CR-3300.

The card reader has 4 different slots, i use 2 of them.
One slot for SD (secure digital) memory cards, one for SM (Smart Media) Memory cards,
and 2 more i dont use.

When the drivers are modprobed, the kernel reports the addition of 4 scsi devices.

/dev/sda
/dev/sdb
/dev/sdc
/dev/sdd

But when i insert a memory card, for example SD card into the slot (/dev/sdd)
the card is not detected. and cannot to used.

"cat /proc/partitons" shows only my hard disks.

HOWEVER, if i insert the card BEFORE loading the drivers, then aswell as the 4 scsi controllers being registed, the kernel also makes note of a 512 meg card, and attaches it to /dev/sdd1.

"cat /proc/partitons" shows
Quote:
major minor #blocks name

8 49 500203 sdd1
and i can mount the card as /dev/sdd1.

This is very annoying,
i have to keep loading, and unloading the drivers every time i want to use, or switch over a memory card.

EDIT: ive found i can make the kernel probe the device for new cards with the "hdparm -z /dev/sdd" command. It makes the kernel re-load partiton tables.

This command also uptades the data shown in /proc/partitons.

But this is still very annoying, it means i need to become root, anter root password, an run hdparm EVERY TIME i need ot switch a card.

There are only 2 solutions i can think of, both are messy...

1) make hdparm suid root, so i can quickly add cards with a shortcut applet in KDE.
(this is very un0-secure to give un-privilaged users access to hdparm)

2) make a boot script that runs loops forever, running hdparm -z /dev/sdd, and hdparm -z /dev/sdb, every 2 seconds.

Does anyone have a better idea ???

EDIT2:
Ive tested the device in windows, the activity light blinks every half second.

in linux he activity light doesnt blink when the device is idle, however it does blink when i run the hdparm command.

so it seems windows is useing my hdparm on a loop method.

i suppose running 4 disks off a single usb connection means the device hs lost its ability to hot-plug ???

HELP.

thanks.

EDIT3:
The hdparm -z on a loop is a very bad idea.
it fills the logs with mesages about re-scanning the partiton table.

and when the device is in use, and files are being transfered, the constant poling for new cards degrages performance and genrates "media is busy" errors all over the place.

there MUST be a way ?

is there maybe a patch to usb storeage that can poll for new cards, but only when there device is idle ???

thanks again,

Last edited by qwijibow; 10-11-2005 at 11:18 PM.
 
Old 08-25-2005, 07:23 AM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,038

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
In my experience, multi-slot USB card readers do not work unless you plug the card into the reader before you plug the card reader into the USB socket.
So I have to plug in the card, then plug in the reader. Then it works just fine, with an icon added to my desktop (Mandriva 2005LE, 2.6.11-12mdk).
As you have probably already discovered, each different card-slot is associated with a different sdx
HTH
 
Old 08-25-2005, 01:10 PM   #3
qwijibow
Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Original Poster
Rep: Reputation: 47
My USB card reader is internal, you cannot unplug it.

Anyways, i have fixed it by adding an extra script to run before mount.

here is the script for others.

Code:
#!/bin/bash
# Code by Chris Stones (chris.stones@ googles email [i hate spam])
# If you can think of a better way of doing this ( patch the usb_storage drivers ?) Please let me know;)

# fake mount !!!!
# intercept parameters to mount.
# may need to re-scan the media pannel for new / removed cards before mounting.

#this script assumes you have sudo setup to allow regular users to run hdparm -z /dev/sd[a-z]
#add line "%users ALL = NOPASSWD:/sbin/hdparm -z /dev/sd[a-e]" to /etc/sudoers

#this script ALSO assumes the mount points are /mnt/sd[a-z]
#if anyone can edit this script to parse /etc/fstab, please do so, and let me know.

test_wait() {
       if [ ! -f $1 ]; then
               sleep 1
       fi
}

probe() {
   sudo /sbin/hdparm -z $1 > /dev/null
   test_wait $1"1"
   test_wait $1"1"
   test_wait $1"1"
}

if [ `echo $1| head -c 7` = "/mnt/sd" ]; then
   probe "/dev/"`echo $1 | tail -c 4`
fi


# call real mount
/bin/mount-real $1 $2 $3 $4 $5 $6 $7
Basically, you rename /bin/mount to mount-real.
and save this script as /bin/mount

so when somhing calls /bin/mount
my script looks at what you are mounting... if you are mounting a multi slot usb, the script uses hdparm to re-scan the partiton table.

this causes the kernel to SEE cards that were inserted after bootup, or after the device was plugged in.

for my full guide of how to get it working, see http://www.astahost.com/index.php?sh...=0&#entry50147


ENJOY !
 
Old 08-27-2005, 02:20 AM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,038

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
Interesting work-around. Thanks.
 
Old 10-04-2005, 12:51 PM   #5
qwijibow
Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Original Poster
Rep: Reputation: 47
I wrote a much better, much more simplistiv, much less complicated script...

here it is.

Code:
#!/bin/bash

# re-scans partiton table of multi-media card readers prior to mounting them
# (allows linux to SEE newl inserted cards)

# INSTALL...
# 1)    edit /etc/fstab, change filesystem of multi-media card reader enteries to "card"
#       e.g. "/dev/sda1  /mnt/slot1 card noauto,user,sync,umask=0  0 0"

# 2)    run "sudoedit /etc/sudoers" and add the following line
#       %users ALL = NOPASSWD:/sbin/hdparm -z /dev/sd[a-z]
#       sudo must be installed first

# 3)    save mount.card (this file) to /sbin/mount.card
#       set owner...            "chown root /sbin/mount.card"
#       set permissions...      "chmod 755 /sbin/mount.card"

# After completing steps 1,2 and 3. you can insert a card and ount it at any time,
# without hac#ving to re-attach the usb card reader.

sudo /sbin/hdparm -z `echo $1 | head -c 8`

sleep 1

mount -t vfat $@
The script itself is the last 3 lines, Install instructions at the top of the script.

ENJOY !
 
Old 10-11-2005, 11:17 PM   #6
qwijibow
Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Original Poster
Rep: Reputation: 47
SOLVED..

use HAL (hardware abstraction layer)

once the hal daemon is running, it automatically probes USB card readers for newly inserted cards !

Igore pretty much everything in this thread !
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
multi mem card reader doesnt detect newly inserted cards qwijibow Linux - Hardware 1 08-24-2005 04:51 PM
usb multi card reader doesnt detect newly inserted cards qwijibow Linux - Hardware 1 08-24-2005 04:50 PM
multi-card usb reader support MikTheUser Linux - Hardware 1 02-14-2005 05:53 PM
USB multi-card reader; only one card can be mounted in Slack 10. KidsWriter71 Linux - Hardware 6 09-11-2004 08:24 PM
Recognizing USB card reader when card is inserted hqo201 Fedora 0 08-02-2004 06:08 PM


All times are GMT -5. The time now is 08:42 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