Näytetään tekstit, joissa on tunniste Android. Näytä kaikki tekstit
Näytetään tekstit, joissa on tunniste Android. Näytä kaikki tekstit

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.


sunnuntai 31. joulukuuta 2017

Rooting LG Leon with Android 6.0

Disclaimer: This post is for information purposes only. It is not a guide but a log of what I did to root the phone. Rooting may result in loss of data or brick your device, everything is done at your own risk. I'm not a developer, I do not know the details of how rooting works, and I cannot help if something goes wrong during the process.

Introduction

I have a LG Leon phone, which is a low-end Android phone. It has limited storage space and also other limitations, like not being able to store applications on SD card. It constantly runs out of storage space so I wanted to root the device to be able to delete non important stock apps and also to do other things, like maybe move apps from internal storage to SD card.
The phone model is LG-H340n, software versions Android 6.0, V20a-EUR-XX  .

Rooting process

I found a forum thread describing the process for this phone and Android version (post here). Other guides were for earlier Android versions or using Kingroot. I've heard some bad words about Kingroot so I didn't want to use that, this new guide was with TWRP and SuperSU which were familiar to me. This process is a copy of the guide with some changes I needed to do to get it to work. Thanks to users hokutojm and Wolftein for the process.

Prerequirements

  1. Back'd-up everything, since failing the process may result in factory result or bricked device
  2. Enabled developer mode by tapping Settings -> General -> About phone -> Software Info -> Build number about 8 times. 
  3. Now in Settings -> General -> Developer options checked Enable OEM unlock and USB debugging
  4. Connected the phone to computer with USB cable, then tapped the notification for more USB options. From the USB PC connection screen selected the 3 dot menu and Install PC drivers. This made the phone to show up as a disc drive in Windows My Computer. Double clicking on that installed the LG USB drivers.
  5. Python is needed, I had 2.7 already installed so I used that and it worked.
  6. Downloaded LGLAF python scripts and unzipped them to C:\LG\. I had to modify the lglaf.py script according to this bug report to make it work, otherwise it would hang on read. I also replaced name.endswith('ANDNETDIAG1'): with name.endswith('DIAG1'): in lglaf.py.
  7. Downloaded TWRP recovery with the correct partition size (Recovery.bin wiped out + TWRP 3.1.0). I used this file since according to the posts it works better than using the stock TWRP binary from the site or from the download site. Put the img file in the same folder where lglaf was unzipped.
  8. Downloaded Custom Android Bootloader, more info in this thread. Put the aboot.bin to same folder where lglaf was unzipped.
  9. Downloaded latest SuperSU and copied the zip file to the root folder of an SD card. I did not use the same SD card which was used for backup just to be sure that the data was safe. Put the SD card to the phone.

 

 Dangerous parts

  1. Turned off the phone. Then while pressing the Volume up button connected the phone to PC with USB cable. Kept the Volume up pressed until Firmware Update screen showed up.
  2. Now in Windows' Command prompt (cmd) browsed to where lglaf was unzipped.
  3. First I tried running
    python partitions.py --debug –list
    This resulted in a long list of partition names and offsets, which indicated that the communication was working properly.
  4. Run following commands to dump the original partitions:
    python partitions.py --dump aboot.old aboot
    python partitions.py --dump recovery.old recovery
    Commands resulted in the script giving this kind of information on success:
    2017-12-30 22:15:26,241 partitions: INFO: Wrote 2096640 bytes to aboot.old
  5. Replace the partitions with the custom ones:
    python partitions.py --wipe recovery
    python partitions.py --restore twrp-3.1.0-0-c50.img recovery
    python partitions.py --wipe aboot
    python partitions.py --restore aboot.bin aboot
  6. Turned off the phone by running
     python lglaf.py --debug -c "!CTRL POFF"
    and then disconnecting the USB cable.
  7. Next step was to enter download mode again. It was VERY IMPORTANT to PREVENT THE PHONE FROM BOOTING. If it rebooted and started android, all the changes were reverted and continuing wiped the phone. This happened to me. So now back to download mode by pressing Volume up and connecting USB cable.
  8. Run
    python partitions.py --dump recovery.new recovery
    to dump the newly flashed recovery partition.
  9. Compared the recovery image the the flashed on with fc /b recovery.new twrp-3.1.0-0-c50.img The files must match, otherwise the flashing failed and continuing would result in factory reset. fc displayed
    Comparing files recovery.new and TWRP-3.1.0-0-C50.IMG
    FC: TWRP-3.1.0-0-C50.IMG longer than recovery.new

    which indicates that files are identical, except for length (I don't know why the length is different)
  10. Again turn off by running following command and disconnecting USB cable
    lglaf.py --debug -c "!CTRL POFF"
  11. Next up was booting into factory reset menu, failing this would revert all changes again. Factory reset menu was reached by powering up pressing Volume down and power button, and as soon as LG logo appeared, released the buttons and re-pressed them again until menu was displayed.
  12. In the menu factory reset was selected and confirmed, but instead of reset the TWRP would boot up.
  13. In TWRP I followed this guide to install SuperSU:
    1. Selected Allow modifications
    2. In TWRP ->  Advanced -> Terminal wrote the following command:
      echo "SYSTEMLESS=true" > /data/.supersu
    3.  In TWRP -> Advanced -> File manager checked that there was indeed .supersu file in /data/
    4. Installed SuperSU from memory card with TWRP -> Install and browsing to the external SD and selected the zip file. Confirmed flashing, wiped cache/dalvik and then rebooted. I opted not to install the applications, but I don't quite know what those were anyways...
  14. After the phone rebooted, I was root! Now just to restore backups since I first failed the procedure...