diff options
author | Ming Liu <ming.liu@toradex.com> | 2023-05-12 11:01:15 +0200 |
---|---|---|
committer | Francesco Dolcini <francesco.dolcini@toradex.com> | 2023-06-05 10:34:26 +0000 |
commit | 82b92298bead3a93fa905d1724ff17e0affbebc8 (patch) | |
tree | 7270f6bab7c1346a0c73816d33b836799fab07c8 | |
parent | 2571c8cd1b72b95b1094507ac20abf9dedbc318f (diff) |
libusbgx: fix systemd service
- Drop '/sbin/modprobe libcomposite' and
'/bin/mount -t configfs configfs /sys/kernel/config' from
ExecStartPre, they are redundant since libcomposite would be
automatically loaded during system starting up due to the following
setting in linux-toradex recipe:
KERNEL_MODULE_AUTOLOAD += "libcomposite", insteadly, now let
usbg.service require and run after sys-kernel-config.mount.
- Since we have "WantedBy=usb-gadget.target" in systemd service, that
ensures when udev trigger UDC rules, usbgx.service would run as well
so the "Before=systemd-networkd.service" condition could be dropped
from usbg.service.
- Use "Type=simple" rather than "Type=oneshot", this ensures
usbg.service would not hang on failures, failures could happen in
many conditions, like if the end user has manually configured
something in configfs, or start usbg.service twice, or someting
wrong in /etc/usbg/g1.schema.
Signed-off-by: Ming Liu <ming.liu@toradex.com>
-rw-r--r-- | recipes-support/libusbgx/files/usbg.service | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/recipes-support/libusbgx/files/usbg.service b/recipes-support/libusbgx/files/usbg.service index 860587b..9ed5100 100644 --- a/recipes-support/libusbgx/files/usbg.service +++ b/recipes-support/libusbgx/files/usbg.service @@ -1,12 +1,11 @@ [Unit] Description=Load default USB gadget schema g1.schema ConditionPathExists=/etc/usbg/g1.schema -Before=systemd-networkd.service +Requires=sys-kernel-config.mount +After=sys-kernel-config.mount [Service] -Type=oneshot -ExecStartPre=-/sbin/modprobe libcomposite -ExecStartPre=-/bin/mount -t configfs configfs /sys/kernel/config +Type=simple ExecStart=/usr/bin/gadget-import g1 /etc/usbg/g1.schema ExecStartPost=/bin/sh -c '/bin/echo $((0x4000+$(expr $(tr -d "\0" < /proc/device-tree/toradex,product-id) + 0))) > \ /sys/kernel/config/usb_gadget/g1/idProduct' |