Mainline on Galaxy S3

After successfully getting UART working, the next thing to do is boot a mainline kernel. Fortunately, on i9300 we have something of a head start: Samsung has upstreamed some amount of support for "trats2", a variant of the GT-I9300 used as the reference device for Tizen. However, the i9300 and trats2 have different partition layouts and different bootloaders: I learned in IRC that trats2 has a version of Samsung's proprietary bootloader S-BOOT which chainloads u-boot.

Unfortunately, the older Samsung bootloader doesn't fully comply with Linux's requirements - namely, it doesn't properly disable the MMU before booting into Linux. Fortunately, a commit exists in the Android kernel to fix this. Nor do we get DTB support - so we have to use appended DTBs until another solution can be figured out. After applying that commit, and a few other commits from Wolfgang Wiedmeyer's experiments with running Replicant on mainline, we have a kernel that (should) boot. Now, we just have to boot it...

Coming from an Android background, I wasn't really sure where to start. Going straight to Android sounds attractive, but the overhead Android adds to a system is massive - spending an hour or two building an image, only to find it doesn't work is a big investment of time. Fortunately, buildroot exists. All it needs is a defconfig and two patches to build on Arch with a 4.13 target kernel, and we have something working (hopefully).

But first, one small hurdle: buildroot produces two files, rootfs.cpio.lzma and zImage.exynos4412-trats2 - we need to combine these, using abootimg. Fortunately, I have no shortage of reference boot.imgs for i9300 - all I need is the boot image config, and we're away:

$ abootimg --create boot.img -f bootimg-i9300.cfg -k zImage.exynos4412-trats2 -r rootfs.cpio.lzma

reading config file bootimg-i9300.cfg
reading kernel from zImage.exynos4412-trats2
reading ramdisk from rootfs.cpio.lzma
Writing Boot Image boot.img

The moment of truth

So, I flashed the boot.img from the device, using TWRP and dd, and rebooted.

mainline

(This image contains a few spoilers for upcoming posts, but you get the idea...)

And sure enough, on the serial console (after hitting "enter" once):

Welcome to Buildroot
(none) login:

Nice!

What seems to be working in mainline for i9300 is:

  • Display (sort of - there seems to have been a regression in the DSI driver which causes some intermittent artifacting)
  • Touchscreen
  • Hardware keys
  • USB
  • UART
  • MMC

There's probably more that I haven't tested - but this is a pretty nice place to start hacking :)