summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils/nwztools/scripts/Makefile71
-rw-r--r--utils/nwztools/scripts/README2
-rw-r--r--utils/nwztools/scripts/exec_file.sh62
3 files changed, 117 insertions, 18 deletions
diff --git a/utils/nwztools/scripts/Makefile b/utils/nwztools/scripts/Makefile
index 590fe775ba..36ccfbb496 100644
--- a/utils/nwztools/scripts/Makefile
+++ b/utils/nwztools/scripts/Makefile
@@ -5,36 +5,73 @@ scsitool:="../scsitools/scsitool"
5 5
6all: 6all:
7 @echo "Please select an action:" 7 @echo "Please select an action:"
8 @echo "- update: uses script update.sh"
9 @echo "- dump_rootfs: dumps the root filesystem to rootfs.tgz" 8 @echo "- dump_rootfs: dumps the root filesystem to rootfs.tgz"
10 @echo "- my_update: craft an arbitrary upgrade script found in my_update.sh" 9 @echo "- do_fw_upgrade: put the device in NWZ_DEV in firmware upgrade mode"
11 @echo "- do_fw_upgrade: send a firmware upgrade to the device in NWZ_DEV" 10 @echo "- copy_fw_upgrade: copy firmware to a device with the right name"
11 @echo "- exec_file: craft an upgrade that executes a script/executable"
12 @echo "- list_targets: produce of list of available targets" 12 @echo "- list_targets: produce of list of available targets"
13 13
14my_update: my_update.upg 14ifndef UPG
15dump_rootfs: dump_rootfs.upg 15want_upg:
16 $(info Please set UPG to the upg filename. For example:)
17 $(info make exec_file UPG=hello_world.upg ...)
18 $(error "")
19else
20want_upg: ;
21endif
22
23ifndef EXEC
24want_exec:
25 $(info Please set EXEC to the executable filename. For example:)
26 $(info make exec_file EXEC=hello_world.sh ...)
27 $(error "")
28else
29want_exec: ;
30endif
16 31
17%.upg: %.sh
18ifndef NWZ_TARGET 32ifndef NWZ_TARGET
19 @echo "Please set NWZ_TARGET to your target. For example:" 33want_target:
20 @echo "make $@ NWZ_TARGET=nwz-e463" 34 $(info Please set NWZ_TARGET to your target. For example:)
21 @echo "Run 'make list_targets' to get a list of all targets" 35 $(info make dump_rootfs NWZ_TARGET=nwz-e463)
36 $(info Run 'make list_targets' to get a list of all targets)
37 $(error "")
22else 38else
23 @echo "Target: $(NWZ_TARGET)" 39want_target: ;
24 $(upgtool) -c -m $(NWZ_TARGET) $@ $^
25endif 40endif
26 41
42ifndef NWZ_DEV
43want_dev:
44 $(info Please set NWZ_DEV to your dev. For example:)
45 $(info make do_fw_upgrade NWZ_DEV=/dev/sdx)
46else
47want_dev: ;
48endif
49
50ifndef NWZ_MOUNT
51want_mount:
52 $(info Please set NWZ_MOUNT to your dev mount point. For example:)
53 $(info make copy_fw_upgrade NWZ_MOUNT=/media/WALKMAN ...)
54else
55want_mount: ;
56endif
57
58UPGPACK=$(upgtool) -c -m $(NWZ_TARGET) $(UPG) $(1)
59
60exec_file: want_target want_exec want_upg
61 $(call UPGPACK, exec_file.sh $(EXEC))
62
63dump_rootfs: want_target want_upg
64 $(call UPGPACK, dump_rootfs.sh)
65
27clean: 66clean:
28 rm -rf *.upg 67 rm -rf *.upg
29 68
30list_targets: 69list_targets:
31 $(upgtool) -m ?; true # upgtool returns an error in this case, ignore it 70 $(upgtool) -m ?; true # upgtool returns an error in this case, ignore it
32 71
33do_fw_upgrade: 72copy_fw_upgrade: want_upg want_mount
34ifdef NWZ_DEV 73 cp $(UPG) "$(NWZ_MOUNT)/NW_WM_FW.UPG"
74
75do_fw_upgrade: want_dev
35 @echo "Device: $(NWZ_DEV)" 76 @echo "Device: $(NWZ_DEV)"
36 $(scsitool) $(NWZ_DEV) do_fw_upgrade 77 $(scsitool) $(NWZ_DEV) do_fw_upgrade
37else
38 @echo "Please set NWZ_DEV to your dev. For example:"
39 @echo "make do_fw_upgrade NWZ_DEV=/dev/sdx"
40endif
diff --git a/utils/nwztools/scripts/README b/utils/nwztools/scripts/README
index e103647bd6..1744fbe9fe 100644
--- a/utils/nwztools/scripts/README
+++ b/utils/nwztools/scripts/README
@@ -46,7 +46,7 @@ your device to build this firmware upgrade. Once you known it, run
46to list all available targets. For example if your targets is one of the 46to list all available targets. For example if your targets is one of the
47NWZ-E460 series, the corresponding target is nwz-e46x. 47NWZ-E460 series, the corresponding target is nwz-e46x.
48Once you have identified the target. Run 48Once you have identified the target. Run
49 make dump_rootfs NWZ_TARGET=nwz-exyz 49 make dump_rootfs NWZ_TARGET=nwz-exyz UPG=dump_rootfs.upg
50(replace nwz-exyz with your target) 50(replace nwz-exyz with your target)
51This command will produce a firmware upgrade file called 51This command will produce a firmware upgrade file called
52 dump_rootfs.upg 52 dump_rootfs.upg
diff --git a/utils/nwztools/scripts/exec_file.sh b/utils/nwztools/scripts/exec_file.sh
new file mode 100644
index 0000000000..059014de2c
--- /dev/null
+++ b/utils/nwztools/scripts/exec_file.sh
@@ -0,0 +1,62 @@
1#!/bin/sh
2
3# The updater script on the NWZ has a major bug/feature:
4# it does NOT clear the update flag if the update scrit fails
5# thus causing a update/reboot loop and a bricked device
6# always clear to make sure we don't end up being screwed
7nvpflag fup 0xFFFFFFFF
8
9#
10# This script extracts the second file from the UPG to /tmp and runs it
11#
12
13
14# go to /tmp
15cd /tmp
16
17# get content partition path
18CONTENTS="/contents"
19CONTENTS_PART=`mount | grep contents | awk '{ print $1 }'`
20
21lcdmsg -c -f /usr/local/bin/font_08x12.bmp -l 0,3 "Contents partition:\n$CONTENTS_PART"
22
23# 2) We need to remount the contents partition in read-write mode be able to
24# write something on it
25lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,6 "Remount $CONTENTS rw"
26if ! mount -o remount,rw $CONTENTS_PART $CONTENTS
27then
28 lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,7 "ERROR: remount failed"
29 sleep 3
30 exit 0
31fi
32
33# get update filename
34_UPDATE_FN_=`nvpstr ufn`
35
36# extract second file
37fwpchk -f /contents/$_UPDATE_FN_.UPG -c -1 exec
38if [ "$?" != 0 ]; then
39 lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,7 "ERROR: no file to execute"
40 sleep 3
41 exit 0
42fi
43
44# make it executable
45chmod 755 exec
46if [ "$?" != 0 ]; then
47 lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,7 "ERROR: cannot make it executable"
48 sleep 3
49 exit 0
50fi
51
52# run it and redirect all outputs to exec.txt
53lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,7 "Running file..."
54/tmp/exec 2>&1 >$CONTENTS/exec.txt
55
56# 4) Success screen
57lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "Rebooting in 3 seconds."
58sleep 3
59sync
60
61# finish
62exit 0