Wednesday, 15 April 2015

Installing Arch Linux on Asus X205TA

Introduction

After contemplating whether to purchase the Asus X205TA after reading many forum posts about how difficult it is installing *nix on to it because of it's 32bit efi bootloader. I went and bought it anyway thinking of it as a challenge to get arch on to it (and I did) so here I am documenting the process.
  • What works:
    • WiFi works after some tweaks
    • Battery status ( now working thanks to Killian )
    • Everything else works, there are some things I haven't tested yet though..
  • What doesn't ( or just isn't set up properly ):
    • Sound

What you will need:

  1. A spare USB WiFi adapter OR an Android phone with a cable ( for tethering since wifi will not work in during install for kernel < 4.0 ), I used my android phone for this since I didn't have a spare WiFi adapter.
  2. A USB at least larger than 2GB as an installation medium.

Before you do anything you need to:

Installation phase:

Get the Arch ISO:

You want to get the latest iso from https://www.archlinux.org/download/
after you have the iso you will need to extract it.
Look here for more details (https://wiki.archlinux.org/index.php/Remastering_the_Install_ISO) scroll down to “Extracting the ISO” section.

Now, create a new directory to mount the ISO:
# mkdir /mnt/archiso
Mount the ISO to this directory (due to the nature of ISOs, the result is read-only):
# mount -t iso9660 -o loop /path/to/archISO /mnt/archiso
Copy the contents to another directory, where they can be edited:
$ cp -a /mnt/archiso ~/customiso

Get yourself a bootia32.efi file:

There's 2 ways to get one:

1) The easy way (Use the one I compiled)

https://mega.nz/#!dEVAyQjD!_ea-JzHGdtSh9NHZn38Tk1z_EQGcbuuv63vYsWeYmr4

2) The hard way (Compile your own)

make a new folder somewhere
make a new file call it grub.cfg and paste this inside it:
insmod part_gpt
insmod part_msdos
insmod fat
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
insmod font
if loadfont "${prefix}/fonts/unicode.pf2" ; then
insmod gfxterm
set gfxmode="1024x768x32;auto"
terminal_input console
terminal_output gfxterm
fi
menuentry "Arch Linux archiso x86_64" {
set gfxpayload=keep
search --no-floppy --set=root --label ARCH_201412
linux /arch/boot/x86_64/vmlinuz archisobasedir=arch archisolabel=ARCH_201412 add_efi_memmap
initrd /arch/boot/x86_64/archiso.img
}
menuentry "UEFI Shell x86_64 v2" {
search --no-floppy --set=root --label ARCH_201412
chainloader /EFI/shellx64_v2.efi
}
menuentry "UEFI Shell x86_64 v1" {
search --no-floppy --set=root --label ARCH_201412
chainloader /EFI/shellx64_v1.efi
}
Now open up a terminal in that folder and run:
grub-mkstandalone -d /usr/lib/grub/i386-efi/ -O i386-efi --modules="part_gpt part_msdos" --fonts="unicode" --locales="uk" --themes="" -o "/home/panda/grubi386_standalone.efi" "boot/grub/grub.cfg=/tmp/grub.cfg" -v
you should now have a bootia32.efi file


After you have your bootia21.efi

Remember that Arch iso you extracted earlier? Good, now copy the “bootia32.efi” into “/YourExtractedIso/EFI/boot/”

The purpose of the “bootia32.efi” is because the laptop only supports 32 bit bootloaders so since arch doesn't include a 32bit efi loader by default we had to make one for it.

Now you can re-build that iso.

It's probably a very good idea to read “https://wiki.archlinux.org/index.php/Remastering_the_Install_ISO” and follow the instructions there for “Create a new ISO” image.

Note: Use the same iso label as your untouched arch iso.
To determine this we use the 'file' command:
file originalArchImage.iso

In my case the output was:
triforce% file originalArchImage.iso 
archiso_orig.iso: DOS/MBR boot sector ISO 9660 CD-ROM filesystem data (DOS/MBR boot sector) 'ARCH_201412' (bootable); partition 2 : ID=0xef, start-CHS (0x3ff,254,63), end-CHS (0x3ff,254,63), startsector 252, 63488 sectors
The part "ARCH_201412" is the iso label you  should use when you run 'genisoimage', so substitute this part in the next command with whatever label the above command gave you.

Run:
genisoimage -l -r -J -V "ARCH_201209" -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -c isolinux/boot.cat -o ~/arch-custom.iso ~/customiso

After you have your ISO you can now create a bootable USB from it.

Making a boot-able disk:

For this part I booted into my windows partition and used Rufus (https://rufus.akeo.ie/) since dd failed to make a boot-able usb for me so for this part of the tutorial you will need to boot into windows for this or you can try dd, or another way to make a boot-able usb but Rufus is yet to fail me.

After installing Rufus (https://rufus.akeo.ie/)
load it up, select your USB device
set “partition scheme” to GPT partition
tick “quick format”
open up the ISO file you created and start the process.
After rufus is done making the usb continue.

Booting the USB:

plug in your USB into your shiny X205TA and boot it up.
It should ignore your USB and boot into windows 8.1 instead (don't panic, it's fine).
I don't remember the process completely, but navigate to the following:

“Change PC Settings” > “General” > “Advanced Startup” > “Restart now”.

After it restarts click on “Use a device” and select your USB.

Installing the Arch System.

If all went well your usb should have booted and you'd be in a root shell.

Getting an internet connection:

I'm using my android phone to tether. The instructions on https://wiki.archlinux.org/index.php/Android_tethering

worked perfectly for me.

Now that you have an internet connection you can proceed to install arch up to the "install and configure a bootloader” section of the beginners guide: https://wiki.archlinux.org/index.php/Beginners'_guide

I would Highly suggest you do not dual boot and remove all the partitions first.

You can follow my partitioning scheme:

mmcblk0p1 512MB /boot
mmcblk0p1 28.6GB /

You can also find a bunch of UEFI partitioning schemes in here

you can create a separate /home partition and also create a SWAP partition but really not necessary.

Installing the boot-loader:

make sure you're chroot'd into the system
arch-chroot /mnt /bin/bash
1) install grub and efibootmgr packages:
# pacman -S grub efibootmgr
2) install grub with 32bit efi:
# grub-install –target=i386-efi –efi-directory=/boot --bootloader-id=grub_uefi –recheck

3) Generate the grub.cfg file
# grub-mkconfig -o /boot/grub/grub.cfg
more info: https://wiki.archlinux.org/index.php/GRUB#Installation_2

After rebooting you should be booted into your arch system.


Post installation:

After you've installed your base system we can now continue to fixing various parts to get it working with x205ta.

Installing the Linux kernel 4.0:

Note: As of writing this linux 4.0-2 is now on the arch testing repo, so you could change your /etc/pacman.conf file to enable the testing repository and run # pacman -Syyu
However I have not tested this method. 

You can compile the 4.0 kernel on your main machine and just copy over the install files on a usb or compile them on the laptop.

To compile them on your laptop (probably slower) you can install linux-mainline package form the Arch user repository (https://aur.archlinux.org/packages/linux-mainline/)

After updating your kernel to the latest you will probably have to re-generate your grub config file:
# grub-mkconfig -o /boot/grub/grub.cfg


After rebooting check with “uname -a” if you're running the 4.0 kernel.

Getting wifi working:

note: you'll probably have to tether with your android phone again to get wifi in order to download the drivers to install.

Get the wifi drivers by
wget https://android.googlesource.com/platform/hardware/broadcom/wlan/+archive/master/bcmdhd/firmware/bcm43341.tar.gz
then extract tar
tar xf bcm43341.tar.gz

copy firmware files over
cp fw_bcm43341.bin /lib/firmware/brcm/brcmfmac43340-sdio.bin
cp /sys/firmware/efi/efivars/nvram-74b00bd9-805a-4d61-b51f-43268123d113 /lib/firmware/brcm/brcmfmac43340-sdio.txt


We need to disable SDHCI-ACPI for wireless (more info on this https://wiki.debian.org/InstallingDebianOn/Asus/X205TA)

make a file in your home folder “~/.startup.sh” and populate it with:
#!/bin/sh
echo on > /sys/bus/platform/drivers/sdhci-acpi/INT33BB\:00/power/control
next cd into /etc/systemd/system/
make a file called startup.service
and populate it with:
[Unit]
Description=startup

[Service]
ExecStart=/root/.startup.sh

[Install]
WantedBy=multi-user.target
Enable that service by
# systemctl enable startup.service
reboot

Your WiFi should now be working.

enjoy your super light weight arch laptop!

Getting battery status working

You'll need to recompile linux-mainline with these options:
CONFIG_X86_INTEL_LPSS=y
CONFIG_PINMUX=y
CONFIG_PINCONF=y
CONFIG_PINCTRL_BAYTRAIL=y
CONFIG_I2C=y
CONFIG_ACPI_I2C_OPREGION=y
 However if you don't want to go through compiling it; Here's the one I've compiled with the above configuration options enabled. (linux-mainline-4.2rc5.tar.gz)
https://mega.nz/#!EINmBYbL!dAuPsCE-tGK-qYp7uX_bHxBTqfN_x4wHbQGr9Dj908s

Extract the tar.xz and install each package with the "pacman -U filename" command, so:
#pacman -U linux-mainline-headers-4.1rc3-1-x86_64.pkg.tar.xz
#pacman -U linux-mainline-4.1rc3-1-x86_64.pkg.tar.xz
the "linux-mainline-docs-4.1rc3-1-x86_64.pkg.tar.xz" is optional.

Fixing the freezing (almost)

After testing, i realized that the laptop would freeze almost always during graphic intensive games like minecraft. So this led me to believe the main cause was something to do with the gpu frequency. 

So what we want to do is underclock the gpu.

you can check the max frequency using:
#cat /sys/kernel/debug/dri/0/i915_max_freq
We then change the max frequency to 333.
#echo 333 > /sys/kernel/debug/dri/0/i915_max_freq
you would need to type in that command every reboot as root or if you're lazy like me you can make a script to do it for you!. I used the "session-setup-script" option from /etc/lightdm/lightdm.conf, so the script is executed as root when i log in.

This almost fixes the freezing; It still occurs but much more rarely.

information sources:

https://wiki.debian.org/InstallingDebianOn/Asus/X205TA
http://ubuntuforums.org/showthread.php?t=2254322
https://wiki.archlinux.org/index.php/Remastering_the_Install_ISO
https://rufus.akeo.ie/
http://blog.terranux.net/2013/11/playing-with-the-gpu-frequencies-on-a-samsung-np530-u3c/

Pictures and screenshots:

Running i3wm


Running xfce4


Photo of how it looks. The screen looks faded but it's not noticeable at all when facing it head on. 


42 comments:

  1. Hi Irfan
    Could you please share your custom ISO file?
    Thanks

    ReplyDelete
  2. can you provide your nvram-blah.txt?

    I tried to search /sys/firmware/efi/efivars but there's no file starts with nvram-*.
    there's a BDADDR-74b00bd9-blah, but that's a 10-byte binary file...

    I tried to copy that file to /lib/firmware/brcm/brcmfmac43340-sdio.txt, but modprobe fails with error -22.

    is your file also a 10-byte binary? or is it something text-looking?

    ReplyDelete
    Replies
    1. here's the nvram file https://mega.co.nz/#!NRlVmCyJ!b1c_p7Q891HTYt6YMan2yCgUWam3IrUNfDBpR6RxCWg

      The file is around 2.7 kB, and can be edited/opened in an editor.

      Delete
  3. What kind of battery life are you getting?

    Again, thank so much for this writeup, it is really helpful for us Thinkpad users who aren't used to a "just works" install :)

    ReplyDelete
    Replies
    1. I get around 9-10 hours, sometimes more.

      haha you're welcome :)

      Delete
  4. Hey, thanks a lot for the info.
    Is this completely formating the drive or dual-booting is possible?
    And is the audio still not working?
    Thank you

    ReplyDelete
    Replies
    1. The tutorial focuses on completely removing windows.
      You can setup a dual boot if you want although i wouldn't recommend it since windows is going to take up a lot of space.

      The audio is still not working sadly

      Delete
    2. Hi, I'm interested in having the same setup as you. Just wondering about two things, first is how do you find this setup and laptop? Do you like it other than the fact the audio isn't working?

      And lastly, Linux 4.1 has been released on Arch's core repositories if I'm not wrong. I'm just wondering if you have updated and how your laptop took it.

      Delete
    3. And thank you for your EFI 32-bit file btw. Very useful. :)

      Delete
    4. The setup i am using is awesome; I don't mind the audio so much since i mostly use this laptop for taking lecture notes, and working on programming projects during long train rides.

      I'm running the 4.1.0-1-mainline kernel which i compiled myself to get battery status working.
      However i also tested the current 4.1.3-1 kernel from the base repo which works great except for battery status which doesn't work unless you compile your own with custom options.

      Delete
  5. I followed your instructions step by step however once I boot into grub menu and select any option my system freezes with a black screen until I hard reset it :(

    ReplyDelete
    Replies
    1. That's terrible;
      I don't know what could've gone wrong. Are you getting any errors?
      Maybe something went wrong with your install, or there's something wrong with your grub config file.

      When you get to the grub menu press 'e' which should allow you to edit boot parameters.

      Delete
    2. That is a label issue. When creating a bootable usb with rufus you need to lookup the iso label it automatically assigns and use it to modify grub.cfg and everywhere it appears. You used "ARCH_201209" which is old and cannot be used anymore.
      Since you don't warn against this I think a lot of ppl will run into such problem without even knowing what caused it.

      Delete
    3. Yeah i forgot to mention the label part.
      use "file originalArchiso.iso" command to get the correct label to use.

      the above command should give you an output along the lines of: "archiso_orig.iso: DOS/MBR boot sector ISO 9660 CD-ROM filesystem data (DOS/MBR boot sector) 'ARCH_201412' (bootable);"..etc

      use the "ARCH_201412" as the label when you run genisoimage.

      Delete
  6. Another thing, I was able to install Lubuntu on this machine and with their latest available kernel 4.0.3 everything seems to work fine except audio and suspend which I think is current biggest problem of this machine.
    I also managed to install Manjaro on it with even newer 4.1.3-2 kernel. However battery status is not available for some mysterious reason out of the box and I assume I need to recompile the kernel. Since I have never did it myself could you please add an example of how to compile and install a kernel for x205ta (how did you do it?). Because the one I compiled from sources with all baytrail options enabled produces kernel panics:(

    ReplyDelete
    Replies
    1. I used linux-mainline from AUR, changed the config.x86_64 file to include the baytrail options, updated the sha256sums in buildpkg then ran buildpkg -s

      Delete
  7. I did what you said to get the battery monitor working but nothing has changed. I still cant get the battery monitor to show the right values in the xfce4 panel.

    ReplyDelete
    Replies
    1. Here's the latest kernel (4.2rc5) i compiled with the battery options:

      https://mega.nz/#!EINmBYbL!dAuPsCE-tGK-qYp7uX_bHxBTqfN_x4wHbQGr9Dj908s

      remember to update grub.config
      and select "Arch Linux, linux-X205TA" in the grub menu.

      Delete
    2. may be problem with the specific file sharing website in my country.. can you share it via google drive?

      Delete
    3. yes.. https://mega.nz is blocked in india.. :( .. Thanks in advance ;)

      Delete
  8. is there anything such as a brightness control :P

    ReplyDelete
    Replies
    1. I use "xbacklight" to set brightness from terminal.

      Delete
  9. This comment has been removed by the author.

    ReplyDelete
  10. Thanks for the post, I just purchased and ASUS x205ta and plan on installin' arch. Hope I can get it working well.

    ReplyDelete
  11. Hey.

    I'm thinking about getting this thing, but I was wondering is it any good for programming? I'm mostly looking for a cheap, portable notebook with a good battery life where I can code and do some uni work. I will also (most likely) a ssh to my desktop computer back home for more compute heavy activities. So, did anything improve in terms of hardware support? Cheers

    ReplyDelete
    Replies
    1. It's a great little laptop, if you don't mind the freezing although it rarely happens. I use it as my lightweight uni laptop for taking notes and programming.

      Delete
    2. Would ssh work fine on this thing? Like I said, I have a powerful linux server back home from which I work so I'd probably connect to it. Would this laptop suffice ?

      Delete
    3. This comment has been removed by the author.

      Delete
  12. Guys, is their any hope in getting the sound working for this device??

    ReplyDelete
  13. i installed archlinux on the tiny little thing for no more than 1 day, but already encounter more than 5 times system freezing!!!! do not know how to settle this problem.

    ReplyDelete
    Replies
    1. Yup, just updated the blog on how to almost fix it.

      Delete
  14. can you please upload bootia32.efi file.The current link seems to be down.
    Thanks in advance

    ReplyDelete
  15. cant get the keyboard backlight working :(. i cant remember if this laptop even has one lol

    ReplyDelete
  16. Hi, i'm stuck. when i run the comand "file OriginalArchISO" i get the following outcome:

    archlinux-2016.03.01-dual.iso: ; partition 2 : ID=0xef, start-CHS (0x3ff,254,63), end-CHS (0x3ff,254,63), startsector 172, 63488 sectors

    but i dont see the LABEL here... i dont know what i'm doing wrong.

    ReplyDelete
  17. Thanks for sharing this useful information about phone wifi adapters….keep it up
    phone wifi adapter

    ReplyDelete
  18. Amazing guide I will try it on my ASUS EEEBOOK X205TA and will give review.

    ReplyDelete
  19. Could I trouble you to compile another .efi file but with "ARCH_201609" instead?

    Doesn't seem to be a way to compile EFI files on Windows. And just using the one in this guide gets me the black screen another commenter mentioned.

    Cheers.

    ReplyDelete