summaryrefslogtreecommitdiffstats
path: root/recipes-ti/beagleboard/gadget-init
diff options
context:
space:
mode:
authorJoel A Fernandes <joelagnel@ti.com>2011-11-10 00:06:35 -0600
committerKoen Kooi <koen@dominion.thruhere.net>2011-11-10 08:23:08 +0100
commit89c54f502b38ec21e79056a5510f77836d013e81 (patch)
tree8679cbdb468fdf5abfa55bc63b537d174f2205d1 /recipes-ti/beagleboard/gadget-init
parent2cd35f07bfcb6ea76f329d6f278a7d7e98c5d79a (diff)
downloadmeta-ti-89c54f502b38ec21e79056a5510f77836d013e81.tar.gz
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 Signed-off-by: Joel A Fernandes <joelagnel@ti.com> Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Diffstat (limited to 'recipes-ti/beagleboard/gadget-init')
-rw-r--r--recipes-ti/beagleboard/gadget-init/bone-gmass-eject.rules1
-rwxr-xr-xrecipes-ti/beagleboard/gadget-init/g-ether-load.sh46
-rwxr-xr-xrecipes-ti/beagleboard/gadget-init/g-ether-start-service.sh11
-rwxr-xr-xrecipes-ti/beagleboard/gadget-init/g-storage-reinsert.sh4
-rw-r--r--recipes-ti/beagleboard/gadget-init/network-gadget-init.service9
-rw-r--r--recipes-ti/beagleboard/gadget-init/storage-gadget-init.service2
-rw-r--r--recipes-ti/beagleboard/gadget-init/udhcpd.conf5
-rw-r--r--recipes-ti/beagleboard/gadget-init/udhcpd.service11
8 files changed, 89 insertions, 0 deletions
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 00000000..ee6f93e2
--- /dev/null
+++ b/recipes-ti/beagleboard/gadget-init/bone-gmass-eject.rules
@@ -0,0 +1 @@
SUBSYSTEM=="block",ACTION=="change",KERNEL=="mmcblk0p1",RUN+="/usr/bin/g-ether-start-service.sh"
diff --git a/recipes-ti/beagleboard/gadget-init/g-ether-load.sh b/recipes-ti/beagleboard/gadget-init/g-ether-load.sh
new file mode 100755
index 00000000..f9400649
--- /dev/null
+++ b/recipes-ti/beagleboard/gadget-init/g-ether-load.sh
@@ -0,0 +1,46 @@
1#!/bin/sh
2
3function get_devmem()
4{
5 /usr/bin/devmem2 $1 | grep ": " | cut -d ":" -f 2|cut -d "x" -f 2
6}
7
8function hex_to_mac_addr()
9{
10 addr=$1
11 n=0
12 mac_addr=$(echo ${addr} | while read -r -n2 c; do
13 if [ ! -z "$c" ]; then
14 if [ $n -ne 0 ] ; then
15 echo -n ":${c}"
16 else
17 echo -n "${c}"
18 fi
19 fi
20 n=$(($n+1))
21 done)
22 echo ${mac_addr}
23}
24
25function reverse_bytes()
26{
27 addr=$1
28 New_addr=$(echo ${addr} | while read -r -n2 c; do
29 if [ ! -z "$c" ]; then
30 New_addr=${c}${New_addr}
31 else echo
32 echo ${New_addr}
33 fi
34 done)
35 echo ${New_addr}
36}
37
38DEVMEM_ADDR_LO=$(get_devmem 0x44e10638|bc)
39DEVMEM_ADDR_LO=$(reverse_bytes ${DEVMEM_ADDR_LO})
40
41DEVMEM_ADDR_HI=$(get_devmem 0x44e1063C)
42DEVMEM_ADDR_HI=$(reverse_bytes ${DEVMEM_ADDR_HI})
43
44DEV_ADDR=$(hex_to_mac_addr "${DEVMEM_ADDR_HI}${DEVMEM_ADDR_LO}")
45
46modprobe g_ether host_addr=${DEV_ADDR}
diff --git a/recipes-ti/beagleboard/gadget-init/g-ether-start-service.sh b/recipes-ti/beagleboard/gadget-init/g-ether-start-service.sh
new file mode 100755
index 00000000..2db16c26
--- /dev/null
+++ b/recipes-ti/beagleboard/gadget-init/g-ether-start-service.sh
@@ -0,0 +1,11 @@
1#!/bin/sh
2if [ -a /sys/devices/platform/omap/ti81xx-usbss/musb-hdrc.0/gadget/lun0/file ]
3then
4 x=$(cat /sys/devices/platform/omap/ti81xx-usbss/musb-hdrc.0/gadget/lun0/file)
5 if [ -z "$x" ]
6 then
7 /bin/systemctl stop storage-gadget-init.service
8 /bin/systemctl start network-gadget-init.service
9 /bin/systemctl start udhcpd.service
10 fi
11fi
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 00000000..d358640a
--- /dev/null
+++ b/recipes-ti/beagleboard/gadget-init/g-storage-reinsert.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2/bin/systemctl stop storage-gadget-init.service
3/bin/systemctl stop network-gadget-init.service
4/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 00000000..979d8aa4
--- /dev/null
+++ b/recipes-ti/beagleboard/gadget-init/network-gadget-init.service
@@ -0,0 +1,9 @@
1[Unit]
2Description=Start USB Ethernet gadget
3Conflicts=storage-gadget-init.service
4
5[Service]
6RemainAfterExit=yes
7ExecStart=/usr/bin/g-ether-load.sh
8ExecStartPost=/sbin/ifconfig usb0 192.168.7.2 netmask 255.255.255.252
9ExecStop=/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 2fe48e15..9a8513e8 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
3After=dev-mmcblk0p1.device 3After=dev-mmcblk0p1.device
4 4
5[Service] 5[Service]
6RemainAfterExit=yes
6ExecStart=/sbin/modprobe g_mass_storage file=/dev/mmcblk0p1 cdrom=0 stall=0 removable=1 nofua=1 7ExecStart=/sbin/modprobe g_mass_storage file=/dev/mmcblk0p1 cdrom=0 stall=0 removable=1 nofua=1
8ExecStop=/sbin/rmmod g_mass_storage
7 9
8[Install] 10[Install]
9WantedBy=basic.target 11WantedBy=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 00000000..3bcf00f0
--- /dev/null
+++ b/recipes-ti/beagleboard/gadget-init/udhcpd.conf
@@ -0,0 +1,5 @@
1start 192.168.7.1
2end 192.168.7.1
3interface usb0
4max_leases 1
5option 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 00000000..f0766733
--- /dev/null
+++ b/recipes-ti/beagleboard/gadget-init/udhcpd.service
@@ -0,0 +1,11 @@
1[Unit]
2Description=DHCP server for USB0 network gadget
3After=sys-devices-platform-omap-ti81xx\x2dusbss-musb\x2dhdrc.0-gadget-net-usb0.device
4
5[Service]
6ExecStart=/usr/sbin/udhcpd -f -S /etc/udhcpd.conf
7ExecStop=/bin/kill -TERM $MAINPID
8KillSignal=SIGINT
9
10[Install]
11WantedBy=basic.target