[Home page](/) [Latest blog](../all.html)

# slef-reflections on Device Drivers

  * Oracom ORC-200M Media Player
  * [Samsung GDI driver used for my ML-4500](../software.html#other)
  * USB Flash Sticks
  * [Windows Samba Printers](software#samba)

* * *

## USB Flash Sticks

### Fringe Benefits of LUGs: USB Flash Stick Devices

2007-09-03 (Permalink): Here's my latest silly trick with the [udev rules
discussed previously.](http://mjr.towers.org.uk/blog/2007/drivers#udevusb)

Add a udev rule of ACTION=="add", KERNEL=="sd*[!0-9]",
ENV{ID_SERIAL}=="10d6_USB_2.0(HS)_Flash_Disk_A00000000001",
RUN+="/usr/local/bin/dapsync" where dapsync is something like this script:-

    
    
    /sbin/mount /mnt/USB-DAP \
    && cd /opt/Podcasts \
    && { /bin/tar --create --remove-files * \
         | /bin/tar --extract --directory /Mount/USB-DAP }
    /sbin/umount /Mount/USB-DAP \
    && /bin/ogg123 -q /home/mjr/House/Audio/three-note.ogg
    

and fstab has a line for /Mount/USB-DAP pointing to the right device/location
thing in /dev/disk/by-id

Then, build up podcasts under /opt/Podcasts, plug the audio player
10d6_USB_2.0(HS)_Flash_Disk_A00000000001 into the right port and wait for the
three notes to play...

  * Comment on this

2007-08-17 (Permalink): I might be the last to notice, but when trying to
answer the LUG question

> "All I want to do is mount a particular USB stick to a directory
/mnt/particular_usb_stick/ without having to go check on what device it is and
editing the script that does the mounting every time."

I discovered that I seem to have a /dev/disk/by-id/usb-
0930_USB_Flash_Memory_LONGHEXSTRING-part1 and an even less meaningful (but
hopefully globally unique) /dev/disk/by-uuid/ device by default already.

That'll make a lot of things much simpler.

[Didier Raboud](http://didier.raboud.com) commented:

> "For the USB Flash disks, why not use udev rules ? It allows to create
correct /dev/* nodes and then automatic mounters (KDE's, ...) mount them on
the right place...

>

> I once had a device I wanted to be mounted under /media/iaudio. I created
the correct udev rule to get /dev/iaudio addressing always the same device and
partition, _when connected_. KDE was then able to mount it on /media/iaudio
(visibly taken from node name).

>

> Hope it helps, regards,

>

> Didier"

Thanks. The by-id device is created by udev rules, but who needs KDE to auto-
mount it? I added a line to my udev rules.d/99-local

> "ACTION=="add", KERNEL=="sd*[0-9]",
ENV{ID_SERIAL}=="0930_USB_Flash_Memory_LOGHEXSTRING", RUN+="/sbin/mount
/Mount/BlueKey""

and a matching line to fstab

> "/dev/disk/by-id/usb-0930_USB_Flash_Memory_LOGHEXSTRING-part1 /Mount/BlueKey
auto rw,noauto,users,uid=1000,noexec,iocharset=utf8 1 0"

and that seems to work. It would be clever to use automount, which would also
sync and unmount it after inactivity, but I don't have it installed on that
machine.

[Simon Ward](http://bleah.co.uk/) commented:

> "usbmount is a package I find useful, and doesn't depend on your choice of
desktop environment. When a USB storage device is inserted, it will get
mounted. Hooks can be used to create symlinks at mount time. There is one that
links by model name included in the package. I also have another hook that
creates a symlink based on the volume label."

[Its homepage](http://users.actrix.co.nz/michael/usbmount.html) suggests its
author has abandoned it:

> "Many distributions are now adequately handling usb - so I haven't spent
much time improving usb-mount."

What does usbmount give that [automount](http://www.am-utils.org/) wouldn't?

[Simon Ward](http://bleah.co.uk/) commented:

> "(I did not realise that usb-mount is no longer maintained.) usb-mount's
main advantage is that it did something useful without configuration: simply
by installing it you get USB devices automatically mounted when they are
plugged in, and symlinks created based on model name. A mere copy-paste-modify
was required to get symlinks created for volume labels.

>

> I think automount can do just as well (better, given that it will unmount
the device after inactivity), but requires a little more thought to set up."

Ben Hutchings commented:

> "The identifiers used under /dev/disk/by-id encode location, including in
this case which USB port is being used. You will probably do better to use the
filesystem's label or UUID. Rather than writing out /dev/disk/... you can
specify LABEL=&lt;label&gt; or UUID=&lt;uuid&gt; in place of a device name in
fstab (or on a mount command line, though this doesn't seem to be
documented)."

I always seem to plug devices into the same ports, so it didn't bother me
much.

  * Comment on this
  * Start of this section
  * Start of this page
  * [All of this blog](../)

* * *

## Oracom ORC-200M Media Player with Linux 2.6.21.5 usb-storage driver

2007-07-03: Now that [my Samsung YP-U2 was
destroyed,](http://mjr.towers.org.uk/blog/2007/debian#b5fdebconf) I'm left
with the Oracom ORC-200M USB Audio Player [that I was given a while
ago.](http://mjr.towers.org.uk/blog/2004-7.html#fsbits1025)

It seems that this doesn't work with recent 2.6 kernels. Tales of brokenness
abound [on
livejournal,](http://community.livejournal.com/ubuntu_users/222884.html?view=1512100)
[in ubuntu forums,](http://ubuntuforums.org/showthread.php?t=91164) and [in
Gentoo forums.](http://www.gentooforum.de/thread.php?threadid=9063)

Its USB ID (in lsusb or /proc/bus/usb/devices) is 0f19:0103 and there is [a
patch available for
0f19:0101](http://www.qbik.ch/usb/devices/showdev.php?id=1705), which is the
similar ORC-100 and DION-MX player. Simply changing the ID and using that
patch didn't work for me. I could see the device appear in /proc/scsi/usb-
storage (which was new), but still nothing in /proc/scsi/scsi, so I updated
the patch slightly.

The new patch for linux-2.6.21.5 is:

    
    
    --- linux/drivers/usb/storage/unusual_devs.h.orig       2007-07-03 18:44:59.000000000 +0100
    +++ linux/drivers/usb/storage/unusual_devs.h    2007-07-03 19:01:47.000000000 +0100
    @@ -1317,6 +1317,16 @@
                    US_SC_DEVICE, US_PR_DEVICE, NULL,
                    US_FL_IGNORE_RESIDUE | US_FL_GO_SLOW | US_FL_MAX_SECTORS_64),
    
    +/* Patch by Leonid Petrov mail at lpetrov.net
    + * http://www.qbik.ch/usb/devices/showdev.php?id=1705
    + * Updated to 103 device by MJ Ray mjr at phonecoop.coop
    + */
    +UNUSUAL_DEV(  0x0f19, 0x0103, 0x0100, 0x0100,
    +               "Oracom Co., Ltd",
    +               "ORC-200M",
    +                US_SC_DEVICE, US_PR_DEVICE, NULL,
    +                US_FL_IGNORE_RESIDUE | US_FL_FIX_INQUIRY),
    +
     /* David Kuehling <dvdkhlng@gmx.de>:
      * for MP3-Player AVOX WSX-300ER (bought in Japan).  Reports lots of SCSI
      * errors when trying to write.
    

Hope that helps someone else. Leave a comment if you have any improvements,
please. I don't really know what I'm doing with USB and I didn't find
descriptions of the usb-storage flags (US_FL_ right?). I just experimented
until it worked.

If you need to learn how to patch, here are the notes that I sent [an
introduction to koha-devel in March](http://lists.nongnu.org/archive/html
/koha-devel/2007-03/msg00092.html):

2007-03-17:

> "I can't find the guide that I mentioned on IRC, but those looking for tips
on better use of diff and patch may find them in this book

>

>> "Comparing and Merging Files with GNU diff and patch"

>

> by David MacKenzie, Paul Eggert, and Richard Stallman <http://www.network-
theory.co.uk/docs/diff/Overview.html>

>

> My most frequent commands are:

>

> 1\. generating a patch of changes to one file: cp file file.orig ; edit file
; diff -u file.orig file | tee file.patch

>

> 2\. generating a patch of all changes in a directory: diff -ruN dir.orig
dir.mod > all-changes-in-dir.patch

>

> 3\. applying a patch to a file: patch file < file.patch

>

> 4\. applying a patch to a directory: cd dir &amp;&amp; patch -p1 < /tmp/all-
changes-in-dir.patch

>

> 5\. reversing that patch out again when it doesn't work: cd dir &amp;&amp;
patch -Rp1 < /tmp/all-changes-in-dir.patch

>

> There are some handy cvs diff commands:

>

> 1\. cvs diff -u file # changes since last commit

>

> 2\. cvs diff -r1.1 -r1.2 -u file # changes between given revisions

>

> and with git:

>

> 1\. git diff -u file # changes since last commit

>

> 2\. git diff -u rel22 master file # changes between given branches

>

> This can also give a crude way to reverse a change: use diff to make a patch
file and then feed it to patch -R... but there are usually better ways, like
cvs update's merge options and git revert.

>

> If you are using patch files without revision control much, you may find
[wiggle](http://cgi.cse.unsw.edu.au/%7Eneilb/source/wiggle/) helpful.

>

> Ask questions and I'll try to answer. Mangling files is one thing I have had
far too much practice at!"

  * Comment on this
  * Start of this section
  * Start of this page
  * [All of this blog](../)

* * *

[Comment form for non-frame browsers](../../comp/respond.pl).

Comments are moderated (damn spammers) but almost anything sensible gets
approved (albeit eventually). If you give a web address, I'll link it. I won't
publish your email address unless you ask me to, but I'll email you a link
when the comment is posted, or the reason why it's not posted.

This is copyright 2007 MJ Ray. See fuller notice on [front page](/).

