summaryrefslogtreecommitdiffstats
path: root/tools/hiby_patcher.pl
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-10-08 09:47:40 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-10-11 16:37:17 -0400
commit2a471e288c16b91a7186a60b3fb84dd55a494c7a (patch)
tree3e746212c5fa69b59f61d19b6e29d11aa8a5e31b /tools/hiby_patcher.pl
parent5efaa9ef8073bb216e3dcdbb4476f2fa7c672b76 (diff)
downloadrockbox-2a471e288c16b91a7186a60b3fb84dd55a494c7a.tar.gz
rockbox-2a471e288c16b91a7186a60b3fb84dd55a494c7a.zip
New port: AIGO EROS Q / EROS K
The Q and K have a slightly different case, but the hardware under the shell is completely identical. These models are rebadged versions: * Hifiwalker H2 (== Q) * AGPTek H3 (== K) * Surfans F20 (== K) Other notes: * Significant improvements in the shared Hiby-platform launcher/loader * SD card can theoretically be hot-swapped now * Support external USB mass storage! * Some consolidation of Hiby-platform targets * Some consolidation of plugin keymaps Todo/known issues: * Keymaps need to be gone over properly * Convert to HAVE_SCROLLWHEEL? Change-Id: I5a8a4f22c38a5b69392ca7c0a8ad8c4e07d9523c
Diffstat (limited to 'tools/hiby_patcher.pl')
-rwxr-xr-xtools/hiby_patcher.pl77
1 files changed, 70 insertions, 7 deletions
diff --git a/tools/hiby_patcher.pl b/tools/hiby_patcher.pl
index 9c45ce6dd3..86b8ad3d3f 100755
--- a/tools/hiby_patcher.pl
+++ b/tools/hiby_patcher.pl
@@ -38,6 +38,10 @@ if ($model eq 'rocker') {
@ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U");
} elsif ($model eq 'x20') {
@ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U");
+} elsif ($model eq 'eros_q') {
+ @ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U");
+} elsif ($model eq 'm3k') {
+ @ubiopts = ("-e", "124KiB", "-c", "2048", "-m", "2048", "-j", "8192KiB", "-U");
} else {
die ("Unknown hiby model: $model\n");
}
@@ -81,7 +85,6 @@ while (<UPDATE>) {
if ($rootfs_found) {
if (/file_path=(.*)/) {
$ubiname = basename($1);
- $ubiname =~ tr/[a-z]/[A-Z]/;
last;
}
} else {
@@ -92,7 +95,11 @@ while (<UPDATE>) {
}
close UPDATE;
-die("can't locate rootfs image") if (! -e "$isowork/$ubiname");
+if (! -e "$isowork/$ubiname") {
+ $ubiname =~ tr/[a-z]/[A-Z]/;
+ die("can't locate rootfs image ($ubiname)") if (! -e "$isowork/$ubiname");
+}
+
$ubiname = "$isowork/$ubiname";
### Extract RootFS
@@ -102,6 +109,7 @@ mkdir($rootfsdir) || die ("Can't create '$rootfsdir'");
@sysargs = ("ubireader_extract_files", "-k", "-o", $rootfsdir, $ubiname);
system(@sysargs);
+# exit(0);
### Mangle RootFS
# Generate rb_bootloader.sh
@@ -109,19 +117,74 @@ my $rbbasename = basename($rbbname);
my $bootloader_sh =
"#!/bin/sh
-mount /dev/mmcblk0 /mnt/sd_0 &>/dev/null || \
-mount /dev/mmcblk0p1 /mnt/sd_0 &>/dev/null
+#mkdir -p /mnt/sd_0
+#
+#mount /dev/mmcblk0 /mnt/sd_0 &>/dev/null || \
+#mount /dev/mmcblk0p1 /mnt/sd_0 &>/dev/null
+
+killall hiby_player &>/dev/null
+killall -9 hiby_player &>/dev/null
+
+killall $rbbasename &>/dev/null
+killall -9 $rbbasename &>/dev/null
-killall $rbbasename
-killall -9 $rbbasename
+# /etc/init.d/K90adb start
+# Rockbox launcher!
/usr/bin/$rbbasename
sleep 1
reboot
- ";
+";
open FILE, ">$rootfsdir/usr/bin/hiby_player.sh" || die ("can't write bootloader script!");
print FILE $bootloader_sh;
close FILE;
+chmod 0755, "$rootfsdir/usr/bin/hiby_player.sh";
+
+# Auto mount/unmount external USB drives
+open FILE, ">>$rootfsdir/etc/mdev.conf" || die ("can't access mdev conf!");
+print FILE "sd[a-z][0-9]+ 0:0 664 @ /etc/rb_inserting.sh\n";
+print FILE "mmcblk[0-9]p[0-9] 0:0 664 @ /etc/rb_inserting.sh\n";
+print FILE "mmcblk[0-9] 0:0 664 @ /etc/rb_inserting.sh\n";
+print FILE "sd[a-z] 0:0 664 \$ /etc/rb_removing.sh";
+print FILE "mmcblk[0-9] 0:0 664 \$ /etc/rb_removing.sh\n";
+close FILE;
+
+my $insert_sh = '
+#!/bin/sh
+# $MDEV is the device
+
+case $MDEV in
+ mmc*)
+ MNT_POINT=/mnt/sd_0
+ ;;
+ sd*)
+ MNT_POINT=/mnt/sd_0/USB
+ ;;
+esac
+
+if [ ! -d $MNT_POINT ];then
+ mkdir $MNT_POINT
+fi
+
+mount $MDEV $MNT_POINT
+';
+
+open FILE, ">$rootfsdir/etc/rb_inserting.sh" || die("can't write hotplug helpers!");
+print FILE $insert_sh;
+close FILE;
+chmod 0755, "$rootfsdir/etc/rb_inserting.sh";
+
+my $remove_sh = '
+#!/bin/sh
+# $MDEV is the device
+sync;
+unmount -f $MDEV;
+';
+
+open FILE, ">$rootfsdir/etc/rb_removing.sh" || die("can't write hotplug helpers!");
+print FILE $remove_sh;
+close FILE;
+chmod 0755, "$rootfsdir/etc/rb_removing.sh";
# Copy bootloader over
@sysargs=("cp", "$rbbname", "$rootfsdir/usr/bin/$rbbasename");