[meta-ti] [PATCH] gadget-init: Add network-gadget services and other fixes
Jason Kridner
jkridner at beagleboard.org
Wed Nov 9 08:26:51 PST 2011
On Wed, Nov 9, 2011 at 11:07 AM, Koen Kooi <koen at dominion.thruhere.net> wrote:
>
> Op 9 nov. 2011, om 17:02 heeft Joel A Fernandes het volgende geschreven:
>
>> * 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
>>
>> Signed-off-by: Joel A Fernandes <joelagnel at ti.com>
>> ---
>> recipes-ti/beagleboard/gadget-init.bb | 10 ++++++++--
>> .../beagleboard/gadget-init/bone-gmass-eject.rules | 1 +
>> .../beagleboard/gadget-init/g-ether-insert.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 +++++++++++
>> 8 files changed, 51 insertions(+), 2 deletions(-)
>> create mode 100644 recipes-ti/beagleboard/gadget-init/bone-gmass-eject.rules
>> create mode 100755 recipes-ti/beagleboard/gadget-init/g-ether-insert.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
>>
>> diff --git a/recipes-ti/beagleboard/gadget-init.bb b/recipes-ti/beagleboard/gadget-init.bb
>> index ee51586..7b440ff 100644
>> --- a/recipes-ti/beagleboard/gadget-init.bb
>> +++ b/recipes-ti/beagleboard/gadget-init.bb
>> @@ -1,6 +1,6 @@
>> DESCRIPTION = "Units to initialize usb gadgets"
>>
>> -PR = "r3"
>> +PR = "r4"
>>
>> LICENSE = "MIT"
>> LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58"
>> @@ -9,8 +9,14 @@ 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 \
>
> Please put those in a separe udhcpd-conf (or similarly named) recipe
>
>> file://99-hokey-pokey.rules \
>> file://hokey-pokey.sh \
>> + file://bone-gmass-eject.rules \
>> + file://g-storage-reinsert.sh \
>> + file://g-ether-insert.sh \
>> "
>>
>> do_install() {
>> @@ -23,10 +29,10 @@ 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}"
>> diff --git a/recipes-ti/beagleboard/gadget-init/bone-gmass-eject.rules b/recipes-ti/beagleboard/gadget-init/bone-gmass-eject.rules
>> new file mode 100644
>> index 0000000..fa5d627
>> --- /dev/null
>> +++ b/recipes-ti/beagleboard/gadget-init/bone-gmass-eject.rules
>> @@ -0,0 +1 @@
>> +SUBSYSTEM=="block",ACTION=="change",KERNEL=="mmcblk0p1",RUN+="/usr/sbin/g-ether-insert.sh"
>> diff --git a/recipes-ti/beagleboard/gadget-init/g-ether-insert.sh b/recipes-ti/beagleboard/gadget-init/g-ether-insert.sh
>> new file mode 100755
>> index 0000000..6c6956e
>> --- /dev/null
>> +++ b/recipes-ti/beagleboard/gadget-init/g-ether-insert.sh
>> @@ -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`
>
> please use $() instead of ``
>
>> + if [ "$x" == "" ]
>
> use -z ?
>
>> + then
>> + /bin/systemctl stop storage-gadget-init.service
>> + /bin/systemctl start network-gadget-init.service
>> + /bin/systemctl start udhcpd.service
>> + fi
>> +fi
>> diff --git a/recipes-ti/beagleboard/gadget-init/g-storage-reinsert.sh b/recipes-ti/beagleboard/gadget-init/g-storage-reinsert.sh
>> new file mode 100755
>> index 0000000..546b438
>> --- /dev/null
>> +++ b/recipes-ti/beagleboard/gadget-init/g-storage-reinsert.sh
>> @@ -0,0 +1,4 @@
>> +#!/bin/bash
>
> /bin/sh please
>
>> +/bin/systemctl stop storage-gadget-init.service
>> +/bin/systemctl stop network-gadget-init.service
>> +/bin/systemctl start storage-gadget-init.service
>> diff --git a/recipes-ti/beagleboard/gadget-init/network-gadget-init.service b/recipes-ti/beagleboard/gadget-init/network-gadget-init.service
>> new file mode 100644
>> index 0000000..0a03898
>> --- /dev/null
>> +++ b/recipes-ti/beagleboard/gadget-init/network-gadget-init.service
>> @@ -0,0 +1,9 @@
>> +[Unit]
>> +Description=Start USB Ethernet gadget
>> +Conflicts=storage-gadget-init.service
>> +
>> +[Service]
>> +RemainAfterExit=yes
>> +ExecStart=/sbin/modprobe g_ether host_addr=00:dc:c8:f7:75:05 dev_addr=00:dd:dc:eb:6d:f1
>
> This is going to break with >1 bone connect, please remove the addresses
I would prefer to not have it coming up with a new MAC address every
time. How hard would it be to pull the MAC address from the EEPROM or
from the 2nd port of the switch? Not much time on this, so we need a
quick solution.
There is also the solution that went into the BeagleBoard/-xM based on
the die-ID.
All of these approaches sound time consuming. Given that the same MAC
address is only one of our problems, since these boards will also be
providing the same DHCP addresses, is it worth trying to fix today?
>
>> +ExecStartPost=/sbin/ifconfig usb0 192.168.7.2 netmask 255.255.255.252
>> +ExecStop=/sbin/rmmod g_ether
>> diff --git a/recipes-ti/beagleboard/gadget-init/storage-gadget-init.service b/recipes-ti/beagleboard/gadget-init/storage-gadget-init.service
>> index 2fe48e1..9a8513e 100644
>> --- a/recipes-ti/beagleboard/gadget-init/storage-gadget-init.service
>> +++ b/recipes-ti/beagleboard/gadget-init/storage-gadget-init.service
>> @@ -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
>> diff --git a/recipes-ti/beagleboard/gadget-init/udhcpd.conf b/recipes-ti/beagleboard/gadget-init/udhcpd.conf
>> new file mode 100644
>> index 0000000..3bcf00f
>> --- /dev/null
>> +++ b/recipes-ti/beagleboard/gadget-init/udhcpd.conf
>> @@ -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
>> diff --git a/recipes-ti/beagleboard/gadget-init/udhcpd.service b/recipes-ti/beagleboard/gadget-init/udhcpd.service
>> new file mode 100644
>> index 0000000..f076673
>> --- /dev/null
>> +++ b/recipes-ti/beagleboard/gadget-init/udhcpd.service
>> @@ -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
>
> Please don't hardcode bone specific stuff in this generic udhcp recipe. The script seems to take care of ordering anyway
>
> regards,
>
> Koen
> -----BEGIN PGP SIGNATURE-----
>
> iEYEARECAAYFAk66pS0ACgkQMkyGM64RGpGDpACgjdEv4CKi6yWiMQBLhY9ubtRr
> nOMAn1YI92KWpivo38dBN5t/WxL7QNok
> =lUEv
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> meta-ti mailing list
> meta-ti at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/meta-ti
>
>
More information about the meta-ti
mailing list