Asus Transformer Prime

Installing Gentoo on the Asus Transformer Prime (TF201)

This is an introduction to installing gentoo on the Asus Transformer Prime (TF201). At the moment, we can get it to boot and launch X, but there are quite a few problems. Hopefully, this site will invite others to share their own experiences, and maybe even generate some solutions to these problems.

INSTRUCTIONS
The basic steps are as follows:

PRELIMINARIES
This guide assumes that you have installed the Jelly Bean update from ASUS. THIS GUIDE IS A WORK IN PROGRESS: CHECK BACK OFTEN FOR UPDATES! (CHECK THE HISTORY.)

NOTA BENE: WE ARE NOT RESPONSIBLE FOR ANY DAMAGE DONE TO YOUR TFP!

CREATE A CHROOT
The first thing you'll want to do is generate a gentoo "rootFS". You can either do this by using a cross-compiler on another computer or on the TFP within a chroot environment. This guide assumes that you are doing the latter. It further assumes that you will be installing the rootFS on the microSD card (mmcblk1p1) which you have mounted on the TFP in the directory /sdcard/gentoo.

modules="bcm4329" module_bcm4329_args="iface_name=wlan0" FEATURES="-sandbox" emerge -1 packagename
 * Follow the standard Gentoo Installation Guide.
 * You should use the armv7a-hardfp stage3.
 * Download and extract root_patch.tar.gz inside your chroot. This will install some configuration files and the kernel modules and the (binary) firmware.
 * If you don't trust us, then run:
 * 1) emerge linux-firmware (or just mkdir /lib/firmware)
 * 2) mkdir /system && ln -s /lib /system/vendor && ln -s /lib/firmware /system/etc
 * 3) (outside chroot) cp -R /system/vendor/firmware/* /system/etc/*.txt /sdcard/gentoo/lib/firmware
 * 4) (TODO: Not all of these files are necessary.  We should weed out the ones that aren't.  AFAIK, just the bcm4329 firmware is required.  See make menuconfig for more information.)
 * 5) Compile your own kernel (see below) to populate /lib/modules.
 * 6) Add to /etc/conf.d/modules:
 * NB: I found that mounting /dev/pts to /sdcard/gentoo/dev/pts before you chroot allows tmux to work.
 * NB: You can either add -userfetch to make.conf FEATURES (to fix an emerge error about the user being unable to fetch packages) or add the portage user to the 3003 group. See AndroidSecurityUserAndGroups.  See also CONFIG_ANDROID_PARANOID_NETWORK=y.
 * NB: You will also need to establish /etc/resolv.conf by hand, by adding "nameserver x.x.x.x" to it inside the chroot. You can get the  in Android by running getprop.
 * NB: You must install wpa_supplicant, dhcpcd, and sshd and add them to the default run-level.
 * NB: It would be easiest to disable qt4 USE flag with respect to wpa_supplicant (for now).
 * NB: If you get a "sandbox violation" error while emerging, you have to emerge the single package that cause you this as follows (ideally, these should be reported as bug reports to bugs.gentoo.org):

INSTALLING THE KERNEL
There are at present two ways to install the kernel on the TFP: nvflash or fastboot. Once you have installed the kernel on the TFP and reboot, your machine should boot into Android (not Linux). In order to have it boot into Linux, you need to configure the bootchooser. See the next section. Instructions on how to regenerate a kernel, blob, and LNX file are given further below.

FASTBOOT METHOD
In order to do fastboot, do the following: o WARNING: AS USUAL, FASTBOOT AND THE TFP ARE CRANKY AND SO WHAT FOLLOWS MIGHT "BRICK" YOUR DEVICE. PLEASE RESEARCH THE FASTBOOT UTILITY BEFOREHAND. dd if=/dev/zero bs=28 count=1 of=newtest.blob && dd if=test.blob of=newtest.blob oflag=append conv=notrunc fastboot -i 0x0b05 flash boot newtest.blob.
 * Download the blob file to your computer: test.blob
 * Add 28 bytes to the front of the blob file:
 * Put the TFP in 'fastboot' mode: connect it to the computer via a usb cable, install ClockworkModRecovery app on the TFP, reboot the TFP and hold down VOLUMEDOWN upon reboot until some text shows up about going into recovery. Release VOLUMEDOWN and wait, then select the USB ICON (VOLUMEDOWN to move, VOLUMEUP to select).  This is all standard, and documented elsewhere.
 * Flash the blob to your TFP:
 * NB: 'flashboot devices' will claim there is no device. But it is there.

NVFLASH METHOD
In order to do the nvflash method, do the following: wheelie --blob mysecret.blob (mysecret.blob is the blob you created when you installed wheelie). nvflash -r --download 6 test.LNX nvflash -r --go (this sometimes won't reboot the machine)
 * WARNING: AS USUAL, NVFLASH AND THE TFP ARE CRANKY. IT MIGHT "BRICK" YOUR DEVICE.  PLEASE RESEARCH WHEELIE AND NVFLASH BEFOREHAND.
 * WARNING (2): wheelie is a binary with no open source (yet), and as with any binary you should be worried.
 * Download the LNX file: test.LNX
 * Put the TFP in nvflash APX mode (reboot + VOLUMEUMP; this will yield a blank screen, but check dmesg to see that it is in APX mode).
 * Run wheelie:
 * Flash the LNX file to your TFP:
 * Reboot the TFP:

CONFIGURE BOOTCHOOSER
The blob and LNX files we provide in git include a modified initrd. What we did is overwrite 'init' with bootchooser. Bootchooser will mount the 8th partition of your eMMC, read the first line of the root-level file '.boot', which will be parsed as "device:directory:init" where: 'device' is the block device where you put your gentoo system, e.g. /dev/mmcblk0p8, /dev/mmcblk1p1, or /dev/sda1. 'directory' is the directory inside the previous device where your gentoo lives, e.g. /gentoo or /. 'init' is the init script location in your gentoo root, usually /sbin/init. If anything goes wrong, bootchooser will boot into Android.

Hence, if you have gentoo on the microSD card, .boot will be: /dev/mmcblk1p1:/:/sbin/init If it is on /data/gentoo, then: /dev/mmcblk0p8:/gentoo:/sbin/init If on the usb stick: /dev/sda1:/:/sbin/init

Once you have created this file, reboot and it should boot into Linux. However, unless you have configured your gentoo to automatically start Xorg, you will see nothing but the ASUS logo. In order to verify that it worked, either ssh in or reboot back into Android and check /sdcard/gentoo/var/log/messages. You can debug problems by checking boot_chooser.log which is generated in the root of the Android filesystem (i.e. /data/boot_chooser.log).

GENERATE A TEST.BLOB / MODIFY INITRD / COMPILE THE KERNEL
The are not steps, but pointers:
 * Unpack the blob (test.blob in git) to generate a .LNX file: blobunpack test.blob
 * Extract the zImage and initrd from the .LNX file: abootimg -x test.LNX
 * Extract the initrd: mkdir tmp && cd tmp && gunzip < ../initrd.img | cpio -i --make-directories
 * Regenerate the initrd (from tmp): find . | cpio --create --format='newc' > ../initrd.img && gzip ../initrd.img
 * NB: Don't forget to gcc -o boot_chooser2.c init and cp that over to initrd as your init file.
 * Regenerate the zImage (kernel): You will want to apply the JB15.patch in our git kernel/ directory, fixing an obvious error. The kernel we used was the one from ASUS: kernel_v10_4_2_15.zip.  The patch also applies our .config file.
 * Regenerate the .LNX file: abootimg --create test.LNX -r initrd.img -k zImage
 * Reblob pack: Use blobpack and when done add 28 bytes to the front of the file (see the fastboot method section above)

KNOWN BUGS
Solution: There is none. Make sure you have sshd installed.
 * Problem: After I launch X and I kill X, the screen is blank.

Solution: Disable X blanking. xset -dpms or xset s off or xset s noblank (or all three)
 * Problem: X goes blank and won't go unblank.

Solution: Install the tegra_drv (xorg driver) from RC16.2 of their Linux For Tegra release (see below)
 * Problem: xrandr -o left/right/normal/inverted don't work

Solution: None yet. (See below: ATMEL MAXTOUCH)
 * Problem: With Tegra Drivers (RC16.2) installed, xinput set-int-prop 8 "Evdev Axes Swap" 8 1 and xinput set-int-prop 8 "Evdev Axis Inversion" 8 1 0 get registered in, e.g., xinput list-props but fail to have an actual effect on the input x/y coordinates.

Solution: None yet.
 * My messages is spammed up with asusdec_kp_key and asusdec_keypad_processing debugging statements in /var/log/messages.

Solution: None yet.
 * With Tegra Drivers (RC16.2) installed, I also get some further cpu spam messages.

Solution: Install a kernel with the latest patches. Write 1 or 0 to /dev/asusdec to enable or disable the touchpad. (Check out tux_mind's github)
 * The touchpad (on the ASUS Keyboard Dock) doesn't work.

Solution: None yet.
 * Sound doesn't work.

Solution: (tmux_mind: Did wart's tegra_drv installation fix this? wart doesn't use compositing.)
 * Compositing doesn't work due to unavailable graphics shared memory.

TIPS
Here are some tips:
 * edit /etc/inittab and comment out the c* and s* entries. nvidia doesn't give us console or serial.  boo!
 * mount /var/tmp and /tmp as tmpfs
 * make a 2G swapfile
 * /dev/mmcblk0p1,2,8 are ext4; mnt these in /mnt as system, cache, data respectively.
 * sudo -u yourusername startx in /etc/local.d/mystuff.start for a quick and dirty test
 * cpufreq-set -c 0 -g performance|powersave (do this for 0-3) (For some reason, placing /etc/init/nv.conf contents in lcoal.d/start.start causes cpufreq-set to stop working,s o whatever those things do, they broke this.)

UNDER DEVELOPMENT (TEGRA XORG DRIVER)
The tegra xorg driver (from L4T RC16.2) works!
 * extract (using --backup!) config.tbz2 and nvidia_drivers.tgz to /
 * (notice that two files libjpeg.so and libEGL.so.1 are overwritten (TODO: test the conflicts))
 * remove /etc/wpa_supplicant.conf (unnecessary; and in the wrong place)
 * ln -s /usr/lib/xorg/modules/drivers/tegra_drv.abi13.so tegra_drv.so
 * recompile your kernel with CONFIG_SYSVIPC (otherwise X won't boot and will tell you to do this! TODO: add to test.blob/test.LNX)
 * place the contents /etc/init/nv.conf in an local.d/mystart.start (I'm not sure what these do, but they cause cpufreq-set to not work and give us wonderful new messages in messages)
 * rm -rf /etc/init (the ttyS0.conf file has no effect).

TEGRA XORG DRIVER
Recently (DEC 2012/JAN 2013), Stephen Warren and Thierry Reding have been working on getting an open tegra implementation in the kernel and also an xorg driver associated with that. Purportedly, this will be in the 3.8 kernel. We'll be keeping an eye on this over the next few weeks! If anyone has given it a go, drop me a line! Thiery's git is: https://gitorious.org/thierryreding/xf86-video-opentegra

ATMEL MAXTOUCH
JAN 2013:

I'll be busy over the next few weeks, so here's a status quaestionis:

(1) The nvidia tegra drivers (Linux For Tegra RC16.2, documented on the wiki) seem to work. There will be conflicts with two files, and it would be nice to package things in an ebuild. (2) As a result, xrandr -o left/right/normal/inverted work! (3) But xinput set-prop 8 "Evdev Axis Inversion" 1, 1 && xinput set-prop "Evdev Axes Swap" 1 don't (i.e. I can't get the input to switch its coordiantes when I rotate the screen). (NB: fiddling with xinput set-prop 8 "Coordinate Transformation Matrix" does change the input coordinates ,but it is strange. I fiddled with this for a while.)

The problem with (3) must be with the Atmel-Maxtouch code. I did some digging around and comparison to other atmel_maxtouch.c files located in:

o https://github.com/EnJens/kernel_tf201_stock THis seems to have an older version, although Rayman doesn't document where he patched it from.

o https://github.com/AndroidRoot/android_kernel_asus_tf201/tree/10.4.2.17-mr1 Rayman recommended this as the latest and greatest, and it has the latest Asus kernel_V10_4_2_17.zip (We should probably upgrade at some point!), but the files in question related to atmel_maxtouch are the same as Asus 10.4.2.15 (our version).

o https://github.com/atmel-maxtouch/linux/tree/maxtouch-v3.0/drivers/input/touchscreen This looks promising. CFR http://forum.xda-developers.com/showthread.php?t=1496246

And that's where I am at. Soooo if you ever get around to thinking about this problem -- and solve it or have more hints --- let me know.

CONTRIBUTE
Please feel free to add new problems! Even better: new solutions!

Please contact peter period hartman at utoronto period ca a.k.a. wart_ in #gentoo-embedded (and elsewhere)

Or contact massimo period dragano at gmail period com a.k.a tux_mind all over the internet