A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
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 dumps the root filesystem of the device and saves the resulting
11# in rootfs.tgz in the user partition.
12#
13
14# 1) First we need to detect what is the user (aka contents) device. It is mounted
15# read-only at /contents during upgrade and the device is usually /dev/contents_part
16# The output of mount will look like this:
17# /dev/contents_part on /contents type ....
18CONTENTS="/contents"
19CONTENTS_PART=`mount | grep contents | awk '{ print $1 }'`
20DUMP_DIR="$CONTENTS/dump_rootfs"
21
22lcdmsg -c -f /usr/local/bin/font_08x12.bmp -l 0,3 "Contents partition:\n$CONTENTS_PART"
23
24# 2) We need to remount the contents partition in read-write mode be able to
25# write something on it
26lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,6 "Remount $CONTENTS rw"
27if ! mount -o remount,rw $CONTENTS_PART $CONTENTS
28then
29 lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,7 "ERROR: remount failed"
30 sleep 10
31 exit 0
32fi
33
34# 3) Dump various files
35lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,8 "Dumping various files"
36
37mkdir -p "$DUMP_DIR"
38mount 2>&1 >$DUMP_DIR/mount.txt
39dmesg 2>&1 >$DUMP_DIR/dmesg.txt
40mmcinfo map 2>&1 >$DUMP_DIR/mmcinfo_map.txt
41sysinfo 2>&1 >$DUMP_DIR/sysinfo.txt
42
43# 4) Dump / (which is the FU initrd)
44# Don't forget to exclude contents, that would be useless
45# NOTE: this code assumes that CONTENTS is always at the root: /contents
46# NOTE: also exclude /sys because it makes tar stop earlier
47lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,9 "Dumping FU initrd..."
48LIST=""
49for entry in /*
50do
51 # exclude contents
52 if [ "$entry" != "$CONTENTS" -a "$entry" != "/sys" ]
53 then
54 LIST="$LIST $entry"
55 fi
56done
57tar -cf $DUMP_DIR/fu_initrd.tar $LIST
58find / > $DUMP_DIR/fu_initrd.list
59lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,10 "Done."
60
61# 5) Dump the root filesystem
62# Mount the root filesystem read-only and dump it
63# NOTE some platforms use ext4 with a custom mount program
64# (/usr/local/bin/icx_mount.ext4), some probably use an mtd too
65lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,12 "Dumping rootfs..."
66ROOTFS_TMP_DIR=/tmp/rootfs
67mkdir $ROOTFS_TMP_DIR
68. /install_script/constant.txt
69
70# If there is an ext4 mounter, try it. Otherwise or on failure, try ext3 and
71# then ext2.
72# NOTE some platforms probably use an mtd and this might need some fixing
73if [ -e /usr/local/bin/icx_mount.ext4 ]; then
74 /usr/local/bin/icx_mount.ext4 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR
75else
76 false
77fi
78if [ "$?" != 0 ]; then
79 mount -t ext3 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR
80fi
81if [ "$?" != 0 ]; then
82 mount -t ext2 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR
83fi
84if [ "$?" != 0 ]; then
85 lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,13 "ERROR: cannot mount rootfs"
86else
87 tar -cf $DUMP_DIR/rootfs.tar $ROOTFS_TMP_DIR
88 umount $ROOTFS_TMP_DIR
89 lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,13 "Done."
90fi
91
92# 4) Success screen
93lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "Rebooting in 10 seconds."
94
95sleep 10
96
97sync
98
99exit 0