add upgrade-fw script

This commit is contained in:
Jaroslav Kysela 2015-05-24 10:55:58 +02:00
parent 4edffe2695
commit f5a1be8e8f
4 changed files with 98 additions and 14 deletions

View File

@ -1,4 +1,4 @@
BUILD=8
BUILD=9
VERSION=$(shell date +%Y%m%d%H%M)-$(BUILD)
CPUS=4
CURDIR=$(shell pwd)
@ -103,11 +103,12 @@ CPIO_SRCS += oscam
CPIO_SRCS += tools/axehelper
CPIO_SRCS += nfsutils
CPIO_SRCS += nano
CPIO_SRCS += mtd-utils
fs.cpio: $(CPIO_SRCS)
fakeroot tools/do_min_fs.py \
-r "$(VERSION)" \
-b "bash strace" \
-b "bash strace openssl" \
$(foreach m,$(EXTRA_AXE_MODULES), -e "$(EXTRA_AXE_MODULES_DIR)/$(m):lib/modules/axe/$(m)") \
$(foreach m,$(ORIG_FILES), -e "$(EXTRA_AXE_MODULES_DIR)/../$(m):lib/modules/axe/$(m)") \
-e "tools/i2c_mangle.ko:lib/modules/axe/i2c_mangle.ko" \
@ -125,6 +126,7 @@ fs.cpio: $(CPIO_SRCS)
-e "apps/minisatip/icons/sm.jpg:usr/share/minisatip/icons/sm.jpg" \
-e "apps/minisatip/icons/sm.png:usr/share/minisatip/icons/sm.png" \
-e "apps/$(NANO)/src/nano:usr/bin/nano" \
-e "apps/mtd-utils/nandwrite:usr/sbin/nandwrite2" \
-e "apps/oscam-svn/Distribution/oscam-1.20-unstable_svn$(OSCAM_REV)-sh4-linux:sbin/oscamd"
.PHONY: fs-list

8
dist/README vendored
View File

@ -138,6 +138,14 @@ Bugs:
History:
- added http://boxip:8080/axe-status.txt status page (shell parseable)
- fixed ntpd start
- added crond start / configuration
- added customd start (custom daemon/service/setup - script) from sysinit
- added nano text editor
- updated oscam to 10663
- added update-fw script for the internal flash upgrade without an USB stick
satip-axe-201504211434-8 - Tue Apr 21 2015
- faster boot (approx. 25 seconds from flash)
- tuners - configurable gain (0-16dB) - STV6210_BAMP in config

View File

@ -1,27 +1,99 @@
#!/bin/sh
FILE="$1"
MTDDEV="/dev/mtd3"
SAFEFILE="/root/new.fw"
CHECKSTR="Linux-2.6.32.42_stm24_0208-idl4k"
GITHUB1="https://github.com/perexg/satip-axe/tree/master/dist"
GITHUB2="https://github.com/perexg/satip-axe/blob/master/dist/$FILE?raw=true"
if test -z "$FILE"; then
if test "$FILE" = "-h" -o "$FILE" = "--help"; then
echo "Usage: $0 FIRMWARE"
exit 1
fi
if test -z "$FILE"; then
echo "Trying to fetch the list of available firmware files:"
if ! wget -q -O /root/list.txt "$GITHUB1"; then
echo "FAILED"
exit 1
fi
grep -o -E ">satip-axe-.*.fw<" /root/list.txt | grep -o -E "satip-axe.*.fw"
rm /root/list.txt
exit 0
fi
if ! test -r "$FILE"; then
echo "Downloading $FILE:"
if ! wget -O "$SAFEFILE" "$GITHUB2/$FILE"; then
echo "Unable to fetch firmware file $GITHUB2"
exit 1
fi
FILE="$SAFEFILE"
fi
if ! grep "$CHECKSTR" "$FILE" > /dev/null; then
echo "$FILE does not appear to be the satip-axe firmware!"
exit 1
fi
if ! cp "$FILE" /root/new.fw; then
echo "Copy error..."
exit 1
if test "$FILE" != "$SAFEFILE"; then
if ! cp "$FILE" "$SAFEFILE"; then
echo "Copy error..."
exit 1
fi
fi
if nandwrite -p /dev/mtd3 /root/new.fw; then
echo "Success, type 'reboot' to reboot"
else
echo "FAIL (try again)"
fi
echo "Preparing to flash - killing minisatip, unmounting USB sticks"
umount /media/*
touch /tmp/nosatip
killall -9 minisatip
sync ; sync
rm -f /root/new.fw
sleep 3
first=true
second=true
while test 1 -eq 1; do
FILESIZE=$(stat -c "%s" "$SAFEFILE")
if test -z "$FILESIZE" -o $FILESIZE -le 0; then
echo "Unable to determine file size for $SAFEFILE"
exit 1
fi
echo "Verifying... Dumping current flash contents."
nanddump -f "$SAFEFILE.old" -l "$FILESIZE" "$MTDDEV"
FILESIZE2=$(stat -c "%s" "$SAFEFILE.old")
if test "$FILESIZE" -gt "$FILESIZE2"; then
echo "Unable to verify (file sizes does not match - $FILESIZE > $FILESIZE2"
exit 1
fi
if ! dd if=/dev/null seek="$FILESIZE" bs=1 of="$SAFEFILE.old" 2> /dev/null; then
echo "DD truncate failed"
exit 1
fi
FILESIZE2=$(stat -c "%s" "$SAFEFILE.old")
if test "$FILESIZE" != "$FILESIZE2"; then
echo "Unable to verify (file sizes does not match - $FILESIZE != $FILESIZE2"
exit 1
fi
result=$(diff "$SAFEFILE.old" "$SAFEFILE")
if test -z "$result"; then
echo "Verify OK. Flash write successful."
echo "Type 'reboot' now..."
rm -f "$SAFEFILE" "$SAFEFILE.old"
exit 0
fi
rm -f "$FILESIZE.old"
if test "$first" != "true"; then
echo "** Flash contents do not match. **"
if test "$second" != "true"; then
echo "** Flashing failed. Consider to use an USB stick to recover. **"
fi
echo -n "Repeat the flash write? Use 'Ctrl-C' to abort or Enter to repeat: "
read i
second=
fi
echo "Flashing..."
nandwrite2 -p "$MTDDEV" "$SAFEFILE"
first=
done

View File

@ -311,6 +311,8 @@ def gen_fs(lib_list, init_type):
run_cmd('cp -d ' + target_prefix + '/lib/libnsl*' + ' fs/usr/lib/')
run_cmd('cp -d ' + target_prefix + '/lib/libncurses.so*' + ' fs/lib/')
run_cmd('cp -d ' + target_prefix + '/usr/lib/libmagic.so*' + ' fs/usr/lib/')
run_cmd('cp -d ' + target_prefix + '/usr/lib/libssl.so*' + ' fs/usr/lib/')
run_cmd('cp -d ' + target_prefix + '/usr/lib/libcrypto.so*' + ' fs/usr/lib/')
if init_type == 'busybox':
setup_busybox()
@ -582,9 +584,9 @@ f.close()
files = run_cmd('find fs -name "*~"')
for f in files:
run_cmd('rm ' + f.strip())
for r in ['usr/bin/bashbug']:
for r in ['usr/bin/bashbug', 'usr/lib/pkgconfig']:
if os.path.exists('fs/' + r):
run_cmd('rm fs/' + r)
run_cmd('rm -rf fs/' + r)
for e in extra_list:
src, dst = e.split(':')
dir = os.path.dirname(dst)