From: Grazvydas Ignotas Date: Thu, 22 Mar 2012 22:43:38 +0000 (+0200) Subject: flasher: revise kernel flashing to be OE friendly X-Git-Tag: sz_beta3^0 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-misc.git;a=commitdiff_plain;h=d6d8ec53da597267b19a5f41f7b59e9c82d7e4c9 flasher: revise kernel flashing to be OE friendly also wait for ubi files --- diff --git a/flasher/rootfs/etc/init.d/rc b/flasher/rootfs/etc/init.d/rc index 189dd21..afb5b8d 100755 --- a/flasher/rootfs/etc/init.d/rc +++ b/flasher/rootfs/etc/init.d/rc @@ -4,6 +4,9 @@ . /etc/updater_funcs.sh chvt $LOG_TTY +# hmh Linux fb console wants 16bpp for correct colors? +fbset -depth 16 + log "Starting updater. Press Alt+RightArrow for verbose output.." log "" diff --git a/flasher/rootfs/etc/updater.sh b/flasher/rootfs/etc/updater.sh index 8478382..202f045 100755 --- a/flasher/rootfs/etc/updater.sh +++ b/flasher/rootfs/etc/updater.sh @@ -1,9 +1,9 @@ #/bin/sh # # on-target updater script for Pandora -# Copyright (c) 2010, Gražvydas Ignotas +# Copyright (c) 2010,2012 Gražvydas Ignotas -set -e +set -e -x . /etc/updater_funcs.sh @@ -25,6 +25,20 @@ cleanup() fi } +wait_for_file() +{ + for a in `seq 10` + do + if test -e "$1" + then + return 0 + fi + sleep .5 + done + return 1 +} + + mkdir /mnt/ubifs 2> /dev/null || true if [ ! -e /dev/mmcblk0p1 ] @@ -119,34 +133,71 @@ then log "u-boot environment cleared." fi -if [ -e uImage ] -then - # attempt to mount and check - ubiattach /dev/ubi_ctrl -m 3 || true - mount -t ubifs ubi0:boot /mnt/ubifs 2> /dev/null || true - if ! cmp uImage /mnt/ubifs/uImage 2> /dev/null +# make sure ubifs boot partition is in order +format_boot() +{ + log "formatting boot partition.." + umount /mnt/ubifs 2> /dev/null || true + ubidetach /dev/ubi_ctrl -d 0 2> /dev/null || true + ubiformat /dev/mtd3 -s 512 -y || return 1 + ubiattach /dev/ubi_ctrl -m 3 || return 1 + wait_for_file /dev/ubi0 || return 1 + ubimkvol /dev/ubi0 -m -N boot || return 1 + wait_for_file /dev/ubi0_0 || return 1 + mount -t ubifs ubi0:boot /mnt/ubifs || return 1 +} + +handle_kernels() +{ + kernels=`ls uImage* 2> /dev/null || true` + if [ -z "$kernels" ] then - log "flashing uImage.." - umount /mnt/ubifs 2> /dev/null || true - ubidetach /dev/ubi_ctrl -d 0 2> /dev/null || true - # format just in case, should be harmless even it's formated already - ubiformat /dev/mtd3 -s 512 -y - ubiattach /dev/ubi_ctrl -m 3 - ubimkvol /dev/ubi0 -m -N boot - mount -t ubifs ubi0:boot /mnt/ubifs - cp uImage /mnt/ubifs/uImage - status_uimage="flashed" - log "done" - else - log "uImage already flashed, skipped." - status_uimage="already there" + return 0 fi - umount /mnt/ubifs - ubidetach /dev/ubi_ctrl -d 0 -else - log "uImage is missing, skipped." + + # presence of uImage* is a sign that we can wipe whole boot partition, + # but first get rid of potentially bad autoboot.txt + rm -f /mnt/ubifs/autoboot.txt + + for kernel in $kernels + do + if ! cmp $kernel /mnt/ubifs/$kernel 2> /dev/null + then + log "flashing $kernel .." + cp -a $kernel /mnt/ubifs/$kernel || return 1 + status_uimage="flashed" + log "done" + else + log "$kernel already flashed, skipped." + status_uimage="already there" + fi + done + if [ -e bootmenu.txt ] + then + if ! cmp bootmenu.txt /mnt/ubifs/bootmenu.txt 2> /dev/null + then + log "updating bootmenu.txt" + cp -a bootmenu.txt /mnt/ubifs/bootmenu.txt || return 1 + fi + fi +} + +ubiattach /dev/ubi_ctrl -m 3 || true +if ! mount -t ubifs ubi0:boot /mnt/ubifs 2> /dev/null +then + format_boot fi +if ! handle_kernels +then + log "kernel flashing failed, retrying.." + format_boot + handle_kernels +fi + +umount /mnt/ubifs +ubidetach /dev/ubi_ctrl -d 0 + if [ -n "$rootfs_file" ] then log "Calculating checksum, this might take a few minutes.." @@ -164,7 +215,9 @@ then log "formatting.." ubiformat /dev/mtd4 -s 512 -y ubiattach /dev/ubi_ctrl -m 4 + wait_for_file /dev/ubi0 ubimkvol /dev/ubi0 -m -N rootfs + wait_for_file /dev/ubi0_0 log "done." log "Writing rootfs, please wait. This may take up to 15 minutes.." ubiupdatevol /dev/ubi0_0 $rootfs_file