mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
nwztools: upgrade upgtools and add dumping script
Change-Id: I315d1010ce5477c0112f4a890156b360e8123e11
This commit is contained in:
parent
3db0363b78
commit
9d121cfd51
4 changed files with 186 additions and 20 deletions
40
utils/nwztools/scripts/Makefile
Normal file
40
utils/nwztools/scripts/Makefile
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
upgtool:="../upgtools/upgtool"
|
||||
scsitool:="../scsitools/scsitool"
|
||||
|
||||
.SUFFIXES: # disable old suffix rules
|
||||
|
||||
all:
|
||||
@echo "Please select an action:"
|
||||
@echo "- update: uses script update.sh"
|
||||
@echo "- dump_rootfs: dumps the root filesystem to rootfs.tgz"
|
||||
@echo "- my_update: craft an arbitrary upgrade script found in my_update.sh"
|
||||
@echo "- do_fw_upgrade: send a firmware upgrade to the device in NWZ_DEV"
|
||||
@echo "- list_targets: produce of list of available targets"
|
||||
|
||||
my_update: my_update.upg
|
||||
dump_rootfs: dump_rootfs.upg
|
||||
|
||||
%.upg: %.sh
|
||||
ifndef NWZ_TARGET
|
||||
@echo "Please set NWZ_TARGET to your target. For example:"
|
||||
@echo "make $@ NWZ_TARGET=nwz-e463"
|
||||
@echo "Run 'make list_targets' to get a list of all targets"
|
||||
else
|
||||
@echo "Target: $(NWZ_TARGET)"
|
||||
$(upgtool) -c -m $(NWZ_TARGET) $@ $^
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -rf *.UPG
|
||||
|
||||
list_targets:
|
||||
$(upgtool) -m ?; true # upgtool returns an error in this case, ignore it
|
||||
|
||||
do_fw_upgrade:
|
||||
ifdef NWZ_DEV
|
||||
@echo "Device: $(NWZ_DEV)"
|
||||
$(scsitool) $(NWZ_DEV) do_fw_upgrade
|
||||
else
|
||||
@echo "Please set NWZ_DEV to your dev. For example:"
|
||||
@echo "make do_fw_upgrade NWZ_DEV=/dev/sdx"
|
||||
endif
|
||||
59
utils/nwztools/scripts/README
Normal file
59
utils/nwztools/scripts/README
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
This directory contains various scripts that can be used to help development
|
||||
process on the Sony NWZ players. The proper way to use it is to use the Makefile.
|
||||
|
||||
In case of doubt, run
|
||||
make
|
||||
to get the up-to-date documentation.
|
||||
|
||||
*****************************
|
||||
Performing a firmware upgrade
|
||||
*****************************
|
||||
|
||||
To perform a firmware upgrade, first copy the firmware upgrade file to the root of
|
||||
the device, and make sure its named
|
||||
NW_WM_FW.UPG
|
||||
Another other name WILL NOT WORK. You've been warned.
|
||||
|
||||
DO NOT FORGET TO UNMOUNT YOUR DEVICE PROPERLY BEFORE DOING WHAT FOLLOWS
|
||||
|
||||
Once once, you need to tell the device to reboot in firmware upgrade mode.
|
||||
At the moment, we only support this operation in UMS/MSC (Mass Storage) mode. So if
|
||||
your device appears as a MTP device, go to the preference settings of your device
|
||||
and make sure your device is set to UMS/MSC or Auto.
|
||||
You need to identify the linux device associated with your device. There are
|
||||
plenty of tutorials on the net on how to do that, you can use mount or dmesg.
|
||||
Assuming the linux device corresponding to your player is
|
||||
/dev/sdx
|
||||
run AS ROOT OR USING SUDO
|
||||
make do_fw_upgrade NWZ_DEV=/dev/sdx
|
||||
|
||||
If everything goes well, the device should reboot and perform the firmware upgrade.
|
||||
|
||||
********************************
|
||||
Building a firmware upgrade that
|
||||
dumps important stuff
|
||||
********************************
|
||||
|
||||
In early development stage, the most useful thing you can do is to dump important
|
||||
stuff from your device:
|
||||
- dmesg and mount output
|
||||
- FU (firmware upgrade) initrd
|
||||
- root FS (file system)
|
||||
We carefully wrote a script that does the following. First make sure that your device
|
||||
has enough free space (at least 300MB to be safe). You need to know the model of
|
||||
your device to build this firmware upgrade. Once you known it, run
|
||||
make list_targets
|
||||
to list all available targets. For example if your targets is one of the
|
||||
NWZ-E460 series, the corresponding target is nwz-e46x.
|
||||
Once you have identified the target. Run
|
||||
make dump_rootfs NWZ_TARGET=nwz-exyz
|
||||
(replace nwz-exyz with your target)
|
||||
This command will produce a firmware upgrade file called
|
||||
dump_rootfs.upg
|
||||
|
||||
In order to run this firmware upgrade, you need to follows the instruction
|
||||
on how to perform a firmware upgrade.
|
||||
|
||||
When performing the firmware upgrade, the script will perform various operation
|
||||
and create several files. Once the "upgrade" is finish and the device has rebooted,
|
||||
you should find the files in the dump_rootfs/ directory at the root of your device.
|
||||
83
utils/nwztools/scripts/dump_rootfs.sh
Normal file
83
utils/nwztools/scripts/dump_rootfs.sh
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#!/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
|
||||
|
||||
#
|
||||
# This script dumps the root filesystem of the device and saves the resulting
|
||||
# in rootfs.tgz in the user partition.
|
||||
#
|
||||
|
||||
# 1) First we need to detect what is the user (aka contents) device. It is mounted
|
||||
# read-only at /contents during upgrade and the device is usually /dev/contents_part
|
||||
# The output of mount will look like this:
|
||||
# /dev/contents_part on /contents type ....
|
||||
CONTENTS="/contents"
|
||||
CONTENTS_PART=`mount | grep contents | awk '{ print $1 }'`
|
||||
DUMP_DIR="$CONTENTS/dump_rootfs"
|
||||
|
||||
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
|
||||
# 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
|
||||
then
|
||||
lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,7 "ERROR: remount failed"
|
||||
sleep 10
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 3) Dump various files
|
||||
lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,8 "Dumping various files"
|
||||
|
||||
mkdir -p "$DUMP_DIR"
|
||||
mount 2>&1 >$DUMP_DIR/mount.txt
|
||||
dmesg 2>&1 >$DUMP_DIR/dmesg.txt
|
||||
mmcinfo map 2>&1 >$DUMP_DIR/mmcinfo_map.txt
|
||||
sysinfo 2>&1 >$DUMP_DIR/sysinfo.txt
|
||||
|
||||
# 4) Dump / (which is the FU initrd)
|
||||
# Don't forget to exclude contents, that would be useless
|
||||
# NOTE: this code assumes that CONTENTS is always at the root: /contents
|
||||
# NOTE: also exclude /sys because it makes tar stop earlier
|
||||
lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,9 "Dumping FU initrd..."
|
||||
LIST=""
|
||||
for entry in /*
|
||||
do
|
||||
# exclude contents
|
||||
if [ "$entry" != "$CONTENTS" -a "$entry" != "/sys" ]
|
||||
then
|
||||
LIST="$LIST $entry"
|
||||
fi
|
||||
done
|
||||
tar -cf $DUMP_DIR/fu_initrd.tar $LIST
|
||||
find / > $DUMP_DIR/fu_initrd.list
|
||||
lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,10 "Done."
|
||||
|
||||
# 5) Dump the root filesystem
|
||||
# Mount the root filesystem read-only and dump it
|
||||
lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,12 "Dumping rootfs..."
|
||||
ROOTFS_TMP_DIR=/tmp/rootfs
|
||||
mkdir $ROOTFS_TMP_DIR
|
||||
. /install_script/constant.txt
|
||||
if ! mount -t ext2 -o ro $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR
|
||||
then
|
||||
lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,13 "ERROR: cannot mount rootfs"
|
||||
else
|
||||
tar -cf $DUMP_DIR/rootfs.tar $ROOTFS_TMP_DIR
|
||||
umount $ROOTFS_TMP_DIR
|
||||
lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,13 "Done."
|
||||
fi
|
||||
|
||||
# 4) Success screen
|
||||
lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "Rebooting in 10 seconds."
|
||||
|
||||
sleep 10
|
||||
|
||||
sync
|
||||
|
||||
exit 0
|
||||
|
|
@ -58,24 +58,6 @@ enum keysig_search_method_t g_keysig_search = KEYSIG_SEARCH_NONE;
|
|||
{ cprintf(RED, str_bad); let_the_force_flow(__LINE__); } \
|
||||
else { cprintf(RED, str_ok); }
|
||||
|
||||
static void print_hex(void *p, int size, int unit)
|
||||
{
|
||||
uint8_t *p8 = p;
|
||||
uint16_t *p16 = p;
|
||||
uint32_t *p32 = p;
|
||||
for(int i = 0; i < size; i += unit, p8++, p16++, p32++)
|
||||
{
|
||||
if(i != 0 && (i % 16) == 0)
|
||||
printf("\n");
|
||||
if(unit == 1)
|
||||
printf(" %02x", *p8);
|
||||
else if(unit == 2)
|
||||
printf(" %04x", *p16);
|
||||
else
|
||||
printf(" %08x", *p32);
|
||||
}
|
||||
}
|
||||
|
||||
static void usage(void);
|
||||
|
||||
/* key and signature */
|
||||
|
|
@ -118,8 +100,10 @@ struct upg_entry_t
|
|||
|
||||
struct nwz_model_t g_model_list[] =
|
||||
{
|
||||
{ "nwz-e463", HAS_KAS | HAS_KEY | HAS_SIG | CONFIRMED, {"89d813f8f966efdebd9c9e0ea98156d2"}, "eb4431eb", "4f1d9cac" },
|
||||
{ "nwz-a86x", HAS_KEY | HAS_SIG, {""}, "c824e4e2", "7c262bb0" },
|
||||
{ "nwz-e46x", HAS_KAS | HAS_KEY | HAS_SIG | CONFIRMED, {"89d813f8f966efdebd9c9e0ea98156d2"}, "eb4431eb", "4f1d9cac" },
|
||||
{ "nwz-a86x", HAS_KAS | HAS_KEY | HAS_SIG | CONFIRMED, {"a7c4af6c28b8900a783f307c1ba538c5"}, "c824e4e2", "7c262bb0" },
|
||||
/* The following keys were obtained by brute forcing firmware upgrades,
|
||||
* someone with a device needs to confirm that they work */
|
||||
{ "nw-a82x", HAS_KEY | HAS_SIG, {""}, "4df06482", "07fa0b6e" },
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue