From patchwork Mon Mar 9 09:55:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Lukyanchuk X-Patchwork-Id: 1251398 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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=none (p=none dis=none) header.from=skif-web.ru Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=skif-web.ru header.i=@skif-web.ru header.a=rsa-sha256 header.s=mail header.b=qmxxaEE5; 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 48bYWb0LQVz9sPR for ; Mon, 9 Mar 2020 20:55:54 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 0E28C888BA; Mon, 9 Mar 2020 09:55:52 +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 e2EL8SCpTQQQ; Mon, 9 Mar 2020 09:55:50 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 96F31888C3; Mon, 9 Mar 2020 09:55:50 +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 2DA441BF59B for ; Mon, 9 Mar 2020 09:55:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 2563D888C2 for ; Mon, 9 Mar 2020 09:55: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 GdH59sp3pvDs for ; Mon, 9 Mar 2020 09:55:47 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by hemlock.osuosl.org (Postfix) with ESMTPS id 1FF66883F9 for ; Mon, 9 Mar 2020 09:55:47 +0000 (UTC) Received: from forward101q.mail.yandex.net (forward101q.mail.yandex.net [IPv6:2a02:6b8:c0e:4b:0:640:4012:bb98]) by forward100p.mail.yandex.net (Yandex) with ESMTP id 60D3A5981067; Mon, 9 Mar 2020 12:55:42 +0300 (MSK) Received: from mxback7q.mail.yandex.net (mxback7q.mail.yandex.net [IPv6:2a02:6b8:c0e:41:0:640:cbbf:d618]) by forward101q.mail.yandex.net (Yandex) with ESMTP id 5C275CF40004; Mon, 9 Mar 2020 12:55:42 +0300 (MSK) Received: from vla1-61ce7aa04735.qloud-c.yandex.net (vla1-61ce7aa04735.qloud-c.yandex.net [2a02:6b8:c0d:3e86:0:640:61ce:7aa0]) by mxback7q.mail.yandex.net (mxback/Yandex) with ESMTP id eNHH36ui1r-tg4aXJxo; Mon, 09 Mar 2020 12:55:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skif-web.ru; s=mail; t=1583747742; bh=kjRG8fcDp3hyCMv3hJvwQwIlcT5cC3fiZy/RW5g/pq4=; h=Subject:To:From:Message-Id:Cc:Date; b=qmxxaEE58O0sB38g5M3f5paAM+VuCjtjKpCkkiZJtbI+8Ekx87Rj2tUuPKEkg6FvZ hqNCNPHmo4h7vota5MwqDFzDetuavu5fQK9WYuH8/gfvDtGlQxyDINRNtJuR7K85Ew pu17naCQlQsGEkjiuZUe6PNdQAFvj9Yak1Y28DgM= Authentication-Results: mxback7q.mail.yandex.net; dkim=pass header.i=@skif-web.ru Received: by vla1-61ce7aa04735.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id QVqy1XPdKe-tfYWtGNB; Mon, 09 Mar 2020 12:55:41 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) From: Alexey Lukyanchuk To: buildroot@buildroot.org Date: Mon, 9 Mar 2020 12:55:40 +0300 Message-Id: <20200309095540.15448-1-skif@skif-web.ru> X-Mailer: git-send-email 2.17.1 Subject: [Buildroot] [PATCH 1/1] boot/grub2: add '--memdisk' option to grub-makeimage X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Lukyanchuk , Thomas Petazzoni MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" The memdisk is a virtual disk device viewed by grub. Memdisk can store some files(pictures, gpg key for verify module,etc), grub modules, into a core.img. In UEFI platform, grub-mkimage does not pose a limit on the size of memdisk. It's good solution for secure-boot or embedded systems Signed-off-by: Alexey Lukyanchuk --- boot/grub2/Config.in | 6 ++++++ boot/grub2/grub2.mk | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/boot/grub2/Config.in b/boot/grub2/Config.in index e45133999e..6ee2f351d9 100644 --- a/boot/grub2/Config.in +++ b/boot/grub2/Config.in @@ -107,6 +107,12 @@ config BR2_TARGET_GRUB2_BUILTIN_CONFIG device and other configuration parameters, but however menu entries cannot be described in this embedded configuration. +config BR2_TARGET_GRUB2_MEMDISK_DIR + string "memdisk" + help + Path to directory that will be a memdisk (-m option in + grub2-mkimage) + config BR2_TARGET_GRUB2_INSTALL_TOOLS bool "install tools" help diff --git a/boot/grub2/grub2.mk b/boot/grub2/grub2.mk index a202525d71..0627c6857f 100644 --- a/boot/grub2/grub2.mk +++ b/boot/grub2/grub2.mk @@ -22,6 +22,7 @@ endif GRUB2_BUILTIN_MODULES = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES)) GRUB2_BUILTIN_CONFIG = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG)) GRUB2_BOOT_PARTITION = $(call qstrip,$(BR2_TARGET_GRUB2_BOOT_PARTITION)) +GRUB2_MEMDISK_DIR = $(call qstrip,$(BR2_TARGET_GRUB2_MEMDISK_DIR)) ifeq ($(BR2_TARGET_GRUB2_I386_PC),y) GRUB2_IMAGE = $(BINARIES_DIR)/grub.img @@ -87,6 +88,15 @@ GRUB2_CONF_ENV = \ TARGET_OBJCOPY="$(TARGET_OBJCOPY)" \ TARGET_STRIP="$(TARGET_CROSS)strip" +ifneq ($(GRUB2_MEMDISK_DIR),) +GRUB2_POST_BUILD_HOOKS += GRUB2_MAKE_MEMDISK +define GRUB2_MAKE_MEMDISK + mkdir -p $(@D)/grub2_memdisk + cp -a $(GRUB2_MEMDISK_DIR)/* $(@D)/grub2_memdisk/ + tar -cvf $(@D)/memdisk.tar -C $(@D)/grub2_memdisk/ . +endef +endif + GRUB2_CONF_OPTS = \ --target=$(GRUB2_TARGET) \ --with-platform=$(GRUB2_PLATFORM) \ @@ -121,6 +131,7 @@ define GRUB2_INSTALL_IMAGES_CMDS -O $(GRUB2_TUPLE) \ -o $(GRUB2_IMAGE) \ -p "$(GRUB2_PREFIX)" \ + $(if $(BR2_TARGET_GRUB2_MEMDISK_DIR),-m $(@D)/memdisk.tar) \ $(if $(GRUB2_BUILTIN_CONFIG),-c $(GRUB2_BUILTIN_CONFIG)) \ $(GRUB2_BUILTIN_MODULES) mkdir -p $(dir $(GRUB2_CFG))