3 RAMFS_COPY_DATA="/lib/cns3xxx.sh"
7 platform_find_partitions() {
8 local first dev size erasesize name
9 while read dev size erasesize name; do
10 name=${name#'"'}; name=${name%'"'}
12 vmlinux.bin.l7|kernel|linux|rootfs)
13 if [ -z "$first" ]; then
16 echo "$erasesize:$first:$name"
24 platform_find_kernelpart() {
26 for part in "${1%:*}" "${1#*:}"; do
28 vmlinux.bin.l7|kernel|linux)
36 platform_do_upgrade_combined() {
37 local partitions=$(platform_find_partitions)
38 local kernelpart=$(platform_find_kernelpart "${partitions#*:}")
39 local erase_size=$((0x${partitions%%:*})); partitions="${partitions#*:}"
40 local kern_length=0x$(dd if="$1" bs=2 skip=1 count=4 2>/dev/null)
41 local kern_blocks=$(($kern_length / $CI_BLKSZ))
42 local root_blocks=$((0x$(dd if="$1" bs=2 skip=5 count=4 2>/dev/null) / $CI_BLKSZ))
44 v "platform_do_upgrade_combined"
45 v "partitions=$partitions"
46 v "kernelpart=$kernelpart"
47 v "erase_size=$erase_size"
48 v "kern_blocks=$kern_blocks"
49 v "root_blocks=$root_blocks"
51 if [ -n "$partitions" ] && [ -n "$kernelpart" ] && \
52 [ ${kern_blocks:-0} -gt 0 ] && \
53 [ ${root_blocks:-0} -gt 0 ] && \
54 [ ${erase_size:-0} -gt 0 ];
57 [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR"
59 dd if="$1" bs=$CI_BLKSZ skip=1 count=$kern_blocks 2>/dev/null | mtd write - kernel
60 dd if="$1" bs=$CI_BLKSZ skip=$((1+$kern_blocks)) count=$root_blocks 2>/dev/null | \
61 mtd -r $append write - rootfs
67 platform_check_image() {
68 local board=$(cns3xxx_board_name)
69 local magic="$(get_magic_word "$1")"
70 local magic_long="$(get_magic_long "$1")"
72 [ "$#" -gt 1 ] && return 1
76 [ "$magic" != "4349" ] && {
77 echo "Invalid image. Use *-sysupgrade.bin files on this board"
81 local md5_img=$(dd if="$1" bs=2 skip=9 count=16 2>/dev/null)
82 local md5_chk=$(dd if="$1" bs=$CI_BLKSZ skip=1 2>/dev/null | md5sum -); md5_chk="${md5_chk%% *}"
84 if [ -n "$md5_img" -a -n "$md5_chk" ] && [ "$md5_img" = "$md5_chk" ]; then
87 echo "Invalid image. Contents do not match checksum (image:$md5_img calculated:$md5_chk)"
94 echo "Sysupgrade is not yet supported on $board."
98 platform_do_upgrade() {
99 local board=$(cns3xxx_board_name)
104 platform_do_upgrade_combined "$ARGV"
107 default_do_upgrade "$ARGV"
115 ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
116 echo 'Could not disable watchdog'
121 # CONFIG_WATCHDOG_NOWAYOUT=y - can't kill watchdog unless kernel cmdline has a mpcore_wdt.nowayout=0
122 #append sysupgrade_pre_upgrade disable_watchdog