USB-OTG: change way to start

Use udev rules instead of service.

Signed-off-by: Christophe Priouzeau <christophe.priouzeau@foss.st.com>
Change-Id: If77afaba6d763d34ec08cdc7f18f781e0fd30362
This commit is contained in:
Christophe Priouzeau
2022-06-07 09:53:38 +02:00
committed by bernard PUEL
parent 1372c4a9d7
commit b1631a799a
4 changed files with 20 additions and 33 deletions

View File

@ -1,41 +1,32 @@
# Copyright (C) 2018, STMicroelectronics - All Rights Reserved # Copyright (C) 2018, STMicroelectronics - All Rights Reserved
# Released under the MIT license (see COPYING.MIT for the terms) # Released under the MIT license (see COPYING.MIT for the terms)
DESCRIPTION = "The goal is to enable USB gadget configuration" SUMMARY = "The goal is to enable USB gadget configuration"
LICENSE = "MIT" LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
PV = "1.0" PV = "1.0"
SRC_URI = " file://usbotg-config.service \ SRC_URI = " file://stm32_usbotg_eth_config.sh \
file://stm32_usbotg_eth_config.sh \
file://53-usb-otg.network \ file://53-usb-otg.network \
file://97-ustotg.rules \
" "
S = "${WORKDIR}/git" S = "${WORKDIR}/git"
inherit systemd update-rc.d
SYSTEMD_PACKAGES += "${PN}"
SYSTEMD_SERVICE_${PN} = "usbotg-config.service"
SYSTEMD_AUTO_ENABLE_${PN} = "enable"
do_install() { do_install() {
if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
install -d ${D}${systemd_unitdir}/system ${D}${base_sbindir} ${D}${systemd_unitdir}/network install -d ${D}${systemd_unitdir}/network
install -m 0644 ${WORKDIR}/usbotg-config.service ${D}${systemd_unitdir}/system
install -m 0755 ${WORKDIR}/stm32_usbotg_eth_config.sh ${D}${base_sbindir}
install -m 0644 ${WORKDIR}/53-usb-otg.network ${D}${systemd_unitdir}/network install -m 0644 ${WORKDIR}/53-usb-otg.network ${D}${systemd_unitdir}/network
fi fi
install -d ${D}${sysconfdir}/init.d install -d ${D}${base_sbindir}
install -m 0755 ${WORKDIR}/stm32_usbotg_eth_config.sh ${D}${sysconfdir}/init.d/ install -m 0755 ${WORKDIR}/stm32_usbotg_eth_config.sh ${D}${base_sbindir}
# install udev rule
install -D -p -m0644 ${WORKDIR}/97-ustotg.rules ${D}${sysconfdir}/udev/rules.d/97-ustotg.rules
} }
INITSCRIPT_NAME = "stm32_usbotg_eth_config.sh"
INITSCRIPT_PARAMS = "start 22 5 3 ."
FILES:${PN} += "${systemd_unitdir}/network ${sysconfdir}/udev" FILES:${PN} += "${systemd_unitdir}/network ${sysconfdir}/udev"

View File

@ -0,0 +1,2 @@
ACTION=="add", SUBSYSTEM=="udc", RUN+="/sbin/stm32_usbotg_eth_config.sh restart"

View File

@ -63,7 +63,7 @@ do_start() {
mkdir -p "${d}/configs/${c}" mkdir -p "${d}/configs/${c}"
mkdir -p "${d}/configs/${c}/strings/0x409" mkdir -p "${d}/configs/${c}/strings/0x409"
echo "Config 1: RNDIS" > "${d}/configs/${c}/strings/0x409/configuration" echo "Config 1: RNDIS" > "${d}/configs/${c}/strings/0x409/configuration"
echo 250 > "${d}/configs/${c}/MaxPower" echo 0 > "${d}/configs/${c}/MaxPower"
echo 0xC0 > "${d}/configs/${c}/bmAttributes" # self powered device echo 0xC0 > "${d}/configs/${c}/bmAttributes" # self powered device
# Windows extension to force RNDIS config # Windows extension to force RNDIS config
@ -131,13 +131,20 @@ do_stop() {
case $1 in case $1 in
start) start)
echo "Start usb gadget" echo "Start usb gadget"
do_start $2 do_start
;; ;;
stop) stop)
echo "Stop usb gadget" echo "Stop usb gadget"
do_stop do_stop
;; ;;
restart)
echo "Stop usb gadget"
do_stop
sleep 1
echo "Start usb gadget"
do_start
;;
*) *)
echo "Usage: $0 (stop | start)" echo "Usage: $0 (stop | start | restart)"
;; ;;
esac esac

View File

@ -1,13 +0,0 @@
[Unit]
Description=Enable USB Ethernet gadget
After=systemd-remount-fs.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=-/sbin/stm32_usbotg_eth_config.sh start
ExecStop=/sbin/stm32_usbotg_eth_config.sh stop
[Install]
WantedBy=multi-user.target