3 RAMFS_COPY_DATA="/lib/ixp4xx.sh"
6 RAMFS_COPY_BIN="/usr/bin/less /usr/bin/hexdump"
11 platform_find_partitions() {
12 local first dev size erasesize name
13 while read dev size erasesize name; do
14 name=${name#'"'}; name=${name%'"'}
16 vmlinux.bin.l7|kernel|linux|rootfs)
17 if [ -z "$first" ]; then
20 echo "$erasesize:$first:$name"
28 platform_find_kernelpart() {
30 for part in "${1%:*}" "${1#*:}"; do
32 vmlinux.bin.l7|kernel|linux)
40 platform_find_part_size() {
41 local first dev size erasesize name
42 while read dev size erasesize name; do
43 name=${name#'"'}; name=${name%'"'}
44 [ "$name" = "$1" ] && {
51 platform_do_upgrade_combined() {
52 local partitions=$(platform_find_partitions)
53 local kernelpart=$(platform_find_kernelpart "${partitions#*:}")
54 local erase_size=$((0x${partitions%%:*})); partitions="${partitions#*:}"
55 local kern_part_size=0x$(platform_find_part_size "$kernelpart")
56 local kern_part_blocks=$(($kern_part_size / $CI_BLKSZ))
57 local kern_length=0x$(dd if="$1" bs=2 skip=1 count=4 2>/dev/null)
58 local kern_blocks=$(($kern_length / $CI_BLKSZ))
59 local root_blocks=$((0x$(dd if="$1" bs=2 skip=5 count=4 2>/dev/null) / $CI_BLKSZ))
61 v "platform_do_upgrade_combined"
62 v "partitions=$partitions"
63 v "kernelpart=$kernelpart"
64 v "kernel_part_size=$kern_part_size"
65 v "kernel_part_blocks=$kern_part_blocks"
66 v "kern_length=$kern_length"
67 v "erase_size=$erase_size"
68 v "kern_blocks=$kern_blocks"
69 v "root_blocks=$root_blocks"
70 v "kern_pad_blocks=$(($kern_part_blocks-$kern_blocks))"
72 if [ -n "$partitions" ] && [ -n "$kernelpart" ] && \
73 [ ${kern_blocks:-0} -gt 0 ] && \
74 [ ${root_blocks:-0} -gt 0 ] && \
75 [ ${erase_size:-0} -gt 0 ];
78 [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR"
81 dd if="$1" bs=$CI_BLKSZ skip=1 count=$kern_blocks 2>/dev/null | \
82 mtd -F$kernelpart:$kern_part_size:$CI_LDADR write - $kernelpart
84 dd if="$1" bs=$CI_BLKSZ skip=$((1+$kern_blocks)) count=$root_blocks 2>/dev/null | \
85 mtd $append write - rootfs
91 platform_check_image() {
92 local board=$(ixp4xx_board_name)
93 local magic="$(get_magic_word "$1")"
94 local partitions=$(platform_find_partitions)
95 local kernelpart=$(platform_find_kernelpart "${partitions#*:}")
96 local kern_part_size=0x$(platform_find_part_size "$kernelpart")
97 local kern_length=0x$(dd if="$1" bs=2 skip=1 count=4 2>/dev/null)
99 [ "$ARGC" -gt 1 ] && return 1
103 [ "$magic" != "4349" ] && {
104 echo "Invalid image. Use *-sysupgrade.bin files on this board"
108 kern_length_b=$(printf '%d' $kern_length)
109 kern_part_size_b=$(printf '%d' $kern_part_size)
110 if [ $kern_length_b -gt $kern_part_size_b ]; then
111 echo "Invalid image. Kernel size ($kern_length) exceeds kernel partition ($kern_part_size)"
115 local md5_img=$(dd if="$1" bs=2 skip=9 count=16 2>/dev/null)
116 local md5_chk=$(dd if="$1" bs=$CI_BLKSZ skip=1 2>/dev/null | md5sum -); md5_chk="${md5_chk%% *}"
117 if [ -n "$md5_img" -a -n "$md5_chk" ] && [ "$md5_img" = "$md5_chk" ]; then
120 echo "Invalid image. Contents do not match checksum (image:$md5_img calculated:$md5_chk)"
128 echo "Sysupgrade is not yet supported on $board."
132 platform_do_upgrade() {
133 local board=$(ixp4xx_board_name)
138 platform_do_upgrade_combined "$ARGV"
141 default_do_upgrade "$ARGV"
149 ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
150 echo 'Could not disable watchdog'
155 # CONFIG_WATCHDOG_NOWAYOUT=y - can't kill watchdog unless kernel cmdline has a mpcore_wdt.nowayout=0
156 #append sysupgrade_pre_upgrade disable_watchdog