Buildroot support for Chromebook Elm
cover Buildroot support for Chromebook Elm
This patch series adds supports for generating Buildroot kernel + rootfs images for the Arm Elm Chromebook
(https://www.acer.com/ac/en/US/content/series/acerchromebookr13).
A board is added under boards/chromebook which provides infrastructure necessary to generate images. For example, the kernel.its file helps to generate FIT image while the kernel.args file lists all the necessary kernel command line params. Both of these files are used to generate a signed kernel image by the sign.sh file. This folder also contains a patch which must be applied to the linux kernel to get the HDMI working. This patch is lying in "drm-misc-next" and should make it to the mainline by 5.10, at which point it should be removed from buildroot and kernel up-reved to 5.10 assuming nothing else fails. We also add a configuration necessary to build the kernel.
In addition, a defconfig for Elm chromebook is added to make life easy for the user. To generate kernel+rootfs, the user only needs to do
make chromebook_elm_defconfig
make menuconfig # If changes are required
make -j ${nproc}
All of this is briefly mentioned in the readme file under the elm board file.
Bilal Wasim (3):
configs: Add default configuration for Chromebook Elm.
boards: chromebook: Move "mksd.sh" out of chromebook snow folder.
boards: chromebook: Add support of Chromebook Elm
board/chromebook/elm/kernel.args | 1 +
board/chromebook/elm/kernel.its | 38 ++
board/chromebook/elm/linux-5.9-elm-hdmi.patch | 404 ++++++++++++++++
board/chromebook/elm/linux.config | 453 ++++++++++++++++++
board/chromebook/elm/readme.txt | 56 +++
board/chromebook/elm/sign.sh | 41 ++
board/chromebook/{snow => }/mksd.sh | 0
configs/chromebook_elm_defconfig | 35 ++
configs/chromebook_snow_defconfig | 2 +-
9 files changed, 1029 insertions(+), 1 deletion(-)
create mode 100644 board/chromebook/elm/kernel.args
create mode 100644 board/chromebook/elm/kernel.its
create mode 100644 board/chromebook/elm/linux-5.9-elm-hdmi.patch
create mode 100644 board/chromebook/elm/linux.config
create mode 100644 board/chromebook/elm/readme.txt
create mode 100644 board/chromebook/elm/sign.sh
rename board/chromebook/{snow => }/mksd.sh (100%)
create mode 100644 configs/chromebook_elm_defconfigSignature · 1 line
2.25.1
PATCH 1/3 configs: Add default configuration for Chromebook Elm.
The architecture of the MT8173 SoC is armv8-a in a big-little config. This SoC is supported by the Chrome-OS linux kernel, but the mainline support is reasonably good as well (benchmarks / conformance run fine) and so that is used. For now, the kernel is 5.9-rc5 which will be uprevd to 5.9 once its released.
The defconfig also lists all the tools (parted, vboot) that are necessary to create a bootable image.
--- configs/chromebook_elm_defconfig | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 configs/chromebook_elm_defconfig
configs/chromebook_elm_defconfig new file +35 -0
@@ -0,0 +1,35 @@ +# Architecture +BR2_aarch64=y +BR2_cortex_a72_a53=y + +# Filesystem +BR2_TARGET_ROOTFS_EXT2=y +BR2_TARGET_ROOTFS_EXT2_4=y + +# Kernel +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_VERSION=y +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.9-rc5" +BR2_LINUX_KERNEL_PATCH="board/chromebook/elm/linux-5.9-elm-hdmi.patch" + +# Build Kernel with a Custom config. +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/chromebook/elm/linux.config" + +# DTS support +BR2_LINUX_KERNEL_DTS_SUPPORT=y +BR2_LINUX_KERNEL_INTREE_DTS_NAME="mediatek/mt8173-elm" + +# Package Firmware for WiFi chip. +BR2_PACKAGE_LINUX_FIRMWARE=y +BR2_PACKAGE_LINUX_FIRMWARE_MWIFIEX_SD8797=y + +# Scripts to generate final images. +BR2_ROOTFS_POST_BUILD_SCRIPT="board/chromebook/elm/sign.sh" +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/chromebook/mksd.sh" + +# Supporting host tools to build / sign FIT Image. +BR2_PACKAGE_HOST_PARTED=y +BR2_PACKAGE_HOST_UBOOT_TOOLS=y +BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT=y +BR2_PACKAGE_HOST_VBOOT_UTILS=y
Signature · 1 line
2.25.1
PATCH 1/3 configs: Add default configuration for Chromebook Elm.
Hello,
Quoted 10 lines · On Mon, 21 Sep 2020 23:12:44 +0500 Bilal Wasim <[email protected]> wrote:
The architecture of the MT8173 SoC is armv8-a in a big-little config. This SoC is supported by the Chrome-OS linux kernel, but the mainline support is reasonably good as well (benchmarks / conformance run fine) and so that is used. For now, the kernel is 5.9-rc5 which will be uprevd to 5.9 once its released.
The defconfig also lists all the tools (parted, vboot) that are necessary to create a bootable image.
Signed-off-by Bilal Wasim <[email protected]>
The commit title should be:
configs/chromebook_elm: new defconfig
and it should be squashed with your PATCH 3/3. Indeed as it is, your PATCH 1/3 alone doesn't build: it depends on files added by PATCH 3/3.
Quoted 10 lines
configs/chromebook_elm_defconfig | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 configs/chromebook_elm_defconfigconfigs/chromebook_elm_defconfig new file +0
-0
configs/chromebook_elm_defconfig line 7
Quoted 7 lines
configs/chromebook_elm_defconfig new file +7
-0@@ -0,0 +1,35 @@ +# Architecture +BR2_aarch64=y +BR2_cortex_a72_a53=y + +# Filesystem +BR2_TARGET_ROOTFS_EXT2=y +BR2_TARGET_ROOTFS_EXT2_4=y
You'll need a:
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_9=y
but this option doesn't exist yet, so we'll have to add it.
Other than that, the defconfig looks good to me.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 2/3 boards: chromebook: Move "mksd.sh" out of chromebook snow folder.
In reply to Bilal WasimThe same script is used by Chromebook Elm to generate a bootable SD / USB image. Therefore, move the script out of the snow folder to one level above (boards/chromebook/snow -> boards/chromebook).
Update the Chrome snow defconfig to reflect the new location of the script.
---
board/chromebook/{snow => }/mksd.sh | 0
configs/chromebook_snow_defconfig | 2 +-
2 files changed, 1 insertion(+), 1 deletion(-)
rename board/chromebook/{snow => }/mksd.sh (100%)board/chromebook/mksd.sh renamed from board/chromebook/snow/mksd.sh +0 -0
configs/chromebook_snow_defconfig +1 -1
@@ -4,7 +4,7 @@ BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_15=y BR2_TARGET_GENERIC_GETTY_PORT="tty1" BR2_TARGET_GENERIC_GETTY_TERM="linux" BR2_ROOTFS_POST_BUILD_SCRIPT="board/chromebook/snow/sign.sh" -BR2_ROOTFS_POST_IMAGE_SCRIPT="board/chromebook/snow/mksd.sh" +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/chromebook/mksd.sh" BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_VERSION=y BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.15"
Signature · 1 line
2.25.1
PATCH 2/3 boards: chromebook: Move "mksd.sh" out of chromebook snow folder.
Hello Bilal,
Thanks for your contribution!
Quoted 7 lines · On Mon, 21 Sep 2020 23:12:45 +0500 Bilal Wasim <[email protected]> wrote:
The same script is used by Chromebook Elm to generate a bootable SD / USB image. Therefore, move the script out of the snow folder to one level above (boards/chromebook/snow -> boards/chromebook).
Update the Chrome snow defconfig to reflect the new location of the script.
Quoted 6 lines
Signed-off-by Bilal Wasim <[email protected]>--- board/chromebook/{snow => }/mksd.sh | 0 configs/chromebook_snow_defconfig | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename board/chromebook/{snow => }/mksd.sh (100%)
I fixed up a bit the commit title and commit log, and applied. This indeed is needed as a pre-requisite to adding the Chromebook Elm configuration.
Another question: could you see if this mksd.sh script can be dropped in favor of using genimage to generate the SD card image? Indeed, genimage now has support for GPT partitions, so I believe it should be able to generate a working image. Do you think you could have a look at that ?
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 3/3 boards: chromebook: Add support of Chromebook Elm
In reply to Bilal WasimThis commit adds supports for building buildroot kernel + rootfs for MT8173 Elm board, also known as Chromebook Elm
(https://www.acer.com/ac/en/US/content/series/acerchromebookr13).
Though Chrome-OS is officially supproted on this board, the mainline kernel works as well (benchmarks + conformance), and so the 5.9 kernel is used. As the 5.9 kernel isn't yet released, we use the 5.9-rc5 for now, which will be up-revd to 5.9 once its released.
Using the mainline kernel means that we have to apply certain patches to get the HDMI screen working. These patches are lying in the "drm-misc-next" list and will make it to the kernel after 5.9. At that time, we will remove the patches and point buildroot to use the latest kernel (hopefully, 5.10).
This commit also adds an ITS file(for creating FIT images), an ARGS file(for providing kernel args) and a "sign.sh" script to generate signed kernel images.
Additionally a readme is added to help the user get started.
--- board/chromebook/elm/kernel.args | 1 + board/chromebook/elm/kernel.its | 38 ++ board/chromebook/elm/linux-5.9-elm-hdmi.patch | 404 ++++++++++++++++ board/chromebook/elm/linux.config | 453 ++++++++++++++++++ board/chromebook/elm/readme.txt | 56 +++ board/chromebook/elm/sign.sh | 41 ++ 6 files changed, 993 insertions(+) create mode 100644 board/chromebook/elm/kernel.args create mode 100644 board/chromebook/elm/kernel.its create mode 100644 board/chromebook/elm/linux-5.9-elm-hdmi.patch create mode 100644 board/chromebook/elm/linux.config create mode 100644 board/chromebook/elm/readme.txt create mode 100644 board/chromebook/elm/sign.sh
board/chromebook/elm/kernel.args new file +1 -0
@@ -0,0 +1 @@ +root=PARTUUID=%U/PARTNROFF=1 rootwait rw noinitrd kern_guid=%U console=tty0
board/chromebook/elm/kernel.its new file +38 -0
@@ -0,0 +1,38 @@ +/dts-v1/; + +/ { + description = "Chrome OS kernel image with FDT"; + #address-cells = <1>; + + images { + kernel-1 { + data = /incbin/("Image"); + type = "kernel_noload"; + arch = "arm64"; + os = "linux"; + compression = "none"; + load = <0>; + entry = <0>; + }; + + fdt-1 { + description = "mt8173-elm.dtb"; + data = /incbin/("mt8173-elm.dtb"); + type = "flat_dt"; + arch = "arm64"; + compression = "none"; + + hash-1 { + algo = "sha1"; + }; + }; + }; + + configurations { + default = "conf-1"; + conf-1 { + kernel = "kernel-1"; + fdt = "fdt-1"; + }; + }; +};
board/chromebook/elm/linux-5.9-elm-hdmi.patch new file +404 -0
404 lines not on this page · raw message
board/chromebook/elm/linux.config new file +453 -0
454 lines not on this page · raw message
board/chromebook/elm/readme.txt new file +56 -0
56 lines not on this page · raw message
board/chromebook/elm/sign.sh new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 3/3 boards: chromebook: Add support of Chromebook Elm
Hello,
Quoted 7 lines · On Mon, 21 Sep 2020 23:12:46 +0500 Bilal Wasim <[email protected]> wrote:
board/chromebook/elm/kernel.args | 1 + board/chromebook/elm/kernel.its | 38 ++ board/chromebook/elm/linux-5.9-elm-hdmi.patch | 404 ++++++++++++++++ board/chromebook/elm/linux.config | 453 ++++++++++++++++++ board/chromebook/elm/readme.txt | 56 +++ board/chromebook/elm/sign.sh | 41 ++ 6 files changed, 993 insertions(+)
You should add an entry in the DEVELOPERS file to reference the defconfig and board/chromebook/elm/ directory.
board/chromebook/elm/linux-5.9-elm-hdmi.patch
Quoted 5 lines
board/chromebook/elm/linux-5.9-elm-hdmi.patch new file +0
-0
Please use one file for each patch, instead of concatenating all patches into one file. The patches should be generated with "git format-patch".
Quoted 79 lines
board/chromebook/elm/readme.txt new file +56
-0@@ -0,0 +1,56 @@ +Mediatek MT8173 aka Chromebook Elm +================================== + +This file describes booting the Chromebook from an SD card containing +Buildroot kernel and rootfs, using the original bootloader. This is +the least invasive way to get Buildroot onto the devices and a good +starting point. + +The bootloader will only boot a kernel from a GPT partition marked +bootable with cgpt tool from vboot-utils package. +The kernel image must be signed using futility from the same package. +The signing part is done by sign.sh script in this directory. + +It does not really matter where rootfs is as long as the kernel is able +to find it, but this particular configuration assumes the kernel is on +partition 1 and rootfs is on partition 2 of the SD card. +Make sure to check kernel.args if you change this. + +Making the boot media +--------------------- +Start by configuring and building the images. + + make chromebook_elm_defconfig + make menuconfig # if necessary + make + +The important files are: + + uImage.kpart (kernel and device tree, signed) + rootfs.tar + bootsd.img (SD card image containing both kernel and rootfs) + +Write the image directly to some SD card. +WARNING: make sure there is nothing important on that card, +and double-check the device name! + + SD=/dev/mmcblk1 # may be /dev/sdX on some hosts + dd if=output/images/bootsd.img of=$SD + +Switching to developer mode and booting from SD +----------------------------------------------- +Power Chromebook down, then power it up while holding Esc+F3. +BEWARE: switching to developer mode deletes all user data. +Create backups if you need them. + +While in developer mode, Chromebook will boot into a white screen saying +"OS verification is off". + +Press Ctrl-D at this screen to boot Chromium OS from eMMC. +Press Ctrl-U at this screen to boot from SD (or USB) +Press Power to power it off. +Do NOT press Space unless you mean it. +This will switch it back to normal mode. + +The is no way to get rid of the white screen without re-flashing the bootloader. +board/chromebook/elm/sign.sh new file +11
-0@@ -0,0 +1,41 @@ +#!/bin/sh + +# This script creates u-boot FIT image containing the kernel and the DT, +# then signs it using futility from vboot-utils. +# The resulting file is called uImage.kpart. + +BOARD_DIR=$(dirname $0)/${BOARD_NAME} +mkimage=$HOST_DIR/bin/mkimage +futility=$HOST_DIR/bin/futility +devkeys=$HOST_DIR/share/vboot/devkeys +
board/chromebook/elm/sign.sh line 21
Quoted 10 lines
board/chromebook/elm/sign.sh new file +10
-0+run() { echo "$@"; "$@"; } +die() { echo "$@" >&2; exit 1; } +test -f $BINARIES_DIR/Image || \ + die "No kernel image found" +test -x $mkimage || \ + die "No mkimage found (host-uboot-tools has not been built?)" +test -x $futility || \ + die "No futility found (host-vboot-utils has not been built?)" + +# kernel.its references zImage and exynos5250-snow.dtb, and all three
Bad copy paste here :-)
Quoted 10 lines
board/chromebook/elm/sign.sh new file +10
-0+# files must be in current directory for mkimage. +run cp $BOARD_DIR/kernel.its $BINARIES_DIR/kernel.its || exit 1 +echo "# entering $BINARIES_DIR for the next command" +(cd $BINARIES_DIR && run $mkimage -f kernel.its uImage.itb) || exit 1 + +# futility requires non-empty file to be supplied with --bootloader +# even if it does not make sense for the target platform. +echo > $BINARIES_DIR/dummy.txt + +run $futility vbutil_kernel \
board/chromebook/elm/sign.sh line 41
Quoted 10 lines
board/chromebook/elm/sign.sh new file +10
-0+ --keyblock $devkeys/kernel.keyblock \ + --signprivate $devkeys/kernel_data_key.vbprivk \ + --arch aarch64 \ + --version 1 \ + --config $BOARD_DIR/kernel.args \ + --vmlinuz $BINARIES_DIR/uImage.itb \ + --bootloader $BINARIES_DIR/dummy.txt \ + --pack $BINARIES_DIR/uImage.kpart || exit 1 + +rm -f $BINARIES_DIR/kernel.its $BINARIES_DIR/dummy.txt
This script looks very very similar to the one for the snow Chromebook. The only difference that I could spot is the --arch argument, which is --arch arm in snow, and --arch aarch64 here.
So, I guess you could easily do a:
if test grep -q ^BR2_arm=y ${BR2_CONFIG}; then
arch="arm" else arch="aarch64"
fi
or something along those lines.
Other than that, the rest looks good.
Could you take into account those comments, and submit an updated version?
Thanks a lot!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com