mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
update the hibi patcher script to handle initial m3k stuff
Change-Id: I63ed8443952888da3dafb23ff6e7daf9c7aca574
This commit is contained in:
parent
0cde20fadb
commit
82787709bd
2 changed files with 166 additions and 112 deletions
|
|
@ -69,10 +69,11 @@ void audiohw_preinit(void)
|
||||||
{
|
{
|
||||||
alsa_controls_init();
|
alsa_controls_init();
|
||||||
hw_open();
|
hw_open();
|
||||||
// set 19/'ADC Mux' 0
|
// NOTE:
|
||||||
// set 4/'Digital Capture Volume' 0
|
// Of the exported controls, only these do anything:
|
||||||
// set 6/'Mic Volume' 0
|
// 10 DACL Playback Volume
|
||||||
// set 11/'DACR Playback Volume' 0 (wtf?? vortex used 1, of used 0)
|
// 11 DACR Playback Volume
|
||||||
|
// 12 Low Mode Switch (see table 25 in datasheet, not simple..)
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_postinit(void)
|
void audiohw_postinit(void)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#
|
#
|
||||||
# Hiby patcher Copyright (C) 2020 Solomon Peachy <pizza@shaftnet.org>
|
# Hiby patcher Copyright (C) 2020 Solomon Peachy <pizza@shaftnet.org>
|
||||||
#
|
#
|
||||||
# Licensed under the GNU GPLv2 (or newer)
|
# Licensed under the GNU GPLv2 (or later)
|
||||||
#
|
#
|
||||||
##################
|
##################
|
||||||
|
|
||||||
|
|
@ -29,6 +29,8 @@ my $rbbname = $ARGV[2];
|
||||||
my $prefix = "/tmp"; # XXX mktmp
|
my $prefix = "/tmp"; # XXX mktmp
|
||||||
my $debug = 0; # Set to 1 to prevent cleaning up work dirs
|
my $debug = 0; # Set to 1 to prevent cleaning up work dirs
|
||||||
|
|
||||||
|
my $hiby = 1; # 1 for hibyplayer-style updates, 0 for ingenic updates
|
||||||
|
|
||||||
#### Let's get to work
|
#### Let's get to work
|
||||||
|
|
||||||
my @ubiopts;
|
my @ubiopts;
|
||||||
|
|
@ -42,6 +44,7 @@ if ($model eq 'rocker') {
|
||||||
@ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U");
|
@ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U");
|
||||||
} elsif ($model eq 'm3k') {
|
} elsif ($model eq 'm3k') {
|
||||||
@ubiopts = ("-e", "124KiB", "-c", "2048", "-m", "2048", "-j", "8192KiB", "-U");
|
@ubiopts = ("-e", "124KiB", "-c", "2048", "-m", "2048", "-j", "8192KiB", "-U");
|
||||||
|
$hiby = 0;
|
||||||
} else {
|
} else {
|
||||||
die ("Unknown hiby model: $model\n");
|
die ("Unknown hiby model: $model\n");
|
||||||
}
|
}
|
||||||
|
|
@ -52,35 +55,34 @@ my $isowork = "$prefix/iso.$uptname";
|
||||||
my $rootfsdir = "$prefix/rootfs.$uptname";
|
my $rootfsdir = "$prefix/rootfs.$uptname";
|
||||||
my $ubiname;
|
my $ubiname;
|
||||||
my $ubinamenew;
|
my $ubinamenew;
|
||||||
|
my $updatename;
|
||||||
|
my $versionname;
|
||||||
|
|
||||||
my @sysargs;
|
my @sysargs;
|
||||||
|
|
||||||
|
#### Extract OF image wrapper
|
||||||
|
if ($hiby) {
|
||||||
|
system("rm -Rf $isowork");
|
||||||
|
mkdir($isowork) || die ("Can't create '$isowork'");
|
||||||
|
@sysargs = ("7z", "x", "-aoa", "-o$isowork", $inname);
|
||||||
|
system(@sysargs);
|
||||||
|
|
||||||
### Extract outer ISO9660 image
|
### figure out the rootfs image filenames
|
||||||
system("rm -Rf $isowork");
|
if ( -e "$isowork/UPDATE.TXT") {
|
||||||
mkdir($isowork) || die ("Can't create '$isowork'");
|
|
||||||
@sysargs = ("7z", "x", "-aoa", "-o$isowork", $inname);
|
|
||||||
system(@sysargs);
|
|
||||||
|
|
||||||
### figure out the rootfs image filenames
|
|
||||||
my $updatename;
|
|
||||||
if ( -e "$isowork/UPDATE.TXT") {
|
|
||||||
$updatename = "$isowork/UPDATE.TXT";
|
$updatename = "$isowork/UPDATE.TXT";
|
||||||
} elsif ( -e "$isowork/update.txt") {
|
} elsif ( -e "$isowork/update.txt") {
|
||||||
$updatename = "$isowork/update.txt";
|
$updatename = "$isowork/update.txt";
|
||||||
}
|
}
|
||||||
my $versionname;
|
if ( -e "$isowork/VERSION.TXT") {
|
||||||
if ( -e "$isowork/VERSION.TXT") {
|
|
||||||
$versionname = "$isowork/VERSION.TXT";
|
$versionname = "$isowork/VERSION.TXT";
|
||||||
} elsif ( -e "$isowork/version.txt") {
|
} elsif ( -e "$isowork/version.txt") {
|
||||||
$versionname = "$isowork/version.txt";
|
$versionname = "$isowork/version.txt";
|
||||||
}
|
}
|
||||||
|
|
||||||
open UPDATE, $updatename || die ("Can't open update.txt!");;
|
open UPDATE, $updatename || die ("Can't open update.txt!");;
|
||||||
|
|
||||||
my $rootfs_found = 0;
|
my $rootfs_found = 0;
|
||||||
while (<UPDATE>) {
|
while (<UPDATE>) {
|
||||||
chomp;
|
chomp;
|
||||||
if ($rootfs_found) {
|
if ($rootfs_found) {
|
||||||
if (/file_path=(.*)/) {
|
if (/file_path=(.*)/) {
|
||||||
|
|
@ -92,29 +94,49 @@ while (<UPDATE>) {
|
||||||
$rootfs_found = 1;
|
$rootfs_found = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close UPDATE;
|
close UPDATE;
|
||||||
|
|
||||||
if (! -e "$isowork/$ubiname") {
|
if (! -e "$isowork/$ubiname") {
|
||||||
$ubiname =~ tr/[a-z]/[A-Z]/;
|
$ubiname =~ tr/[a-z]/[A-Z]/;
|
||||||
die("can't locate rootfs image ($ubiname)") if (! -e "$isowork/$ubiname");
|
die("can't locate rootfs image ($ubiname)") if (! -e "$isowork/$ubiname");
|
||||||
|
}
|
||||||
|
|
||||||
|
$ubiname = "$isowork/$ubiname";
|
||||||
|
} else {
|
||||||
|
# Deconstruct original file
|
||||||
|
# TODO. Rough sequence:
|
||||||
|
|
||||||
|
# unzip m3k.fw
|
||||||
|
# for x in recovery-update/nand/update*zip ; do unzip -o $x ; done
|
||||||
|
# rm -Rf *zip META-INF
|
||||||
|
# parse update000/update.xml:
|
||||||
|
# <name>system.ubi</name>
|
||||||
|
# <type>ubifs</type>
|
||||||
|
# <size>###</size> ## total size, bytes
|
||||||
|
# <chunksize>##</chunksize> ## max for each one I guess [optional, 0 def]
|
||||||
|
# <chunkcount>##</chunkcount> ## add up [optional, 1 def]
|
||||||
|
#
|
||||||
|
# * Track name, start block
|
||||||
|
# * when we find the first ubifs block, record name, start block #, end block #
|
||||||
|
#
|
||||||
|
# alternatively, cat update*/$name* > combined.ubi
|
||||||
|
|
||||||
|
$ubiname = "$uptname";
|
||||||
}
|
}
|
||||||
|
|
||||||
$ubiname = "$isowork/$ubiname";
|
#### Extract RootFS
|
||||||
|
|
||||||
### Extract RootFS
|
|
||||||
system("rm -Rf $rootfsdir");
|
system("rm -Rf $rootfsdir");
|
||||||
mkdir($rootfsdir) || die ("Can't create '$rootfsdir'");
|
mkdir($rootfsdir) || die ("Can't create '$rootfsdir'");
|
||||||
|
|
||||||
@sysargs = ("ubireader_extract_files", "-k", "-o", $rootfsdir, $ubiname);
|
@sysargs = ("ubireader_extract_files", "-k", "-o", $rootfsdir, $ubiname);
|
||||||
system(@sysargs);
|
system(@sysargs);
|
||||||
|
|
||||||
# exit(0);
|
|
||||||
### Mangle RootFS
|
|
||||||
|
|
||||||
# Generate rb_bootloader.sh
|
|
||||||
my $rbbasename = basename($rbbname);
|
my $rbbasename = basename($rbbname);
|
||||||
my $bootloader_sh =
|
|
||||||
|
#### Mangle RootFS
|
||||||
|
if ($hiby) {
|
||||||
|
my $bootloader_sh =
|
||||||
"#!/bin/sh
|
"#!/bin/sh
|
||||||
|
|
||||||
#mkdir -p /mnt/sd_0
|
#mkdir -p /mnt/sd_0
|
||||||
|
|
@ -135,21 +157,21 @@ killall -9 $rbbasename &>/dev/null
|
||||||
sleep 1
|
sleep 1
|
||||||
reboot
|
reboot
|
||||||
";
|
";
|
||||||
open FILE, ">$rootfsdir/usr/bin/hiby_player.sh" || die ("can't write bootloader script!");
|
open FILE, ">$rootfsdir/usr/bin/hiby_player.sh" || die ("can't write bootloader script!");
|
||||||
print FILE $bootloader_sh;
|
print FILE $bootloader_sh;
|
||||||
close FILE;
|
close FILE;
|
||||||
chmod 0755, "$rootfsdir/usr/bin/hiby_player.sh";
|
chmod 0755, "$rootfsdir/usr/bin/hiby_player.sh";
|
||||||
|
|
||||||
# Auto mount/unmount external USB drives and SD card
|
# Auto mount/unmount external USB drives and SD card
|
||||||
open FILE, ">>$rootfsdir/etc/mdev.conf" || die ("can't access mdev conf!");
|
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 "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]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 "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 "sd[a-z] 0:0 664 \$ /etc/rb_removing.sh";
|
||||||
print FILE "mmcblk[0-9] 0:0 664 \$ /etc/rb_removing.sh\n";
|
print FILE "mmcblk[0-9] 0:0 664 \$ /etc/rb_removing.sh\n";
|
||||||
close FILE;
|
close FILE;
|
||||||
|
|
||||||
my $insert_sh = '
|
my $insert_sh = '
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# $MDEV is the device
|
# $MDEV is the device
|
||||||
|
|
||||||
|
|
@ -169,25 +191,51 @@ fi
|
||||||
mount $MDEV $MNT_POINT
|
mount $MDEV $MNT_POINT
|
||||||
';
|
';
|
||||||
|
|
||||||
open FILE, ">$rootfsdir/etc/rb_inserting.sh" || die("can't write hotplug helpers!");
|
open FILE, ">$rootfsdir/etc/rb_inserting.sh" || die("can't write hotplug helpers!");
|
||||||
print FILE $insert_sh;
|
print FILE $insert_sh;
|
||||||
close FILE;
|
close FILE;
|
||||||
chmod 0755, "$rootfsdir/etc/rb_inserting.sh";
|
chmod 0755, "$rootfsdir/etc/rb_inserting.sh";
|
||||||
|
|
||||||
my $remove_sh = '
|
my $remove_sh = '
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# $MDEV is the device
|
# $MDEV is the device
|
||||||
sync;
|
sync;
|
||||||
unmount -f $MDEV;
|
unmount -f $MDEV;
|
||||||
';
|
';
|
||||||
|
|
||||||
open FILE, ">$rootfsdir/etc/rb_removing.sh" || die("can't write hotplug helpers!");
|
open FILE, ">$rootfsdir/etc/rb_removing.sh" || die("can't write hotplug helpers!");
|
||||||
print FILE $remove_sh;
|
print FILE $remove_sh;
|
||||||
close FILE;
|
close FILE;
|
||||||
chmod 0755, "$rootfsdir/etc/rb_removing.sh";
|
chmod 0755, "$rootfsdir/etc/rb_removing.sh";
|
||||||
|
|
||||||
# Deal with a nasty race condition in automount scripts
|
# Deal with a nasty race condition in automount scripts
|
||||||
system("perl -pni -e 's/rm -rf/#rm -Rf/;' $rootfsdir/etc/init.d/S50sys_server");
|
system("perl -pni -e 's/rm -rf/#rm -Rf/;' $rootfsdir/etc/init.d/S50sys_server");
|
||||||
|
} else {
|
||||||
|
my $bootloader_sh =
|
||||||
|
"#!/bin/sh
|
||||||
|
|
||||||
|
killall $rbbasename &>/dev/null
|
||||||
|
killall -9 $rbbasename &>/dev/null
|
||||||
|
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
# Try to save the flash
|
||||||
|
if ! [ -L /data/userfs/app.log ] ; then
|
||||||
|
rm -f /data/userfs/app.log
|
||||||
|
ln -s /dev/null /data/userfs/app.log
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Rockbox launcher!
|
||||||
|
/usr/bin/$rbbasename
|
||||||
|
sleep 1
|
||||||
|
reboot
|
||||||
|
";
|
||||||
|
open FILE, ">$rootfsdir/usr/project/bin/play.sh" || die ("can't write bootloader script!");
|
||||||
|
print FILE $bootloader_sh;
|
||||||
|
close FILE;
|
||||||
|
chmod 0755, "$rootfsdir/usr/project/bin/play.sh";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# Copy bootloader over
|
# Copy bootloader over
|
||||||
@sysargs=("cp", "$rbbname", "$rootfsdir/usr/bin/$rbbasename");
|
@sysargs=("cp", "$rbbname", "$rootfsdir/usr/bin/$rbbasename");
|
||||||
|
|
@ -201,19 +249,20 @@ system(@sysargs);
|
||||||
|
|
||||||
system("rm -Rf $rootfsdir") if (!$debug);
|
system("rm -Rf $rootfsdir") if (!$debug);
|
||||||
|
|
||||||
# md5sum
|
if ($hiby) {
|
||||||
my $md5 = `md5sum $ubinamenew | cut -d ' ' -f 1`;
|
# md5sum
|
||||||
|
my $md5 = `md5sum $ubinamenew | cut -d ' ' -f 1`;
|
||||||
|
|
||||||
system("mv $ubinamenew $ubiname");
|
system("mv $ubinamenew $ubiname");
|
||||||
|
|
||||||
### Generate new ISO9660 update image
|
### Generate new ISO9660 update image
|
||||||
|
|
||||||
# Correct md5sum for new rootfs image
|
# Correct md5sum for new rootfs image
|
||||||
open UPDATE, "<$updatename" || die ("Can't open update.txt!");
|
open UPDATE, "<$updatename" || die ("Can't open update.txt!");
|
||||||
open UPDATEO, ">$updatename.new" || die ("Can't open update.txt!");
|
open UPDATEO, ">$updatename.new" || die ("Can't open update.txt!");
|
||||||
|
|
||||||
$rootfs_found = 0;
|
my $rootfs_found = 0;
|
||||||
while (<UPDATE>) {
|
while (<UPDATE>) {
|
||||||
if ($rootfs_found) {
|
if ($rootfs_found) {
|
||||||
if (s/md5=.*/md5=$md5/) {
|
if (s/md5=.*/md5=$md5/) {
|
||||||
$rootfs_found=0;
|
$rootfs_found=0;
|
||||||
|
|
@ -224,26 +273,30 @@ while (<UPDATE>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print UPDATEO;
|
print UPDATEO;
|
||||||
}
|
}
|
||||||
close UPDATE;
|
close UPDATE;
|
||||||
close UPDATEO;
|
close UPDATEO;
|
||||||
system("mv $updatename.new $updatename");
|
system("mv $updatename.new $updatename");
|
||||||
|
|
||||||
# Fix up version text, if needed (AGPTek Rocker 1.31 beta)
|
# Fix up version text, if needed (AGPTek Rocker 1.31 beta)
|
||||||
|
|
||||||
open UPDATE, "<$versionname" || die ("Can't open version.txt!");;
|
open UPDATE, "<$versionname" || die ("Can't open version.txt!");;
|
||||||
open UPDATEO, ">$versionname.new" || die ("Can't open version.txt!");
|
open UPDATEO, ">$versionname.new" || die ("Can't open version.txt!");
|
||||||
|
|
||||||
while (<UPDATE>) {
|
while (<UPDATE>) {
|
||||||
s/ver=1\.0\.0\.0/ver=2018-10-07T00:00:00+08:00/;
|
s/ver=1\.0\.0\.0/ver=2018-10-07T00:00:00+08:00/;
|
||||||
print UPDATEO;
|
print UPDATEO;
|
||||||
|
}
|
||||||
|
|
||||||
|
close UPDATE;
|
||||||
|
close UPDATEO;
|
||||||
|
system("mv $versionname.new $versionname");
|
||||||
|
|
||||||
|
@sysargs = ("mkisofs", "-volid", "CDROM", "-o", $uptnamenew, $isowork);
|
||||||
|
system(@sysargs);
|
||||||
|
|
||||||
|
system("rm -Rf $isowork") if (!$debug);
|
||||||
|
} else {
|
||||||
|
# Reconstruct fiio/ingenic firmware update image
|
||||||
|
# very TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
close UPDATE;
|
|
||||||
close UPDATEO;
|
|
||||||
system("mv $versionname.new $versionname");
|
|
||||||
|
|
||||||
@sysargs = ("mkisofs", "-volid", "CDROM", "-o", $uptnamenew, $isowork);
|
|
||||||
system(@sysargs);
|
|
||||||
|
|
||||||
system("rm -Rf $isowork") if (!$debug);
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue