aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files
diff options
context:
space:
mode:
authorJan-Niklas Burfeind <git@aiyionpri.me>2022-12-23 22:03:14 +0100
committerDavid Bauer <mail@david-bauer.net>2022-12-25 02:27:55 +0100
commitc7d3bbb909bdcccd4f26f18b18cc1cb00500a874 (patch)
treeaf9de04cf6c5b065d15ce34f0983b8f4666b7a7b /package/base-files
parent59254010077c9086afee8a8b4c490943d6749065 (diff)
downloadupstream-c7d3bbb909bdcccd4f26f18b18cc1cb00500a874.tar.gz
upstream-c7d3bbb909bdcccd4f26f18b18cc1cb00500a874.tar.bz2
upstream-c7d3bbb909bdcccd4f26f18b18cc1cb00500a874.zip
sunxi: ensure NanoPi R1 has unique MAC address
Ensure the MAC address for all NanoPi R1 boards is assigned uniquely for each board. The vendor ships the device in two variants; one with and one without eMMC; but both without static mac-addresses. In order to assign both board types unique MAC addresses, fall back on the same method used for the NanoPi R2S and R4S in case the EEPROM chip is not present by generating the board MAC from the SD card CID. [0] https://wiki.friendlyelec.com/wiki/index.php/NanoPi_R1#Hardware_Spec Similar too and based on: commit b5675f500daf ("rockchip: ensure NanoPi R4S has unique MAC address") Co-authored-by: David Bauer <mail@david-bauer.net> Signed-off-by: Jan-Niklas Burfeind <git@aiyionpri.me>
Diffstat (limited to 'package/base-files')
-rw-r--r--package/base-files/files/lib/functions/system.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh
index 29de2e5dd6..176c10d065 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -204,6 +204,14 @@ macaddr_add() {
echo $oui:$nic
}
+macaddr_generate_from_mmc_cid() {
+ local mmc_dev=$1
+
+ local sd_hash=$(sha256sum /sys/class/block/$mmc_dev/device/cid)
+ local mac_base=$(macaddr_canonicalize "$(echo "${sd_hash}" | dd bs=1 count=12 2>/dev/null)")
+ echo "$(macaddr_unsetbit_mc "$(macaddr_setbit_la "${mac_base}")")"
+}
+
macaddr_geteui() {
local mac=$1
local sep=$2