diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-10-15 10:34:30 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-10-15 13:31:28 -0400 |
commit | 82787709bd0c943e5d0d2b4fce7e8464a0de0edb (patch) | |
tree | 86fed437439c7991a4663448bd9626e6997fc345 | |
parent | 0cde20fadb9aeeb8e724d76e51bce7580296621b (diff) | |
download | rockbox-82787709bd0c943e5d0d2b4fce7e8464a0de0edb.tar.gz rockbox-82787709bd0c943e5d0d2b4fce7e8464a0de0edb.zip |
update the hibi patcher script to handle initial m3k stuff
Change-Id: I63ed8443952888da3dafb23ff6e7daf9c7aca574
-rw-r--r-- | firmware/drivers/audio/fiiolinux_codec.c | 9 | ||||
-rwxr-xr-x | tools/hiby_patcher.pl | 267 |
2 files changed, 165 insertions, 111 deletions
diff --git a/firmware/drivers/audio/fiiolinux_codec.c b/firmware/drivers/audio/fiiolinux_codec.c index 894d16dae1..44ebdd092c 100644 --- a/firmware/drivers/audio/fiiolinux_codec.c +++ b/firmware/drivers/audio/fiiolinux_codec.c | |||
@@ -69,10 +69,11 @@ void audiohw_preinit(void) | |||
69 | { | 69 | { |
70 | alsa_controls_init(); | 70 | alsa_controls_init(); |
71 | hw_open(); | 71 | hw_open(); |
72 | // set 19/'ADC Mux' 0 | 72 | // NOTE: |
73 | // set 4/'Digital Capture Volume' 0 | 73 | // Of the exported controls, only these do anything: |
74 | // set 6/'Mic Volume' 0 | 74 | // 10 DACL Playback Volume |
75 | // set 11/'DACR Playback Volume' 0 (wtf?? vortex used 1, of used 0) | 75 | // 11 DACR Playback Volume |
76 | // 12 Low Mode Switch (see table 25 in datasheet, not simple..) | ||
76 | } | 77 | } |
77 | 78 | ||
78 | void audiohw_postinit(void) | 79 | void audiohw_postinit(void) |
diff --git a/tools/hiby_patcher.pl b/tools/hiby_patcher.pl index af98cfdafc..e8ade006b1 100755 --- a/tools/hiby_patcher.pl +++ b/tools/hiby_patcher.pl | |||
@@ -9,7 +9,7 @@ | |||
9 | # | 9 | # |
10 | # Hiby patcher Copyright (C) 2020 Solomon Peachy <pizza@shaftnet.org> | 10 | # Hiby patcher Copyright (C) 2020 Solomon Peachy <pizza@shaftnet.org> |
11 | # | 11 | # |
12 | # Licensed under the GNU GPLv2 (or newer) | 12 | # Licensed under the GNU GPLv2 (or later) |
13 | # | 13 | # |
14 | ################## | 14 | ################## |
15 | 15 | ||
@@ -29,6 +29,8 @@ my $rbbname = $ARGV[2]; | |||
29 | my $prefix = "/tmp"; # XXX mktmp | 29 | my $prefix = "/tmp"; # XXX mktmp |
30 | my $debug = 0; # Set to 1 to prevent cleaning up work dirs | 30 | my $debug = 0; # Set to 1 to prevent cleaning up work dirs |
31 | 31 | ||
32 | my $hiby = 1; # 1 for hibyplayer-style updates, 0 for ingenic updates | ||
33 | |||
32 | #### Let's get to work | 34 | #### Let's get to work |
33 | 35 | ||
34 | my @ubiopts; | 36 | my @ubiopts; |
@@ -42,6 +44,7 @@ if ($model eq 'rocker') { | |||
42 | @ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U"); | 44 | @ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U"); |
43 | } elsif ($model eq 'm3k') { | 45 | } elsif ($model eq 'm3k') { |
44 | @ubiopts = ("-e", "124KiB", "-c", "2048", "-m", "2048", "-j", "8192KiB", "-U"); | 46 | @ubiopts = ("-e", "124KiB", "-c", "2048", "-m", "2048", "-j", "8192KiB", "-U"); |
47 | $hiby = 0; | ||
45 | } else { | 48 | } else { |
46 | die ("Unknown hiby model: $model\n"); | 49 | die ("Unknown hiby model: $model\n"); |
47 | } | 50 | } |
@@ -52,69 +55,88 @@ my $isowork = "$prefix/iso.$uptname"; | |||
52 | my $rootfsdir = "$prefix/rootfs.$uptname"; | 55 | my $rootfsdir = "$prefix/rootfs.$uptname"; |
53 | my $ubiname; | 56 | my $ubiname; |
54 | my $ubinamenew; | 57 | my $ubinamenew; |
55 | |||
56 | |||
57 | my @sysargs; | ||
58 | |||
59 | |||
60 | ### Extract outer ISO9660 image | ||
61 | system("rm -Rf $isowork"); | ||
62 | mkdir($isowork) || die ("Can't create '$isowork'"); | ||
63 | @sysargs = ("7z", "x", "-aoa", "-o$isowork", $inname); | ||
64 | system(@sysargs); | ||
65 | |||
66 | ### figure out the rootfs image filenames | ||
67 | my $updatename; | 58 | my $updatename; |
68 | if ( -e "$isowork/UPDATE.TXT") { | ||
69 | $updatename = "$isowork/UPDATE.TXT"; | ||
70 | } elsif ( -e "$isowork/update.txt") { | ||
71 | $updatename = "$isowork/update.txt"; | ||
72 | } | ||
73 | my $versionname; | 59 | my $versionname; |
74 | if ( -e "$isowork/VERSION.TXT") { | ||
75 | $versionname = "$isowork/VERSION.TXT"; | ||
76 | } elsif ( -e "$isowork/version.txt") { | ||
77 | $versionname = "$isowork/version.txt"; | ||
78 | } | ||
79 | 60 | ||
80 | open UPDATE, $updatename || die ("Can't open update.txt!");; | 61 | my @sysargs; |
62 | |||
63 | #### Extract OF image wrapper | ||
64 | if ($hiby) { | ||
65 | system("rm -Rf $isowork"); | ||
66 | mkdir($isowork) || die ("Can't create '$isowork'"); | ||
67 | @sysargs = ("7z", "x", "-aoa", "-o$isowork", $inname); | ||
68 | system(@sysargs); | ||
69 | |||
70 | ### figure out the rootfs image filenames | ||
71 | if ( -e "$isowork/UPDATE.TXT") { | ||
72 | $updatename = "$isowork/UPDATE.TXT"; | ||
73 | } elsif ( -e "$isowork/update.txt") { | ||
74 | $updatename = "$isowork/update.txt"; | ||
75 | } | ||
76 | if ( -e "$isowork/VERSION.TXT") { | ||
77 | $versionname = "$isowork/VERSION.TXT"; | ||
78 | } elsif ( -e "$isowork/version.txt") { | ||
79 | $versionname = "$isowork/version.txt"; | ||
80 | } | ||
81 | 81 | ||
82 | my $rootfs_found = 0; | 82 | open UPDATE, $updatename || die ("Can't open update.txt!");; |
83 | while (<UPDATE>) { | 83 | |
84 | chomp; | 84 | my $rootfs_found = 0; |
85 | if ($rootfs_found) { | 85 | while (<UPDATE>) { |
86 | if (/file_path=(.*)/) { | 86 | chomp; |
87 | $ubiname = basename($1); | 87 | if ($rootfs_found) { |
88 | last; | 88 | if (/file_path=(.*)/) { |
89 | $ubiname = basename($1); | ||
90 | last; | ||
91 | } | ||
92 | } else { | ||
93 | if (/rootfs/) { | ||
94 | $rootfs_found = 1; | ||
89 | } | 95 | } |
90 | } else { | ||
91 | if (/rootfs/) { | ||
92 | $rootfs_found = 1; | ||
93 | } | 96 | } |
94 | } | 97 | } |
95 | } | 98 | close UPDATE; |
96 | close UPDATE; | ||
97 | 99 | ||
98 | if (! -e "$isowork/$ubiname") { | 100 | if (! -e "$isowork/$ubiname") { |
99 | $ubiname =~ tr/[a-z]/[A-Z]/; | 101 | $ubiname =~ tr/[a-z]/[A-Z]/; |
100 | die("can't locate rootfs image ($ubiname)") if (! -e "$isowork/$ubiname"); | 102 | die("can't locate rootfs image ($ubiname)") if (! -e "$isowork/$ubiname"); |
101 | } | 103 | } |
104 | |||
105 | $ubiname = "$isowork/$ubiname"; | ||
106 | } else { | ||
107 | # Deconstruct original file | ||
108 | # TODO. Rough sequence: | ||
109 | |||
110 | # unzip m3k.fw | ||
111 | # for x in recovery-update/nand/update*zip ; do unzip -o $x ; done | ||
112 | # rm -Rf *zip META-INF | ||
113 | # parse update000/update.xml: | ||
114 | # <name>system.ubi</name> | ||
115 | # <type>ubifs</type> | ||
116 | # <size>###</size> ## total size, bytes | ||
117 | # <chunksize>##</chunksize> ## max for each one I guess [optional, 0 def] | ||
118 | # <chunkcount>##</chunkcount> ## add up [optional, 1 def] | ||
119 | # | ||
120 | # * Track name, start block | ||
121 | # * when we find the first ubifs block, record name, start block #, end block # | ||
122 | # | ||
123 | # alternatively, cat update*/$name* > combined.ubi | ||
102 | 124 | ||
103 | $ubiname = "$isowork/$ubiname"; | 125 | $ubiname = "$uptname"; |
126 | } | ||
104 | 127 | ||
105 | ### Extract RootFS | 128 | #### Extract RootFS |
106 | system("rm -Rf $rootfsdir"); | 129 | system("rm -Rf $rootfsdir"); |
107 | mkdir($rootfsdir) || die ("Can't create '$rootfsdir'"); | 130 | mkdir($rootfsdir) || die ("Can't create '$rootfsdir'"); |
108 | 131 | ||
109 | @sysargs = ("ubireader_extract_files", "-k", "-o", $rootfsdir, $ubiname); | 132 | @sysargs = ("ubireader_extract_files", "-k", "-o", $rootfsdir, $ubiname); |
110 | system(@sysargs); | 133 | system(@sysargs); |
111 | 134 | ||
112 | # exit(0); | ||
113 | ### Mangle RootFS | ||
114 | |||
115 | # Generate rb_bootloader.sh | ||
116 | my $rbbasename = basename($rbbname); | 135 | my $rbbasename = basename($rbbname); |
117 | my $bootloader_sh = | 136 | |
137 | #### Mangle RootFS | ||
138 | if ($hiby) { | ||
139 | my $bootloader_sh = | ||
118 | "#!/bin/sh | 140 | "#!/bin/sh |
119 | 141 | ||
120 | #mkdir -p /mnt/sd_0 | 142 | #mkdir -p /mnt/sd_0 |
@@ -135,21 +157,21 @@ killall -9 $rbbasename &>/dev/null | |||
135 | sleep 1 | 157 | sleep 1 |
136 | reboot | 158 | reboot |
137 | "; | 159 | "; |
138 | open FILE, ">$rootfsdir/usr/bin/hiby_player.sh" || die ("can't write bootloader script!"); | 160 | open FILE, ">$rootfsdir/usr/bin/hiby_player.sh" || die ("can't write bootloader script!"); |
139 | print FILE $bootloader_sh; | 161 | print FILE $bootloader_sh; |
140 | close FILE; | 162 | close FILE; |
141 | chmod 0755, "$rootfsdir/usr/bin/hiby_player.sh"; | 163 | chmod 0755, "$rootfsdir/usr/bin/hiby_player.sh"; |
142 | 164 | ||
143 | # Auto mount/unmount external USB drives and SD card | 165 | # Auto mount/unmount external USB drives and SD card |
144 | open FILE, ">>$rootfsdir/etc/mdev.conf" || die ("can't access mdev conf!"); | 166 | open FILE, ">>$rootfsdir/etc/mdev.conf" || die ("can't access mdev conf!"); |
145 | print FILE "sd[a-z][0-9]+ 0:0 664 @ /etc/rb_inserting.sh\n"; | 167 | print FILE "sd[a-z][0-9]+ 0:0 664 @ /etc/rb_inserting.sh\n"; |
146 | print FILE "mmcblk[0-9]p[0-9] 0:0 664 @ /etc/rb_inserting.sh\n"; | 168 | print FILE "mmcblk[0-9]p[0-9] 0:0 664 @ /etc/rb_inserting.sh\n"; |
147 | print FILE "mmcblk[0-9] 0:0 664 @ /etc/rb_inserting.sh\n"; | 169 | print FILE "mmcblk[0-9] 0:0 664 @ /etc/rb_inserting.sh\n"; |
148 | print FILE "sd[a-z] 0:0 664 \$ /etc/rb_removing.sh"; | 170 | print FILE "sd[a-z] 0:0 664 \$ /etc/rb_removing.sh"; |
149 | print FILE "mmcblk[0-9] 0:0 664 \$ /etc/rb_removing.sh\n"; | 171 | print FILE "mmcblk[0-9] 0:0 664 \$ /etc/rb_removing.sh\n"; |
150 | close FILE; | 172 | close FILE; |
151 | 173 | ||
152 | my $insert_sh = ' | 174 | my $insert_sh = ' |
153 | #!/bin/sh | 175 | #!/bin/sh |
154 | # $MDEV is the device | 176 | # $MDEV is the device |
155 | 177 | ||
@@ -169,25 +191,51 @@ fi | |||
169 | mount $MDEV $MNT_POINT | 191 | mount $MDEV $MNT_POINT |
170 | '; | 192 | '; |
171 | 193 | ||
172 | open FILE, ">$rootfsdir/etc/rb_inserting.sh" || die("can't write hotplug helpers!"); | 194 | open FILE, ">$rootfsdir/etc/rb_inserting.sh" || die("can't write hotplug helpers!"); |
173 | print FILE $insert_sh; | 195 | print FILE $insert_sh; |
174 | close FILE; | 196 | close FILE; |
175 | chmod 0755, "$rootfsdir/etc/rb_inserting.sh"; | 197 | chmod 0755, "$rootfsdir/etc/rb_inserting.sh"; |
176 | 198 | ||
177 | my $remove_sh = ' | 199 | my $remove_sh = ' |
178 | #!/bin/sh | 200 | #!/bin/sh |
179 | # $MDEV is the device | 201 | # $MDEV is the device |
180 | sync; | 202 | sync; |
181 | unmount -f $MDEV; | 203 | unmount -f $MDEV; |
182 | '; | 204 | '; |
183 | 205 | ||
184 | open FILE, ">$rootfsdir/etc/rb_removing.sh" || die("can't write hotplug helpers!"); | 206 | open FILE, ">$rootfsdir/etc/rb_removing.sh" || die("can't write hotplug helpers!"); |
185 | print FILE $remove_sh; | 207 | print FILE $remove_sh; |
186 | close FILE; | 208 | close FILE; |
187 | chmod 0755, "$rootfsdir/etc/rb_removing.sh"; | 209 | chmod 0755, "$rootfsdir/etc/rb_removing.sh"; |
188 | 210 | ||
189 | # Deal with a nasty race condition in automount scripts | 211 | # Deal with a nasty race condition in automount scripts |
190 | system("perl -pni -e 's/rm -rf/#rm -Rf/;' $rootfsdir/etc/init.d/S50sys_server"); | 212 | system("perl -pni -e 's/rm -rf/#rm -Rf/;' $rootfsdir/etc/init.d/S50sys_server"); |
213 | } else { | ||
214 | my $bootloader_sh = | ||
215 | "#!/bin/sh | ||
216 | |||
217 | killall $rbbasename &>/dev/null | ||
218 | killall -9 $rbbasename &>/dev/null | ||
219 | |||
220 | source /etc/profile | ||
221 | |||
222 | # Try to save the flash | ||
223 | if ! [ -L /data/userfs/app.log ] ; then | ||
224 | rm -f /data/userfs/app.log | ||
225 | ln -s /dev/null /data/userfs/app.log | ||
226 | fi | ||
227 | |||
228 | # Rockbox launcher! | ||
229 | /usr/bin/$rbbasename | ||
230 | sleep 1 | ||
231 | reboot | ||
232 | "; | ||
233 | open FILE, ">$rootfsdir/usr/project/bin/play.sh" || die ("can't write bootloader script!"); | ||
234 | print FILE $bootloader_sh; | ||
235 | close FILE; | ||
236 | chmod 0755, "$rootfsdir/usr/project/bin/play.sh"; | ||
237 | |||
238 | } | ||
191 | 239 | ||
192 | # Copy bootloader over | 240 | # Copy bootloader over |
193 | @sysargs=("cp", "$rbbname", "$rootfsdir/usr/bin/$rbbasename"); | 241 | @sysargs=("cp", "$rbbname", "$rootfsdir/usr/bin/$rbbasename"); |
@@ -201,49 +249,54 @@ system(@sysargs); | |||
201 | 249 | ||
202 | system("rm -Rf $rootfsdir") if (!$debug); | 250 | system("rm -Rf $rootfsdir") if (!$debug); |
203 | 251 | ||
204 | # md5sum | 252 | if ($hiby) { |
205 | my $md5 = `md5sum $ubinamenew | cut -d ' ' -f 1`; | 253 | # md5sum |
254 | my $md5 = `md5sum $ubinamenew | cut -d ' ' -f 1`; | ||
206 | 255 | ||
207 | system("mv $ubinamenew $ubiname"); | 256 | system("mv $ubinamenew $ubiname"); |
208 | 257 | ||
209 | ### Generate new ISO9660 update image | 258 | ### Generate new ISO9660 update image |
210 | 259 | ||
211 | # Correct md5sum for new rootfs image | 260 | # Correct md5sum for new rootfs image |
212 | open UPDATE, "<$updatename" || die ("Can't open update.txt!"); | 261 | open UPDATE, "<$updatename" || die ("Can't open update.txt!"); |
213 | open UPDATEO, ">$updatename.new" || die ("Can't open update.txt!"); | 262 | open UPDATEO, ">$updatename.new" || die ("Can't open update.txt!"); |
214 | 263 | ||
215 | $rootfs_found = 0; | 264 | my $rootfs_found = 0; |
216 | while (<UPDATE>) { | 265 | while (<UPDATE>) { |
217 | if ($rootfs_found) { | 266 | if ($rootfs_found) { |
218 | if (s/md5=.*/md5=$md5/) { | 267 | if (s/md5=.*/md5=$md5/) { |
219 | $rootfs_found=0; | 268 | $rootfs_found=0; |
220 | } | 269 | } |
221 | } else { | 270 | } else { |
222 | if (/rootfs/) { | 271 | if (/rootfs/) { |
223 | $rootfs_found = 1; | 272 | $rootfs_found = 1; |
273 | } | ||
224 | } | 274 | } |
275 | print UPDATEO; | ||
225 | } | 276 | } |
226 | print UPDATEO; | 277 | close UPDATE; |
227 | } | 278 | close UPDATEO; |
228 | close UPDATE; | 279 | system("mv $updatename.new $updatename"); |
229 | close UPDATEO; | ||
230 | system("mv $updatename.new $updatename"); | ||
231 | 280 | ||
232 | # Fix up version text, if needed (AGPTek Rocker 1.31 beta) | 281 | # Fix up version text, if needed (AGPTek Rocker 1.31 beta) |
233 | 282 | ||
234 | open UPDATE, "<$versionname" || die ("Can't open version.txt!");; | 283 | open UPDATE, "<$versionname" || die ("Can't open version.txt!");; |
235 | open UPDATEO, ">$versionname.new" || die ("Can't open version.txt!"); | 284 | open UPDATEO, ">$versionname.new" || die ("Can't open version.txt!"); |
236 | 285 | ||
237 | while (<UPDATE>) { | 286 | while (<UPDATE>) { |
238 | s/ver=1\.0\.0\.0/ver=2018-10-07T00:00:00+08:00/; | 287 | s/ver=1\.0\.0\.0/ver=2018-10-07T00:00:00+08:00/; |
239 | print UPDATEO; | 288 | print UPDATEO; |
240 | } | 289 | } |
241 | 290 | ||
242 | close UPDATE; | 291 | close UPDATE; |
243 | close UPDATEO; | 292 | close UPDATEO; |
244 | system("mv $versionname.new $versionname"); | 293 | system("mv $versionname.new $versionname"); |
245 | 294 | ||
246 | @sysargs = ("mkisofs", "-volid", "CDROM", "-o", $uptnamenew, $isowork); | 295 | @sysargs = ("mkisofs", "-volid", "CDROM", "-o", $uptnamenew, $isowork); |
247 | system(@sysargs); | 296 | system(@sysargs); |
248 | 297 | ||
249 | system("rm -Rf $isowork") if (!$debug); | 298 | system("rm -Rf $isowork") if (!$debug); |
299 | } else { | ||
300 | # Reconstruct fiio/ingenic firmware update image | ||
301 | # very TODO | ||
302 | } | ||