meta-quanta: meta-common: Add "mac-address" and "usb-network" services
Add two services into meta-quanta/meta-common:
(1)mac-address
(2)usb-network
These two service is used to set network config when initialize system.
Signed-off-by: Spencer Ku <Spencer.Ku@quantatw.com>
Change-Id: I599009531559613c276bc2e9d20666061ea3b37a
diff --git a/meta-common/network/usb-network/usb-network.service b/meta-common/network/usb-network/usb-network.service
new file mode 100644
index 0000000..917b552
--- /dev/null
+++ b/meta-common/network/usb-network/usb-network.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Enable USB Network
+
+[Service]
+Type=oneshot
+ExecStart=/usr/sbin/usb-network.sh
+EnvironmentFile=/usr/share/usb-network/usb-network.conf
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-common/network/usb-network/usb-network.sh b/meta-common/network/usb-network/usb-network.sh
new file mode 100644
index 0000000..444d4ae
--- /dev/null
+++ b/meta-common/network/usb-network/usb-network.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+cd /sys/kernel/config/usb_gadget
+
+if [ ! -f "g1" ]; then
+ mkdir g1
+ cd g1
+
+ echo 0x1d6b > idVendor # Linux foundation
+ echo 0x0104 > idProduct # Multifunction composite gadget
+ mkdir -p strings/0x409
+ echo "Linux" > strings/0x409/manufacturer
+ echo "Etherned/ECM gadget" > strings/0x409/product
+
+ mkdir -p configs/c.1
+ echo 100 > configs/c.1/MaxPower
+ mkdir -p configs/c.1/strings/0x409
+ echo "ECM" > configs/c.1/strings/0x409/configuration
+
+ mkdir -p functions/ecm.usb0
+ cat /tmp/usb0_dev > functions/ecm.usb0/dev_addr # write device mac address
+ cat /tmp/usb0_host > functions/ecm.usb0/host_addr # write usb mac address
+
+ ln -s functions/ecm.usb0 configs/c.1
+
+ echo "$UDC" > UDC
+
+ rm /tmp/usb0_dev
+ rm /tmp/usb0_host
+
+fi
+
+exit 0