From 21925e99d423f68c6b0f7c6a8bf0333979d75664 Mon Sep 17 00:00:00 2001 From: Andrej Rosano Date: Fri, 11 Sep 2015 15:48:04 +0200 Subject: [PATCH 1/3] common.sh: add arm64 chroot utility functions By copying and removing the relevant qemu static executable the functions enable and disable the chroot environment for arm64 rootfs. Signed-off-by: Andrej Rosano --- common.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/common.sh b/common.sh index 573b309a95..1e82d5b7d8 100644 --- a/common.sh +++ b/common.sh @@ -992,3 +992,36 @@ BOAT echo -e "${V_VIDOFF}" die "$* failed" } + +# The binfmt_misc support in the kernel is required. +# The aarch64 binaries should be executed through +# "/usr/bin/qemu-aarch64-static" +setup_qemu_static() { + local root_fs_dir="$1" + case "${BOARD}" in + amd64-usr) return 0;; + arm64-usr) + if [[ -f "${root_fs_dir}/sbin/ldconfig" ]]; then + sudo cp /usr/bin/qemu-aarch64 "${root_fs_dir}"/usr/bin/qemu-aarch64-static + else + die "Missing basic layout in target rootfs" + fi + ;; + *) die "Unsupported arch" ;; + esac +} + +clean_qemu_static() { + local root_fs_dir="$1" + case "${BOARD}" in + amd64-usr) return 0;; + arm64-usr) + if [[ -f "${root_fs_dir}/usr/bin/qemu-aarch64-static" ]]; then + sudo rm "${root_fs_dir}"/usr/bin/qemu-aarch64-static + else + die "File not found" + fi + ;; + *) die "Unsupported arch" ;; + esac +} From acea447ccd163a0b0d36598d5f4ab3141f4e698d Mon Sep 17 00:00:00 2001 From: Andrej Rosano Date: Fri, 11 Sep 2015 15:55:46 +0200 Subject: [PATCH 2/3] build_packages: Fix ramdisk creation for non-native arches Chrooting in the target non-native arch rootfs is required for update-bootengine to be run correctly. Signed-off-by: Andrej Rosano --- build_packages | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build_packages b/build_packages index 23722d68dd..6579c58154 100755 --- a/build_packages +++ b/build_packages @@ -222,6 +222,8 @@ break_dep_loop sys-apps/util-linux udev,systemd sys-apps/systemd cryptsetup break_dep_loop sys-apps/systemd cryptsetup info "Merging board packages now" +# The following line is required by chroots present in "update-bootengine" +setup_qemu_static "${BOARD_ROOT}" sudo -E "${EMERGE_CMD[@]}" "${EMERGE_FLAGS[@]}" \ @system coreos-devel/board-packages From 16feac5ef6558c40da890e5c36f805f8d963db76 Mon Sep 17 00:00:00 2001 From: Andrej Rosano Date: Mon, 14 Sep 2015 12:24:41 +0200 Subject: [PATCH 3/3] Add arm64 grub installation support Add the necessary variables in grub.cfg and populate the EFI partition with arm64 efi executable and modules. Signed-off-by: Andrej Rosano --- build_library/build_image_util.sh | 6 +++++- build_library/grub.cfg | 11 ++++++++++- build_library/grub_install.sh | 11 +++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index 03b681aac2..54ccaffd32 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -361,7 +361,11 @@ finish_image() { # This script must mount the ESP partition differently, so run it after unmount if [[ "${install_grub}" -eq 1 ]]; then local target - for target in i386-pc x86_64-efi x86_64-xen; do + local target_list="i386-pc x86_64-efi x86_64-xen" + if [[ ${BOARD} == "arm64-usr" ]]; then + target_list="arm64-efi" + fi + for target in ${target_list}; do if [[ "${PROD_IMAGE}" -eq 1 && ${FLAGS_enable_verity} -eq ${FLAGS_TRUE} ]]; then ${BUILD_LIBRARY_DIR}/grub_install.sh \ --target="${target}" --disk_image="${disk_img}" --verity diff --git a/build_library/grub.cfg b/build_library/grub.cfg index c21fcba6e9..a1cc75df59 100644 --- a/build_library/grub.cfg +++ b/build_library/grub.cfg @@ -53,7 +53,11 @@ if [ -z "$linux_console" ]; then terminal_input console serial_com0 terminal_output console serial_com0 elif [ "$grub_platform" = efi ]; then - set linux_console="console=ttyS0,115200n8 console=tty0" + if [ "$grub_cpu" = arm64 ]; then + set linux_console="console=ttyAMA0,115200n8" + else + set linux_console="console=ttyS0,115200n8 console=tty0" + fi elif [ "$grub_platform" = xen ]; then set linux_console="console=hvc0" fi @@ -66,6 +70,11 @@ else set suf="" fi +# Use standard linux command for arm64 +if [ "$grub_cpu" = arm64 ]; then + set suf="" +fi + menuentry "CoreOS default" --id=coreos { gptprio.next -d usr -u usr_uuid if [ "$usr_uuid" = "7130c94a-213a-4e5a-8e26-6cce9662f132" ]; then diff --git a/build_library/grub_install.sh b/build_library/grub_install.sh index 760333849f..b84a35d6c0 100755 --- a/build_library/grub_install.sh +++ b/build_library/grub_install.sh @@ -49,6 +49,10 @@ case "${FLAGS_target}" in x86_64-xen) CORE_NAME="core.elf" ;; + arm64-efi) + CORE_MODULES+=( serial efi_gop ) + CORE_NAME="core-arm64.efi" + ;; *) die_notrace "Unknown GRUB target ${FLAGS_target}" ;; @@ -192,6 +196,13 @@ case "${FLAGS_target}" in sudo cp "${BUILD_LIBRARY_DIR}/menu.lst" \ "${ESP_DIR}/boot/grub/menu.lst" ;; + arm64-efi) + info "Installing default arm64 UEFI bootloader." + sudo mkdir -p "${ESP_DIR}/EFI/boot" + #FIXME(andrejro): shim not ported to aarch64 + sudo cp "${ESP_DIR}/${GRUB_DIR}/${CORE_NAME}" \ + "${ESP_DIR}/EFI/boot/bootaa64.efi" + ;; esac cleanup