3
# Copyright (C) 2006 Martin Michlmayr <tbm@cyrius.com>
5
# This code is covered by the GNU General Public License.
7
# See installer/doc/devel/hardware/arm/thecus/firmware for an explanation
8
# of the upgrade process on Thecus machines.
12
echo "$@" > /tmp/upgrade/message
16
echo "$@" > /tmp/upgrade/debug
19
# Note: the firmware upgrade script looks for the string "fail" in the
20
# error message, so make sure this passed to the error function.
24
rm -f /var/lock/upgrade.lock
29
grep "$1" /proc/mtd | cut -d: -f 1 | sed 's/mtd/\/dev\/mtd/'
33
grep "$1" /proc/mtd | cut -d: -f 1 | sed 's/mtd/\/dev\/mtdblock/'
38
lockfile /var/lock/upgrade.lock
42
# If hw_status is 0 the machine is being reset to "factory default". In
43
# our case, this means that we don't check whether the machine name
44
# matches /app/manifest.txt.
45
HW_STATUS=$(redboot_config get /dev/mtdblock4 hw_status)
46
if [ $HW_STATUS -ne 1 ]; then
47
product=$(grep "^type" /app/manifest.txt | cut -f 2)
49
# N2100 and compatible machines
51
info "N2100 compatible machine $product found"
53
# N4100 and compatible machines
54
n4100 | all6400 | PlatinumNAS)
55
info "N4100 compatible machine $product found"
59
error "Machine detection of $product: fail"
64
if [ ! -e /proc/mtd ]; then
65
error "Finding /proc/mtd: fail"
67
mtdramdisk=$(mtddevblock ramdisk)
68
mtdkernel=$(mtddev kernel)
69
if [ -z "$mtdramdisk" ]; then
70
error "Finding mtd ramdisk: fail"
72
if [ -z "$mtdkernel" ]; then
73
error "Finding mtd kernel: fail"
76
info "Writing installer ramdisk... please wait..."
78
size=$(grep "ramdisk" /proc/mtd | cut -d " " -f 2)
79
size=$(printf "%d" 0x$size)
80
isize=$(wc -c $ifile | cut -d " " -f 1)
81
pad=$(expr $size - $isize)
84
dd if=/dev/zero bs=$pad count=1 2>/dev/null
87
error "Upgrading ramdisk: fail"
90
info "Writing installer kernel... please wait..."
91
fcp vmlinuz $mtdkernel
93
error "Upgrading kernel: fail"
96
echo "Buzzer 0" > /proc/thecus_io
98
echo "Buzzer 1" > /proc/thecus_io
99
# The firmware upgrade script looks for the following string. If it cannot
100
# find it, it won't terminate.
102
rm -f /var/lock/upgrade.lock