我一直在研究一个简单的Linux固件来加载一个需要驱动程序rt2800usb的Ralink wifi卡。固件在相关位置包含文件rt2800usb
,启动udev守护程序并具有匹配卡的属性的规则。
这是我最初用来匹配卡片的规则:
KERNEL=="wlan*", ATTRS{manufacturer}=="Ralink", NAME="wificard%E{SLOT}"
虽然该规则与卡的属性相匹配,但它不会加载卡的rt2800usb
驱动程序。
我已经使用udevadm trigger --attr-match=manufacturer="Ralink"
检查了这一点,我看到同样的事情,它会选择设备路径,但不会加载驱动程序。
有一条规则似乎加载了驱动程序,就是这样:
udevadm trigger --verbose --parent-match=/sys/devices/pci0000\:00/0000\:00\:0f.5/usb1/1-2/1-2\:1.0/
但是,就我对udev的理解而言,此规则会触发插入该特定USB插槽的任何设备。我正在尝试调整此规则以仅适用于Ralink卡。我尝试添加--attr-match=manufacturer="Ralink"
,但规则不再匹配。
如果有人能帮助我阐明这一点,我真的很感激,特别是为什么有些udev比赛会启动驱动程序而其他人没有?
此处还有udevadm info --attribute-walk udevadm info --attribute-walk --path=/sys/devices/pci0000\:00/0000\:00\:0f.5/usb1/1-2/1-2\:1.0
的输出:
looking at device '/devices/pci0000:00/0000:00:0f.5/usb1/1-2/1-2:1.0':
KERNEL=="1-2:1.0"
SUBSYSTEM=="usb"
DRIVER=="rt2800usb"
ATTR{bInterfaceClass}=="ff"
ATTR{bInterfaceSubClass}=="ff"
ATTR{bInterfaceProtocol}=="ff"
ATTR{bNumEndpoints}=="07"
ATTR{supports_autosuspend}=="0"
ATTR{bAlternateSetting}==" 0"
ATTR{bInterfaceNumber}=="00"
ATTR{interface}=="1.0"
looking at parent device '/devices/pci0000:00/0000:00:0f.5/usb1/1-2':
KERNELS=="1-2"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{devpath}=="2"
ATTRS{idVendor}=="148f"
ATTRS{speed}=="480"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{busnum}=="1"
ATTRS{devnum}=="2"
ATTRS{configuration}==""
ATTRS{bMaxPower}=="450mA"
ATTRS{authorized}=="1"
ATTRS{bmAttributes}=="80"
ATTRS{bNumConfigurations}=="1"
ATTRS{maxchild}=="0"
ATTRS{bcdDevice}=="0101"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{quirks}=="0x0"
ATTRS{serial}=="1.0"
ATTRS{version}==" 2.00"
ATTRS{urbnum}=="2719"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Ralink"
ATTRS{removable}=="unknown"
ATTRS{idProduct}=="5370"
ATTRS{bDeviceClass}=="00"
ATTRS{product}=="802.11 n WLAN"
looking at parent device '/devices/pci0000:00/0000:00:0f.5/usb1':
KERNELS=="usb1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{devpath}=="0"
ATTRS{idVendor}=="1d6b"
ATTRS{speed}=="480"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{authorized_default}=="1"
ATTRS{busnum}=="1"
ATTRS{devnum}=="1"
ATTRS{configuration}==""
ATTRS{bMaxPower}=="0mA"
ATTRS{authorized}=="1"
ATTRS{bmAttributes}=="e0"
ATTRS{bNumConfigurations}=="1"
ATTRS{maxchild}=="4"
ATTRS{bcdDevice}=="0312"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{quirks}=="0x0"
ATTRS{serial}=="0000:00:0f.5"
ATTRS{version}==" 2.00"
ATTRS{urbnum}=="40"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Linux 3.12.9 ehci_hcd"
ATTRS{removable}=="unknown"
ATTRS{idProduct}=="0002"
ATTRS{bDeviceClass}=="09"
ATTRS{product}=="EHCI Host Controller"
looking at parent device '/devices/pci0000:00/0000:00:0f.5':
KERNELS=="0000:00:0f.5"
SUBSYSTEMS=="pci"
DRIVERS=="ehci-pci"
ATTRS{irq}=="12"
ATTRS{subsystem_vendor}=="0x1022"
ATTRS{broken_parity_status}=="0"
ATTRS{class}=="0x0c0320"
ATTRS{companion}==""
ATTRS{consistent_dma_mask_bits}=="32"
ATTRS{dma_mask_bits}=="32"
ATTRS{local_cpus}=="1"
ATTRS{device}=="0x2095"
ATTRS{uframe_periodic_max}=="100"
ATTRS{enable}=="1"
ATTRS{msi_bus}==""
ATTRS{local_cpulist}=="0"
ATTRS{vendor}=="0x1022"
ATTRS{subsystem_device}=="0x2095"
looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""
答案 0 :(得分:2)
1)
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*", ATTR{flags}=="0x1002", DRIVERS=="rt2800usb"
2)
ACTION=="add", SUBSYSTEM=="compat_firmware"
1)此规则检测到USB适配器的插入但未链接。我将此规则用于重新启动网络,udhcpd和hostapd(用于主模式)。重新启动网络服务会导致固件加载,并且wlan会获得IP地址; - )
2)我使用从Compat Driver编译的驱动程序,使用:
加载firmare成功SUBSYSTEM ==" compat_firmware",ACTION ==" add",RUN + =" compat_firmware.sh"
" compat_firmware.sh"的代码#!/bin/sh -e
FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \
/lib/firmware/$(uname -r) /lib/firmware"
err() {
echo "$@" >&2
logger -t "${0##*/}[$$]" "$@" 2>/dev/null || true
}
if [ ! -e /sys$DEVPATH/loading ]; then
err "udev firmware loader misses sysfs directory"
exit 1
fi
for DIR in $FIRMWARE_DIRS; do
[ -e "$DIR/$FIRMWARE" ] || continue
echo 1 > /sys$DEVPATH/loading
cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data
echo 0 > /sys$DEVPATH/loading
exit 0
done
echo -1 > /sys$DEVPATH/loading
err "Cannot find firmware file '$FIRMWARE'"
mkdir -p /dev/.udev/firmware-missing
file=$(echo "$FIRMWARE" | sed 's:/:\\x2f:g')
ln -s -f "$DEVPATH" /dev/.udev/firmware-missing/$file
exit 1
抱歉我的英文
见G + GustavoReyes71