22 July, 2016

An Annoying Week With Allwinner

Many months ago, I got an Allwinner A33 Q8H tablet, a BrightTab, from Ollie's Bargain Outlet.  I do not know why, but one day a couple of months ago, it would not authenticate with Google no matter what I did (wipe all the tablet's data, etc.).  I'm guessing the firmware that was on it got either obsoleted or blacklisted (it would fail more or less immediately).

Earlier this week, since my Nexus 7 has developed distorted audio, I decided that I'm going to try to revive the Google functionality on this BrightTab since it's not particularly useful to me w/o Google cloud services.  In an attempt to correct this authentication failure, I copied some .apk and .odex files over from my Nexus 7.  Except I had one fatal procedural flaw: I did not back up one of the BrightTab's original .apk's in /system/priv-app .  And since the ones for the Nex7 did not work at all with this Android, it got into a bootloop, basically an unrecoverable one (since I did not have any of the original firmware anywhere), with essential processes dying over and over again.

Unfortunately, I was in for a rude awakening about Allwinner.  They seem to have implemented fastboot, but ultimately, it's not all that useful.  Most Androids, you can take partition files and flash them from fastboot.  Buuuuuuut.....Allwinner decided to go their own way, and create a whole different way of packaging firmware, one giant image lump (which apparently contains boot0, uboot, the bootloader, recovery, and system, judging from the messages which their flashing tool puts out on the stdout/stderr).

The first hurdle is, of course, that the majority of readily extant tools is written to be run on Microsoft (ugh).  Not knowing what effect these things would have on WinXP, I decided to run my WinXP VirtualBox, making a snapshot before installing anything "foreign."  This was good for about a day of hacking around, because unfortunately, this goofball of a tablet is not recognized by USB drivers, even ones that are supposed to be "universal."  Some of the Allwinner-specific tools even have drivers packaged with them, but this VM didn't seem to recognize the tablet when physically then logically connected (would always pop up the "new hardware found, please install a driver for it" dialogs).  In retrospect, one of the problems was that the tablet wasn't even being put into the correct mode (I guess similar to Samsung's download mode), possibly due to me not knowing how to do that/poor documentation.  It seemed like the instructions were wanting to do their deeds through ADB, which I knew was active because i could see the processes which were dying with logcat. Eventually I came across "PhoenixCard," which is a utility to prepare microSD cards for firmware flashing.

Cleverly, Allwinner does seem to have some sort of provision for booting from microSD cards, a feature lacking on a lot of other tablets.  That's particularly handy when you're in a boot loop and all the firmware writing tools you can find can't seem to find your tablet on USB.  But it is a really tedious way to go through several iterations of trying things.

The second hurdle was that BrightTab does not publish their firmware anywhere.  At least for the Pandigital I had, a .zip file which I could flash from recovery was available for download from Pandigital's site, so that any time my tablet's Android got corrupted (and it did, many times, before it died for good) I could reboot into recovery and reflash the stock firmware.  Also, the great pleasure of Nexus devices is that the factory images are readily available from Google's site.  There are several Allwinner boards with different ARM CPUs each, each with dozens and dozens of firmware variations for each processor (in my case, an A33).  Thankfully, Google searching eventually led me to a blogger who has collected links to a lot of them.  These pages may be in Spanish, but heck, with my 4 years of high school classes I knew most of the words used, and Google Translate helped with the rest.

The third hurdle was, given these dozens of firmware files, which one would work for my particular tablet?  The first blob I downloaded actually was pointed to by XDA-Developers, a trusted Android site.  I stuck it on a microSD card with PhoenixCard, it was accepted and flashed by the tablet, but after booting, the touch coordinates were way off, and I could not even activate the "continue" button after sliding the chooser to US English.  So, I started going down the huge-ish list of links to ROMs, looking for ones which indicated the proper size (in my case, 800x480).

The next breakthrough was finding Linux tools on Allwinner's wiki and Git repository.  This is in the form of source code for a USB kernel module and their flashing utility, LiveSuit.  (Seriously...it's "LiveSuit," like clothing.  It's not missing an "e;" I would have called it "LiveSuite," but apparently Allwinner wouldn't.)  And the breakthrough right after that was in the very explicit on-screen instructions for LiveSuit: you have to disconnect and turn off your tablet, hold a key other than power as you plug USB in, and then press power many times (they suggest 10,, but it seems the tablet may come alive to LiveSuit in fewer than 10 presses).  This apparently wakes up the boot code in the tablet to go into a special mode to accept ROMs. Now that I think of it, it's something like Apple's DFU mode, except the screen stays off.  Yay!  There was no more need to keep Windows XP in VirtualBox booted!

Another hurdle to endure was that a lot of these blobs are hosted on freemium download hosting sites.  Sure, give them your credit card number, and for varying amounts for various terms (one month, six months, a year, etc.) you can log in and have "gold member" access, which amounts to faster data rates and no wait for the link to appear.  Me being the cheap (and currently unemployed) type, I had to endure one minute countdowns, CAPTCHAs, and approximately DS-1 rates (roughly 180KBytes/sec).  Since these files are considerable (maybe at least 300M), they took plenty of time to come across, and the site had stream counting too (so you couldn't download more than one file at a time...unless of course you are a gold member).

At the point of getting native Linux flashing working, I had tried a couple of ROMs using PhoenixCard.  They ranged from not flashing (apparently a firmware image file either inconpatible with PhoenixCard or incompatible with my tablet) to flashing OK but being unusable.  But then, with the Linux kernel module loaded and better instructions on how to prepare the tablet for another ROM image download, also without needing to go through VirtualBox, the pace of trials picked up considerably.

One of the ROMs looked (and sounded) while booting almost exactly how it did after I got it from Ollie's...except the touchscreen didn't work.  bummer.  A couple of tries later, it booted OK, the touchscreen worked, but it was all in (as best I could tell) Arabic.  Actually, I found a YouTube video which explains the settings entries to look for to change any Android's language, and managed to switch it to English.  But then I thought...any time you go into recovery and wipe all data, you're going to have to muddle through changing to English.  So although the ROM seemed to be suitable, I plodded on to more ROMs.

Finally, I found an image that, when loaded and booted, it behaves much like the original firmware, except of course the Google stuff works.  I also spent about half the day today perfecting the tablet, such as installing SuperSU, copying over some of the shell environment from my Nexus 7, installing some applications and generally customizing it.

As usual though, it wasn't necessarily all the annoyances of getting where I want to be, it was somewhat the fun of the challenge of the hacks needed to get there.  So it wasn't the adventure of the destination, but the adventure of how to get to the destination.

Direct all comments to Google+, preferably under the post about this blog entry.

English is a difficult enough language to interpret correctly when its rules are followed, let alone when the speaker or writer chooses not to follow those rules.

"Jeopardy!" replies and randomcaps really suck!

Please join one of the fastest growing social networks, Google+!