17 November 2017

How to root Nexus 7 (2012) and flash it to LineageOS, from Mac OSX

I've finally got fed up enough with the old Nexus 7 (2012) that we originally bought to let the kids play - it's never really worked properly, getting laggy every 5 minutes and running out of battery after an hour. The kids moved on to an iPad, so I "installed" this crappy tablet to the kitchen wall, hoping to use it for calendaring and podcasts, but it was still horrendously laggy. I've decided to give a chance to LineageOS (previously CyanogenMod) to see if it helps. I'd be interested to know if anybody else uses a tablet wall-mounted in their kitchen, and what apps they installed - at the moment I have Paprika, the BBC players and weather, and PodcastAddict.

Here are the full steps required for flashing - I write them here because some of these are at risk to disappear from the internet for good after the demise of CyanogenMod wiki.

Note: THIS WILL WIPE YOUR DEVICE, YOU WILL LOSE EVERYTHING THAT IS ON IT so first make backups etc etc.

First you need to install the Android tools. I recommend doing this with homebrew, install it if you don't have it yet (it's extremely useful in many many cases).
Then open a terminal on your mac and type:
  • brew tap caskroom/cask
  • brew tap caskroom/versions
  • brew cask install java8
  • brew cask install android-sdk
Enable Developer Mode on the tablet by tapping 7 times on the build number under Settings -> About tablet.
Back to Settings, tap on Developer Options and enable USB Debug mode and Stay Awake.
Go back to your mac terminal and type:
  • sudo adb start-server
This starts the android debugger server.
Connect the tablet with a real USB cable (beware charging-only cables! Those won't work.)
On the tablet screen, you should be prompted to authorize the device; do it.
Back to terminal:
  • adb reboot bootloader
once the device comes back in bootloader mode:
  • fastboot oem unlock
Accept the disclaimer on the tablet by clicking the power button when Yes is highlighted (you can move with the volume buttons).
If it doesn't reboot on its own, select Start (again with the power button). At this point you should see an unlocked pad at the bottom of the screen as Android loads.
Note: if you plan to flash another OS, there is no point in going through the whole setup at this point, skip as much as you can.
Re-enable Developer mode and USB Debugging.

At this point the machine is rooted. The following steps are necessary only if you want to install LineageOS or other hacks; at the very minimum, though, you should install Trimmer (fstrim) from the Play store and use it liberally. Anyway, on with the flashing...

Get the latest image for "grouper" from https://twrp.me/, and unzip it.
Back to the terminal:
  • cd folder/where/you/have/your-downloaded-image.img
  • fastboot flash recovery your-downloaded-image.img
  • adb reboot bootloader
At this point you have a custom recovery image with a bunch of nifty features that make it very easy to hack the device. Tap Wipe and select system, cache, and dalvik.
Get the image you want to install. I'm currently trying this but in general anything after CM10 / Android 4.1 may be on the slow side for the original Nexus. You probably want the Google Apps from opengapps.org - choose ARM / 7.1 and the Micro option. Save both the apps zip and the image zip in the same folder.
Back to Terminal, let's copy these files to the device:
  • cd folder/where/you/have/your/zips
  • adb push your-downloaded-image.zip /
  • adb push your-downloaded-gapps.zip /
On the tablet, in the recovery screen, select Install, tap on Install ZIP, then select the image file and install. Repeat for the gapps file. If gapps refuse to go in because of space constraints, download this file, rename it gapps-config.txt, then copy it to the device in the same location as the gapps zip:
  • adb push gapps-config.txt /
and try again to install the gapps image.
Reboot the tablet. You might have to re-enable developer mode and usb debugging.
Install the Trimmer (fstrim) app, which is absolutely necessary. Launch it and click Trim Now. Click on the settings icon and enable autotrim as frequently as possible. In fact, every time you install an app or write a bunch of files, before you launch the new app, open Trimmer and do a trim, or it will all get laggy again.
Another good app is Android SSH Server, although it's a bit old it still works fine and it's easy to configure. You just have to use the options -t -oHostKeyAlgorithms=+ssh-dss -p XXXXX (where XXXXX is the custom port configured in the app, Android won't allow the classic one) when connecting.


And that's it.

No comments:

Post a Comment