User:0xdc/Drafts/Samsung ARM Chromebook

The Samsung ARM Chromebook is the first generation of 11.6 inch Chromebook laptops built by Samsung.

The laptop features:


 * a dual-core Samsung Exynos5250 ARMv7-A (Cortex-A15) CPU with virtualisation extensions, clocked at 1.7GHz
 * 2GB RAM
 * 16GB eMMC flash
 * 11.6&quot;, 1366x768 (16:9 ratio), TN panel
 * One USB3 (Type-A) port
 * One USB2 (Type-A) port
 * One HDMI port
 * One SD card slot

At the time of writing, the ChromeOS Auto Update Expiry date was July 2018.

= Installation options =

You need to have the Chromebook in developer mode to run a custom Linux distribution.

Developer mode includes a shell that can be used to install a Gentoo system to a USB drive (or SD card for the Samsung ARM Chromebook).

By default, most of the ChromeOS filesystem is mounted read-only. While it is possible to make more of the system writable and persistant, locations such as  and   are already writable.

If you have a prepared stage4, or are willing to build upon the upstream stage3, a bootable disk can be prepared from another machine. Once unpacked, you can chroot into the environment to customise it.

= Hardware support =

These instructions target ARM Chromebooks running the Samsung Exynos 5250 SoC in 11.6&quot; laptop bodies, specifically the following:

Bootable ports
Snow can boot from the USB2 port (the port closest to the HDMI port) and the SD card.

Snow cannot boot from the USB3 port.

Snow revisions
The XE303C12 has up to 5 revisions:

= First time setup =

Entering developer mode
Warning

This action causes the laptop to wipe its disk and disable security protections Instructions can be found on the chromium website.

Once rebooted, enable  with:

Once set, operating systems can be booted from an SD card or USB storage device by pressing  on the startup warning screen.
 * 1) enable_dev_usb_boot

Tip

If you want the Chromebook in Developer Mode but not run a custom kernel (e.g. crouton, which isn’t covered here), set  with.

Getting a shell
You can access a console window by pressing Ctrl+Alt+F2. The top row of function keys is equivalent to the Functionkeys, so it may be labelled as a Forward arrow (→). You can use Ctrl+Alt+F1 (Back, ←) to return to Aura. You can do this at any time once ChromeOS has booted.

If you log in as a guest (Browse as Guest) or with a Google Account, you can open a shell with Ctrl+Alt+T. From the crosh shell (prompt ), use the   command to get a shell as the user.

has sudo access to gain root privileges.

Neutering the warning screen (optional)
Warning

This requires the removal of the firmware write-protect screw By default, the &quot;scary&quot; developer screen has a 30 second timeout and a loud beep. These can be neutered to a 3 second delay and no beep.

These changes persist even if the laptop is taken out of developer mode (i.e. back to secure ChromeOS mode).

The easy way
Use :

Run  without arguments for a description of available flags.
 * 1) /usr/share/vboot/bin/set_gbb_flags.sh 0x11

The hard way
For full instructions, including backing up the firmware flash data, see these instructions (johnlewis.ie).

= Cross-compiling =

When building the kernel, set the following environment variables:
 * 1) crossdev -S -t armv7a-hardfloat-linux-gnueabi

ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi-

qemu user-mode emulation
Because arm has a variety of possible CPU emulations, you will need to use a wrapper script to customise the CPU.
 * 1) emerge --buildpkg -a qemu[static-user,qemu_user_targets_arm]
 * 2) mkdir stage3-armv7a
 * 3) tar xf stage3-armv7a_hardfp-latest.tar.bz2 -C stage3-armv7a
 * 4) ROOT=stage3-armv7a emerge --nodeps --oneshot --usepkgonly qemu

I recommend unpacking qemu into its own directory and copying that prepared directory into any arm chroots that you need (if you need a lot).

You can then chroot, pychroot or systemd-nspawn as normal.
 * 1) ROOT=qemu emerge --nodeps --oneshot --usepkgonly qemu
 * 2) cd qemu
 * 1) gcc -static qemu-wrapper.c -O3 -s -o qemu-wrapper
 * 2) cd ..
 * 3) echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/qemu-wrapper:' &gt; /proc/sys/fs/binfmt_misc/register
 * 4) rsync -a qemu/ stage3-armv7a

= Building a kernel =

Build requirements:

Note

ChromeOS 3.8 requires additional patches for gcc 4.9.4, 5.4.0-r4 and 6.4.0. Warning

However, a ChromeOS kernel built with 6.4.0 does not boot correctly (or at all?) --keyblock /usr/share/vboot/devkeys/kernel.keyblock \ --version 1 \ --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \ --config cmdline \ --bootloader cmdline \ --vmlinuz kernel.itb \ --arch arm = Prepare installation media =
 * 1) make zImage
 * 2) make dtbs
 * 3) make modules
 * 1) mkimage -f kernel.its kernel.itb
 * 2) tee cmdline &lt;&lt;&lt;&quot;console=tty1 debug verbose root=/dev/${DEVICE}2 rootwait ro&quot;
 * 3) vbutil_kernel --pack exynos5.kpart \
 * 1) dd if=exynos5.kpart of=/dev/${DEVICE}1


 * GPT partition table
 * SD card
 * Samsung ARM Chromebook only
 * Device is /dev/mmcblk1
 * Partitions are separated with p, e.g. /dev/mmcblk1p2
 * USB storage
 * Device is /dev/sda
 * Internal Storage
 * Device is /dev/mmcblk0
 * Factory shipped with ChromeOS

The minimum required partition layout is as follows:

8MB is the size of a bootable kernel image. Additional space may need to be allocated to support an initramfs.

Depending on your partitioning tool, the type of the ChromeOS kernel partition may differ:

Booting with nv-u-boot / upstream u-boot
While the stock firmware is capable of booting custom Operating Systems, it can have a number of strange quirks:


 * updating a kernel requires overwriting a ChromeOS kernel partition, which (depending on your partition layout) may be limited in number, or cause your system to fail to boot
 * in addition to the configured kernel command line, the firmware prepends the string &quot;console= cros_secure&quot;
 * will disable kernel output during boot if it is not overridden in the cmdline
 * is an identifier for how the kernel was loaded https://www.chromium.org/chromium-os/chromiumos-design-docs/disk-format#TOC-Which-kernel-
 * embedded (e.g. ARM) developers may be more familiar with a u-boot environment to boot payloads

Google provide a version called nv-u-boot that can be booted like any other ChromeOS kernel, that boots to a u-boot prompt. Upstream u-boot also contains support for these boards.

The default nv-u-boot environment assumes a layout like this:

More info:


 * https://www.chromium.org/chromium-os/firmware-porting-guide/using-nv-u-boot-on-the-samsung-arm-chromebook

= Customisations =

make.conf
CFLAGS=&quot;-mfloat-abi=hard -mfpu=vfpv3-d16 -mtls-dialect=gnu -march=armv7ve -mtune=cortex-a15 -fstack-protector-strong&quot; CPU_FLAGS_ARM=&quot;edsp neon thumb vfp vfpv3 vfpv4 vfp-d32 v4 v5 v6 v7 thumb2&quot;

Wireless networking

 * Driver:
 * Firmware:
 * Software



ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel update_config=1 You can customise wpa_supplicant further or use wpa_cli as root or, if configured like above, as a user in the wheel group.

X11


Section &quot;InputClass&quot; Identifier &quot;Keyboard&quot; MatchProduct &quot;cros-ec-i2c&quot; #XXX: Confirm product name MatchIsKeyboard &quot;on&quot; Option &quot;XkbLayout&quot; &quot;gb&quot; Option &quot;XkbModel&quot; &quot;chromebook&quot; EndSection

Multi Format Codec (Hardware Video Encode/Decode Acceleration)
Caution

This has not been tested by the author and is here for reference The Samsung SoC contains a hardware accelerated video encoder and decoder which requires a firmware blob and compatible software.

Firmware:


 * https://www.kernel.org/doc/Documentation/devicetree/bindings/media/s5p-mfc.txt
 * https://s-opensource.org/2016/09/01/video-decoding-exynos-multi-format-codec-gstreamer/