diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2017-02-23 11:33:19 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2017-09-05 21:42:12 +0200 |
commit | 1d121e8c082fe67757cf0d4df7b9e6ca1e26f755 (patch) | |
tree | 1c93842d99bb8e4a5f3ed5bca38c05e7f17894fa /rbutil/mknwzboot/install_script.sh | |
parent | 142f80f07d96305f1618c99c28c13319b1b279e6 (diff) | |
download | rockbox-1d121e8c082fe67757cf0d4df7b9e6ca1e26f755.tar.gz rockbox-1d121e8c082fe67757cf0d4df7b9e6ca1e26f755.zip |
Initial commit for the Sony NWZ linux port
SUPPORTED SERIES:
- NWZ-E450
- NWZ-E460
- NWZ-E470
- NWZ-E580
- NWZ-A10
NOTES:
- bootloader makefile convert an extra font to be installed alongside the bootloader
since sysfont is way too small
- the toolsicon bitmap comes from the Oxygen iconset
- touchscreen driver is untested
TODO:
- implement audio routing driver (pcm is handled by pcm-alsa)
- fix playback: it crashes on illegal instruction in DEBUG builds
- find out why the browser starts at / instead of /contents
- implement radio support
- implement return to OF for usb handling
- calibrate battery curve (NB: of can report a battery level on a 0-5 scale but
probabl don't want to use that ?)
- implement simulator build (we need a nice image of the player)
- figure out if we can detect jack removal
POTENTIAL TODOS:
- try to build a usb serial gadget and gdbserver
Change-Id: Ic77d71e0651355d47cc4e423a40fb64a60c69a80
Diffstat (limited to 'rbutil/mknwzboot/install_script.sh')
-rw-r--r-- | rbutil/mknwzboot/install_script.sh | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/rbutil/mknwzboot/install_script.sh b/rbutil/mknwzboot/install_script.sh new file mode 100644 index 0000000000..18296d257e --- /dev/null +++ b/rbutil/mknwzboot/install_script.sh @@ -0,0 +1,142 @@ +#!/bin/sh + +# The updater script on the NWZ has a major bug/feature: +# it does NOT clear the update flag if the update scrit fails +# thus causing a update/reboot loop and a bricked device +# always clear to make sure we don't end up being screwed +nvpflag fup 0xFFFFFFFF + +# go to /tmp +cd /tmp + +# get content partition path +CONTENTS="/contents" +CONTENTS_PART=`mount | grep contents | awk '{ print $1 }'` + +lcdmsg -c -f /usr/local/bin/font_08x12.bmp -l 0,3 "Contents partition:\n$CONTENTS_PART" + +# We need to remount the contents partition in read-write mode be able to +# write something on it +lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,6 "Remount $CONTENTS rw" +mount -o remount,rw $CONTENTS_PART $CONTENTS +if [ "$?" != 0 ]; then + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: remount failed" + sleep 3 + exit 0 +fi + +# redirect all output to a log file +exec > "$CONTENTS/install_dualboot_log.txt" 2>&1 + +# import constants +. /install_script/constant.txt +_UPDATE_FN_=`nvpstr ufn` +ROOTFS_TMP_DIR=/tmp/rootfs +SPIDERAPP_PATH=$ROOTFS_TMP_DIR/usr/local/bin/SpiderApp + +# mount root partition +lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,7 "Mount root filesystem" +mkdir $ROOTFS_TMP_DIR +if [ "$?" != 0 ]; then + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: mkdir failed" + sleep 3 + exit 0 +fi + +# If there is an ext4 mounter, try it. Otherwise or on failure, try ext3 and +# then ext2. +# NOTE some platforms probably use an mtd and this might need some fixing +if [ -e /usr/local/bin/icx_mount.ext4 ]; then + /usr/local/bin/icx_mount.ext4 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR +else + false +fi +if [ "$?" != 0 ]; then + mount -t ext3 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR +fi +if [ "$?" != 0 ]; then + mount -t ext2 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR +fi +if [ "$?" != 0 ]; then + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: mount failed" + sleep 3 + exit 0 +fi + +# rename the previous main application unless there is already a copy +lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,8 "Backup OF" +if [ ! -e $SPIDERAPP_PATH.of ]; then + mv $SPIDERAPP_PATH $SPIDERAPP_PATH.of +fi + +# extract our payload: the second file in the upgrade is a tar file +# the files in the archive have paths of the form ./absolute/path and we extract +# it at the rootfs mount it, so it can create/overwrite any file +# +# we need a small trick here: we want to pipe directly the output of the decryption +# tool to tar, to avoid using space in /tmp/ or on the user partition +lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,9 "Install rockbox" +FIFO_FILE=/tmp/rb.fifo +mkfifo $FIFO_FILE +if [ "$?" != 0 ]; then + umount "$ROOTFS_TMP_DIR" + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: cannot create fifo" + sleep 3 + exit 0 +fi +fwpchk -f /contents/$_UPDATE_FN_.UPG -c -1 $FIFO_FILE & +#tar -tvf $FIFO_FILE +tar -C $ROOTFS_TMP_DIR -xvf $FIFO_FILE +if [ "$?" != 0 ]; then + umount "$ROOTFS_TMP_DIR" + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: extraction failed" + sleep 3 + exit 0 +fi +# wait for fwpchk +wait +if [ "$?" != 0 ]; then + umount "$ROOTFS_TMP_DIR" + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: no file to extract" + sleep 3 + exit 0 +fi + +# create a symlink from /.rockbox to /contents/.rockbox (see dualboot code +# for why) +lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,10 "Create rockbox symlink" +rm -f "$ROOTFS_TMP_DIR/.rockbox" +ln -s "$CONTENTS/.rockbox" "$ROOTFS_TMP_DIR/.rockbox" +if [ "$?" != 0 ]; then + umount "$ROOTFS_TMP_DIR" + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: cannot create rockbox symlink" + sleep 3 + exit 0 +fi + +# unmount root partition +lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,11 "Unmount root filesystem" +sync +if [ "$?" != 0 ]; then + umount "$ROOTFS_TMP_DIR" + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: sync failed" + sleep 3 + exit 0 +fi + +umount $ROOTFS_TMP_DIR +if [ "$?" != 0 ]; then + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: umount failed" + sleep 3 + exit 0 +fi + +# Success screen +lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "Rebooting in 3 seconds." +sleep 3 +sync + +echo "Installation successful" +# finish +exit 0 + |