perjantai 10. huhtikuuta 2020

Installing linux on Asus TF101

Years ago I bought myself an Asus Eee Pad Transformer TF101, which is an Android tablet with an (optional) keyboard dock. In the keyboard dock there is additional battery and two USB ports. I bought it as I- thought it could be used as a replacement for a laptop, but it turned out that Android is not very suitable for that. I never had any good use for the tablet..

Many years ago I rooted the tablet and installed a custom, newer Android ROM made by Timduru. It was nice, but still I didn't find much use for the tablet.

Some weeks ago I found out, that it is possible to install Linux on the tablet. It had been possible for many years already, and significant development had happened until 2016 or so. So I decided to go for it, and it turns out, the process was very easy with the already-rooted tablet!

In this post I present the process I used since the guides were scattered around multiple posts.

Sources

Main sources for the process were following:
  1. [Linux] [IMG] [Dev] [WIP] *Ubuntu images for Rootbind [TF101 / TF101G]
  2. [KERNEL/MOD] [LINUX] [Rootbind] [Native EMMC/all TF101&TF101G/fast/tested] [2-Jul-13]
  3. [GUIDE][Dual Boot][TheEasyway] How to setup Linux RootBind Method [Updated May 16th]

Preparation

To prepare for the installation, one needs an empty micro-SD card, at least some 2 GB or so. It is necessary to download to the SD card (root) following files:
  • tf101-14.04-Lubuntu-Tegra-armaf.tar.gz from the first source link and
  • Ubuntu-3.1.10-12-rootbind-oc1.2GHz.zip from the second source link
it may not be necessary, but I also downloaded
  • modules-3.1.10-12.tar.gz from the second link 
Note that in the first link there is also other distributions that can be used. I assume their installation is similar, but I used the lubuntu one.

Also in the second link there is different kernels. I understood that the difference is that 1.0GHz is the standard processor speed, while 1.2GHz is a bit overclocked and 1.5GHz is rather high overclock. I used the slightly overclocked 1.2 GHz version.

Make sure you have latest TWRP recovery on the tablet. It is needed to flash the kernel. You also need SuperSU or similar and a terminal emulator.

Installing the distribution

When all the necessary files are downloaded (or installed), it is time to uncompress the linux distribution. With these versions, they can reside side by side with Android, so it is possible to have both installed and run either one by just flashing the correct kernel.

In Android terminal run the following commands to uncompress the Linux distribution to /data/linuxroot: 
su

mkdir -p /data/linuxroot
busybox chmod 755 /data/linuxroot
cd /data/linuxroot
tar -xpjf /storade/6E20-1C26/lubuntu-14.04.tar.bz2
the external micro-SD card where I put all the files was in the path /storage/6E20-1C26/ so that needs to be changed to match where the SD-card is located.

It may be also necessary to copy the necessary kernel modules, at least for some kernel versions:
cd /data/linuxroot/lib/modules
tar -xzf /storage/6E20-1C26/modules-3.1.10-12.tar.gz
That is all for now, next is time to install the kernel.

Installing the kernel

To install the kernel, it is necessary to reboot to the recovery with the external micro-SD card still installed.

In the recovery, select Install. From the menu select SD card as the source directory, and then select the kernel zip file, Ubuntu-3.1.10-12-rootbind-oc1.2GHz.zip. Confirm flashing the image by swiping right.

After a moment the flash process is done and it is time to reboot the system.

Booting

After reboot, there was quite a long time with black screen, and then...

Two penguins! This is promising... waiting a bit more...

Linux boot messages! And no errors so far! And finally login screen! From the top right menu (after a few clicks) it was possible to get the on-screen keyboard.

Easy! The installation was a success on the first try!

Issues


There are several issues, some of which can be fixed and some do not at the moment seem to have a fix.
  • The tablet cannot be booted with the dock connected. Remove the dock before turning the tablet on!
  • Do not run apt-get update && apt-get upgrade. It seems to break something and the system no longer boots. Upgrade only the necessary packages.
  • Sometimes the mouse/GTK would hang if moving/resizing a window. It seemed to be fixed by upgrading anything libgtk-2.0 and libgtk-3.0 related (~6 packages or so).
  • Network-manager (wifi) icon is broken, fix is to re-install icon themes, as described here.
  • Lock-key in the upper right corner can be made to be delete key by adding /usr/sbin/mapdeletekey to startup applications.

Dock battery issue

There is a quite major issue with the keyboard and touchpad stopping working if dock battery goes low. My tablet had broken battery which I removed (and later installed a new one) so the dock could never be used. The issue seems to be related to the system reading the battery status, and it starts to spam the (i2c?) bus which also has keyboard and touchpad.

I found a workaround which seems to work somewhat well. The key is to remove anything that tries to read the battery status. I've not encountered the issue since doing following:

  • Remove lxde4-power-manager and upower: sudo apt-get remove upower lxde4-power-manager
  • Remove  anything battery related from conky (or disable conky altogether) by editing ~/.conkyrc
If and when you still want a battery gauge, use my version of batterymon-clone. It is necessary to force usage of battery capacity and prevent reading "present" status to work around the bugs:
batterymon --use-capacity --no-present
 I also like to have separate gauges for tablet and dock batteries, which can be achieved by running
batterymon --use-capacity --no-present --show-all --no-total
I recommend adding one of those commands to startup applications.

For some background, I noticed that the issues with the dock installed start to appear if one reads either "energy" or "charge" values of EITHER the dock battery or the tablet battery. Reading the capacity (and status) seems to work just fine. So I think the bug is related to those variables, and so it is necessary to prevent (remove) all programs that might read those values and use only ones that use the capacity.

Lid close fix

When Upower is removed, the fixlidclose.py in the original lubuntu package stops working. For a workaround, I made another set of scripts to achieve the same functionality. The scrips can be found from my github repository. From the repository, it is necessary to copy both python scripts to /usr/local/bin/. Then add
python /usr/local/bin/tf101monitor.py &
to /etc/rc.local before the exit statement to launch the script at boot. Also it is necessary to create /etc/dbus-1/system.d/tf101.conf with following content:

   <busconfig>
        <policy user="root">
            <allow own="org.tf101" />
        </policy>
        <policy group="tf101">
            <allow send_destination="org.tf101" />
        </policy>
    </busconfig>

which allows the script to run. Then just add /usr/local/bin/fixlidclose.py to startup applications list.

There still seems to be a bug, at least with updated xorg and its drivers, that the screen stays blach when the lid is opened. Picture comes back on by pressing ctrl+alt+f1 (which opens a text console) and the ctrl+alt+f7 (to go back to graphical console). Alt key is the magnifying glass key, and f1 to f7 are in the top row (bluetooth toggle etc buttons). I have an idea on how to work around this and will update the script if it works.