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 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 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 +}