Hello, I'm learning (and appreciating) the new systemd; and I'm currently trying to make it work to load some firmware, in the most generic way.
The hardware needing that firmware is a cheap bluetooth usb dongle; so cheap that without loading the firware it just plain doesn't work. So, the idea is to have udev trigger a generic systemd .service unit that will call the user space firmware loader with the right parameters. by default the firmware loader uses the interface name (eg: "hci0"), but that isn't right for a generic solution; what if it actually is named "hci1" ? I can however use the bdaddr adress instead, and it seems udev provides it (without the colons) as ID_SERIAL_SHORT However, in order to have the service properly show when listing services with systemctl status, etc; and have it removed when device in unplugged, I made the service BindTo= the generated .device Problem is the generated .device unit has the interface name "hci0" in its name. So my questions are: - how to get the interface name of a given device to use in a generic systemd service unit ? can udev provide that ? if not how to retrieve it ? - is the udev variable ID_SERIAL_SHORT always holding the bdaddr of a bluetooth device ? if not, what is the way to write an udev rule so that a given device can be specifically identified ? And here are the udev rules and systemd service files I wrote so far: ---------- /etc/udev/rules.d/60-brcm_patchram_plus_usb.rules ---------- SUBSYSTEM!="usb", GOTO="brcm_patchram_plus_usb_end" ACTION!="add", GOTO="brcm_patchram_plus_usb_end" ## FIXME: should be lines like this (with TAG+="systemd"), but I'm unable to make it work (old systemd at home?) ##SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_VENDOR_ID}=="0a5c", ENV{ID_MODEL_ID}=="21e8", GROUP="usb", TAG+="systemd", ENV{SYSTEMD_WANTS}="brcm_patchram_plus_usb@$env{ID_VENDOR_ID}_$env{ID_MODEL_ID}.service" ###### ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0a5c", ATTRS{idProduct}=="21e[1358b-d]", GROUP="usb", RUN+="/usr/bin/systemctl start brcm_patchram_plus_usb@$env{ID_VENDOR_ID}_$env{ID_MODEL_ID}.service" # end LABEL="brcm_patchram_plus_usb_end" ------------------------------------------------------------------------ ---------- /etc/systemd/system/brcm_patchram_plus_usb@.service---------- [Unit] Description=uploading firmware to Broadcom USB bluetooth device # fixme: how to get the bluez device name? it could be hci1, hci2,... Requires=sys-subsystem-bluetooth-devices-hci0.device After=sys-subsystem-bluetooth-devices-hci0.device BindTo=sys-subsystem-bluetooth-devices-hci0.device [Service] Type=simple RemainAfterExit=yes # fixme: how to get the bluez device name? it could be hci1, hci2,... ExecStart=/usr/bin/brcm_patchram_plus_usb --patchram /lib/firmware/fw-%i.hcd hci0 [Install] Alias=fw-upload-broadcom-bluetooth.service [Service] TimeoutSec=300 ------------------------------------------------------------------------ (another question: is [Install] section needed at all? the service can be run only when device is plugged, and has to be rerun again with each plug; so doing systemctl {enable|disable} is pointless) The automatically generated .device units are: sys-devices-pci0000:00-0000:00:1a.0-usb1-1\x2d1-1\x2d1:1.0-bluetooth-hci0.device loaded active plugged /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1:1.0/bluetooth/hci0 sys-subsystem-bluetooth-devices-hci0.device loaded active plugged /sys/subsystem/bluetooth/devices/hci0 Thanks -- Ki ça vos våye bén, Pablo Saratxaga http://chanae.walon.org/pablo/ PGP Key available, key ID: 0xD9B85466
pgpIyr01dz71C.pgp
Description: PGP signature
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel