summaryrefslogtreecommitdiff
path: root/meta-quanta/meta-common
diff options
context:
space:
mode:
authorGeorge Hung <george.hung@quantatw.com>2020-07-13 09:12:03 +0300
committerAndrew Geissler <geissonator@yahoo.com>2020-07-22 05:06:59 +0300
commit1a9ed116c84118c2d705838795cc410340e8ef11 (patch)
tree975dd70d2023ede61d9ec40beb03851f99ac2f04 /meta-quanta/meta-common
parent64f33f77259c9a0a5aef065e752540c3d0bd2ad1 (diff)
downloadopenbmc-1a9ed116c84118c2d705838795cc410340e8ef11.tar.xz
meta-quanta: common: set locally administered bit to usb-network
We hope the MAC address of the usb-network is locally administered address, so it needs to set locally administered bit (0x02) to the first octet of the MAC address. (From meta-quanta rev: ebe01d25bbb5b139feb7c9b089f322e45a28a68e) Signed-off-by: George Hung <george.hung@quantatw.com> Change-Id: I9bd0702359479514b385daf447a9747fd270e351 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Diffstat (limited to 'meta-quanta/meta-common')
-rw-r--r--meta-quanta/meta-common/recipes-quanta/network/usb-network/usb-network.sh36
1 files changed, 32 insertions, 4 deletions
diff --git a/meta-quanta/meta-common/recipes-quanta/network/usb-network/usb-network.sh b/meta-quanta/meta-common/recipes-quanta/network/usb-network/usb-network.sh
index 444d4aee7..6840f9ffc 100644
--- a/meta-quanta/meta-common/recipes-quanta/network/usb-network/usb-network.sh
+++ b/meta-quanta/meta-common/recipes-quanta/network/usb-network/usb-network.sh
@@ -1,5 +1,25 @@
#!/bin/bash
+mac_config="/usr/share/mac-address/config.txt"
+dev_mac_path="/tmp/usb0_dev"
+host_mac_path="/tmp/usb0_host"
+
+check_usb_local_administered() {
+ is_enable="$(cat ${mac_config} | grep 'USBLAA')"
+ echo ${is_enable}
+}
+
+# Set the locally administered bit (the second least-significant
+# bit of the first octet) of the MAC address
+set_local_administered_bit() {
+ mac="$(cat $1)"
+ first_byte="${mac:0:2}"
+ first_byte="$((0x$first_byte|2))"
+ first_byte="$(printf "%02x\n" "$first_byte")"
+ mac="${first_byte}${mac:2}"
+ echo $mac
+}
+
cd /sys/kernel/config/usb_gadget
if [ ! -f "g1" ]; then
@@ -17,16 +37,24 @@ if [ ! -f "g1" ]; then
mkdir -p configs/c.1/strings/0x409
echo "ECM" > configs/c.1/strings/0x409/configuration
+
+ if [[ $(check_usb_local_administered) == "USBLAA=true" ]]; then
+ dev_mac="$(set_local_administered_bit $dev_mac_path)"
+ host_mac="$(set_local_administered_bit $host_mac_path)"
+ echo $dev_mac > $dev_mac_path
+ echo $host_mac > $host_mac_path
+ fi
+
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
+ cat $dev_mac_path > functions/ecm.usb0/dev_addr # write device mac address
+ cat $host_mac_path > 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
+ rm $dev_mac_path
+ rm $host_mac_path
fi