forked from raspberrypi/rpi-eeprom
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpicore-rpi-eeprom-update
More file actions
executable file
·123 lines (101 loc) · 3.23 KB
/
picore-rpi-eeprom-update
File metadata and controls
executable file
·123 lines (101 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/sh
# pCP script to update Raspberry Pi4/5 boot EEPROM.
VERSION="v27.9-1-piCore"
. /etc/init.d/tc-functions
PACKAGEDIR=/etc/sysconfig/tcedir/optional
checknotroot
function update_ext() {
WGET="busybox wget"
DIFF="busybox diff"
MD5="busybox md5sum"
UPGRADE_DIR=${PACKAGEDIR}/upgrade
rm -f /tmp/rpi-eeprom.tcz*
echo "[ INFO ] Checking for package update: rpi-eeprom.tcz"
echo "[ INFO ] You are running release $VERSION"
LATEST=$($WGET -q https://api.github.com/repos/tinycorelinux/rpi-eeprom/releases/latest -O - | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
echo "[ INFO ] The latest release is $LATEST"
$WGET -q https://github.com/tinycorelinux/rpi-eeprom/releases/latest/download/rpi-eeprom.tcz.md5.txt -P /tmp
$DIFF -q /tmp/rpi-eeprom.tcz.md5.txt /etc/sysconfig/tcedir/optional/rpi-eeprom.tcz.md5.txt >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "[ INFO ] Extension version Matches"
exit 2
else
echo "[ INFO ] Update Required."
$WGET -q https://github.com/tinycorelinux/rpi-eeprom/releases/latest/download/rpi-eeprom.tcz -P /tmp
fi
cd /tmp
echo "[ INFO ] Validating MD5's of new extensions"
$MD5 -cs rpi-eeprom.tcz.md5.txt
[ -d $UPGRADE_DIR ] || mkdir -p $UPGRADE_DIR
if [ $? -eq 0 ]; then
mv -f /tmp/rpi-eeprom.tcz* ${UPGRADE_DIR}
else
echo "[ERROR] rpi-eeprom.tcz failed md5 check."
exit 1
fi
echo "[ INFO ] A reboot is needed to load new rpi-eeprom extension."
exit
}
function usage() {
echo "Usage:"
echo "$0 --update: Update rpi-eeprom.tcz extension"
echo ""
echo "The default firmware upgrade is from the critical firmware branch"
echo " to override, set the FIRMWARE_RELEASE_STATUS environmen variable"
echo " export FIRMWARE_RELEASE_STATUS=<default|latest>"
echo ""
echo "----------------------------------------------"
echo ""
echo "rpi-eeprom-update options"
rpi-eeprom-update -h
exit
}
function mount_boot_partition() {
BOOTPART="$(tc_autoscan 'bootcode.bin' 'f')"
BOOTDEV=${BOOTPART%%/*}
find_mountpoint "$BOOTDEV"
if [ -n "$MOUNTPOINT" ]; then
mount $MOUNTPOINT
fi
}
function load_deps() {
if [ ! -f ${PACKAGEDIR}/raspi-utils.tcz ]; then
echo "raspi-utils extension is required for this tool"
exit 1
elif [ ! -f /usr/local/bin/vcgencmd ]; then
tce-load -i raspi-utils.tcz
fi
if [ ! -f ${PACKAGEDIR}/pciutils.tcz ]; then
echo "pciutils extension is required for this tool"
exit 1
elif [ ! -f /usr/local/bin/lspci ]; then
tce-load -i pciutils.tcz
fi
[ -f ${PACKAGEDIR}/python3.11.tcz ] && PYTHON3PKG=python3.11.tcz
[ -f ${PACKAGEDIR}/python3.12.tcz ] && PYTHON3PKG=python3.12.tcz
if [ ! -f ${PACKAGEDIR}/$PYTHON3PKG ]; then
echo "python 3 extension is required for this tool"
exit 1
elif [ ! -f /usr/local/bin/python3 ]; then
tce-load -i $PYTHON3PKG
fi
[ ! -x /usr/local/bin/python ] && sudo ln -s /usr/local/bin/python3 /usr/local/bin/python
if [ ! -f ${PACKAGEDIR}/coreutils.tcz ]; then
echo "coreutils extension is required for this tool"
exit 1
elif [ ! -f /usr/local/bin/sha256sum ]; then
tce-load -i coreutils.tcz
fi
}
OPTS=""
for A in $@; do
case $A in
--update) update_ext;;
--help) usage;;
*)OPTS="$OPTS $A";;
esac
done
load_deps
mount_boot_partition >/dev/null 2>&1
echo "piCore rpi-eeprom package version: $VERSION"
sudo -E rpi-eeprom-update $OPTS