From patchwork Wed Sep 26 22:37:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erico Nunes X-Patchwork-Id: 975479 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HXH7F62i"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42LCWN1s2Hz9s47 for ; Thu, 27 Sep 2018 08:37:51 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 378E2877B9; Wed, 26 Sep 2018 22:37:49 +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 Bu2KG7GViZLe; Wed, 26 Sep 2018 22:37:46 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 1B86F877A7; Wed, 26 Sep 2018 22:37:46 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 896571C14A4 for ; Wed, 26 Sep 2018 22:37:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 871AB23492 for ; Wed, 26 Sep 2018 22:37:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D7uW10ZoSISq for ; Wed, 26 Sep 2018 22:37:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by silver.osuosl.org (Postfix) with ESMTPS id 9BD1423376 for ; Wed, 26 Sep 2018 22:37:41 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id m16so478583wrx.12 for ; Wed, 26 Sep 2018 15:37:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bfYL2jAel4iJasslOOxW7dlqprLrfaObutFkoPCFyMg=; b=HXH7F62imDLGv1CzIzfhiN5tNWK+h04CyyB2LBP/5CmQrqlBLobHaYu91JpKhoDRHa Hq+2nncwfBie7tFyDx5U8xDAkYwY2KyaK8rp8zhojN4kzmqR0V0baN6otz5SukOmkfJR c/gnDJd4NJ8QyWl/5e6PVzfEqU6C2vDSCVOlnpp12znZvin5ZkUiTBJ2xmn+UYRB2+GW F78YjUUHJz/BohVpKBph/ENvGeMtSxU9pL9Ye3Ejh1nQSEGnfd6NUJmplSzTHqomL91w drOdnq+xnTM6kAK62LHqBMKGmCR7Dy1rlSnOUV3lUhi7EbcfAdPBTpUlZQzv23hJZpdD GwFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bfYL2jAel4iJasslOOxW7dlqprLrfaObutFkoPCFyMg=; b=iohk43MipdKPfi5Jc8PPkFmMS5MTZ7WxcXuZFOq5g+ucx8fT0KyyPSiPlODu002OCS /5BFjqlX/0Xz7Nej7ocwtz2UNDPIKLhJqXdctJ4w86ZmMAHX9MVTFro5l9oOjaHHMiHr ZtnBcYV+OdtuoBI5/qNe0RmfECTxzWog7+KRLTEYdgxSUMw38av9fYy8XanVhSotmVKD TPhs6UY5oSjro/QRz0fjK3gz4FZFAw2RUcFMoRVNcv/K4devzsrXPDeo9nXSgLomDDrg yAezJ41b0K0IDCtnJ3wIrPXjXVzZIKbX8kGIoWSrcoP99q+OfezWFCkuzlvvpmjZW9Pd T07w== X-Gm-Message-State: ABuFfoizZZY7JCrHLr5SfZF6Ulra9jFwrcGZKAz0Qsr/5TeLedQeWrB8 NeRqA++oao5oVMXhQIBCk58DNM8h X-Google-Smtp-Source: ACcGV60S+zTfxf3c12/BrNvyqb+Xw/NK/2c3NaWntC5RjEDK/GvEu7P2Ao9OODdauvzQ/jDJjCPGLw== X-Received: by 2002:adf:9a62:: with SMTP id z89-v6mr6758544wrb.53.1538001459970; Wed, 26 Sep 2018 15:37:39 -0700 (PDT) Received: from localhost.localdomain (ip-78-102-114-60.net.upcbroadband.cz. [78.102.114.60]) by smtp.gmail.com with ESMTPSA id x132-v6sm6438230wmg.3.2018.09.26.15.37.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 15:37:39 -0700 (PDT) From: Erico Nunes To: buildroot@buildroot.org Date: Thu, 27 Sep 2018 00:37:17 +0200 Message-Id: <20180926223719.12604-4-nunes.erico@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926223719.12604-1-nunes.erico@gmail.com> References: <20180926223719.12604-1-nunes.erico@gmail.com> Subject: [Buildroot] [PATCH v3 3/5] grub2: enable support for arm and aarch64 targets X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This commit enables the arm-uboot, arm-efi and aarch64-efi grub2 platforms in Buildroot. With the uboot platform, the grub2 image gets built as a u-boot image and is loaded from u-boot through a regular "bootm". The only requirement from the 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). With the efi platform, grub2 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 uboot 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. Signed-off-by: Erico Nunes --- boot/grub2/Config.in | 42 ++++++++++++++++++++++++++++++++++++++---- boot/grub2/grub2.mk | 21 +++++++++++++++++++++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/boot/grub2/Config.in b/boot/grub2/Config.in index f760f95e84..5e0e47a5bb 100644 --- a/boot/grub2/Config.in +++ b/boot/grub2/Config.in @@ -2,10 +2,13 @@ config BR2_TARGET_GRUB2_ARCH_SUPPORTS bool default y if BR2_i386 default y if BR2_x86_64 + default y if BR2_arm + default y if BR2_aarch64 config BR2_TARGET_GRUB2 bool "grub2" depends on BR2_TARGET_GRUB2_ARCH_SUPPORTS + depends on BR2_USE_MMU depends on BR2_USE_WCHAR help GNU GRUB is a Multiboot boot loader. It was derived from @@ -29,12 +32,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 @@ -42,14 +47,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" @@ -60,13 +89,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" @@ -88,4 +121,5 @@ endif # BR2_TARGET_GRUB2 comment "grub2 needs a toolchain w/ wchar" depends on BR2_TARGET_GRUB2_ARCH_SUPPORTS + depends on BR2_USE_MMU depends on !BR2_USE_WCHAR diff --git a/boot/grub2/grub2.mk b/boot/grub2/grub2.mk index bb678ef5de..65371f0170 100644 --- a/boot/grub2/grub2.mk +++ b/boot/grub2/grub2.mk @@ -44,6 +44,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/grub.img +GRUB2_CFG = $(BINARIES_DIR)/boot-part/grub/grub.cfg +GRUB2_PREFIX = ($(GRUB2_BOOT_PARTITION))/boot/grub +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