From patchwork Tue Sep 13 04:15:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erico Nunes X-Patchwork-Id: 669099 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sY7bG40cdz9sC4 for ; Tue, 13 Sep 2016 12:16:42 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=CZmFuvQ5; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8E8B089142; Tue, 13 Sep 2016 02:16:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qmIiqfpUFJ2j; Tue, 13 Sep 2016 02:16:34 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 45B788900E; Tue, 13 Sep 2016 02:16:34 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 7CD8B1C2A56 for ; Tue, 13 Sep 2016 02:16:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 79CEA89915 for ; Tue, 13 Sep 2016 02:16:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O6CwgRsod0Ax for ; Tue, 13 Sep 2016 02:16:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by hemlock.osuosl.org (Postfix) with ESMTPS id 8ACD2898C4 for ; Tue, 13 Sep 2016 02:16:25 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id b184so190253wma.3 for ; Mon, 12 Sep 2016 19:16:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MOPhb0r/gN5lQikv8+0+iiZ79SQTRdvauoUZDCBNbYs=; b=CZmFuvQ501ulobA6tu+4DShnbIsqM1KjQKlqdDgEt0aFf/8rK0AXT80YN1vVruyKEx 1X4p8cQUCqSIljGdfyOQIhn6Adul3A+V2YVWeDLbyaqW/vZgZ96fXp7l3lQIEvvhyTtr c70pWDbCv/rHtf/cuUyULkmg8wkKAuH+buLxBdQdbpP8cEl+1W1AOUDPr82DqWv8WzRw Nl93VqZpM7DekvRPZv3soMI4xaJU5V3GDP6to+3tlog47Fa3q8u8KYnv+9/dQ+YEJCx4 WInBRANv5zHYgnxs7syfVsS71NPI+uv4LG8ugYSBFobpWELTMpN+LqUuZtWV6xQyJg5f q+Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MOPhb0r/gN5lQikv8+0+iiZ79SQTRdvauoUZDCBNbYs=; b=HwxlfTAMCvWmJX6LDslxhWXoNG6ww1J5rHfU6hwEUa5U++6ihTJ739Ad33Ha1Wrp/x 7uyiXRXdtMpxoBP2yO1X+7r9FLSAB5wi/IZBoZFlLqnltcTCilvExmZKNs0sfFeGfHFt 8uDWS5rHDSflkehUdan6nv2J1spLYpSmvWrnP8P+TYKPq1uBT9n8o3h0Y9vVecgBfT/W SbR9OkqDjin2TOE59tQU9KRemIkvyV2GPqHTTG30XpyNuhg7deGPw7Lv78xvraATvcov XNr/tCxMFw2ZZdmB+xbpdmVuLtw+vDbwNW1JEcIX1InP28N7mwSjC6SRx27/lCnuDdS1 wI/A== X-Gm-Message-State: AE9vXwNlelRyLM9KuDwgxINojO800wtaF5I/TjJcvMoviAIA14qzO2bKgvNT+0H/sss33Q== X-Received: by 10.28.191.22 with SMTP id p22mr12713161wmf.117.1473732984100; Mon, 12 Sep 2016 19:16:24 -0700 (PDT) Received: from localhost.localdomain (ip-78-102-173-25.net.upcbroadband.cz. [78.102.173.25]) by smtp.gmail.com with ESMTPSA id i131sm15124827wmg.10.2016.09.12.19.16.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Sep 2016 19:16:22 -0700 (PDT) From: Erico Nunes To: buildroot@buildroot.org Date: Tue, 13 Sep 2016 06:15:47 +0200 Message-Id: <20160913041548.10290-5-nunes.erico@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160913041548.10290-1-nunes.erico@gmail.com> References: <20160913041548.10290-1-nunes.erico@gmail.com> Cc: Thomas Petazzoni Subject: [Buildroot] [PATCH 4/5] grub2: enable support for arm and aarch64 targets X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This commit enables the arm-uboot, arm-efi and aarch64-efi Grub 2 platforms in Buildroot. As a uboot platform, Grub 2 image gets built as a u-boot image (i.e. u-boot mkimage) and is loaded from u-boot through a regular "bootm". The only requirement from u-boot side in order to allow this is that u-boot is built with CONFIG_API enabled. CONFIG_API seems to not be enabled by default in most in-tree configurations, however, it seems to be available for quite some time now. So it might be possible to use this even on older u-boot versions. This is available only for arm (32-bit). As an efi platform, Grub 2 gets built as an EFI executable. This allows EFI firmware to find and load it similarly as it can be done for x86_64. Also, since u-boot v2016.05, u-boot is able to load and boot an EFI executable, so the Grub 2 efi platform can also be used from u-boot in recent versions. This has been enabled (mostly) by default for ARM u-boot. efi platform is available for both arm and aarch64. These targets have been tested in the following environments: arm-uboot: qemu arm vexpress and BeagleBone arm-efi: BeagleBone aarch64-efi: qemu aarch64 virt and Odroid-C2 Signed-off-by: Erico Nunes --- boot/grub2/Config.in | 48 +++++++++++++++++++++++++++++++++++++++--------- boot/grub2/grub2.mk | 23 ++++++++++++++++++++++- 2 files changed, 61 insertions(+), 10 deletions(-) diff --git a/boot/grub2/Config.in b/boot/grub2/Config.in index 7dc5cae..527ff37 100644 --- a/boot/grub2/Config.in +++ b/boot/grub2/Config.in @@ -1,6 +1,6 @@ config BR2_TARGET_GRUB2 bool "grub2" - depends on BR2_i386 || BR2_x86_64 + depends on BR2_i386 || BR2_x86_64 || BR2_arm || BR2_aarch64 help GNU GRUB is a Multiboot boot loader. It was derived from GRUB, the GRand Unified Bootloader, which was originally @@ -66,8 +66,8 @@ config BR2_TARGET_GRUB2 qemu-system-{i386,x86-64} -hda disk.img - Notes on using Grub2 for EFI-based platforms - ============================================ + Notes on using Grub2 for i386/x86-64 EFI-based platforms + ======================================================== 1. Create a disk image dd if=/dev/zero of=disk.img bs=1M count=32 @@ -96,8 +96,8 @@ config BR2_TARGET_GRUB2 sudo losetup -d /dev/loop0 7. Your disk.img is ready! - To test your EFI image in Qemu - ------------------------------ + To test your i386/x86-64 EFI image in Qemu + ------------------------------------------ 1. Download the EFI BIOS for Qemu Version IA32 or X64 depending on the chosen Grub2 @@ -119,12 +119,14 @@ choice config BR2_TARGET_GRUB2_I386_PC bool "i386-pc" + depends on BR2_i386 || BR2_x86_64 help Select this option if the platform you're targetting is a x86 or x86-64 legacy BIOS based platform. config BR2_TARGET_GRUB2_I386_EFI bool "i386-efi" + depends on BR2_i386 || BR2_x86_64 help Select this option if the platform you're targetting has a 32 bits EFI BIOS. Note that some x86-64 platforms use a 32 @@ -132,14 +134,38 @@ config BR2_TARGET_GRUB2_I386_EFI config BR2_TARGET_GRUB2_X86_64_EFI bool "x86-64-efi" - depends on BR2_ARCH_IS_64 + depends on BR2_x86_64 help Select this option if the platform you're targetting has a 64 bits EFI BIOS. +config BR2_TARGET_GRUB2_ARM_UBOOT + bool "arm-uboot" + depends on BR2_arm + help + Select this option if the platform you're targetting is an + ARM u-boot platform, and you want to boot Grub 2 as an u-boot + compatible image. + +config BR2_TARGET_GRUB2_ARM_EFI + bool "arm-efi" + depends on BR2_arm + help + Select this option if the platform you're targetting is an + ARM platform and you want to boot Grub 2 as an EFI + application. + +config BR2_TARGET_GRUB2_ARM64_EFI + bool "arm64-efi" + depends on BR2_aarch64 + help + Select this option if the platform you're targetting is an + Aarch64 platform and you want to boot Grub 2 as an EFI + application. + endchoice -if BR2_TARGET_GRUB2_I386_PC +if BR2_TARGET_GRUB2_I386_PC || BR2_TARGET_GRUB2_ARM_UBOOT config BR2_TARGET_GRUB2_BOOT_PARTITION string "boot partition" @@ -150,13 +176,17 @@ config BR2_TARGET_GRUB2_BOOT_PARTITION first disk if using a legacy partition table, or 'hd0,gpt1' if using GPT partition table. -endif # BR2_TARGET_GRUB2_I386_PC +endif # BR2_TARGET_GRUB2_I386_PC || BR2_TARGET_GRUB2_ARM_UBOOT config BR2_TARGET_GRUB2_BUILTIN_MODULES string "builtin modules" default "boot linux ext2 fat squash4 part_msdos part_gpt normal biosdisk" if BR2_TARGET_GRUB2_I386_PC default "boot linux ext2 fat squash4 part_msdos part_gpt normal efi_gop" \ - if BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI + if BR2_TARGET_GRUB2_I386_EFI || \ + BR2_TARGET_GRUB2_X86_64_EFI || \ + BR2_TARGET_GRUB2_ARM_EFI || \\ + BR2_TARGET_GRUB2_ARM64_EFI + default "linux ext2 fat part_msdos normal" if BR2_TARGET_GRUB2_ARM_UBOOT config BR2_TARGET_GRUB2_BUILTIN_CONFIG string "builtin config" diff --git a/boot/grub2/grub2.mk b/boot/grub2/grub2.mk index 8a063f1..910967e 100644 --- a/boot/grub2/grub2.mk +++ b/boot/grub2/grub2.mk @@ -38,6 +38,27 @@ GRUB2_PREFIX = /EFI/BOOT GRUB2_TUPLE = x86_64-efi GRUB2_TARGET = x86_64 GRUB2_PLATFORM = efi +else ifeq ($(BR2_TARGET_GRUB2_ARM_UBOOT),y) +GRUB2_IMAGE = $(BINARIES_DIR)/boot-part/grub.img +GRUB2_CFG = $(BINARIES_DIR)/boot-part/grub.cfg +GRUB2_PREFIX = ($(GRUB2_BOOT_PARTITION)) +GRUB2_TUPLE = arm-uboot +GRUB2_TARGET = arm +GRUB2_PLATFORM = uboot +else ifeq ($(BR2_TARGET_GRUB2_ARM_EFI),y) +GRUB2_IMAGE = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootarm.efi +GRUB2_CFG = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg +GRUB2_PREFIX = /EFI/BOOT +GRUB2_TUPLE = arm-efi +GRUB2_TARGET = arm +GRUB2_PLATFORM = efi +else ifeq ($(BR2_TARGET_GRUB2_ARM64_EFI),y) +GRUB2_IMAGE = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootaa64.efi +GRUB2_CFG = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg +GRUB2_PREFIX = /EFI/BOOT +GRUB2_TUPLE = arm64-efi +GRUB2_TARGET = aarch64 +GRUB2_PLATFORM = efi endif # Grub2 is kind of special: it considers CC, LD and so on to be the @@ -83,7 +104,7 @@ endif define GRUB2_INSTALL_IMAGES_CMDS mkdir -p $(dir $(GRUB2_IMAGE)) $(HOST_DIR)/usr/bin/grub-mkimage \ - -d $(HOST_DIR)/usr/lib/grub/$(GRUB2_TUPLE) \ + -d $(@D)/grub-core/ \ -O $(GRUB2_TUPLE) \ -o $(GRUB2_IMAGE) \ -p "$(GRUB2_PREFIX)" \