Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] boot/grub2: add '--memdisk' option to grub-makeimage
@ 2020-03-09  9:55 Alexey Lukyanchuk
  2021-10-24  8:45 ` Yann E. MORIN
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Lukyanchuk @ 2020-03-09  9:55 UTC (permalink / raw)
  To: 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 <skif@skif-web.ru>
---
 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))
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-30  9:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-09  9:55 [Buildroot] [PATCH 1/1] boot/grub2: add '--memdisk' option to grub-makeimage Alexey Lukyanchuk
2021-10-24  8:45 ` Yann E. MORIN
     [not found]   ` <ff892e05-06aa-1f08-e534-2a5cd656592b@skif-web.ru>
2021-11-30  9:21     ` Köry Maincent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox