Execute command with udev rule on loading driver

0

I have a touchscreen driver named "my_touch" which is loaded at boot because it's listed in /etc/modules. I want to write an Udev rule to change the line disciple after it is loaded by executing /usr/sbin/ldattach 25 /dev/ttymxc1. I've tried multiple udev rules, but they don't seem to work. I'm almost certain the rule has to look something like:

KERNEL=="my_touch", SUBSYSTEM=="module", ACTION=="add", RUN+="/usr/sbin/ldattach 25 /dev/ttymxc1"

Both the driver and device are available in sysfs.

$ udevadm info -ap /module/my_touch/
  looking at device '/module/my_touch':
    KERNEL=="my_touch"
    SUBSYSTEM=="module"
    DRIVER==""
    ATTR{coresize}=="16384"
    ATTR{initsize}=="0"
    ATTR{initstate}=="live"
    ATTR{refcnt}=="0"
    ATTR{srcversion}=="45DFE5D135E9A5AFB61EB69"
    ATTR{taint}=="O"

  looking at parent device[..]

$ udevadm info -ap /devices/soc0/soc/2100000.aips-bus/21e8000.serial/tty/ttymxc1
  looking at device '/devices/soc0/soc/2100000.aips-bus/21e8000.serial/tty/ttymxc1':
    KERNEL=="ttymxc1"
    SUBSYSTEM=="tty"
    DRIVER==""
    ATTR{close_delay}=="50"
    ATTR{closing_wait}=="3000"
    ATTR{custom_divisor}=="0"
    ATTR{flags}=="0x10000000"
    ATTR{io_type}=="2"
    ATTR{iomem_base}=="0x21E8000"
    ATTR{iomem_reg_shift}=="0"
    ATTR{irq}=="68"
    ATTR{line}=="1"
    ATTR{port}=="0x0"
    ATTR{type}=="62"
    ATTR{uartclk}=="80000000"
    ATTR{xmit_fifo_size}=="32"

  looking at parent device[..]

If if test the rules, my rule does exist and no errors are shown.

$ udevadm test /module/my_touch/
calling: test
version 232
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

=== trie on-disk ===
tool version:          232
file size:         8447619 bytes
header size             80 bytes
strings            1849043 bytes
nodes              6598496 bytes
Load module index
Found container virtualization none
timestamp of '/etc/systemd/network' changed
Parsed configuration file /lib/systemd/network/99-default.link
Created link configuration context.
timestamp of '/etc/udev/rules.d' changed
Reading rules file: [..]
rules contain 49152 bytes tokens (4096 * 12 bytes), 12709 bytes strings
4208 strings (39523 bytes), 3485 de-duplicated (27538 bytes), 724 trie nodes used
RUN '/usr/sbin/ldattach 25 /dev/ttymxc1' /etc/udev/rules.d/10-Prodrive.rules:2
ACTION=add
DEVPATH=/module/my_touch
SUBSYSTEM=module
USEC_INITIALIZED=1366176459
run: '/usr/sbin/ldattach 25 /dev/ttymxc1'
Unload module index
Unloaded link configuration context.

Clues to an appropriate udev rule and some explanation/reading is appreciated.

linux
udev
debian-stretch
asked on Stack Overflow Mar 15, 2019 by Bayou

1 Answer

0

For the completeness of this thread; instead of using udev rules I've created a simple systemd unit file that executes every boot. Sadly, I couldn't get the udev rule to work.

answered on Stack Overflow Apr 26, 2019 by Bayou

User contributions licensed under CC BY-SA 3.0