diff options
author | Amit Pundir <amit.pundir@linaro.org> | 2020-04-25 15:32:30 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-04-25 15:32:30 +0000 |
commit | 0bf1dfe14e58e4d72b792af39981b49466bed497 (patch) | |
tree | 1f8c2e44bd6732ab275c050cf1f73caa5d3782f3 /db845c | |
parent | 6a1138807e00e8b33ff1c1c95b65057444824f16 (diff) | |
parent | 7cc6a2d9d7041917780d2311e66747e8ec789b60 (diff) |
db845c: Set Ethernet MAC address on boot am: 7cc6a2d9d7
Change-Id: I7a4bcc9f89a1bb1c4d8045dfd0f4d213e75fb510
Diffstat (limited to 'db845c')
-rw-r--r-- | db845c/device.mk | 5 | ||||
-rw-r--r-- | db845c/eth_mac_addr.rc | 9 | ||||
-rw-r--r-- | db845c/eth_mac_addr.sh | 15 |
3 files changed, 29 insertions, 0 deletions
diff --git a/db845c/device.mk b/db845c/device.mk index cc5b973..b37e06f 100644 --- a/db845c/device.mk +++ b/db845c/device.mk @@ -43,5 +43,10 @@ PRODUCT_PACKAGES += \ PRODUCT_COPY_FILES += \ device/linaro/dragonboard/qcom/init.qcom.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.qcom.rc +# Install scripts to set Ethernet MAC address +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/eth_mac_addr.rc:/system/etc/init/eth_mac_addr.rc \ + $(LOCAL_PATH)/eth_mac_addr.sh:/system/bin/eth_mac_addr.sh + # Copy firmware files $(call inherit-product-if-exists, $(LOCAL_PATH)/firmware/device.mk) diff --git a/db845c/eth_mac_addr.rc b/db845c/eth_mac_addr.rc new file mode 100644 index 0000000..e710c19 --- /dev/null +++ b/db845c/eth_mac_addr.rc @@ -0,0 +1,9 @@ +service eth_mac_addr /system/bin/eth_mac_addr.sh + class core + user root + group system + disabled + oneshot + +on post-fs-data + start eth_mac_addr diff --git a/db845c/eth_mac_addr.sh b/db845c/eth_mac_addr.sh new file mode 100644 index 0000000..bdc1ba7 --- /dev/null +++ b/db845c/eth_mac_addr.sh @@ -0,0 +1,15 @@ +#! /system/bin/sh +# Set eth0 mac address. +# +# Get the unique board serial number from /proc/cmdline, +# prepend '0's to the serial number to fill 5 LSBs of the +# MAC address and prepend "02" as MSB to prepare a 6 byte +# locally administered unicast MAC address. +# Format the output in xx:xx:xx:xx:xx:xx format for the +# "ip" set address command to work. + +SERIALNO=`cat /proc/cmdline | grep -o serialno.* | cut -f2 -d'=' | awk '{printf("02%010s\n", $1)}' | sed 's/\(..\)/\1:/g' | sed '$s/:$//'` + +/system/bin/ip link set dev eth0 down +/system/bin/ip link set dev eth0 address "${SERIALNO}" +/system/bin/ip link set dev eth0 up |