aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Adami <andrea.adami@gmail.com>2017-05-14 01:28:20 +0200
committerAndrea Adami <andrea.adami@gmail.com>2017-05-14 01:32:49 +0200
commit4c425d5d9949d2ee591bcfcc53a0934f67e3b2d2 (patch)
tree32ff4912fb46589e2c630b5ebc21cc0b39b8e0ca
parent8f2304e5f495dfebf44ce4469775fb884771cf92 (diff)
downloadmeta-handheld-4c425d5d9949d2ee591bcfcc53a0934f67e3b2d2.tar.gz
meta-handheld-4c425d5d9949d2ee591bcfcc53a0934f67e3b2d2.tar.bz2
meta-handheld-4c425d5d9949d2ee591bcfcc53a0934f67e3b2d2.zip
zaurus-updater: new version 2017.05
Adds partition resizing and erasing. Sanity check in case of 128M repartitioned clamshells. Tested on SL-5600, SL-C860, SL-C3200 Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
-rw-r--r--recipes-bsp/zaurus-utils/zaurus-updater.bb6
-rw-r--r--recipes-bsp/zaurus-utils/zaurus-updater/updater.sh239
2 files changed, 216 insertions, 29 deletions
diff --git a/recipes-bsp/zaurus-utils/zaurus-updater.bb b/recipes-bsp/zaurus-utils/zaurus-updater.bb
index f191dc4..daf332e 100644
--- a/recipes-bsp/zaurus-utils/zaurus-updater.bb
+++ b/recipes-bsp/zaurus-utils/zaurus-updater.bb
@@ -1,8 +1,8 @@
DESCRIPTION = "Encrypted shellscript for the Zaurus ROM update"
LICENSE = "MIT"
-LIC_FILES_CHKSUM = "file://updater.sh;endline=59;md5=667f442c1e555f21adb58957306612cc"
+LIC_FILES_CHKSUM = "file://updater.sh;endline=69;md5=0d6bbac0e2abe4edc46690fe4efbaa9b"
DEPENDS = "encdec-updater-native"
-PR = "r27"
+PV = "2017.05"
INHIBIT_DEFAULT_DEPS = "1"
@@ -11,7 +11,7 @@ SRC_URI = "file://updater.sh"
S = "${WORKDIR}"
do_configure() {
- sed -i "s/ZAURUS_UPDATER_VERSION/${PR}/" "${S}/updater.sh"
+ sed -i "s/ZAURUS_UPDATER_VERSION/${PV}/" "${S}/updater.sh"
}
do_compile() {
encdec-updater -e updater.sh
diff --git a/recipes-bsp/zaurus-utils/zaurus-updater/updater.sh b/recipes-bsp/zaurus-utils/zaurus-updater/updater.sh
index b4dff5d..c20c5db 100644
--- a/recipes-bsp/zaurus-utils/zaurus-updater/updater.sh
+++ b/recipes-bsp/zaurus-utils/zaurus-updater/updater.sh
@@ -54,6 +54,19 @@
#
# 2010.04.18 Andrea 'ant' Adami
# - Add support for flashing pure jffs2 rootfs, without Sharp headers
+#
+# 2017.05.05 Andrea 'ant' Adami
+# - Fix RW_MTD_SIZE
+# - Fix RO_MTD_LINE in case of hardcoded partitioning
+# - Define SMF_MTD_* instead of hardcoding, replace LOGOCAL_MTD
+# - Add support for repartitioning
+# - Limit screen output to 30 chars
+#
+# 2017.05.17 Andrea 'ant' Adami
+# - Major Version bump: 2017.05
+# - do not hardcode smf/logocal = mtd1
+# - check total flash size
+# - add Partition Manager: view, resize, erase partitions
DATAPATH=$1
TMPPATH=/tmp/update
@@ -66,6 +79,15 @@ FLASHED_ROOTFS=0
FLASHED_HOMEFS=0
UNPACKED_ROOTFS=0 # spitz only
+SMF_MTD_LINE=`cat /proc/mtd | grep "smf" | tail -n 1`
+if [ "$SMF_MTD_LINE" = "" ]; then
+ SMF_MTD_LINE=`cat /proc/mtd | grep "\<NAND\>.*\<0\>" | tail -n 1`
+fi
+SMF_MTD_NO=`echo $SMF_MTD_LINE | cut -d: -f1 | cut -dd -f2`
+SMF_MTD=/dev/mtd$SMF_MTD_NO
+SMF_SIZE=`echo $SMF_MTD_LINE | cut -d" " -f2`
+SMF_SIZE_MB=`dc 0x$SMF_SIZE 1024 / 1024 /`
+
RO_MTD_LINE=`cat /proc/mtd | grep "root" | tail -n 1`
if [ "$RO_MTD_LINE" = "" ]; then
RO_MTD_LINE=`cat /proc/mtd | grep "\<NAND\>.*\<1\>" | tail -n 1`
@@ -73,6 +95,7 @@ fi
RO_MTD_NO=`echo $RO_MTD_LINE | cut -d: -f1 | cut -dd -f2`
RO_MTD=/dev/mtd$RO_MTD_NO
ROOTFS_SIZE=`echo $RO_MTD_LINE | cut -d" " -f2`
+ROOTFS_SIZE_MB=`dc 0x$ROOTFS_SIZE 1024 / 1024 /`
RW_MTD_LINE=`cat /proc/mtd | grep "home" | tail -n 1`
if [ "$RW_MTD_LINE" = "" ]; then
@@ -81,13 +104,15 @@ fi
RW_MTD_NO=`echo $RW_MTD_LINE | cut -d: -f1 | cut -dd -f2`
RW_MTD=/dev/mtd$RW_MTD_NO
HOMEFS_SIZE=`echo $RW_MTD_LINE | cut -d" " -f2`
+HOMEFS_SIZE_MB=`dc 0x$HOMEFS_SIZE 1024 / 1024 /`
-LOGOCAL_MTD=/dev/mtd1
+MAX_FSRO_SIZE_MB=`expr $ROOTFS_SIZE_MB + $HOMEFS_SIZE_MB - 1`
VERBLOCK=0x48000
MVRBLOCK=0x70000
RESULT=0
+SEP="------------------------------"
Cleanup()
{
@@ -224,8 +249,8 @@ do_flashing()
then
VTMPNAME=$TMPPATH'/vtmp'`date '+%s'`'.tmp'
MTMPNAME=$TMPPATH'/mtmp'`date '+%s'`'.tmp'
- /sbin/nandlogical $LOGOCAL_MTD READ $VERBLOCK 0x4000 $VTMPNAME > /dev/null 2>&1
- /sbin/nandlogical $LOGOCAL_MTD READ $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1
+ /sbin/nandlogical $SMF_MTD READ $VERBLOCK 0x4000 $VTMPNAME > /dev/null 2>&1
+ /sbin/nandlogical $SMF_MTD READ $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1
/sbin/verchg -v $VTMPNAME $TMPHEAD $MODULEID $MTD_PART_SIZE > /dev/null 2>&1
/sbin/verchg -m $MTMPNAME $TMPHEAD $MODULEID $MTD_PART_SIZE > /dev/null 2>&1
@@ -237,9 +262,9 @@ do_flashing()
echo ''
echo -n 'Installing SL-Cxx00 kernel...'
echo ' ' > /tmp/data
- test "$ZAURUS" = "akita" && /sbin/nandlogical $LOGOCAL_MTD WRITE 0x60100 16 /tmp/data > /dev/null 2>&1
- /sbin/nandlogical $LOGOCAL_MTD WRITE 0xe0000 $DATASIZE $TARGETFILE > /dev/null 2>&1
- test "$ZAURUS" = "akita" && /sbin/nandlogical $LOGOCAL_MTD WRITE 0x21bff0 16 /tmp/data > /dev/null 2>&1
+ test "$ZAURUS" = "akita" && /sbin/nandlogical $SMF_MTD WRITE 0x60100 16 /tmp/data > /dev/null 2>&1
+ /sbin/nandlogical $SMF_MTD WRITE 0xe0000 $DATASIZE $TARGETFILE > /dev/null 2>&1
+ test "$ZAURUS" = "akita" && /sbin/nandlogical $SMF_MTD WRITE 0x21bff0 16 /tmp/data > /dev/null 2>&1
echo 'done'
else
echo ''
@@ -273,7 +298,7 @@ do_flashing()
fi
ADDR=$next_addr
else
- /sbin/nandlogical $LOGOCAL_MTD WRITE $ADDR $TMPSIZE $TMPDATA > /dev/null 2>&1
+ /sbin/nandlogical $SMF_MTD WRITE $ADDR $TMPSIZE $TMPDATA > /dev/null 2>&1
ADDR=`expr $ADDR + $TMPSIZE`
fi
@@ -297,13 +322,13 @@ do_flashing()
then
if [ -e $VTMPNAME ]
then
- /sbin/nandlogical $LOGOCAL_MTD WRITE $VERBLOCK 0x4000 $VTMPNAME > /dev/null 2>&1
+ /sbin/nandlogical $SMF_MTD WRITE $VERBLOCK 0x4000 $VTMPNAME > /dev/null 2>&1
rm -f $VTMPNAME > /dev/null 2>&1
fi
if [ -e $MTMPNAME ]
then
- /sbin/nandlogical $LOGOCAL_MTD WRITE $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1
+ /sbin/nandlogical $SMF_MTD WRITE $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1
rm -f $MTMPNAME > /dev/null 2>&1
fi
@@ -315,11 +340,11 @@ do_flashing()
mainte_fix()
{
-# binaries taken from Cacko 1.23 installer
-case "$MODEL" in
+ # binaries taken from Cacko 1.23 installer
+ case "$MODEL" in
SL-C760|SL-C860|SL-C1000|SL-C3100|SL-C3200)
echo -n 'Flashing Mainte fix for 128M flash...'
- if ( /sbin/nandlogical $LOGOCAL_MTD WRITE 0x00, 327680, $TARGETFILE ) > /dev/null 2>&1
+ if ( /sbin/nandlogical $SMF_MTD WRITE 0x00, 327680, $TARGETFILE ) > /dev/null 2>&1
then
echo 'done'
# unnecessary fix for FSRW end addr / size ? (kernel parser sharpslpart ignores it)
@@ -330,32 +355,185 @@ case "$MODEL" in
# rm -f $OUTFILE > /dev/null 2>&1
exit 0
fi
- ;;
- *)
- ;;
-esac
+ ;;
+ *)
+ ;;
+ esac
+}
+
+check_partitions()
+{
+ if [ $FLASH_SIZE_MB -gt `expr $SMF_SIZE_MB + $ROOTFS_SIZE_MB + $HOMEFS_SIZE_MB` ]
+ then
+ printf "%b\n" "$SEP\n\033[1;31mFlash size mismatch!\033[0m\nThis unit is repartitioned and\nyou \033[1;31mmust\033[0m flash \033[1;33mmainte_fix.bin\033[0m"
+ printf "%b\n" "to keep this partition layout,\notherwise resize root to \033[1;32m$DEF_ROOTFS_SIZE_MB\033[0m MB"
+ printf "%b\n" "\nReset to factory settings can\nbe done entering \033[1;33mService Menu\033[0m\nand running \033[1;32mNAND Flash Restore\033[0m\n$SEP\n"
+ fi
+}
+
+partition_manager()
+{
+ while true; do
+ ANSW=""
+ read -p "Partition Manager? (y/n): " ANSW
+ if expr "$ANSW" : '[Yy]\+$' > /dev/null 2>&1
+ then
+ break
+ elif expr "$ANSW" : '[Nn]\+$' > /dev/null 2>&1
+ then
+ return
+ fi
+ done
+
+ clear
+ printf "%b\n" "\n\033[1;31mZAURUS\033[1;32m PARTITION MANAGER\033[0m\n$SEP\n1 View\n2 Resize\n3 Erase\n\n0 Exit\n$SEP"
+
+ while true; do
+ ANSW=""
+ read ANSW
+
+ case "$ANSW" in
+ 1) view_partitions
+ ;;
+ 2) change_partitions
+ ;;
+ 3) erase_partitions
+ ;;
+ 0) exit 0
+ ;;
+ *)
+ ;;
+ esac
+ done
+}
+
+view_partitions()
+{
+ printf "%b\n" "$SEP\nPartition \033[1msmf root home\033[0m"
+ printf "%b\n" "Size (MB) \033[1;32m$SMF_SIZE_MB $ROOTFS_SIZE_MB $HOMEFS_SIZE_MB\033[0m\n$SEP"
+}
+
+
+erase_partitions()
+{
+ while true; do
+ ANSW=""
+ read -p "Erase partitions? (y/n): " ANSW
+ if expr "$ANSW" : '[Yy]\+$' > /dev/null 2>&1
+ then
+ break
+ elif expr "$ANSW" : '[Nn]\+$' > /dev/null 2>&1
+ then
+ return
+ fi
+ done
+
+ echo -n 'Erasing root partition... '
+ /sbin/eraseall $RO_MTD > /dev/null 2>&1
+ echo 'done'
+ echo -n 'Erasing home partition... '
+ /sbin/eraseall $RW_MTD > /dev/null 2>&1
+ echo 'done'
+}
+
+change_partitions()
+{
+ while true; do
+ ANSW=""
+ read -p "Resize partitions? (y/n): " ANSW
+ if expr "$ANSW" : '[Yy]\+$' > /dev/null 2>&1
+ then
+ break
+ elif expr "$ANSW" : '[Nn]\+$' > /dev/null 2>&1
+ then
+ return
+ fi
+ done
+
+ while true; do
+ FSRO_SIZE_MB=""
+ read -p "New root size (1-$MAX_FSRO_SIZE_MB): " FSRO_SIZE_MB
+ if expr "$FSRO_SIZE_MB" : '[0-9]\+$' > /dev/null 2>&1 &&
+ [ $FSRO_SIZE_MB -gt 0 ] > /dev/null 2>&1 &&
+ [ $FSRO_SIZE_MB -le $MAX_FSRO_SIZE_MB ] > /dev/null 2>&1
+ then
+ break
+ fi
+ done
+
+ FSRW_SIZE_MB=`expr $ROOTFS_SIZE_MB + $HOMEFS_SIZE_MB - $FSRO_SIZE_MB`
+
+ FSRO_END_B=`expr $(($(($SMF_SIZE_MB + $FSRO_SIZE_MB)) << 20))`
+
+ B1=`printf '%08x' $FSRO_END_B | cut -c1-2`
+ B2=`printf '%08x' $FSRO_END_B | cut -c3-4`
+ B3=`printf '%08x' $FSRO_END_B | cut -c5-6`
+ B4=`printf '%08x' $FSRO_END_B | cut -c7-8`
+
+ OUTFILE=$TMPPATH/fsro_end_le.bin
+ printf '\x'$B4'\x'$B3'\x'$B2'\x'$B1 > $OUTFILE
+ /sbin/nandlogical $SMF_MTD WRITE 0x60014, 4, $OUTFILE > /dev/null 2>&1
+ /sbin/nandlogical $SMF_MTD WRITE 0x60020, 4, $OUTFILE > /dev/null 2>&1
+ /sbin/nandlogical $SMF_MTD WRITE 0x64014, 4, $OUTFILE > /dev/null 2>&1
+ /sbin/nandlogical $SMF_MTD WRITE 0x64020, 4, $OUTFILE > /dev/null 2>&1
+ rm -f $OUTFILE > /dev/null 2>&1
+
+ printf "%b\n" "$SEP\nPartition \033[1msmf root home\033[0m"
+ printf "%b\n" "Size (MB) \033[1;33m$SMF_SIZE_MB $FSRO_SIZE_MB $FSRW_SIZE_MB\033[0m\n$SEP"
+
+ exit 0
}
### Check model ###
/sbin/writerominfo
MODEL=`cat /proc/deviceinfo/product`
+
case "$MODEL" in
- SL-B500|SL-5600)
+ SL-B500|SL-5600)
ZAURUS='poodle'
+ FLASH_SIZE_MB=64
+ DEF_ROOTFS_SIZE_MB=22
;;
- SL-6000)
- ZAURUS='tosa'
+ SL-C700|SL-C750|SL-C7500)
+ ZAURUS='c7x0'
+ FLASH_SIZE_MB=64
+ DEF_ROOTFS_SIZE_MB=25
+ ;;
+ SL-C760|SL-C860)
+ ZAURUS='c7x0'
+ FLASH_SIZE_MB=128
+ DEF_ROOTFS_SIZE_MB=53
;;
- SL-C1000)
+ SL-C1000)
ZAURUS='akita'
+ FLASH_SIZE_MB=128
+ DEF_ROOTFS_SIZE_MB=58
;;
- SL-C700|SL-C750|SL-7500|SL-C760|SL-C860)
- ZAURUS='c7x0'
+ SL-C3000)
+ ZAURUS='c3x00'
+ check_for_hdd
+ check_for_tar
+ FLASH_SIZE_MB=16
+ DEF_ROOTFS_SIZE_MB=5
+ ;;
+ SL-C3100)
+ ZAURUS='c3x00'
+ check_for_hdd
+ check_for_tar
+ FLASH_SIZE_MB=128
+ DEF_ROOTFS_SIZE_MB=32
;;
- SL-C3000|SL-C3100|SL-C3200)
+ SL-C3200)
ZAURUS='c3x00'
check_for_hdd
check_for_tar
+ FLASH_SIZE_MB=128
+ DEF_ROOTFS_SIZE_MB=43
+ ;;
+ SL-6000)
+ ZAURUS='tosa'
+ FLASH_SIZE_MB=128
+ DEF_ROOTFS_SIZE_MB=28
;;
*)
echo 'MODEL: '$MODEL 'is unsupported'
@@ -368,14 +546,15 @@ case "$MODEL" in
esac
clear
-echo 'Universal Zaurus Updater (ZAURUS_UPDATER_VERSION)'
-echo 'MODEL: '$MODEL' ('$ZAURUS')'
-echo ''
+printf "%b\n" "\033[1;32m--- Zaurus Updater ZAURUS_UPDATER_VERSION ---\033[0m\n MODEL: $MODEL ($ZAURUS)\n"
+
+check_partitions
mkdir -p $TMPPATH > /dev/null 2>&1
cd $DATAPATH/
+FOUND_FILES=0
for TARGETFILE in zimage zImage zImage.bin zimage.bin ZIMAGE ZIMAGE.BIN \
initrd.bin INITRD.BIN hdimage1.tgz HDIMAGE1.TGZ home.bin \
HOME.BIN mainte_fix.bin MAINTE_FIX.BIN
@@ -384,6 +563,7 @@ do
then
continue
fi
+ FOUND_FILES=1
rm -f $TMPPATH/*.bin > /dev/null 2>&1
DATASIZE=`wc -c $TARGETFILE`
@@ -476,9 +656,16 @@ do
*)
;;
+
esac
done
+if [ $FOUND_FILES = 0 ]
+then
+ printf "%b\n" "$SEP\n\033[1;33mNo files found to flash!\033[0m\n$SEP\n"
+ partition_manager
+fi
+
# reboot
exit 0