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.

NEWS!
Created a mailing list: linux-tf201. Please join! Discussion is not limited to just gentoo.

INSTALLATION INSTRUCTIONS
The basic steps are as follows:

PRELIMINARIES
This guide requires the Jelly Bean bootloader from ASUS, and will assume you already have it installed. 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) comment all serial consoles and ttyX where X > 1 in your /etc/inittab
 * 7) 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 rootchooser. See the next section. Instructions on how to regenerate a kernel, blob, and LNX file are given further below.

WARNING: !!KEEP A boot PARTITION BACKUP!!! ( can do this from your recovery )

FASTBOOT METHOD
WARNING: AS USUAL, FASTBOOT AND THE TFP ARE CRANKY AND SO WHAT FOLLOWS MIGHT "BRICK" YOUR DEVICE. PLEASE RESEARCH THE FASTBOOT UTILITY BEFOREHAND. In order to do fastboot, do the following: fastboot -i 0x0b05 flash boot fastboot.blob.
 * Download the blob file to your computer: fastboot.blob
 * Check the md5sum of the downloaded file : md5sums
 * 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.

FASTBOOT METHOD ON DEVICE
In order to do fastboot directly from the TFP, do the following:
 * Download the blob file to your computer: fastboot.blob
 * Check the md5sum of the downloaded file : md5sums
 * Run: # dd if=fastbott.blob of=/dev/mmcblk0p4 ( or /dev/block/mmcblk0p4 if you are on android )
 * reboot
 * NB: you should see a blue bar after rebooting

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 nvflash.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: nvflash.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 ROOTCHOOSER
The blob and LNX files we provide in git include a modified initrd. What we did is overwrite 'init' with root_chooser. Rootchooser will mount the 8th (/data) partition of your eMMC, read the first line of the root-level file '.root', which will be parsed as "blkdev:root_directory_or_image:init_path init_args" where: 'blkdev' is the block device to mount, e.g. /dev/mmcblk0p8, /dev/mmcblk1p1, or /dev/sda1. 'root_directory_or_image' is the directory inside the previous device where your installation lives, e.g. /gentoo or /. It can also be the path to an ext4 formatted image to use. 'init_path' is the init script location in your rootfs, usually /sbin/init. 'init_args' are optional arguments for the init program. If anything goes wrong, rootchooser will boot into Android.

Hence, if you have gentoo on the microSD card, .root 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 If from a ext FS image file in /data/media: /dev/mmcblk0p8:/media/ubuntu.img:/:/sbin/init

If you would like to test a configuration, or boot into another system once the .root.tmp file may be used instead. It follows the same syntax as .root, and will be removed upon the next reboot.

note: if the first character is a '#' rootchooser boot into android, ignoring the file's content.

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 root_chooser.log which is generated in the root (/) of the Android filesystem.

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 root_chooser4.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 many problems. 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)

KEYBOARD
It is possible to change the keyboard layout to be similar to a normal desktop's.

if you are using at least the v3 kernel you're able to modify the kernel keyboard layout using setkeycodes.

give a look to the /etc/local.d/00-setkeycodes.start script installed from the root_patch. otherwise you have to change the way Xorg translate keycodes throught xmodmap ( it's slower, do it only if you have a kernel version minor than the v3 ). xmodmap -pke > ~/.Xmodmap ex: to change home to windows key (Super). Change keycode 180 = XF86HomePage NoSymbol XF86HomePage to keycode 180 = Super_L NoSymbol Super_L note: you can use xev to get the keycode and name of a button press xmodmap ~/.Xmodmap
 * emerge xmodmap
 * create a config file
 * edit the key bindings
 * add the following to ~/.xinitrc to automatically apply this configuration

GRAPHICS / VIDEO / XORG
The tegra xorg driver (from L4T RC16.2) works!

be sure to use at least the v2 images.
 * install X11 ("emerge xorg-x11")
 * download the latest Cardu driver package from Nvidia (https://developer.nvidia.com/linux-tegra)
 * extract the package and copy config.tbz2 and nvidia_drivers.tgz from Linux_for_Tegra/nv_tegra/ to the device
 * extract (using --backup!) the two tars 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)
 * cd /usr/lib/xorg/modules/drivers; ln -s tegra_drv.abi13.so tegra_drv.so
 * 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).
 * add "vt01" to the end of the command line in /etc/X11/xinit/xserverrc (see FAQ below for details)
 * run "startx". If no window/desktop manager is configured but everything is working you'll get a usual X output log and then dumped back at the command prompt; if you have configured a window/desktop manager (e.g. "echo startxfce4 > ~/.xinitrc") it should start; if the system is misconfigured a hang followed by reboot is possible.

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 TOUCHSCREEN
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.

BATTERY
I had no problems with the battery. If do you have any trouble with this try installing your DesktopEnvironment's power manager. For those curious, the battery information files are stored in /sys/class/power_supply/

TOUCHPAD
Please install the v1 kernel. Use touchpad_control to enable and disable the touchpad.

SOUND
Sound now works, but must be manually configured to use the correct card. Write the following to /etc/asound.conf defaults.ctl.card 1 defaults.pcm.card 1 defaults.timer.card 1

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 above: tegra_drv)
 * Problem: xrandr -o left/right/normal/inverted don't work

Solution: None yet. (See above: 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: install at least the v2 kernel.
 * 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: See above: Touchpad
 * The touchpad (on the ASUS Keyboard Dock) doesn't work.

Solution: See above: Sound
 * Sound doesn't work.

Solution: Upgrade to Tegra Drivers (RC16.2)
 * Compositing doesn't work due to unavailable graphics shared memory.

Solution: add that line 'Option "XkbLayout" "$YOUR_KEYBOARD_LAYOUT"' to "/usr/share/X11/xorg.conf.d/10-evdev.conf" in the InputClass with "evdev keyboard catchall" as Identifier.
 * In login screen keyboard has a wrong layout.

Solution: append vt01 to /etc/X11/xinit/xserverrc to make X always use vt1. Other vt's will cause a crash.
 * Xorg crash with v3 kernel.

Solution: you have to upgrade gcc to 4.6.*, emerge firefox with a swapfile, you'll get an error on install. swapoff. ebuild /usr/portage/www-client/firefox-17.0.3/firefox-....ebuil install qmerge celan
 * Cannot emerge firefox.

TIPS
Here are some tips:
 * if you are using a kernel previous then the v3 one edit /etc/inittab and comment out the c* and s* entries.
 * 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.)

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

The current TODO list is on github.

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