diff options
author | Jason M. Bills <jason.m.bills@linux.intel.com> | 2020-12-08 00:38:17 +0300 |
---|---|---|
committer | Jason M. Bills <jason.m.bills@linux.intel.com> | 2020-12-08 00:38:17 +0300 |
commit | 8d6ae7f2a817751fad151168fa10ce28ee0869d8 (patch) | |
tree | 281032f7ec07c41589aa094bd165cc2a98f2d3a7 /meta-quanta/meta-common/recipes-quanta/network/usb-network/usb-network.sh | |
parent | c16fb8893b19075db4bcf3b5bf33c1db8c3ca2bd (diff) | |
parent | 5da3c2284560a7e08ffafd03c5b5ba44a3242228 (diff) | |
download | openbmc-8d6ae7f2a817751fad151168fa10ce28ee0869d8.tar.xz |
Merge tag '0.26' of ssh://git-amr-1.devtools.intel.com:29418/openbmc-openbmc into update
Diffstat (limited to 'meta-quanta/meta-common/recipes-quanta/network/usb-network/usb-network.sh')
-rw-r--r-- | meta-quanta/meta-common/recipes-quanta/network/usb-network/usb-network.sh | 36 |
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 |