gadget-init: Add network-gadget services and other fixes
PATCH 1/1 gadget-init: Add network-gadget services and other fixes
* Add rule to start network-gadget when mass storage is ejected
* Add network-gadget-init service and scripts to switch to g_ether
* Add DHCP service / conf
* Update to storage-gadget: rmmod on stop
v2 changes:
* Fix g-ether MAC address by reading from mac_id
* Split into multiple packages
---
Note about an issue:
This works correctly except that the usb0 iface doesn't come up automatically and has to be manually ifup'ed after the gadget module loads.
recipes-ti/beagleboard/gadget-init.bb | 31 ++++++++++++- .../beagleboard/gadget-init/bone-gmass-eject.rules | 1 + recipes-ti/beagleboard/gadget-init/g-ether-load.sh | 46 ++++++++++++++++++++ .../gadget-init/g-ether-start-service.sh | 11 +++++ .../beagleboard/gadget-init/g-storage-reinsert.sh | 4 ++ .../gadget-init/network-gadget-init.service | 9 ++++ .../gadget-init/storage-gadget-init.service | 2 + recipes-ti/beagleboard/gadget-init/udhcpd.conf | 5 ++ recipes-ti/beagleboard/gadget-init/udhcpd.service | 11 +++++ 9 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 recipes-ti/beagleboard/gadget-init/bone-gmass-eject.rules create mode 100755 recipes-ti/beagleboard/gadget-init/g-ether-load.sh create mode 100755 recipes-ti/beagleboard/gadget-init/g-ether-start-service.sh create mode 100755 recipes-ti/beagleboard/gadget-init/g-storage-reinsert.sh create mode 100644 recipes-ti/beagleboard/gadget-init/network-gadget-init.service create mode 100644 recipes-ti/beagleboard/gadget-init/udhcpd.conf create mode 100644 recipes-ti/beagleboard/gadget-init/udhcpd.service
recipes-ti/beagleboard/gadget-init.bb +28 -3
@@ -1,6 +1,6 @@ DESCRIPTION = "Units to initialize usb gadgets" -PR = "r3" +PR = "r8" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58"
@@ -9,13 +9,21 @@ COMPATIBLE_MACHINE = "(ti33x)" PACKAGE_ARCH = "${MACHINE_ARCH}" SRC_URI = "file://storage-gadget-init.service \ + file://network-gadget-init.service \ + file://udhcpd.service \ + file://udhcpd.conf \ file://99-hokey-pokey.rules \ file://hokey-pokey.sh \ + file://bone-gmass-eject.rules \ + file://g-storage-reinsert.sh \ + file://g-ether-start-service.sh \ + file://g-ether-load.sh \ " do_install() { install -d ${D}${base_libdir}/systemd/system/basic.target.wants install -m 0644 ${WORKDIR}/*.service ${D}${base_libdir}/systemd/system + for i in ${WORKDIR}/*.service ; do install -m 0644 $i ${D}${base_libdir}/systemd/system ln -sf ../$(basename $i) ${D}${base_libdir}/systemd/system/basic.target.wants/
@@ -23,10 +31,27 @@ do_install() { install -d ${D}${sysconfdir}/udev/rules.d install -m 0644 ${WORKDIR}/*.rules ${D}${sysconfdir}/udev/rules.d + install -m 0644 ${WORKDIR}/*.conf ${D}${sysconfdir} install -d ${D}${bindir} install -m 0755 ${WORKDIR}/*.sh ${D}${bindir} - } -FILES_${PN} = "${base_libdir}/systemd ${sysconfdir} ${bindir}" +PACKAGES =+ "${PN}-storage ${PN}-network ${PN}-udhcpd" + +FILES_${PN} = "${sysconfdir}/udev/rules.d/99-hokey-pokey.rules \ + ${bindir}/hokey-pokey.sh \" + +FILES_${PN}-storage = "${base_libdir}/systemd/system/storage-gadget-init.service \ + ${base_libdir}/systemd/system/basic.target.wants/storage-gadget-init.service \ + ${bindir}/g-storage-reinsert.sh \ + ${sysconfdir}/udev/rules.d/bone-gmass-eject.rules" + +FILES_${PN}-network = "${base_libdir}/systemd/system/network-gadget-init.service \ + ${bindir}/g-ether-load.sh \ + ${bindir}/g-ether-start-service.sh" + +FILES_${PN}-udhcpd = "${base_libdir}/systemd/system/udhcpd.service \ + ${sysconfdir}/udhcpd.conf" + +RRECOMMENDS_${PN} = "${PN}-storage ${PN}-network ${PN}-udhcpd"
recipes-ti/beagleboard/gadget-init/bone-gmass-eject.rules new file +1 -0
@@ -0,0 +1 @@ +SUBSYSTEM=="block",ACTION=="change",KERNEL=="mmcblk0p1",RUN+="/usr/bin/g-ether-start-service.sh"
recipes-ti/beagleboard/gadget-init/g-ether-load.sh new file +46 -0
46 lines not on this page · raw message
recipes-ti/beagleboard/gadget-init/g-ether-start-service.sh new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/sh +if [ -a /sys/devices/platform/omap/ti81xx-usbss/musb-hdrc.0/gadget/lun0/file ] +then + x=$(cat /sys/devices/platform/omap/ti81xx-usbss/musb-hdrc.0/gadget/lun0/file) + if [ -z "$x" ] + then + /bin/systemctl stop storage-gadget-init.service + /bin/systemctl start network-gadget-init.service + /bin/systemctl start udhcpd.service + fi +fi
recipes-ti/beagleboard/gadget-init/g-storage-reinsert.sh new file +4 -0
@@ -0,0 +1,4 @@ +#!/bin/sh +/bin/systemctl stop storage-gadget-init.service +/bin/systemctl stop network-gadget-init.service +/bin/systemctl start storage-gadget-init.service
recipes-ti/beagleboard/gadget-init/network-gadget-init.service new file +9 -0
@@ -0,0 +1,9 @@ +[Unit] +Description=Start USB Ethernet gadget +Conflicts=storage-gadget-init.service + +[Service] +RemainAfterExit=yes +ExecStart=/usr/bin/g-ether-load.sh +ExecStartPost=/sbin/ifconfig usb0 192.168.7.2 netmask 255.255.255.252 +ExecStop=/sbin/rmmod g_ether
recipes-ti/beagleboard/gadget-init/storage-gadget-init.service +2 -0
@@ -3,7 +3,9 @@ Description=Start usb mass storage gadget After=dev-mmcblk0p1.device [Service] +RemainAfterExit=yes ExecStart=/sbin/modprobe g_mass_storage file=/dev/mmcblk0p1 cdrom=0 stall=0 removable=1 nofua=1 +ExecStop=/sbin/rmmod g_mass_storage [Install] WantedBy=basic.target
recipes-ti/beagleboard/gadget-init/udhcpd.conf new file +5 -0
@@ -0,0 +1,5 @@ +start 192.168.7.1 +end 192.168.7.1 +interface usb0 +max_leases 1 +option subnet 255.255.255.252
recipes-ti/beagleboard/gadget-init/udhcpd.service new file +11 -0
@@ -0,0 +1,11 @@ +[Unit] +Description=DHCP server for USB0 network gadget +After=sys-devices-platform-omap-ti81xx\x2dusbss-musb\x2dhdrc.0-gadget-net-usb0.device + +[Service] +ExecStart=/usr/sbin/udhcpd -f -S /etc/udhcpd.conf +ExecStop=/bin/kill -TERM $MAINPID +KillSignal=SIGINT + +[Install] +WantedBy=basic.target
Signature · 1 line
1.7.0.4
Quoted 7 lines
-----Original Message-----
From: Fernandes, Joel A
Sent: Thursday, November 10, 2011 12:07 AM
To: [email protected]
Cc: Fernandes, Joel A; Kridner, Jason
Subject: [PATCH] gadget-init: Add network-gadget services and other fixes
Sorry, the title is supposed to have "PATCH v2" prefixed.
Thanks,
Joel
Op 10 nov. 2011, om 07:08 heeft Fernandes, Joel A het volgende geschreven:
Quoted 10 lines
Quoted 7 lines
-----Original Message-----
From: Fernandes, Joel A
Sent: Thursday, November 10, 2011 12:07 AM
To: [email protected]
Cc: Fernandes, Joel A; Kridner, Jason
Subject: [PATCH] gadget-init: Add network-gadget services and other fixesSorry, the title is supposed to have "PATCH v2" prefixed.
I've applied this patch and ran some tests. It pretty much works as expected, but I had to make some small cleanups to make the logic work a bit better. The showstopper is that g_ether, like g_multi will take up 100% cpu in rcu_kthread when loaded :(
regards,
Koen
Please forgive the OWA top-post.
I'm not sure why I wasn't seeing this 2 days ago. Good news is if we fix this, we probably fix g_multi as well. I'm thinking we probably still need to boot with g_mass_storage to enable driver installation because I'm pretty sure g_multi requires drivers on Windows, but we can test that out. Not switching drivers would be so much nicer.
Regards,
Jason
________________________________________
From: [email protected] [[email protected]] on behalf of Koen Kooi [[email protected]]
Sent: Thursday, November 10, 2011 6:38 AM
To: Fernandes, Joel A
Cc: [email protected]
Subject: Re: [meta-ti] [PATCH] gadget-init: Add network-gadget services and other fixes
Op 10 nov. 2011, om 07:08 heeft Fernandes, Joel A het volgende geschreven:
Quoted 10 lines
Quoted 7 lines
-----Original Message-----
From: Fernandes, Joel A
Sent: Thursday, November 10, 2011 12:07 AM
To: [email protected]
Cc: Fernandes, Joel A; Kridner, Jason
Subject: [PATCH] gadget-init: Add network-gadget services and other fixesSorry, the title is supposed to have "PATCH v2" prefixed.
I've applied this patch and ran some tests. It pretty much works as expected, but I had to make some small cleanups to make the logic work a bit better. The showstopper is that g_ether, like g_multi will take up 100% cpu in rcu_kthread when loaded :(
regards,
Koen