[meta-ti] [PATCH] gadget-init: Add network-gadget services and other fixes
Jason Kridner
jkridner at beagleboard.org
Wed Nov 9 08:28:59 PST 2011
On Wed, Nov 9, 2011 at 11:24 AM, Fernandes, Joel A <joelagnel at ti.com> wrote:
>> -----Original Message-----
>> From: Koen Kooi [mailto:koen at dominion.thruhere.net]
>> Sent: Wednesday, November 09, 2011 10:07 AM
>> To: Fernandes, Joel A
>> Cc: meta-ti at yoctoproject.org
>> Subject: Re: [meta-ti] [PATCH] gadget-init: Add network-gadget services
>> and other fixes
>>
>>
>> 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
>
> [Joel]. I feel this service and conf should be here as it is specific to the the g-ether gadget configuration.
>
> If you strongly believe otherwise, can you suggest a location for this recipe? recipes-ti/beagleboard? recipes-misc?
>
>>
>> > 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/sbi
>> n/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 ``
>
> [Joel] OK.
>
>>
>> > + if [ "$x" == "" ]
>>
>> use -z ?
>
> [Joel] OK.
>
>>
>> > + 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
>
> [Joel] OK.
>
>>
>> > +/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
>
> [Joel] Could explain a little more about ">1 bone" connect?
>
>> > +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
>
> [Joel] OK.
> Jason though of asking your opinion as your wrote this ervice, is there any other reason you hardcoded this? Will removing it above have any affect that you were seeing?
This isn't a generic udhcp recipe. It should probably just be
renamed. It is specifically for the point of providing addresses to
the other end of the USB network gadget.
I haven't tried without it. Please remove it and see if it has an impact.
>
> Thanks,
> Joel
> _______________________________________________
> meta-ti mailing list
> meta-ti at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/meta-ti
>
More information about the meta-ti
mailing list