From: Raphael Jacob <r.jacob2002@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 1/1] Add support for custom initramfs contents
Date: Fri, 10 Aug 2018 20:34:06 +0200 [thread overview]
Message-ID: <20180810183405.25378-1-r.jacob2002@gmail.com> (raw)
From: Richard Kunze <richard.kunze@web.de>
Signed-off-by: Raphael Jacob <r.jacob2002@gmail.com>
---
fs/initramfs/Config.in | 34 +++++++++++++++++++++++++++++++++-
fs/initramfs/initramfs.mk | 18 +++++++++++++++++-
linux/linux.mk | 8 ++++----
3 files changed, 54 insertions(+), 6 deletions(-)
diff --git a/fs/initramfs/Config.in b/fs/initramfs/Config.in
index 9d5a3f92e6..9b7ac9475e 100644
--- a/fs/initramfs/Config.in
+++ b/fs/initramfs/Config.in
@@ -1,6 +1,22 @@
config BR2_TARGET_ROOTFS_INITRAMFS
bool "initial RAM filesystem linked into linux kernel"
depends on BR2_LINUX_KERNEL
+ help
+ Integrate an initramfs inside the kernel image.
+ This integration will take place automatically.
+
+ The initramfs contents can either be the full root filesystem
+ generated by buildroot, or an image built from a custom list
+ of files specified via the BR2_TARGET_ROOTFS_INITRAMFS_CUSTOM_CONTENTS
+ config option.
+
+choice
+ prompt "initial RAM filesystem contents"
+ depends on BR2_TARGET_ROOTFS_INITRAMFS
+
+config BR2_TARGET_ROOTFS_INITRAMFS_ROOTFS
+ bool "rootfs.cpio"
+ depends on BR2_TARGET_ROOTFS_INITRAMFS
select BR2_TARGET_ROOTFS_CPIO
help
Integrate the root filesystem generated by Buildroot as an
@@ -13,10 +29,26 @@ config BR2_TARGET_ROOTFS_INITRAMFS
is used, regardless of how buildroot's cpio archive is
configured.
- Note that enabling initramfs together with another filesystem
+ Note that enabling this option together with another filesystem
formats doesn't make sense: you would end up having two
identical root filesystems, one embedded inside the kernel
image, and one separately.
+config BR2_TARGET_ROOTFS_INITRAMFS_CUSTOM
+ bool "custom initramfs contents"
+ depends on BR2_TARGET_ROOTFS_INITRAMFS
+ help
+ Use the contents of BR2_TARGET_ROOTFS_INITRAMFS_CUSTOM_CONTENTS
+ as the linux kernel configuration variable CONFIG_INITRAMFS_SOURCE
+
+endchoice
+
+config BR2_TARGET_ROOTFS_INITRAMFS_CUSTOM_CONTENTS
+ string "custom initramfs contents"
+ depends on BR2_TARGET_ROOTFS_INITRAMFS_CUSTOM
+ help
+ Custom value to use as CONFIG_INITRAMFS_SOURCE linux kernel configuration
+ variable. See Documentation/filesystems/ramfs-rootfs-initramfs.txt in the
+ linux kernel sources for details.
comment "initramfs needs a Linux kernel to be built"
depends on !BR2_LINUX_KERNEL
diff --git a/fs/initramfs/initramfs.mk b/fs/initramfs/initramfs.mk
index c751093214..ef3fdc6d3d 100644
--- a/fs/initramfs/initramfs.mk
+++ b/fs/initramfs/initramfs.mk
@@ -4,6 +4,12 @@
#
################################################################################
+ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS_ROOTFS),y)
+ROOTFS_INITRAMFS_DEPENDENCIES += rootfs-cpio
+endif
+
+ROOTFS_INITRAMFS_DEPENDENCIES += $(BINARIES_DIR)/initramfs.cpio
+
# The generic fs infrastructure isn't very useful here.
#
# The initramfs image does not actually build an image; its only purpose is:
@@ -19,13 +25,23 @@
# advertise that our dependency is on the rootfs-cpio rule, which is
# cleaner in the dependency graph.
-rootfs-initramfs: linux-rebuild-with-initramfs
+rootfs-initramfs: $(ROOTFS_INITRAMFS_DEPENDENCIES) linux-rebuild-with-initramfs
rootfs-initramfs-show-depends:
@echo rootfs-cpio
.PHONY: rootfs-initramfs rootfs-initramfs-show-depends
+ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS_ROOTFS),y)
+$(BINARIES_DIR)/initramfs.cpio: rootfs-cpio
+ ln -sf rootfs.cpio $(BINARIES_DIR)/initramfs.cpio
+endif
+
+ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS_CUSTOM),y)
+$(BINARIES_DIR)/initramfs.cpio: target-finalize $(call qstrip,$(BR2_TARGET_ROOTFS_INITRAMFS_CUSTOM_CONTENTS))
+ $(LINUX_DIR)/usr/gen_init_cpio $(BR2_TARGET_ROOTFS_INITRAMFS_CUSTOM_CONTENTS) > $(BINARIES_DIR)/initramfs.cpio
+endif
+
ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y)
TARGETS_ROOTFS += rootfs-initramfs
endif
diff --git a/linux/linux.mk b/linux/linux.mk
index 7f4c916671..b98043419b 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -278,8 +278,8 @@ define LINUX_KCONFIG_FIXUP_CMDS
# replaced later by the real cpio archive, and the kernel will be
# rebuilt using the linux-rebuild-with-initramfs target.
$(if $(BR2_TARGET_ROOTFS_INITRAMFS),
- touch $(BINARIES_DIR)/rootfs.cpio
- $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,"$${BR_BINARIES_DIR}/rootfs.cpio",$(@D)/.config)
+ touch $(BINARIES_DIR)/initramfs.cpio
+ $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,"$${BR_BINARIES_DIR}/initramfs.cpio",$(@D)/.config)
$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_UID,0,$(@D)/.config)
$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_GID,0,$(@D)/.config))
$(if $(BR2_ROOTFS_DEVICE_CREATION_STATIC),,
@@ -501,11 +501,11 @@ endif # BR_BUILDING
$(eval $(kconfig-package))
# Support for rebuilding the kernel after the cpio archive has
-# been generated.
+# been generated in $(BINARIES_DIR)/initramfs.cpio.
.PHONY: linux-rebuild-with-initramfs
linux-rebuild-with-initramfs: $(LINUX_DIR)/.stamp_target_installed
linux-rebuild-with-initramfs: $(LINUX_DIR)/.stamp_images_installed
-linux-rebuild-with-initramfs: rootfs-cpio
+linux-rebuild-with-initramfs: $(BINARIES_DIR)/initramfs.cpio
linux-rebuild-with-initramfs:
@$(call MESSAGE,"Rebuilding kernel with initramfs")
# Build the kernel.
--
2.18.0
next reply other threads:[~2018-08-10 18:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-10 18:34 Raphael Jacob [this message]
2018-08-19 13:39 ` [Buildroot] [PATCH 1/1] Add support for custom initramfs contents Yann E. MORIN
[not found] ` <b3576a560b4ad4272bdbe2520b0d2378a328deec.camel@web.de>
2018-08-19 16:26 ` Yann E. MORIN
[not found] ` <df75f0d04b1e6a06ab78820fdc838919cb42d04a.camel@web.de>
2018-08-19 17:21 ` Raphael Jacob
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180810183405.25378-1-r.jacob2002@gmail.com \
--to=r.jacob2002@gmail.com \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.