Asus Chromebook C201

From Gentoo Wiki
Jump to: navigation, search

Specs

  • Internal name: veyron/speedy
  • SoC: Rockchip RK3288
  • CPU: Quad-core ARM Cortex-A17 @ 1.8 GHz
  • GPU: Mali T764
  • Audio: Rockchip I2S
  • 11.6" screen @ 1366x768
  • Ram: 2 or 4gb

I highly recommend the 4gb variant.

What works

On ChromeOS 3.14 or patched 4.12+:

  • Suspend/resume
  • Wireless (on newer kernels, with patch)
  • X w/ randr (HDMI assumed to work, not tested)
  • ACPI events (lid, buttons, charger)
  • Audio
  • Touchpad
  • Everything else!

What doesn't

  • No GPU hardware acceleration (yet!). Future progress in this area likely to come from https://gitlab.freedesktop.org/panfrost
  • Bluetooth - Bluetooth works, but if you load the module at any time, it will crash both itself and wireless if you attempt to suspend. The current fix is to blacklist the module.
  • Wireless without blobs - brcmfmac requires non-free firmware here.

Considerations

  • You'll likely want a USB ethernet dongle until you get Gentoo running. Ensure the module is included with your kernel or built-in if you're using the Devsus script to create a bootable USB.
  • This laptop is speedy for its size, but still takes a long time to emerge larger packages. I made heavy use of distcc and crossdev's armv7a-hardfloat-linux-gnueabi target.
  • There is only 16GB of internal storage space available. I use an SD card for my /home and a decent USB flash drive to compile larger packages on (firefox/libreoffice).
  • You can decide on using either the ChromeOS kernel (linux 3.14) or mainline with patches. Despite a large majority claiming you will lose functionality on newer kernels, this was not the case for me; in fact, it fixed several issues from harmless warning messages in logs to X locking up entirely.
  • I recommend adding the arm_support overlay.
  • I also highly recommend you backup your ChromeOS partition (mmcblk0), however you can easily restore ChromeOS if you mess up. You can create a restore USB medium through desktop Chrome or download the files manually to write to a USB drive.
Warning
DO NOT disable cros' developer mode! If you cannot boot your kernel, you will not be able to boot from your install medium and will be forced to "powerwash" your Chromebook. Even if you have a booting kernel, you will need crossystem/mosys to change these flags. This is the solution if this happens to you on Libreboot, though wait for partition 5 to complete instead.

Preparation

First, you must enable developer mode, unsigned boot and booting from external mediums. Look here for more information.

This laptop uses a depthcharge payload to boot, thus standard minimal ISOs will not work here. I recommend creating a Devsus image and writing it to a flash drive to use for your installation medium. If you do so, modify the kernel config file to include modules for either brcmfmac SDIO or your USB wifi/ethernet dongle.

Note
Devsus uses Google's 3.14 kernel. This is out of date and caused some issues for me. I recommend following the 4.13+ kernel configuration below.

Once you're booted into your minimal environment and have obtained an internet connection via either wifi or an ethernet dongle, obtain sys-boot/vboot-utils from whatever distro you're on. We will now wipe ChromeOS and setup a partition for our kernel, and leave the rest for root.

Warning

I cannot stress this enough: CHECK lsblk BEFORE DOING ANYTHING!

On Google's 3.14 kernel, the eMMC storage is presented as mmcblk0, and the SD is presented as mmcblk2. On newer kernels, this can be reversed, with internal storage being mmcblk2. Needless to say this can cause an issue if you partition or dd a device you don't want to!
Important
If you plan on using firmware blobs, copy them from ChromeOS's root partition to your flash medium for later use.
root #parted /dev/mmcblk[ID] mklabel gpt
root #cgpt create -z /dev/mmcblk[root ID]
root #cgpt create /dev/mmcblk[ID]
root #cgpt add -i 1 -t kernel -b 8192 -s 65536 -l Kernel -S 1 -T 5 -P 10 /dev/mmcblk[ID] # 32mb
root #sync

Partition the rest of the free space how you wish with gdisk. Put your root filesystem directly after the kernel partition.

If you plan to use the kernel on your USB drive, simply dd it to the internal storage and copy all modules from it:

root #dd if=/dev/sda1 of=/dev/mmcblk[ID]p1 conv=notrunc
root #mkfs.[fstype] /dev/mmcblk[ID]p2
root #mount /dev/mmcblk[ID]p2 /mnt/gentoo
root #cp -R /lib/modules/* /mnt/gentoo/lib/modules

Optionally, you can copy the firmware blobs you backed up earlier to lib/firmware on your internal storage root.

Base installation

At this point, you should follow generic stage3 install steps. Mount your root filesystem wherever and setup stage3/Portage:

Note
Exchange /mnt/gentoo with your mountpoint.

Proceed to chroot and emerge world and whatever else.

CODE make.conf flags
CFLAGS="-O2 -pipe -march=armv7-a -mtune=cortex-a17 -mfpu=neon -mfloat-abi=hard -pipe -fomit-frame-pointer -fstack-protector-strong"
CXXFLAGS="${CFLAGS}"
CHOST="armv7a-hardfloat-linux-gnueabi"
INPUT_DEVICES="synaptics evdev"
VIDEO_CARDS="fbdev" #fbturbo also works if you're using an overlay

4.13+ kernel configuration

Important
This script is out of date and will require adaptation to get it working, in particular the patches used. The important bits for building the raw kernel begin on line 171. I recommend using the RockMyy repo as is to build a kernel.

Requirements:

Clone the RockMyy repo:

user $cd RockMyy

Download the following gist:

https://gist.github.com/anonymous/d0ce3911c933562154ca2e3f5fe602c5

Save 0007-brcmfmac-wififix.patch to patches/kernel/v4.13

Save c201_kerngen.sh & kernel.its to .

Save config-latest to ./config/v4.13/

Create a file named cmdline in the current directory.

Put the following in it, replace rootfstype:

CODE cmdline
console=tty1 init=/sbin/init root=PARTUUID=%U/PARTNROFF=1 rootfstype=[ext4/f2fs/etc] rootwait rw quiet

The CPU governor defaults to conservative. If you want ondemand, or other modules, set MAKE_CONFIG=menuconfig to enter menuconfig.

Otherwise:

user $sh c201_kerngen.sh

If all goes well, this will put the kernel as ./kernel and the modules in ./modules

You can now scp/copy this file and folder to the C201. Once you've done this, or if you're compiling on the C201, install them:

root #dd if=kernel of=/dev/mmcblk[ID]p1 conv=notrunc
root #cp -Rv ./modules/lib /

You can use this kernel with the Devsus USB as well.

ACPI

CODE /etc/acpi/default.sh
#!/bin/sh
# /etc/acpi/default.sh
# Default acpi script that takes an entry for all actions

set $*

group=${1%%/*}
action=${1#*/}
device=$2
id=$3
value=$4

log_unhandled() {
	logger "ACPI event unhandled: $*"
}

case "$group" in
	jack)
		case "$id" in
			'plug')
				amixer -D hw:0 cset name='Left Speaker Mixer Left DAC Switch' off
				amixer -D hw:0 cset name='Right Speaker Mixer Right DAC Switch' off
				amixer -D hw:0 cset name='Headphone Switch Left' on
                                amixer -D hw:0 cset name='Headphone Switch Right' on
				;;
			'unplug')
				amixer -D hw:0 cset name='Left Speaker Mixer Left DAC Switch' on
                                amixer -D hw:0 cset name='Right Speaker Mixer Right DAC Switch' on
				amixer -D hw:0 cset name='Headphone Switch Left' off
                                amixer -D hw:0 cset name='Headphone Switch Right' off
				;;
			*) uhd $+;;
		esac
		log_unhandled $*
	;;
	button)
		case "$action" in
			#power)
					#pm-suspend
			#		log_unhandled $*
			#	;;

			lid)
				case "$id" in
					close) if [ $(cat /sys/class/power_supply/gpio-charger/online) -eq 0 ]; then
                                                        pm-suspend
                                                fi;;
					open) :;;
					*) uhd $*;;
				esac
				log_unhandled $*
				;;

			*)	log_unhandled $* ;;
		esac
		;;

	*)	log_unhandled $* ;;
esac

This handles alternating between speaker and headphone jack when one is plugged in, as well as lid suspend when the charger is unplugged. You can add power button support if you wish, though keep in mind the device will simply turn on again when you close the lid.

Note
It seems some mixer control names changed from 3.x to 4.x (i.e. Right Headphone Switch vs. Headphone Switch Right). If you are using a 3.x kernel, and this isn't working properly, ensure the names match up to what amixer says they should be.

ALSA/Pulse quirks

Add the following if you use Pulseaudio:

CODE /etc/pulse/default.pa
load-module module-alsa-sink device=sysdefault
load-module module-alsa-source device=sysdefault

See InstallingDebianOn/Asus/C201#Audio for further information. VEYRON-I2S shipped with alsa, so it's unlikely you'll need to add Google's UCM files.

I have not tested HDMI. It appeared under 3.14 as RockchipHDMI, but is missing under 4.13. Possibly a kernel config or UCM issue.

Keybinds

xbacklight doesn't work, however, a backlight device exists. You can use this in tandem with xbindkeys as a replacement for xbacklight:

CODE c201_backlight.sh
#!/bin/bash
if [ "$(($(cat /sys/devices/platform/backlight/backlight/backlight/brightness)+$1))" -gt "255" ];then
        echo 255 > /sys/devices/platform/backlight/backlight/backlight/brightness
        exit
fi
if [ "$(($(cat /sys/devices/platform/backlight/backlight/backlight/brightness)+$1))" -lt "0" ]; then
        echo 0 > /sys/devices/platform/backlight/backlight/backlight/brightness
        exit
fi

echo $(($(cat /sys/devices/platform/backlight/backlight/backlight/brightness)+$1)) > /sys/devices/platform/backlight/backlight/backlight/brightness

Provide the delta for the backlight as an argument, positive or negative.

This file is read-only by default, so you may want to add to the local service:

CODE /etc/local.d/backlight-permissions.start (with +x)
chmod 666 /sys/devices/platform/backlight/backlight/backlight/brightness

If you'd like to reassign your function keys for another purpose, you can do so by editing the /usr/share/X11/xkb/symbols/pc file.

In the following example, I've remapped the search key (LWIN) to Caps and set some of the function keys to much-needed movement keys. I also remapped my power button to the Delete key:

CODE /usr/share/X11/xkb/symbols/pc (add to "pc105" xkb_symbols)
key <LWIN>   {      [ Caps_Lock             ]       };
    key <FK01>   {      [ Home                  ]       };
    key <FK02>   {      [ End                   ]       };
    key <FK03>   {      [ Page_Up               ]       };
    key <FK04>   {      [ Page_Down             ]       };
CODE /usr/share/X11/xkb/symbols/inet (replace)
key <POWR>   {      [ Delete                ]       };

Restart X for these changes to take effect.

You may need to remove old files in /var/lib/xkb:

root #rm -rf /var/lib/xkb/*

Touchpad

Ensure the evdev and synaptics INPUT_DEVICES are set in make.conf.

Put 50-synaptics.conf in /etc/X11/xorg.conf.d

Google tools

You likely have sys-boot/vboot-utils installed at this point. This package contains utilities for Chromebooks, such as cgpt or crossystem, which is used to control firmware flags (USB boot, default boot device, etc). If you wish for this to work, mosys is also needed. You can acquire ebuilds for this here: https://github.com/doughdemon/felix-overlay

Other quirks

sys-apps/lm_sensors does not work here. You can query /sys/devices/virtual/thermal/thermal_zoneX/temp to get temperatures.

This will average the two CPU sensors up and output in a sane format:

user $echo "$((($(cat /sys/devices/virtual/thermal/thermal_zone1/temp)+$(cat /sys/devices/virtual/thermal/thermal_zone2/temp))/2000))"

sys-power/acpi does not display the correct discharge time. This can be obtained through upower:

user $upower -i /org/freedesktop/UPower/devices/battery_sbs_20_000b

If the bluetooth module loads and the system is suspended, both the bluetooth and wireless driver will stop working. A temporary fix is to blacklist the btsdio module:

root #echo "blacklist btsdio" > /etc/modprobe.d/blacklist-btsdio.conf

Resources

Thanks to Miouyouyou and dimkr for their projects!