From e0ea306a95b6eda06eb40b6b2521565a913a79b7 Mon Sep 17 00:00:00 2001 From: Neucrack Date: Mon, 13 Jan 2025 13:14:06 +0800 Subject: [PATCH] add compatibility with old mac addr config --- .../cvitek/SG200X/overlay/etc/init.d/S02devicekey | 2 ++ .../board/cvitek/SG200X/overlay/etc/init.d/S10uuid | 4 ++-- .../cvitek/SG200X/overlay/etc/init.d/S30gadget_nic | 12 ++++++------ .../board/cvitek/SG200X/overlay/etc/init.d/S30wifi | 4 ++-- .../cvitek/SG200X/overlay/etc/init.d/S99temptest | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S02devicekey b/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S02devicekey index 9012b0ecc..a9ff424cd 100755 --- a/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S02devicekey +++ b/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S02devicekey @@ -7,5 +7,7 @@ then second_uint=$(echo $str_value | cut -d'_' -f2) result="$first_uint$second_uint" echo $result > /device_key + # for compatibility with previous network mac addr + echo /sys/class/cvi-base/base_uid > /device_key_legacy fi diff --git a/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S10uuid b/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S10uuid index 3f5c8f095..53afed049 100755 --- a/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S10uuid +++ b/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S10uuid @@ -19,7 +19,7 @@ then prefix=$(cat /boot/hostname.prefix) fi old_hostname=$(cat /etc/hostname) - new_hostname=${prefix}-$(sha512sum /device_key | head -c 4) + new_hostname=${prefix}-$(sha512sum /device_key_legacy | head -c 4) if [ -e /boot/hostname ] then @@ -38,7 +38,7 @@ then then new_ethmac=$(cat /boot/ethmac) else - new_ethmac=$(hex2mac 48da356f$(sha512sum /device_key | head -c 4)) + new_ethmac=$(hex2mac 48da356f$(sha512sum /device_key_legacy | head -c 4)) fi ifconfig eth0 down diff --git a/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S30gadget_nic b/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S30gadget_nic index 8fa9cc8ce..6ed4bb279 100755 --- a/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S30gadget_nic +++ b/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S30gadget_nic @@ -39,7 +39,7 @@ start() { then new_rndismac=$(cat /boot/usb.rndis.mac) else - new_rndismac=$(hex2mac 48da356f$(sha512sum /device_key | head -c 4)) + new_rndismac=$(hex2mac 48da356f$(sha512sum /device_key_legacy | head -c 4)) fi ip link set $rndis_ifname address ${new_rndismac} ifconfig $rndis_ifname up @@ -52,8 +52,8 @@ start() { then ipv4_prefix=`cat /boot/rndis.ipv4_prefix` else - id2=$(printf "%d" 0x$(sha512sum /device_key | head -c 2)) - id3=$(printf "%d" 0x$(sha512sum /device_key | head -c 4 | tail -c 2)) + id2=$(printf "%d" 0x$(sha512sum /device_key_legacy | head -c 2)) + id3=$(printf "%d" 0x$(sha512sum /device_key_legacy | head -c 4 | tail -c 2)) id3=$((id3 + 1)) if [ "$id2" = "$id3" ] then @@ -85,7 +85,7 @@ start() { then new_mac=$(cat /boot/usb.ncm.mac) else - new_mac=$(hex2mac 48da356e$(sha512sum /device_key | head -c 4)) + new_mac=$(hex2mac 48da356e$(sha512sum /device_key_legacy | head -c 4)) fi ip link set $rndis_ifname address ${new_mac} ifconfig $rndis_ifname up @@ -98,8 +98,8 @@ start() { then ipv4_prefix=`cat /boot/ncm.ipv4_prefix` else - id2=$(printf "%d" 0x$(sha512sum /device_key | head -c 2)) - id3=$(printf "%d" 0x$(sha512sum /device_key | head -c 4 | tail -c 2)) + id2=$(printf "%d" 0x$(sha512sum /device_key_legacy | head -c 2)) + id3=$(printf "%d" 0x$(sha512sum /device_key_legacy | head -c 4 | tail -c 2)) if [ "$id2" = "$id3" ] then id2=$((id2 + 1)) diff --git a/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S30wifi b/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S30wifi index 86a7ca455..9c4df0f22 100755 --- a/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S30wifi +++ b/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S30wifi @@ -76,8 +76,8 @@ start() { then cp /boot/hostapd.conf /etc/hostapd.conf else - id2=$(printf "%d" 0x$(sha512sum /device_key | head -c 2)) - id3=$(printf "%d" 0x$(sha512sum /device_key | head -c 4 | tail -c 2)) + id2=$(printf "%d" 0x$(sha512sum /device_key_legacy | head -c 2)) + id3=$(printf "%d" 0x$(sha512sum /device_key_legacy | head -c 4 | tail -c 2)) if [ "$id2" = "$id3" ] then id2=$((id2 + 1)) diff --git a/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S99temptest b/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S99temptest index e6696982b..882456ab4 100755 --- a/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S99temptest +++ b/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S99temptest @@ -27,7 +27,7 @@ case "$1" in fi echo "soc temp: $soc_temp" | fbbar 32 $colorfg $colorbg colorfg=0xFFFFFFFF - echo "soc id: $(cat /device_key)" | fbbar 48 $colorfg $colorbg + echo "soc id: $(cat /device_key_legacy)" | fbbar 48 $colorfg $colorbg sleep 1 done ) &