How to install Lubuntu 16.04 on the ASUS X205TA (F205TA)

There are a lot of guides and discussions that get updated sometimes and therefore are hard to follow.

I did an install twice on my laptop and wanted to share an up-to-date way of installing Ubuntu 16.04 (or one of its flavors - in my case Lubuntu 16.04) on this laptop.


Solution 1:

I have my answer from a post in a thread that is discussing this since 2014 for several linux flavours. I will share my way of installing without the optional parts from the guide.

What still won't work

  • Chrome browser is flickering/tearing (turn off hardware acceleration in settings of chrome to avoid it)
  • Brightness control via FN buttons
  • Sound works, but not with a mainline kernel yet. It probably will be in mainline with version 4.11 or later. (There is the option of compiling a more advanced kernel, but this is not what I did.)
  • Sound through headphones does not work even with patch, but you can use this workaround to get it to work (I did not try it).

Preparing in Windows

If starting from Windows: Turn off BitLocker (this will allow Ubuntu to mount and/or resize the primary data drive). In Windows, click on PC Settings/PC and devices/PC info; scroll to the bottom of the screen and click to turn off BitLocker/decrypt drive

Preparing USB Live

UPDATE: Making a bootable USB-stick is also possible with harryharryharry's script

Otherwise:

Prepare Ubuntu Live bootable USB memory stick. Download .iso file for 64-bit Ubuntu 16.04. In Linux, sudo apt-get install unetbootin. Run unetbootin with the downloaded .iso.

Copying special bootia32.efi onto USB

After the memory stick is set up, copy bootia32.efi to the /EFI/BOOT directory on the memory stick. Fetch bootia32.efi from github. I am not sure if this is the right link, because I forgot which one I used during the installations. If anyone encounters problems, please comment and I will update. There are several such files, or guides how to create them, on the web, although firstly I fetched one that did not work (it was for Arch Linux).

Boot Ubuntu Live from USB

Insert memory stick in Asus X205TA USB port. In Windows, hold Shift key and click on Restart; choose Advanced Options/UEFI Firmware to enter BIOS. Turn off SecureBoot. Select USB stick as boot device. Save and exit

If starting from an existing Linux install, you will need to press ESC when you first turn on the machine; this should pull up a small menu to choose the boot device. Choose the USB stick. When grub menu loads, select Try Ubuntu.

Backup of SSHD

Plug in a USB external hard disk or USB thumb drive with at least 32GB of free space. Right-click on any mounted drives in the Unity launcher (e.g., OS and Recovery if doing a dual-boot with Windows) and choose Unmount for each. Open a terminal and run the following:

dd if=/dev/mmcblk0 of=/media/ubuntu/HD/FILENAME bs=1M`

Replace HD with the name by which the external drive was mounted. Replace FILENAME with the filename you wish to use for the resulting image (or set another path as desired). It will take about 20 minutes for the command to complete; do NOT interrupt it, or you will have to start over! Note: to restore the X205TA to its original state, you can run this command “in reverse”: dd if=/media/ubuntu/HD/FILENAME of=/dev/mmcblk0 bs=1M

Dual-boot

Resize Recovery partition (note that the Recovery partition is required for booting Windows on this machine, so it cannot be removed if you want dual-boot, but it can be reduced in size to allow some additional room). Right-click on the OS and Recovery icons in the Unity launcher and make sure each is unmounted (choose Unmount for each if needed). Run gparted (note: this runs very slowly at this point; be patient!). Shrink the Recovery partition as small as it will go (a little less than 6 GB). Expand the OS partition to take up the extra room.

Installation from Live-USB-Stick

Reboot into the Live-USB.

Set up a wireless connection

This is necessary to download updates during installation. Insert a USB based wifi adapter (Ubuntu will not yet recognize the internal wifi). Choose a wireless connection and connect.

Double-click on Install Ubuntu. Allow the installation to complete

Reboot. It should come up perfectly, with grub-efi-ia32 already installed (and not grub-efi-amd64).

Finalize installation

If dual-booting, clean up Windows. Reboot to grub menu and choose Windows. Allow Windows to check and “repair” drive C: (basically Windows is responding to the fact that the drive has been re-sized). When finished, it will automatically reboot; choose Windows again to verify that the Windows installation is still functioning properly. Reboot again and choose Ubuntu.

Update Ubuntu (assumes the USB wifi adapter is still installed; if not wait until the wifi is fixed) with sudo apt update and sudo apt upgrade.

Set up internal Wifi

Two files are needed in the /lib/firmware/brcm directory:

  • brcmfmac43340-sdio.bin – this was already in place in my 16.04 installation.
  • brcmfmac43340-sdio.txt – you may be able to copy the nvram* file from /sys/firmware/efi/efivars/ (e.g., nvram-74b00bd9-805a-4d61-b51f-43268123d113) as brcmfmac43340-sdio.txt: sudo cp /sys/firmware/efi/efivars/nvram* /lib/firmware/brcm/brcmfmac43340-sdio.txt

If either of the above files does not exist, download brcmfmac43340-sdio.bin and brcmfmac43340-sdio.txt from internet and copy to /lib/firmware/brcm (requires sudo)

sudo -H gedit /etc/modprobe.d/blacklist-custom.conf

(possibly creating the file) and add the following lines:

blacklist brcmfmac
blacklist brcmutil

And

sudo -H gedit /etc/rc.local and add the following line:

modprobe brcmfmac 

Make sure rc.local is executable (sudo chmod a+x /etc/rc.local) Instead of blacklisting, you can add the following lines to /etc/rc.local BEFORE the modprobe command:

modprobe -r brcmfmac
modprobe -r brcmutil

Reboot; internal wifi should now be working

Setup wifi so it finds 5Ghz band

sudo mv /lib/firmware/brcm/brcmfmac43340-sdio.txt /lib/firmware/brcm/brcmfmac43340-sdio.txt.bak
sudo wget https://raw.githubusercontent.com/harryharryharry/x205ta-iso2usb-files/master/brcmfmac43340-sdio.txt -O /lib/firmware/brcm/brcmfmac43340-sdio.txt
sudo modprobe -r brcmfmac
sudo modprobe brcmfmac

Note: no need to fix the SD card reader -- it works from the start.
Note: no need to fix the touchpad -- it works correctly (including two-finger scrolling) from the start.

Suspend

Fix problems caused by attempts to suspend. Goto System Settings/Power and choose “Do not suspend” for “Suspend when inactive for” (do this for both battery and AC).

At this point, everything is working great, except sound and internal bluetooth.You may address both of those with a USB bluetooth dongle until the currently made fixes are included in one of the mainline kernels.

If you need more fixes for freezing, check out the original post from user awakephd here. Be aware that he has a typo in modEprobe.

UPDATE: Applying patches to a mainline kernel

It is possible to apply the most recent patches to a normally installed kernel. Here is an Ubuntu Forums post on how to do this.

Solution 2:

If you have access to an existing Linux system on the X205TA or any other device, I highly recommend using one of harryharryharry's scripts to prepare installation media. The most up-to-date version supports many distros and has the option to create a bootable USB for you. I use an old and much shorter version of the script and make the bootable myself.

NB: USB tethering to an Android device is usually effective for gaining internet access before wifi has been set up on this device. USB wifi adapters sometimes worked for me.

Here's the script (written by harryharryharry and made available on Ubuntu Forums)

#!/bin/bash

set -e
set -u

ISOFILENAME=$1
ISOPATH=$(pwd)
ISO=$ISOPATH/$ISOFILENAME
TEMPDIR=$(mktemp -d -p $ISOPATH)

function checkroot {
if [ "$EUID" -ne 0 ]
    then
        echo "Please run as root"
        removetempdir
        exit 1
    else
        echo "You are root, continuing..."
fi
}

function checkfreespace {
    if [ $(df -hk $ISOPATH|tail -n1|awk '{print $4}') -gt 6000000 ]
    then
        echo "Enough free space, continuing..."
    else
        echo "Not enough free space, move script and iso to a directory with more than 6GB free space and try again"
        removetempdir
        exit 2
    fi
}

function checkpartitiontype {
    if [ $(df -Thk $ISOPATH|tail -n1|awk '{print $2}') = "vfat" ] || [ $(df -Thk $ISOPATH|tail -n1|awk '{print $2}') = "ntfs" ]
    then
        echo "Wrong partition type: move the script and iso to a partition that supports group/ownership"
        removetempdir
        exit 3
    else
        echo "Partition type correct, continuing"
    fi
}

function unzipiso {
    7z x $ISO -o$TEMPDIR
}

function removetempdir {
    cd $ISOPATH
    rm -rf $TEMPDIR
}

function unsquash {
    pushd $TEMPDIR/casper
    unsquashfs filesystem.squashfs
    popd
}

function addstuff2squash {
    mkdir -p $TEMPDIR/casper/squashfs-root/etc/modprobe.d/
    echo "blacklist btsdio" >> $TEMPDIR/casper/squashfs-root/etc/modprobe.d/blacklist.conf
    mkdir -p $TEMPDIR/casper/squashfs-root/etc/systemd/system/suspend.target.wants
    cat > $TEMPDIR/casper/squashfs-root/etc/systemd/system/suspend.target.wants/root-resume.service << "EOF"
[Unit]
Description=Local system resume actions
After=suspend.target

[Service]
Type=simple
ExecStart=/bin/bash /usr/bin/elan-fix

[Install]
WantedBy=suspend.target
EOF
    cat > $TEMPDIR/casper/squashfs-root/usr/bin/elan-fix << "EOF"
#!/bin/sh

rmmod elan_i2c
modprobe elan_i2c
EOF
    chmod +x $TEMPDIR/casper/squashfs-root/usr/bin/elan-fix
    cat > $TEMPDIR/casper/squashfs-root/lib/firmware/brcm/brcmfmac43340-sdio.txt << "EOF"
manfid=0x2d0
prodid=0x0653
vendid=0x14e4
devid=0x4386
boardtype=0x0653
boardrev=0x1203
boardnum=22
macaddr=02:0A:F7:2A:3B:4C
sromrev=3
boardflags=0x0090201
xtalfreq=37400
nocrc=1
ag0=255
aa2g=1
aa5g=1
ccode=ALL
pa0itssit=0x20
pa0b0=6747
pa0b1=-808
pa0b2=-178
tssifloor2g=69
rssismf2g=0xf
rssismc2g=0x8
rssisav2g=0x1
cckPwrOffset=3
rssismf5g=0xf
rssismc5g=0x7
rssisav5g=0x3
pa1lob0=5659
pa1lob1=-693
pa1lob2=-178
tssifloor5gl=93
pa1b0=5172
pa1b1=-671
pa1b2=-212
tssifloor5gm=77
pa1hib0=5320
pa1hib1=-663
pa1hib2=-179
tssifloor5gh=74
rxpo5g=0
maxp2ga0=0x4E
cck2gpo=0x0000
ofdm2gpo=0x42000000
mcs2gpo0=0x2222
mcs2gpo1=0x7662
maxp5ga0=0x46
maxp5gla0=0x46
maxp5gha0=0x46
ofdm5gpo=0x52222222
ofdm5glpo=0x52222222
ofdm5ghpo=0x52222222
mcs5gpo0=0x0000
mcs5gpo1=0x8550
mcs5glpo0=0x0000
mcs5glpo1=0x8550
mcs5ghpo0=0x0000
mcs5ghpo1=0x8550
swctrlmap_2g=0x00080008,0x00100010,0x00080008,0x011010,0x11f
swctrlmap_5g=0x00020002,0x00040004,0x00020002,0x011010,0x2fe
gain=32
triso2g=8
triso5g=8
loflag=0
iqlocalidx5g=40
dlocalidx5g=70
iqcalidx5g=50
lpbckmode5g=1
txiqlopapu5g=0
txiqlopapu2g=0
dlorange_lowlimit=5
txalpfbyp=1
txalpfpu=1
dacrate2xen=1
papden2g=1
papden5g=1
gain_settle_dly_2g=4
gain_settle_dly_5g=4
noise_cal_po_2g=-1
noise_cal_po_40_2g=-1
noise_cal_high_gain_2g=73
noise_cal_nf_substract_val_2g=346
noise_cal_po_5g=-1
noise_cal_po_40_5g=-1
noise_cal_high_gain_5g=73
noise_cal_nf_substract_val_5g=346
cckpapden=0
paparambwver=1
EOF
    curl http://sprunge.us/SZET | base64 -d > $TEMPDIR/casper/squashfs-root/lib/firmware/brcm/brcmfmac43340-sdio.bin
    curl http://sprunge.us/XIKF | base64 -d > $TEMPDIR/casper/squashfs-root/lib/firmware/brcm/BCM43341B0.hcd
    cat > $TEMPDIR/casper/squashfs-root/etc/systemd/system/multi-user.target.wants/btattach.service << "EOF"
[Unit]
Description=Btattach

[Service]
Type=simple
ExecStart=/usr/bin/btattach --bredr /dev/ttyS1 -P bcm
ExecStop=/usr/bin/killall btattach

[Install]
WantedBy=multi-user.target
EOF
    echo "hci_uart" >> $TEMPDIR/casper/squashfs-root/etc/modules
}

function makesquash {
    mksquashfs $TEMPDIR/casper/squashfs-root/ $TEMPDIR/casper/filesystem.squashfs -noappend -always-use-fragments
    rm -rf $TEMPDIR/casper/squashfs-root/
}

function addstuff2iso {
    mkdir -p $TEMPDIR/EFI/BOOT
    curl http://sprunge.us/PYNY |base64 -d > $TEMPDIR/EFI/BOOT/bootia32.efi
    sed -i 's/--/intel_idle.max_cstate=1 --/g' $TEMPDIR/boot/grub/grub.cfg
}

function createzip {
    cd $TEMPDIR
    zip -ry $ISOPATH/$ISOFILENAME.zip .
    removetempdir
    successfulmessage
}

function successfulmessage {
echo "+---------------------------------------------------------------------------------"
echo "| Done creating the Live USB zip-file!                                            "
echo "| Now copy the contents of this zip-file to a fat32 formatted USB stick.          "
echo "+---------------------------------------------------------------------------------"
}

checkroot
checkfreespace
checkpartitiontype
unzipiso
unsquash
addstuff2squash
makesquash
addstuff2iso
createzip

exit 0

To use, copy the text into a file, save it as whatever you like, for example iso2zip, download any 64-bit Ubuntu iso (tested by me for 16.04, 16.10 and 17.04) and place the iso file and the script file in the same directory where you have at least 8GB free space. Run

chmod u+x iso2zip               # or whatever you named the file
sudo ./iso2zip name-of-iso.iso  # replace with the correct name

It will repack the iso as a zip file. Insert a spare USB flash drive and identify it with lsblk. Let's assume it is /dev/sdc (you must correct this and use the right name!) If the drive has mounted filesystems, unmount them (eg udisksctl unmount -b /dev/sdc1) Run these commands from the directory where the iso.zip file is, or use your own favourite method to make a bootable USB:

Please note that this destroys all data on /dev/sdc

sudo apt install p7zip-full                    
sudo sgdisk --zap-all /dev/sdc
sudo sgdisk --new=1:0:0 --typecode=1:ef00 /dev/sdc 
sudo mkfs.vfat -F32 /dev/sdc1                       
sudo mount -t vfat /dev/sdc1 /mnt
sudo 7z x name.of.file.iso.zip -o/mnt/              # use correct name!
sudo umount /mnt          

On the X205TA, from powered off, switch on and hit F2 to bring up the UEFI menu and turn off secure boot if not done already. To boot from USB, either select it in the boot order from here, or start again and hit esc to get the boot menu and select the USB. Select Try Ubuntu and connect to WiFi (it will work). Run the installer selecting whatever options you like. Reboot when done.

After installation, edit the config file for GRUB to pass a boot parameter to prevent freezing:

sudo nano /etc/default/grub

Change

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

to

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_idle.max_cstate=1"

Save, exit, run

sudo update-grub

For sound run the code from harryharryharry's post here to install a kernel that supports it:

wget ftp://x205ta.myftp.org:1337/kernel/kernel-sound-64bit.tar
tar xf kernel-sound-64bit.tar
sudo ./install-sound-kernel.sh -v

or compile yourself

TODO: make hibernation work with sound support kernel. (it works with the stock kernels with some tweaks- see my answer here)

For brightness controls see workaround