Skip to content

Commit

Permalink
add compatibility with old mac addr config
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed Jan 14, 2025
1 parent 48724b1 commit 7416974
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions buildroot/board/cvitek/SG200X/overlay/etc/init.d/S02devicekey
Original file line number Diff line number Diff line change
Expand Up @@ -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
cat /sys/class/cvi-base/base_uid > /device_key_legacy
fi

4 changes: 2 additions & 2 deletions buildroot/board/cvitek/SG200X/overlay/etc/init.d/S10uuid
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions buildroot/board/cvitek/SG200X/overlay/etc/init.d/S30gadget_nic
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions buildroot/board/cvitek/SG200X/overlay/etc/init.d/S30wifi
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) &
Expand Down

0 comments on commit 7416974

Please sign in to comment.