Tf700t

= Installing Gentoo Linux on Asus Transformer Infinity (TF700T) =

Since i bought the amazing Infinity (Asus TF700T) with the keyboard dock, i started wondering how to put a real OS on it, which is my beloved Gentoo.

Finally i managed to get to the point and achieve something usable.

In this wiki page i will be describing what i did and provide both instructions AND the final product.

Preliminary notes
A few preliminary notes.

You MUST have the keyboard dock, otherwise you must try to plugin some kind of USB keyboard, which i guess would be a pain to use. I have not tried bluetooth at the moment on Gentoo and the TF700T (it should work), but i guess getting to the point of pairing the keyboard would require the shitty on-screen keyboard, and X working, which still requires you to type a lot of stuff from command line before you can actually make it start automatically at boot.

I strongly recomand to install Gentoo on the microSD. The SD slot on the dock might work as well but do you trust yourself to never detach the dock itself? Or are you sure it will never happen by accident? If it does, well, at least a reboot + fsck is mandatory! Installing on the internal memory is also al option, but consider the wear and tear due to compilation! In this case you might want to move your portage build dir to the microSD.

The tables has only 1gb of ram. While it might seems a lot, and it surely was up to a few years ago, it's surprsingly small by today standards. Don't ask my wy Asus choose such a limited amount on a top-level device, just live with it. Couple it with the basic useless of swap space on this device: on the internal memory i strongly recomend to avoid, and on the microSD it's really a serial device, so putting swap on it causes the entire device to crawl as soon as it's being used. Given this considerations, i suggest a lightweight desktop like LXDE and memory saves wherever possible like don't run background services or memory-hogs.

Before the first linux boot
The Asus Infinity (TF700T) comes out of the box as an Android tablet, it's provided with android 4.2.1 or something similar but it is not so important because we want to install Linux on it, so these steps will provide information on how to enable dual boot on this device. You will need to do some steps on Android before starting with Linux.

Unlock and root
You must unlock your bootloader first, follow these instructions:

Go to this link: support page on Asus website, select OS Android and from utilities download the "Unlock Device App: Unlock boot loader". Now install, follow directions and enjoy your boot-unlocked tablet (yes, this will void your warranty, you have been warned).

For more directions, check this XDA thread: XDA on unlock TF700T

At this point you need root. My recomandation is to install a custom ROM which will do everything for you. Which one is on you, check this link on XDA how to root and custom ROMS for detailed instructions and a list of ROMS, but bear in mind that at the moment the multi boot has been tested only with a few ROMS: either CROMi-X, CROMBi-KK or ZOMBi-X latest versions, on insternal SD only, no rom2sd, data2sd or anything fancy. I suggest you to stick with one of these.

Making your tablet unbrickable
While there is basically no threat of briking your tablet, it's strongly advised to follow these steps here on how to make your tablet "safe" from any messing up you might do.

In short:
 * download this: flatline
 * install google's ADB and fastboot (from SDK) on oyur linux pc
 * flash the downloaded custom recovery: fastboot flash recovery flatline_device.im
 * reboot device to recovery, select "advanced" and "wheelie", select "Step 1: Flash AndroidRoot BL"
 * it will poweroff. Reboot to asndroid, let it boot, use a bit, then reboot to recovery again
 * select "Step 2: Generate wheelie blobs" from the same menu as before
 * when finished, reboot and save from the device the files it has created (check under /data or /tmp for AndroidRoot or similar)

Keep these files safe, they are your lifeline. (NOTE: these instructions are given with no warranty, use at your risk!)

Prepare the storage
As noted above, i suggest you install Gentoo on the microSD. In addition to that, since also microSD are subject to tear and wear damage, i suggest to disable logs (or put them on a ramdisk) and put the /tmp folder on ram. For additional safety you could also move the portage build dir to some other device, like an usb attached disk or network share (ok, this might be too much, i regularly build on my microSD).

I suggest to plug in a very fast microSD, but be aware that the TF700T microSD slot is a bit picky. I managed to get a Sandisk 32gb Class 10 microSD to work great, while no 64gb card so far: they seems to be working, but at some random point under heavy load will drop to read-only with no warning. It seems to be an hardware issue since moving the same card to the SD slot on the dock fix the issue.

Anyway, i assume we are using the microSD slot here on at least 16gb microSD card.

You need to format it, since i am aware of no good tools on Android for doing this, put the card in to your pc and prepare two partitions:
 * the first formated as EXT4, at lest 16gb (better 32gb)
 * the second as VFAT, for data exchange (not required, just optional if you have spare space)

I will not cover it here, but you could use the Android partition to store Gentoo, but this will get rid of your Android, or install Gentoo on the internal memory data partition, this is left to you to try.

(Repartitioning the internal memory is STRONGLY NOT ADVISED. I was thinking about it but was discouraged by the fact it does not use any common partition scheme and no linux tools are able to mess with it. Plus the fact that it can really brick your tablet requiring you to grab the lifeline from last paragraph)

Setting up dual-boot
Dual-booting the tablet is done using a kexec method which is just brilliant. The full thread on XDA is here.

In short, with the changes we need for Gentoo:
 * Check you have a supported ROM and recovery (CROMBi-KK and TRWP for me worked well)
 * boot into your ROM and make sure you have terminal emulator, root and busybox installed
 * download this: scripts
 * extract in the internal memory, you should get a folder called TF700t-AKBI-v2.6.5
 * don't download any rootfs, you will be making your own with Gentoo on it soon enough.
 * become root: su bash
 * run the script: sh firstintall.sh (it will install the multiboot blob).
 * When prompted, select the proper kernel for your android from the list (a mistake here will make your Android intallation unbootable, but you can fix it from the multiboot prompt later on, left as an exercise in patience)
 * When asked for the rootfs image, just terminate the script. We will not setup a rootfs image.
 * If the script gives an error (missing rootfs image, for example) just ignore it, all you need is the kexec blob for the multiboot to be installed and the android kernel to be copied.

(rememeber you are on Android here, not linux, so things are different. For once, you must run shell script by incoking the shell itself and not by directly run the script, as tany partition you have normally access to it's mounted as no-exec)

Very well, at this point we should have the multiboot installed and the android kernel restored for the multi-boot. We now need to configure the multiboot for booting linux from the microSD card: LABEL=CROMBi-KK BOOT=3 DEVICE=/dev/mmcblk0p1 DIR=/ KERNEL=/boot/zImage INITRD=/boot/initrd.img PRIORITY=10 LABEL=Gentoo on microSD partition 1 BOOT=3 DEVICE=/dev/mmcblk1p1 DIR=/ KERNEL=/boot/zImage INITRD=/boot/initrd.img PRIORITY=110
 * prepare to mount the multiboot partition: mkdir -p /data/media/0/kexecbootcfg/
 * mount the multiboot partition: mount -t vfat /dev/block/mmcblk0p5 /data/media/0/kexecbootcfg/
 * Create the config folder: mkdir -p /data/media/0/kexecbootcfg/multiboot/
 * Create/edit the file called boot.cfg in this directory, this is mine as an example:
 * 1) Android#
 * 1) Linux ext partition image on microsd partition 1 #
 * Adapt the example to your needs!
 * Unmount the multiboot partition: umount /data/media/0/kexecbootcfg/

The linux entry will not boot until we set up the kernel for it, but at least you should be able to reboot into Android. Try it out! The tablet will boot twice, the first time will show you the menu, the second will actually boot Android.

As Workdowg himself explains on XDA:

"What happens here is by flashing the kexecboot kernel blob (to mmcblk0p4) you are given a menu to choose a rootfs to boot from, ie Android, Linux image file, Linux on a partition... So in order for the kexecboot kernel to be of any use to you, you need to install Android and Linux kernels in your rootfs. It then reboots using the kernel you chose. The config file, boot.cfg, is installed to a small 5MB vfat partition (mmcblk0p5)

''ANDROID: Android mounts root (mmcblk0p1) "/" as /system. So we install a kernel (without modules, you did that when you installed your ROM) to a directory we make called /boot which needs to be in the mount /system directory. This kernel (zImage and initrc.img) is just extracted from _that's cm112 or _that9oc+ kernel blobs and a copied to the /boot directory.''

''LINUX: This kernel was especially compiled by JoinTheRealms from _that5 source using configs moreD_cn came up with. It needs to be installed in /boot of a Linux rootfs."''

At this point you have a working dual-boot on your tablet, we need to build gentoo so you also have something to dual-boot!

Build Gentoo
This is basically the standard Gentoo Handbook, so i will not bore you on the basics, but a few important things must be noted, so please keep reading.

Setting up the storage
One option is to install on a loopback image, i prefer to avoid this, instead we will be installing on a dedicated partition of the microSD. So, plug in your newly formatted microSD with the first partition as EXT4 (format and partition on a PC, android is a mess for these things. It could be done, but it's a real pain!

We need to mount the EXT4 partition, so: - boot Android - fire up your Android Terminal Emulator - become root (type su) - create a temporary folder: mkdir tmpGentoo - mount the microSD: mount -t ext4 /dev/mmcblk1p0 tmpGentoo

Based on your busybox, these instruction might require some tweaking, do your homeworks.

Download stage3 for ARM-hf
The tablet is an ARMv7 with hard floating point. The binary NVIDIA packages which we are forced to install do require you to install this architecture, so go to the gentoo ARM download page and download on your tablet the latest Stage3.

Extracting it into the mounted partition can be hard depending on your busybox, decompressing the stage3 is left to your exercize. If you are desperate, just decompress it on a linux pc then mount the microSD on the tablet.

do the usual gentoo initial stuff
chroot into the uncompressed stage3 and follow the gentoo handbook to install it. Just bear in mind your only network interface is wlan0, you do want to specify the "xxx,noatime" mount option to ensure maximum life and speed from your solid state memories (either mSD or internal). Also, remember you must NOT install any bootloader (lilo, grub, etc) and you CANNOT install a linux kernel, you must use the same kernel you are using in the dual boot we have set up. Since some stuff will need the kernel sources to compile, just emerge git and download there sources to /usr/src and make a symlink called /usr/src/linux to them. You can now reboot android and try out the dual boot, if all goes well, you will get to a grentoo login and you can login as root.

Mask and unmask packages
The provided tegra drivers works only with X up to 1.14 (which is not very stable) and since 1.13 has been masked due to security flaws, you must mask any xorg-server above or equal to 1.13. I recomend the following accept_keywords and mask: 

Install Tegra packages
Download the NVIDIA binary package for Tegra3 DEcompress.... copy the following files: <....>

Install touchscreen and touchpad drivers
from here <> and here <>

Suggested configuration from here
You have only 1gb of ram and swap file is strongly discouraged. So i suggest you install lxde-meta and the nice XDM replacement °slim°. I usually configure it for auto-login due to some strange long delays in the login.

Fine tuning some things
Video standby simply hangs 75% of the times, so forget it. Disable any screen blanking from your screensaver. Instead, use this script: <>

install xbindkeys and the following scripts: <->

In this way you can lock the screen and put the brightness to 0 by pressing the power button. If you don'y do this, well, simply the metal dock will keep pressing randomly your touchscreen all the time... and this is NOT what you want!