summaryrefslogtreecommitdiffstats
path: root/utils/nwztools/scripts
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2016-11-01 17:04:26 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2016-11-01 17:09:07 +0100
commitd492f25c54b4134fd6632156efee07670ab4004f (patch)
tree318919b264876a3906d15ecd8781ad0a1e15b3fb /utils/nwztools/scripts
parentb045e4da34165a878c7acc9a82e76b447fe992a7 (diff)
downloadrockbox-d492f25c54b4134fd6632156efee07670ab4004f.tar.gz
rockbox-d492f25c54b4134fd6632156efee07670ab4004f.tar.bz2
rockbox-d492f25c54b4134fd6632156efee07670ab4004f.zip
nwztools: add preliminary dualboot and dualboot install script
At the moment, the script install_duaboot does the following: - rename SpiderApp to SpiderApp.of (unless it already exists) - install payload as SpiderApp - fixes permissions Since SpiderApp is the main app, it will execute instead of the OF. The current dualboot code (dualboot.c) is still a preliminary but the current version displays an "all tools" menu to choose for. When exitting the menu using BACK, it will run the OF. With the modifications made by the install script, it should not be possible to break the device. In the worst case scenario, the dualboot code crashes and it restarted by the sysmgrd, or hangs. A safe way to recover is to plug the USB cable and reset the device: the system manager will then start the USB app and one can reflash the device if necessary. Change-Id: Id9edab0347538ad2a8651a28aea7fd083feaa626
Diffstat (limited to 'utils/nwztools/scripts')
-rw-r--r--utils/nwztools/scripts/Makefile6
-rw-r--r--utils/nwztools/scripts/exec_file.sh4
-rw-r--r--utils/nwztools/scripts/install_dualboot.sh129
3 files changed, 136 insertions, 3 deletions
diff --git a/utils/nwztools/scripts/Makefile b/utils/nwztools/scripts/Makefile
index 207534a006..345fd0f4cb 100644
--- a/utils/nwztools/scripts/Makefile
+++ b/utils/nwztools/scripts/Makefile
@@ -11,6 +11,7 @@ all:
@echo "- exec_file: craft an upgrade that embeds and execute a file"
@echo "- exec_file_extern: craft an upgrade that execute a file on the user partition"
@echo "- list_targets: produce of list of available targets"
+ @echo "- install_dualboot"
ifndef UPG
want_upg:
@@ -33,7 +34,7 @@ endif
ifndef NWZ_TARGET
want_target:
$(info Please set NWZ_TARGET to your target. For example:)
- $(info make dump_rootfs NWZ_TARGET=nwz-e463)
+ $(info make dump_rootfs NWZ_TARGET=nwz-e460)
$(info Run 'make list_targets' to get a list of all targets)
$(error "")
else
@@ -72,6 +73,9 @@ UPGPACK=$(upgtool) -c -m $(NWZ_TARGET) $(UPG) $(1)
exec_file: want_target want_exec want_upg
$(call UPGPACK, exec_file.sh $(EXEC))
+install_dualboot: want_target want_exec want_upg
+ $(call UPGPACK, install_dualboot.sh $(EXEC))
+
exec_file_extern.tmp: want_exec want_upg want_log
cat exec_file_extern.sh.in | sed "s|NWZ_EXEC_THIS|$(EXEC)|" |\
sed "s|NWZ_LOG_THIS|$(LOG)|" > $@
diff --git a/utils/nwztools/scripts/exec_file.sh b/utils/nwztools/scripts/exec_file.sh
index a624e4df35..b005156c37 100644
--- a/utils/nwztools/scripts/exec_file.sh
+++ b/utils/nwztools/scripts/exec_file.sh
@@ -20,7 +20,7 @@ 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"
-# 2) We need to remount the contents partition in read-write mode be able to
+# 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"
if ! mount -o remount,rw $CONTENTS_PART $CONTENTS
@@ -55,7 +55,7 @@ fi
lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,7 "Running file..."
/tmp/exec >$CONTENTS/exec.txt 2>&1
-# 4) Success screen
+# Success screen
lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "Rebooting in 3 seconds."
sleep 3
sync
diff --git a/utils/nwztools/scripts/install_dualboot.sh b/utils/nwztools/scripts/install_dualboot.sh
new file mode 100644
index 0000000000..ece5b9e3a3
--- /dev/null
+++ b/utils/nwztools/scripts/install_dualboot.sh
@@ -0,0 +1,129 @@
+#!/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
+
+#
+# FIXME document this
+#
+
+
+# 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
+
+# import constants
+. /install_script/constant.txt
+_UPDATE_FN_=`nvpstr ufn`
+ROOTFS_TMP_DIR=/tmp/rootfs
+ROCKBOX_NAME=Rockbox
+ROCKBOX_PATH=$ROOTFS_TMP_DIR/usr/local/bin/$ROCKBOX_NAME
+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
+
+# NOTE some platforms use ext3 and some ext4 with a custom mount program
+# (/usr/local/bin/icx_mount.ext4), some probably use an mtd too
+mount -t ext2 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR
+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 executable
+lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,9 "Install rockbox"
+fwpchk -f /contents/$_UPDATE_FN_.UPG -c -1 $SPIDERAPP_PATH
+if [ "$?" != 0 ]; then
+ lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: no file to extract"
+ sleep 3
+ exit 0
+fi
+
+# make it executable and change user/group
+chmod 775 $SPIDERAPP_PATH
+if [ "$?" != 0 ]; then
+ lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: cannot make it executable"
+ sleep 3
+ exit 0
+fi
+chown 500:500 $SPIDERAPP_PATH
+if [ "$?" != 0 ]; then
+ lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: cannot change owner"
+ sleep 3
+ exit 0
+fi
+
+# # change main application
+# lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,9 "Modify app list"
+# sed -i 's/Rockbox/SpiderApp/' $ROOTFS_TMP_DIR/etc/AppList.conf
+# if [ "$?" != 0 ]; then
+# lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,14 "ERROR: sed failed"
+# sleep 3
+# exit 0
+# fi
+# # and fix ownership
+# chown 500:500 $ROOTFS_TMP_DIR/etc/AppList.conf
+# if [ "$?" != 0 ]; then
+# lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,14 "ERROR: cannot change group"
+# sleep 3
+# exit 0
+# fi
+cat $ROOTFS_TMP_DIR/etc/AppList.conf >$CONTENTS/AppList.conf
+ls -l $ROOTFS_TMP_DIR/usr/local/bin/ >$CONTENTS/ls.txt
+ls -l $ROOTFS_TMP_DIR/etc/ >$CONTENTS/ls2.txt
+
+# unmount root partition
+lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,10 "Unmount root filesystem"
+sync
+if [ "$?" != 0 ]; then
+ 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
+
+# finish
+exit 0