Gentoo Linux on the ASUS TF700
This page holds resources useful in installing and using
Gentoo Linux on the
ASUS TF700,
also known as the Transformer Pad Infinity.
Warning: If you make a mistake trying to
install Gentoo, your tablet may become unusable! These resources
are provided in the hope that they will be useful, but with no warranty;
use them at your own risk. (If you don't completely understand the
instructions below, this page is not for you.)
Overview
The procedure and files below allow installation of Gentoo Linux on
the ASUS TF700 tablet. This install is performed directly onto the Android
/data filesystem, allowing Gentoo and Android to coexist on the
same device without repartitioning the internal storage. (On the Gentoo
side, this is accomplished through the hack of doing a chroot() to
the Linux install directory before running /sbin/init.)
Overall, the state of (this image of) Gentoo on the TF700 could be
described as "minimally functional"; it works at a basic level, but doesn't
come close to replacing an ordinary laptop PC. (Which is a shame; even if
not up to Linus
Torvalds standards, the high-resolution display still far outstrips
current laptop offerings, and it has multitouch support as well.)
These instructions worked for my Japanese-model device, starting with
firmware 9.4.5.26 installed; I have no idea how well they work on other
models or firmware versions.
What works
- Booting: Gentoo can boot successfully to a login prompt.
- Framebuffer console, though scrolling is slow.
- Wireless LAN: Available through the bcmdhd module.
- Sound: Works for the headphone jack only, and you need to
explicitly unmute it with alsamixer. Also be sure to turn the
PCM output level down to a reasonable value (70-80 on my device) so you
don't blow your ears out!
- SD card slot (but see below about I/O speed).
- The adbd program is provided through a TF700-specific
package, dev-android/adbd. If enabled via /etc/init.d/adbd
start (or added to the startup service list with rc-update add
adbd default), you can connect the TF700 to a PC and use adb
shell as with Android. Note that adbd gives a root shell,
so use with care.
What doesn't work
- X Window System: I was unable to get X running stably. I
succeeded in getting the X server to start, and I could get the X display
to show for an instant by starting and terminating an X client (I used
xev), but nothing else seemed to work.
- Screen unblanking: If the screen blanks (either from the
standard blanking timeout or from writing 0 to
/sys/class/backlight/pwm_backlight/brightness), you have to
press the power or volume up/down buttons to turn it back on; pressing
keys on the keyboard won't work. Sometimes the screen fails to unblank
and you have to hard-reboot by holding down the power button (I haven't
tested whether adb shell still works in this case).
Other pain points
- Dual booting: Since there is (to my knowledge) no bootloader
software that supports the TF700, the only way to switch between Gentoo
and Android is by manually overwriting the boot partition.
- Storage I/O is extremely slow: I measured only 20MB/sec for
the internal flash storage, and only 10MB/sec for the external SD card
slot (using an SD card rated at 30MB/sec). Operations which cover large
numbers of files, such as extracting the Linux kernel source, can take
tens of minutes to complete.
- Keyboard layout: The TF700's keyboard layout is inconvenient
when using standard Linux applications. In particular:
- The top row of keys (which would be function keys on a PC) are
only labeled with symbols, and also are not split into groups as on
a PC keyboard (F1-F4, F5-F8, and so on) so you can't tell by feel
which Fn key number a given key corresponds to.
- There's no "delete" key (though potentially one of the top row
keys could be reassigned to that function).
- The up-arrow key intrudes on the bottom alphabetic row of keys,
next to the right shift key. I frequently find myself accidentally
hitting up-arrow instead of shift.
- Weight balance: Since the bulk of the TF700's electronics are
in the tablet rather than the dock, the device is somewhat top-heavy
when docked and used in a typical laptop configuration. This isn't a
problem when the TF700 is sitting on a table, but it tends to fall over
backwards when sitting on a lap, cushion, or other soft surface.
- Sharp edges: If you're not careful when lifting open the
screen from its folded position, you can cut your finger on the edge of
the metal casing.
Installation procedure
- Unlock the TF700 bootloader using the Android app provided by ASUS.
Warning: This will void your
warranty! To download:
- Go to the ASUS
download site.
- From the "OS:" dropdown, select "Android".
- Expand the "Utilities" category.
- Download "Unlock Device App".
Note that you need to be connected to the Internet for the unlock tool to
work. Also, as of this writing the app is described as only working with
Android 4.0 (Ice Cream Sandwich), so you may not be able to use it if you
upgrade to Android 4.1 (Jellybean).
- Install a custom recovery tool, such as
TWRP, which allows you to
connect with adb shell to get a root shell. (For the initial
installation, it is also possible to
exploit
a bug in the Android boot sequence to get a root-enabled shell; in
that case, you can use an Android terminal emulator app and perform the
initial installation in Android itself. However, having an
adb-enabled recovery tool is strongly recommended as a way to
recover from a bad kernel install or other errors.)
- Boot into the recovery tool (hold the power and volume-down buttons
until the screen displays "Checking for RCK..." in the upper-left
corner, then release both buttons and press the volume-up button).
- Connect the TF700 to a PC with the USB cable, and verify that you can
get a shell with adb shell.
- Download the Linux image
(linux-root.tar.gz) and the
tar binary, and copy them to
/data/local on the device:
adb push linux-root.tar.gz /data/local
adb push tar /data/local
- In adb shell, expand the Linux image in the /data
directory:
/data/local/tar Cxzvfp /data /data/local/linux-root.tar.gz
- Check that the Linux image was successfully unpacked on the device:
ls /data/linux-root
You should see typical top-level directories for a Linux install
(bin, dev, etc, and so forth).
- Verify the location of the boot partition:
dd bs=512 skip=23552 count=1 </dev/block/mmcblk0 2>/dev/null | dd bs=8 count=1 2>/dev/null; echo
This should output the string "ANDROID!". If it does not,
stop here; you need to find the sector offset of the boot partition
on your device and use that in place of "23552" in these instructions.
- Make a backup copy of your Android boot image:
dd bs=512 skip=23552 count=16384 </dev/block/mmcblk0 >/data/linux-root/boot/boot-android.img
- Install the Gentoo boot image:
dd bs=512 seek=23552 count=16384 </data/linux-root/boot/boot-gentoo.img >/dev/block/mmcblk0
(You can also use this command to restore the original Android
boot image, allowing you to boot into Android again; just change
"boot-gentoo" to "boot-android".)
- In adb shell, run the sync command to ensure that
all changes have been written to disk.
- Reboot the tablet, either using the recovery interface or by running
the command adb reboot from your PC. Gentoo Linux should now
boot up.
Default configuration
The Linux image installed through the instructions above includes a
single user account, "tf700". The password for both this user
account and the root (superuser) account is also "tf700".
Naturally, you should change these if you intend to make any significant
use of your Gentoo install.
The Linux image includes only basic system packages, plus a few packages
specific to the TF700. Those packages are:
- dev-android/adbd: The adbd program which responds to
USB requests from adb on a PC, along with an init script to
start and stop the daemon.
- dev-android/mkbootimg: A utility program to create an Android
boot image, used by the tf700-simpleboot script when installing
a kernel.
- sys-boot/tf700-simpleboot: A trivial boot program which mounts
the /data filesystem and does a chroot() to the root
of the Linux image (/data/linux-root), then calls the standard
/sbin/init program to boot Linux normally. The package also
includes a tf700-simpleboot script which automates the process
of creating a boot image from this boot program and an arbitrary
kernel.
- sys-kernel/tf700-sources: Linux kernel source code, with
patches for the TF700. This is a merge of the kernel source code from
the ASUS firmware version 9.4.5.30, the latest (as of this writing)
Android kernel source for kernel 2.6.39.4 from Google (AOSP packages
kernel/tegra),
and a few custom changes (see the patches downloaded by the package).
The packages above are available from a Portage overlay at
http://achurch.org/hg/portage-tf700,
which is preinstalled via the layman tool (the overlay description
file can be found at
http://achurch.org/portage-tf700-layman.xml).
The image also includes a custom keymap, located at
/usr/local/share/keymaps/tf700.map and loaded by
/etc/conf.d/keymaps. This keymap:
- Maps the top row of keys to Esc and F1-F15. (The lock key is left
unmapped.)
- Maps the Home, Search, and Menu keys on the bottom row to Alt.
Updating and restoring the kernel
If you build a new kernel, you need to install it to the boot partition
before it will be recognized. The tf700-simpleboot script takes
care of this; run tf700-simpleboot install path-to-kernel
to install the new kernel (located at path-to-kernel) to
the boot partition.
tf700-simpleboot does not provide any facility for a backup
kernel, so if the kernel you install fails to boot, you will need to use
the tablet's recovery mode to reinstall a known-good kernel.