* [meta-oe][PATCH 1/2] libusbgx: fix usbgx.service stop / restart
@ 2024-02-15 14:07 max.oss.09
2024-02-15 14:07 ` [meta-oe][PATCH 2/2] libusbgx: uprev to the latest commit max.oss.09
0 siblings, 1 reply; 4+ messages in thread
From: max.oss.09 @ 2024-02-15 14:07 UTC (permalink / raw)
To: openembedded-devel; +Cc: Max Krummenacher
From: Max Krummenacher <max.krummenacher@toradex.com>
On start the usbgx service configures the usb gadget. However if
one stops the service nothing is done, a subsequent start then
tries to configure the gadget again and fails. `systemctl restart`
is implemented by doing a stop followed by a start and thus is
also affected.
Doing a start/stop/start results with the following reported in
status:
| systemd[1]: Starting Load USB gadget schemas...
| gadget-start[801]: usbg_create_gadget() duplicate gadget name
| gadget-start[801]:
| gadget-start[801]: Error on import gadget
| gadget-start[801]: Error: USBG_ERROR_EXIST : Already exist
| gadget-start[812]: ls: write error: Device or resource busy
The run-postinsts service does execute a restart for each package
which uses the systemd class which creates a race condition that the
usbgx service is already started when run-postinsts restarts usbgx
and creates the above error output.
Fix that by unconfiguring the usb gadget on stop.
Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
---
.../recipes-support/libusbgx/libusbgx/gadget-stop | 13 +++++++++++++
.../recipes-support/libusbgx/libusbgx/usbgx.service | 2 ++
meta-oe/recipes-support/libusbgx/libusbgx_git.bb | 3 +++
3 files changed, 18 insertions(+)
create mode 100755 meta-oe/recipes-support/libusbgx/libusbgx/gadget-stop
diff --git a/meta-oe/recipes-support/libusbgx/libusbgx/gadget-stop b/meta-oe/recipes-support/libusbgx/libusbgx/gadget-stop
new file mode 100755
index 000000000..24b7caed5
--- /dev/null
+++ b/meta-oe/recipes-support/libusbgx/libusbgx/gadget-stop
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+[ -r /etc/default/usbgx ] && . /etc/default/usbgx
+
+for i in $IMPORT_SCHEMAS; do
+ if [ -e /sys/kernel/config/usb_gadget/"$i"/idVendor ]; then
+ if [ -e /sys/kernel/config/usb_gadget/"$i"/idProduct ]; then
+ idVendor=$(cat /sys/kernel/config/usb_gadget/"$i"/idVendor)
+ idProduct=$(cat /sys/kernel/config/usb_gadget/"$i"/idProduct)
+ /usr/bin/gadget-vid-pid-remove ${idVendor}:${idProduct}
+ fi
+ fi
+done
diff --git a/meta-oe/recipes-support/libusbgx/libusbgx/usbgx.service b/meta-oe/recipes-support/libusbgx/libusbgx/usbgx.service
index d7d394cfe..7210969d6 100644
--- a/meta-oe/recipes-support/libusbgx/libusbgx/usbgx.service
+++ b/meta-oe/recipes-support/libusbgx/libusbgx/usbgx.service
@@ -5,7 +5,9 @@ After=sys-kernel-config.mount
[Service]
Type=oneshot
+RemainAfterExit=yes
ExecStart=/usr/bin/gadget-start
+ExecStop=/usr/bin/gadget-stop
[Install]
WantedBy=usb-gadget.target
diff --git a/meta-oe/recipes-support/libusbgx/libusbgx_git.bb b/meta-oe/recipes-support/libusbgx/libusbgx_git.bb
index f8ebcc776..484110561 100644
--- a/meta-oe/recipes-support/libusbgx/libusbgx_git.bb
+++ b/meta-oe/recipes-support/libusbgx/libusbgx_git.bb
@@ -13,6 +13,7 @@ SRC_URI = " \
file://0001-libusbgx-Add-interface-name-for-NCM-Feature-Descript.patch \
file://0001-fix-stack-buffer-overflow-in-usbg_f_foo_attr_val-pro.patch \
file://gadget-start \
+ file://gadget-stop \
file://usbgx.initd \
file://usbgx.service \
"
@@ -39,6 +40,8 @@ INHIBIT_UPDATERCD_BBCLASS = "${@bb.utils.contains('PACKAGECONFIG', 'examples', '
do_install:append() {
install -Dm 0755 ${WORKDIR}/gadget-start ${D}${bindir}/gadget-start
sed -i -e 's,/usr/bin,${bindir},g' -e 's,/etc,${sysconfdir},g' ${D}${bindir}/gadget-start
+ install -m 0755 ${WORKDIR}/gadget-start ${D}${bindir}/gadget-stop
+ sed -i -e 's,/usr/bin,${bindir},g' -e 's,/etc,${sysconfdir},g' ${D}${bindir}/gadget-stop
if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
install -Dm 0644 ${WORKDIR}/usbgx.service ${D}${systemd_system_unitdir}/usbgx.service
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [meta-oe][PATCH 2/2] libusbgx: uprev to the latest commit
2024-02-15 14:07 [meta-oe][PATCH 1/2] libusbgx: fix usbgx.service stop / restart max.oss.09
@ 2024-02-15 14:07 ` max.oss.09
2024-02-15 14:16 ` Max Krummenacher
0 siblings, 1 reply; 4+ messages in thread
From: max.oss.09 @ 2024-02-15 14:07 UTC (permalink / raw)
To: openembedded-devel; +Cc: Max Krummenacher
From: Max Krummenacher <max.krummenacher@toradex.com>
Uprev libusbgx to ec0b01c to get following fixes:
```
ec0b01c Merge pull request #83 from mgrzeschik/uac2-controls
cbf1750 uac2: add additional configuration controls
81d7c05 load libcomposite kernel module
caad244 Fix: Memory leak config label
51abbfd Automake: fix distclean of tests
3cc5af7 Added printer function header to installed headers
adc45af Added missing extern C closing brace
```
Refresh 0001-fix-stack-buffer-overflow-in-usbg_f_foo_attr_val-pro.patch.
Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
---
meta-oe/recipes-support/libusbgx/libusbgx_git.bb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meta-oe/recipes-support/libusbgx/libusbgx_git.bb b/meta-oe/recipes-support/libusbgx/libusbgx_git.bb
index 484110561..a20ff4eea 100644
--- a/meta-oe/recipes-support/libusbgx/libusbgx_git.bb
+++ b/meta-oe/recipes-support/libusbgx/libusbgx_git.bb
@@ -6,7 +6,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
inherit autotools pkgconfig systemd update-rc.d update-alternatives
PV = "0.2.0+git"
-SRCREV = "721e3a1cbd7e2b6361bb439d3959e7403e4f0092"
+SRCREV = "ec0b01c03fdc7893997b7b32ec1c12c6103f62f3"
SRCBRANCH = "master"
SRC_URI = " \
git://github.com/libusbgx/libusbgx.git;branch=${SRCBRANCH};protocol=https \
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [meta-oe][PATCH 2/2] libusbgx: uprev to the latest commit
2024-02-15 14:07 ` [meta-oe][PATCH 2/2] libusbgx: uprev to the latest commit max.oss.09
@ 2024-02-15 14:16 ` Max Krummenacher
0 siblings, 0 replies; 4+ messages in thread
From: Max Krummenacher @ 2024-02-15 14:16 UTC (permalink / raw)
To: openembedded-devel; +Cc: Max Krummenacher
On Thu, Feb 15, 2024 at 03:07:14PM +0100, max.oss.09@gmail.com wrote:
> From: Max Krummenacher <max.krummenacher@toradex.com>
>
> Uprev libusbgx to ec0b01c to get following fixes:
> ```
> ec0b01c Merge pull request #83 from mgrzeschik/uac2-controls
> cbf1750 uac2: add additional configuration controls
> 81d7c05 load libcomposite kernel module
> caad244 Fix: Memory leak config label
> 51abbfd Automake: fix distclean of tests
> 3cc5af7 Added printer function header to installed headers
> adc45af Added missing extern C closing brace
> ```
>
> Refresh 0001-fix-stack-buffer-overflow-in-usbg_f_foo_attr_val-pro.patch.
I missed to add the changed patch file to the commit, v2 to follow shortly.
Sorry about that.
Max
>
> Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
> ---
> meta-oe/recipes-support/libusbgx/libusbgx_git.bb | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta-oe/recipes-support/libusbgx/libusbgx_git.bb b/meta-oe/recipes-support/libusbgx/libusbgx_git.bb
> index 484110561..a20ff4eea 100644
> --- a/meta-oe/recipes-support/libusbgx/libusbgx_git.bb
> +++ b/meta-oe/recipes-support/libusbgx/libusbgx_git.bb
> @@ -6,7 +6,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
> inherit autotools pkgconfig systemd update-rc.d update-alternatives
>
> PV = "0.2.0+git"
> -SRCREV = "721e3a1cbd7e2b6361bb439d3959e7403e4f0092"
> +SRCREV = "ec0b01c03fdc7893997b7b32ec1c12c6103f62f3"
> SRCBRANCH = "master"
> SRC_URI = " \
> git://github.com/libusbgx/libusbgx.git;branch=${SRCBRANCH};protocol=https \
> --
> 2.42.0
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [meta-oe][PATCH 2/2] libusbgx: uprev to the latest commit
2024-02-15 14:17 [meta-oe][PATCH 1/2] libusbgx: fix usbgx.service stop / restart max.oss.09
@ 2024-02-15 14:17 ` max.oss.09
0 siblings, 0 replies; 4+ messages in thread
From: max.oss.09 @ 2024-02-15 14:17 UTC (permalink / raw)
To: openembedded-devel; +Cc: Max Krummenacher
From: Max Krummenacher <max.krummenacher@toradex.com>
Uprev libusbgx to ec0b01c to get following fixes:
```
ec0b01c Merge pull request #83 from mgrzeschik/uac2-controls
cbf1750 uac2: add additional configuration controls
81d7c05 load libcomposite kernel module
caad244 Fix: Memory leak config label
51abbfd Automake: fix distclean of tests
3cc5af7 Added printer function header to installed headers
adc45af Added missing extern C closing brace
```
Refresh 0001-fix-stack-buffer-overflow-in-usbg_f_foo_attr_val-pro.patch.
Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
---
meta-oe/recipes-support/libusbgx/libusbgx_git.bb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
V2:
- added the changed patch file to commit
diff --git a/meta-oe/recipes-support/libusbgx/libusbgx_git.bb b/meta-oe/recipes-support/libusbgx/libusbgx_git.bb
index 484110561..a20ff4eea 100644
--- a/meta-oe/recipes-support/libusbgx/libusbgx_git.bb
+++ b/meta-oe/recipes-support/libusbgx/libusbgx_git.bb
@@ -6,7 +6,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
inherit autotools pkgconfig systemd update-rc.d update-alternatives
PV = "0.2.0+git"
-SRCREV = "721e3a1cbd7e2b6361bb439d3959e7403e4f0092"
+SRCREV = "ec0b01c03fdc7893997b7b32ec1c12c6103f62f3"
SRCBRANCH = "master"
SRC_URI = " \
git://github.com/libusbgx/libusbgx.git;branch=${SRCBRANCH};protocol=https \
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-15 14:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-15 14:07 [meta-oe][PATCH 1/2] libusbgx: fix usbgx.service stop / restart max.oss.09
2024-02-15 14:07 ` [meta-oe][PATCH 2/2] libusbgx: uprev to the latest commit max.oss.09
2024-02-15 14:16 ` Max Krummenacher
-- strict thread matches above, loose matches on Subject: below --
2024-02-15 14:17 [meta-oe][PATCH 1/2] libusbgx: fix usbgx.service stop / restart max.oss.09
2024-02-15 14:17 ` [meta-oe][PATCH 2/2] libusbgx: uprev to the latest commit max.oss.09
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.