LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-28-2008, 12:58 PM   #1
559jmp
LQ Newbie
 
Registered: May 2008
Posts: 5

Rep: Reputation: 0
loading firmware on USB device with udev


Hi,

I am trying to use udev to load the firmware into a usb device that I have. The device is a high speed analog to digital converter. I was given the rule and accessloader.sh script from somebody (who is no longer around so I cannot ask him). In the rule the RUN command is issued(shown below)

1) how can I tell if the script is being called when udevruns ?


The path to the device varies when I connect the device :

/dev/bus/usb/00x/00y

When run udevtest it requires the path to the device

priceless:/home/jprice # ls /dev/bus/usb/003
001 016

priceless:/home/jprice # udevtest /dev/usb/bus/003
unable to open device '/dev/usb/bus/003'


I know one issue is figuring out why the device cannot be opened even
if the path is manually specified. Permission is not an issue. I run as root.

But the other issue is how can udev know what x and y are when it runs ?

(if I know what x and why are I can specify the full path to the device in the RUN command in the rule)



A) My rule file contains :

SUBSYSTEM=="usb", SYSFS{idVendor}=="1605", SYSFS{idProduct}=="8001", RUN+="/usr/share/usb/accesloader.sh --chmod --8001"


B)the script accesloader.sh is

It looks like he exected $DEVICE to be set already be set but am not sure where. I think he may have thought it was set by udev.



#!/bin/sh
#This script should work for all ACCES USB devices being produced at the time it was written.

echo performing operation: $1
echo performing on device: $DEVICE

#!/bin/sh

#This script should work for all ACCES USB devices being produced at the time it was written.
#A special thanks go to David Mattes (mattes AT nixnux.org) for providing a really simple version
#that this was built off of


echo performing operation: $1
echo performing on device: $DEVICE


if [ $1 == "--load" ]
then
case $2 in
"--8001") hexfile="/usr/share/usb/atod.hex";;
"--0010") hexfile="/usr/share/usb/atod.hex";;
"--0001") hexfile="/usr/share/usb/atod.hex";;
"--4001") hexfile="/usr/share/usb/atod.hex";;
"--0020") hexfile="/usr/share/usb/atod.hex";;
"--0040") hexfile="/usr/share/usb/atod.hex";;
"--0030") hexfile="/usr/share/usb/atod.hex";;
*) hexfile="invalid";;
esac
echo $hexfile
echo "attempting to fxload firmware"
`/sbin/fxload -t fx2 -D $DEVICE -I $hexfile`
fi

if [ $1 == "--chmod" ]
then
chmod 0666 $DEVICE
fi



C) when I run udevmonitor I see :

UEVENT[1225215075.017604] add@/devices/pci0000:00/0000:00:02.1/usb3/3-2
UEVENT[1225215075.017766] add@/devices/pci0000:00/0000:00:02.1/usb3/3-2/usbdev3.15_ep00
UEVENT[1225215075.017787] add@/devices/pci0000:00/0000:00:02.1/usb3/3-2/3-2:1.0
UEVENT[1225215075.017806] add@/class/usb_device/usbdev3.15
UDEV [1225215075.070469] add@/devices/pci0000:00/0000:00:02.1/usb3/3-2
UDEV [1225215075.100957] add@/devices/pci0000:00/0000:00:02.1/usb3/3-2/usbdev3.15_ep00
UDEV [1225215075.179352] add@/devices/pci0000:00/0000:00:02.1/usb3/3-2/3-2:1.0
UDEV [1225215075.224303] add@/class/usb_device/usbdev3.15



Thank You for help

Jeff
 
Old 10-29-2008, 06:49 AM   #2
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
So the manufacturer hasn't updated the driver to use the kernel's firmware loader feature?

Anyway, what names do you expect in 'DEVICE'? It is obviously an environment variable, but you need to set that somehow - for example, something like this inside your udev rule:

ENV{DEVICE}="%k"

or

ENV{DEVICE}="/dev/bus/usb/$env{BUSNUM}/$env{DEVNUM}"
 
Old 11-09-2008, 10:50 PM   #3
jmp559
LQ Newbie
 
Registered: May 2008
Posts: 8

Rep: Reputation: 0
thank you Pinniped , it works !

Thank You Pinniped !

Your suggestion solved it. I really appreciate it, and learned a bit about udev as well.

Just a small note :

I had to use $attr{busnum} $attr{devnum}

rather than $env(BUSNUM} $env{DEVNUM}


I am using : Redhat - Fedora release 9 (Sulphur)

Jeff
 
  


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
DISCUSSION: Upgrade Plextor Firmware with UDEV and pxupdate How-to Thoreau LinuxAnswers Discussion 15 05-14-2008 12:10 PM
udev not called to remove open USB serial device tm007 Programming 3 09-24-2007 07:46 AM
Debian + IVTV 0.7 + udev = firmware issues bc8o8 Linux - Hardware 1 08-24-2006 07:09 PM
Upgrade Plextor Firmware with UDEV & pxupdate :How-to Thoreau Linux - Hardware 2 04-18-2005 03:20 AM
Loading firmware on boot ? lamiroy Linux - Software 1 03-24-2005 11:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:34 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
Open Source Consulting | Domain Registration