mirror of
https://github.com/sipeed/LicheeRV-Nano-Build.git
synced 2026-09-10 20:59:59 -05:00
optimize uuid usage in init script
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@
|
|||||||
*.ko
|
*.ko
|
||||||
*.d
|
*.d
|
||||||
host-tools/
|
host-tools/
|
||||||
|
host-tools
|
||||||
*.sqfs
|
*.sqfs
|
||||||
build/tools/common/sd_tools/genimage.cfg.tmp
|
build/tools/common/sd_tools/genimage.cfg.tmp
|
||||||
fsbl/build/*
|
fsbl/build/*
|
||||||
|
|||||||
@@ -2,11 +2,6 @@
|
|||||||
|
|
||||||
if [ "$1" = "start" ]
|
if [ "$1" = "start" ]
|
||||||
then
|
then
|
||||||
# Cache uid to prevent deadlock during cvi_base operation
|
|
||||||
if [ ! -e /boot/cvi_base_uid ]; then
|
|
||||||
$(cat /sys/class/cvi-base/base_uid > /boot/cvi_base_uid)
|
|
||||||
fi
|
|
||||||
|
|
||||||
str_value=$(cat /sys/class/cvi-base/base_uid | awk '{print $2}')
|
str_value=$(cat /sys/class/cvi-base/base_uid | awk '{print $2}')
|
||||||
first_uint=$(echo $str_value | cut -d'_' -f1)
|
first_uint=$(echo $str_value | cut -d'_' -f1)
|
||||||
second_uint=$(echo $str_value | cut -d'_' -f2)
|
second_uint=$(echo $str_value | cut -d'_' -f2)
|
||||||
|
|||||||
@@ -19,11 +19,7 @@ then
|
|||||||
prefix=$(cat /boot/hostname.prefix)
|
prefix=$(cat /boot/hostname.prefix)
|
||||||
fi
|
fi
|
||||||
old_hostname=$(cat /etc/hostname)
|
old_hostname=$(cat /etc/hostname)
|
||||||
if [ -e /boot/cvi_base_uid ]; then
|
new_hostname=${prefix}-$(sha512sum /device_key | head -c 4)
|
||||||
new_hostname=${prefix}-$(sha512sum /boot/cvi_base_uid | head -c 4)
|
|
||||||
else
|
|
||||||
new_hostname=${prefix}-$(sha512sum /sys/class/cvi-base/base_uid | head -c 4)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -e /boot/hostname ]
|
if [ -e /boot/hostname ]
|
||||||
then
|
then
|
||||||
@@ -42,11 +38,7 @@ then
|
|||||||
then
|
then
|
||||||
new_ethmac=$(cat /boot/ethmac)
|
new_ethmac=$(cat /boot/ethmac)
|
||||||
else
|
else
|
||||||
if [ -e /boot/cvi_base_uid ]; then
|
new_ethmac=$(hex2mac 48da356f$(sha512sum /device_key | head -c 4))
|
||||||
new_ethmac=$(hex2mac 48da356f$(sha512sum /boot/cvi_base_uid | head -c 4))
|
|
||||||
else
|
|
||||||
new_ethmac=$(hex2mac 48da356f$(sha512sum /sys/class/cvi-base/base_uid | head -c 4))
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ifconfig eth0 down
|
ifconfig eth0 down
|
||||||
|
|||||||
@@ -39,11 +39,7 @@ start() {
|
|||||||
then
|
then
|
||||||
new_rndismac=$(cat /boot/usb.rndis.mac)
|
new_rndismac=$(cat /boot/usb.rndis.mac)
|
||||||
else
|
else
|
||||||
if [ -e /boot/cvi_base_uid ]; then
|
new_rndismac=$(hex2mac 48da356f$(sha512sum /device_key | head -c 4))
|
||||||
new_rndismac=$(hex2mac 48da356f$(sha512sum /boot/cvi_base_uid | head -c 4))
|
|
||||||
else
|
|
||||||
new_rndismac=$(hex2mac 48da356f$(sha512sum /sys/class/cvi-base/base_uid | head -c 4))
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
ip link set $rndis_ifname address ${new_rndismac}
|
ip link set $rndis_ifname address ${new_rndismac}
|
||||||
ifconfig $rndis_ifname up
|
ifconfig $rndis_ifname up
|
||||||
@@ -56,13 +52,8 @@ start() {
|
|||||||
then
|
then
|
||||||
ipv4_prefix=`cat /boot/rndis.ipv4_prefix`
|
ipv4_prefix=`cat /boot/rndis.ipv4_prefix`
|
||||||
else
|
else
|
||||||
if [ -e /boot/cvi_base_uid ]; then
|
id2=$(printf "%d" 0x$(sha512sum /device_key | head -c 2))
|
||||||
id2=$(printf "%d" 0x$(sha512sum /boot/cvi_base_uid | head -c 2))
|
id3=$(printf "%d" 0x$(sha512sum /device_key | head -c 4 | tail -c 2))
|
||||||
id3=$(printf "%d" 0x$(sha512sum /boot/cvi_base_uid | head -c 4 | tail -c 2))
|
|
||||||
else
|
|
||||||
id2=$(printf "%d" 0x$(sha512sum /sys/class/cvi-base/base_uid | head -c 2))
|
|
||||||
id3=$(printf "%d" 0x$(sha512sum /sys/class/cvi-base/base_uid | head -c 4 | tail -c 2))
|
|
||||||
fi
|
|
||||||
id3=$((id3 + 1))
|
id3=$((id3 + 1))
|
||||||
if [ "$id2" = "$id3" ]
|
if [ "$id2" = "$id3" ]
|
||||||
then
|
then
|
||||||
@@ -94,11 +85,7 @@ start() {
|
|||||||
then
|
then
|
||||||
new_mac=$(cat /boot/usb.ncm.mac)
|
new_mac=$(cat /boot/usb.ncm.mac)
|
||||||
else
|
else
|
||||||
if [ -e /boot/cvi_base_uid ]; then
|
new_mac=$(hex2mac 48da356e$(sha512sum /device_key | head -c 4))
|
||||||
new_mac=$(hex2mac 48da356e$(sha512sum /boot/cvi_base_uid | head -c 4))
|
|
||||||
else
|
|
||||||
new_mac=$(hex2mac 48da356e$(sha512sum /sys/class/cvi-base/base_uid | head -c 4))
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
ip link set $rndis_ifname address ${new_mac}
|
ip link set $rndis_ifname address ${new_mac}
|
||||||
ifconfig $rndis_ifname up
|
ifconfig $rndis_ifname up
|
||||||
@@ -111,13 +98,8 @@ start() {
|
|||||||
then
|
then
|
||||||
ipv4_prefix=`cat /boot/ncm.ipv4_prefix`
|
ipv4_prefix=`cat /boot/ncm.ipv4_prefix`
|
||||||
else
|
else
|
||||||
if [ -e /boot/cvi_base_uid ]; then
|
id2=$(printf "%d" 0x$(sha512sum /device_key | head -c 2))
|
||||||
id2=$(printf "%d" 0x$(sha512sum /boot/cvi_base_uid | head -c 2))
|
id3=$(printf "%d" 0x$(sha512sum /device_key | head -c 4 | tail -c 2))
|
||||||
id3=$(printf "%d" 0x$(sha512sum /boot/cvi_base_uid | head -c 4 | tail -c 2))
|
|
||||||
else
|
|
||||||
id2=$(printf "%d" 0x$(sha512sum /sys/class/cvi-base/base_uid | head -c 2))
|
|
||||||
id3=$(printf "%d" 0x$(sha512sum /sys/class/cvi-base/base_uid | head -c 4 | tail -c 2))
|
|
||||||
fi
|
|
||||||
if [ "$id2" = "$id3" ]
|
if [ "$id2" = "$id3" ]
|
||||||
then
|
then
|
||||||
id2=$((id2 + 1))
|
id2=$((id2 + 1))
|
||||||
|
|||||||
@@ -76,13 +76,8 @@ start() {
|
|||||||
then
|
then
|
||||||
cp /boot/hostapd.conf /etc/hostapd.conf
|
cp /boot/hostapd.conf /etc/hostapd.conf
|
||||||
else
|
else
|
||||||
if [ -e /boot/cvi_base_uid ]; then
|
id2=$(printf "%d" 0x$(sha512sum /device_key | head -c 2))
|
||||||
id2=$(printf "%d" 0x$(sha512sum /boot/cvi_base_uid | head -c 2))
|
id3=$(printf "%d" 0x$(sha512sum /device_key | head -c 4 | tail -c 2))
|
||||||
id3=$(printf "%d" 0x$(sha512sum /boot/cvi_base_uid | head -c 4 | tail -c 2))
|
|
||||||
else
|
|
||||||
id2=$(printf "%d" 0x$(sha512sum /sys/class/cvi-base/base_uid | head -c 2))
|
|
||||||
id3=$(printf "%d" 0x$(sha512sum /sys/class/cvi-base/base_uid | head -c 4 | tail -c 2))
|
|
||||||
fi
|
|
||||||
if [ "$id2" = "$id3" ]
|
if [ "$id2" = "$id3" ]
|
||||||
then
|
then
|
||||||
id2=$((id2 + 1))
|
id2=$((id2 + 1))
|
||||||
|
|||||||
@@ -27,11 +27,7 @@ case "$1" in
|
|||||||
fi
|
fi
|
||||||
echo "soc temp: $soc_temp" | fbbar 32 $colorfg $colorbg
|
echo "soc temp: $soc_temp" | fbbar 32 $colorfg $colorbg
|
||||||
colorfg=0xFFFFFFFF
|
colorfg=0xFFFFFFFF
|
||||||
if [ -e /boot/cvi_base_uid ]; then
|
echo "soc id: $(cat /device_key)" | fbbar 48 $colorfg $colorbg
|
||||||
echo "soc id: $(cat /boot/cvi_base_uid)" | fbbar 48 $colorfg $colorbg
|
|
||||||
else
|
|
||||||
echo "soc id: $(cat /sys/class/cvi-base/base_uid)" | fbbar 48 $colorfg $colorbg
|
|
||||||
fi
|
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
) &
|
) &
|
||||||
|
|||||||
Reference in New Issue
Block a user