Skip to content

Commit 7c33a66

Browse files
committed
Detect package, not the board. Warn if using on wrong board.
Change-Id: I4b3f7dd2d5c5d04f4345086205fc54fc9e8c5e87
1 parent 6800469 commit 7c33a66

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

dev-ayufan/root/usr/local/sbin/rock64_upgrade_bootloader.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ if [[ "$(id -u)" -ne "0" ]]; then
77
exit 1
88
fi
99

10-
BOARD=
11-
if grep -qi rockpro64 /proc/device-tree/compatible || grep -qi rockpro64 /etc/flash-kernel/machine; then
10+
if dpkg -s "u-boot-rockchip-rockpro64" &>/dev/null; then
1211
BOARD=rockpro64
1312
LOADER_NAME=rksd_loader
14-
elif grep -qi rock64 /proc/device-tree/compatible || grep -qi rock64 /etc/flash-kernel/machine; then
13+
elif dpkg -s "u-boot-rockchip-rock64" &>/dev/null; then
1514
BOARD=rock64
1615
LOADER_NAME=rksd_loader
1716
else
18-
exit "Unknown board."
17+
exit "Unknown package installed."
1918
exit 1
2019
fi
2120

@@ -30,6 +29,13 @@ echo "If this happens you will have to manually fix that outside of your Rock64.
3029
echo "If you are booting from SPI. You have to use 'rock64_write_spi_flash.sh'."
3130
echo ""
3231

32+
if ! ( grep -qi "$BOARD" /proc/device-tree/compatible || grep -qi "$BOARD" /etc/flash-kernel/machine ); then
33+
echo "You are currently running on different board ($(cat /proc/device-tree/model))."
34+
echo "It may brick your device or the system unless"
35+
echo "you know what are you doing."
36+
echo ""
37+
fi
38+
3339
while true; do
3440
echo "Type YES to continue or Ctrl-C to abort."
3541
read CONFIRM

dev-ayufan/root/usr/local/sbin/rock64_write_spi_flash.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ if ! which nandwrite &>/dev/null; then
1212
exit 1
1313
fi
1414

15-
BOARD=
16-
if grep -qi rockpro64 /proc/device-tree/compatible || grep -qi rockpro64 /etc/flash-kernel/machine; then
15+
if dpkg -s "u-boot-rockchip-rockpro64" &>/dev/null; then
1716
BOARD=rockpro64
1817
LOADER_NAME=rkspi_loader
19-
elif grep -qi rock64 /proc/device-tree/compatible || grep -qi rock64 /etc/flash-kernel/machine; then
18+
elif dpkg -s "u-boot-rockchip-rock64" &>/dev/null; then
2019
BOARD=rock64
2120
LOADER_NAME=rksd_loader
2221
else
23-
exit "Unknown board."
22+
exit "Unknown package installed."
2423
exit 1
2524
fi
2625

@@ -35,6 +34,13 @@ echo " and it will require that you use eMMC or SD"
3534
echo " as your boot device."
3635
echo ""
3736

37+
if ! ( grep -qi "$BOARD" /proc/device-tree/compatible || grep -qi "$BOARD" /etc/flash-kernel/machine ); then
38+
echo "You are currently running on different board ($(cat /proc/device-tree/model))."
39+
echo "It may brick your device or the system unless"
40+
echo "you know what are you doing."
41+
echo ""
42+
fi
43+
3844
while true; do
3945
echo "Type YES to continue or Ctrl-C to abort."
4046
read CONFIRM

0 commit comments

Comments
 (0)