rootfs: add U-Boot image support for cpio + lots of refactoring
Subsystems (2)
This patch series is based on Spenser Gilliland's patch that adds U-Boot
image support to the root filesystem images. It was decided at the BR developer meeting that this is only ever going to be useful for cpio images (to be used as an initramfs), so I rewrote the patch to that end. But then I saw lots and lots of refactoring opportunities, which in the end led to this 7-patch series.
I have only compile-tested the cpio image, Spenser can you do a runtime
test on the Zedboard? Your defconfig should still work.
Regards,
Arnout
----------------------------------------------------------------
Arnout Vandecappelle (Essensium/Mind) (7):
rootfs-ext2: make the symlink as a _POST_TARGET
rootfs-common: remove the now unused ROOTFS_<PKG>_POST_GEN_HOOKS
rootfs-cpio: whitespace cleanup in Config.in
rootfs-common: refactor the common compression commands
rootfs-ext2: symlink with the compressed rootfs
rootfs-cpio: add U-Boot image support
uboot-tools: factor out common mkimage infrastructure
fs/common.mk | 46 +++++++++++++++++++++++++++------------------- fs/cpio/Config.in | 51 +++++++++++++++++++++++++++++++-------------------- fs/cpio/cpio.mk | 8 ++++++++ fs/ext2/ext2.mk | 8 ++++---- fs/iso9660/iso9660.mk | 6 +----- linux/linux.mk | 4 ++-- package/uboot-tools/uboot-tools.mk | 18 ++++++++++++++++++ 7 files changed, 91 insertions(+), 50 deletions(-)
PATCH 1/7 rootfs-ext2: make the symlink as a _POST_TARGET
This will allow us to remove the unused ROOTFS_$(FSTYPE)_POST_GEN_HOOKS.
---
v2:
- Initial revision. This patch was introduced to enable the U-Boot image of the cpio rootfs.
--- fs/common.mk | 2 +- fs/ext2/ext2.mk | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
fs/common.mk +1 -1
@@ -17,7 +17,7 @@ # generating the filesystem image # # ROOTFS_$(FSTYPE)_POST_GEN_HOOKS, a list of hooks to call after -# generating the filesystem image +# generating and compressing the filesystem image # # ROOTFS_$(FSTYPE)_POST_TARGETS, the list of targets that should be # run after running the main filesystem target. This is useful for
fs/ext2/ext2.mk +3 -3
@@ -27,11 +27,11 @@ define ROOTFS_EXT2_CMD PATH=$(TARGET_PATH) $(EXT2_ENV) fs/ext2/genext2fs.sh -d $(TARGET_DIR) $(EXT2_OPTS) $@ endef -define ROOTFS_EXT2_HOOK_SYMLINK +rootfs-ext2-symlink: ln -sf rootfs.ext2 $(BINARIES_DIR)/rootfs.ext$(BR2_TARGET_ROOTFS_EXT2_GEN) -endef + ifneq ($(BR2_TARGET_ROOTFS_EXT2_GEN),2) -ROOTFS_EXT2_POST_GEN_HOOKS += ROOTFS_EXT2_HOOK_SYMLINK +ROOTFS_EXT2_POST_TARGETS += rootfs-ext2-symlink endif $(eval $(call ROOTFS_TARGET,ext2))
Signature · 1 line
1.8.4.rc3
PATCH 2/7 rootfs-common: remove the now unused ROOTFS_<PKG>_POST_GEN_HOOKS
In reply to Arnout Vandecappelle (Essensium/Mind)---
v2:
- Initial revision. This patch was introduced to enable the U-Boot image of the cpio rootfs.
--- fs/common.mk | 4 ---- 1 file changed, 4 deletions(-)
fs/common.mk +0 -4
@@ -16,9 +16,6 @@ # ROOTFS_$(FSTYPE)_PRE_GEN_HOOKS, a list of hooks to call before # generating the filesystem image # -# ROOTFS_$(FSTYPE)_POST_GEN_HOOKS, a list of hooks to call after -# generating and compressing the filesystem image -# # ROOTFS_$(FSTYPE)_POST_TARGETS, the list of targets that should be # run after running the main filesystem target. This is useful for # initramfs, to rebuild the kernel once the initramfs is generated.
@@ -63,7 +60,6 @@ endif $$(HOST_DIR)/usr/bin/fakeroot -- $$(FAKEROOT_SCRIPT) cp support/misc/target-dir-warning.txt $$(TARGET_DIR_WARNING_FILE) - at rm -f $$(FAKEROOT_SCRIPT) $$(FULL_DEVICE_TABLE) - $$(foreach hook,$$(ROOTFS_$(2)_POST_GEN_HOOKS),$$(call $$(hook))$$(sep)) ifeq ($$(BR2_TARGET_ROOTFS_$(2)_GZIP),y) gzip -9 -c $$@ > [email protected] endif
Signature · 1 line
1.8.4.rc3
PATCH 3/7 rootfs-cpio: whitespace cleanup in Config.in
In reply to Arnout Vandecappelle (Essensium/Mind)---
v2:
- Initial revision. This patch was introduced to enable the U-Boot image of the cpio rootfs.
--- fs/cpio/Config.in | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
fs/cpio/Config.in +20 -20
@@ -6,34 +6,34 @@ config BR2_TARGET_ROOTFS_CPIO by the bootloader. choice - prompt "Compression method" - default BR2_TARGET_ROOTFS_CPIO_NONE - depends on BR2_TARGET_ROOTFS_CPIO - help - Select compressor for cpio filesystem of the root filesystem. - If you use the cpio archive as an initial RAM filesystem, make - sure the kernel contains the decompression algorithm selected - here. + prompt "Compression method" + default BR2_TARGET_ROOTFS_CPIO_NONE + depends on BR2_TARGET_ROOTFS_CPIO + help + Select compressor for cpio filesystem of the root filesystem. + If you use the cpio archive as an initial RAM filesystem, make + sure the kernel contains the decompression algorithm selected + here. config BR2_TARGET_ROOTFS_CPIO_NONE - bool "no compression" - help - Do not compress the cpio filesystem. + bool "no compression" + help + Do not compress the cpio filesystem. config BR2_TARGET_ROOTFS_CPIO_GZIP - bool "gzip" - help - Do compress the cpio filesystem with gzip. + bool "gzip" + help + Do compress the cpio filesystem with gzip. config BR2_TARGET_ROOTFS_CPIO_BZIP2 - bool "bzip2" - help - Do compress the cpio filesystem with bzip2. + bool "bzip2" + help + Do compress the cpio filesystem with bzip2. config BR2_TARGET_ROOTFS_CPIO_LZMA - bool "lzma" - help - Do compress the cpio filesystem with lzma. + bool "lzma" + help + Do compress the cpio filesystem with lzma. config BR2_TARGET_ROOTFS_CPIO_LZO bool "lzo"
Signature · 1 line
1.8.4.rc3
PATCH 4/7 rootfs-common: refactor the common compression commands
In reply to Arnout Vandecappelle (Essensium/Mind)This makes the compression extension available in a variable, so it can be used by the fs-specific commands. In this patch, it is used by iso9660. Following patches show more use cases.
---
v2:
- Initial revision. This patch was introduced to enable the U-Boot image of the cpio rootfs.
--- fs/common.mk | 42 +++++++++++++++++++++++++++--------------- fs/iso9660/iso9660.mk | 6 +----- 2 files changed, 28 insertions(+), 20 deletions(-)
fs/common.mk +27 -15
@@ -37,7 +37,31 @@ USERS_TABLE = $(BUILD_DIR)/_users_table.txt define ROOTFS_TARGET_INTERNAL # extra deps -ROOTFS_$(2)_DEPENDENCIES += host-fakeroot host-makedevs $$(if $$(BR2_TARGET_ROOTFS_$(2)_LZMA),host-lzma) $$(if $$(BR2_TARGET_ROOTFS_$(2)_LZO),host-lzop) $$(if $$(BR2_TARGET_ROOTFS_$(2)_XZ),host-xz) +ROOTFS_$(2)_DEPENDENCIES += host-fakeroot host-makedevs + +ifeq ($$(BR2_TARGET_ROOTFS_$(2)_GZIP),y) +ROOTFS_$(2)_COMPRESS_EXT = .gz +ROOTFS_$(2)_COMPRESS_CMD = gzip -9 -c +endif +ifeq ($$(BR2_TARGET_ROOTFS_$(2)_BZIP2),y) +ROOTFS_$(2)_COMPRESS_EXT = .bz2 +ROOTFS_$(2)_COMPRESS_CMD = bzip2 -9 -c +endif +ifeq ($$(BR2_TARGET_ROOTFS_$(2)_LZMA),y) +ROOTFS_$(2)_DEPENDENCIES += host-lzma +ROOTFS_$(2)_COMPRESS_EXT = .lzma +ROOTFS_$(2)_COMPRESS_CMD = $$(LZMA) -9 -c +endif +ifeq ($$(BR2_TARGET_ROOTFS_$(2)_LZO),y) +ROOTFS_$(2)_DEPENDENCIES += host-lzop +ROOTFS_$(2)_COMPRESS_EXT = .lzo +ROOTFS_$(2)_COMPRESS_CMD = $$(LZOP) -9 -c +endif +ifeq ($$(BR2_TARGET_ROOTFS_$(2)_XZ),y) +ROOTFS_$(2)_DEPENDENCIES += host-xz +ROOTFS_$(2)_COMPRESS_EXT = .xz +ROOTFS_$(2)_COMPRESS_CMD = $$(XZ) -9 -C crc32 -c +endif $$(BINARIES_DIR)/rootfs.$(1): $$(ROOTFS_$(2)_DEPENDENCIES) @$$(call MESSAGE,"Generating root filesystem image rootfs.$(1)")
@@ -60,20 +84,8 @@ endif $$(HOST_DIR)/usr/bin/fakeroot -- $$(FAKEROOT_SCRIPT) cp support/misc/target-dir-warning.txt $$(TARGET_DIR_WARNING_FILE) - at rm -f $$(FAKEROOT_SCRIPT) $$(FULL_DEVICE_TABLE) -ifeq ($$(BR2_TARGET_ROOTFS_$(2)_GZIP),y) - gzip -9 -c $$@ > [email protected] -endif -ifeq ($$(BR2_TARGET_ROOTFS_$(2)_BZIP2),y) - bzip2 -9 -c $$@ > [email protected] -endif -ifeq ($$(BR2_TARGET_ROOTFS_$(2)_LZMA),y) - $$(LZMA) -9 -c $$@ > [email protected] -endif -ifeq ($$(BR2_TARGET_ROOTFS_$(2)_LZO),y) - $$(LZOP) -9 -c $$@ > [email protected] -endif -ifeq ($$(BR2_TARGET_ROOTFS_$(2)_XZ),y) - $(XZ) -9 -C crc32 -c $$@ > [email protected] +ifneq ($$(ROOTFS_$(2)_COMPRESS_CMD),) + $$(ROOTFS_$(2)_COMPRESS_CMD) $$@ > $$@$$(ROOTFS_$(2)_COMPRESS_EXT) endif rootfs-$(1)-show-depends:
fs/iso9660/iso9660.mk +1 -5
@@ -10,10 +10,6 @@ ISO9660_TARGET_DIR = $(BUILD_DIR)/iso9660 ISO9660_BOOT_MENU := $(call qstrip,$(BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU)) -ISO9660_CPIO_EXT-$(BR2_TARGET_ROOTFS_CPIO_GZIP) = .gz -ISO9660_CPIO_EXT-$(BR2_TARGET_ROOTFS_CPIO_BZIP2) = .bz2 -ISO9660_CPIO_EXT-$(BR2_TARGET_ROOTFS_CPIO_LZMA) = .lzma - $(BINARIES_DIR)/rootfs.iso9660: host-cdrkit host-fakeroot linux rootfs-cpio grub @$(call MESSAGE,"Generating root filesystem image rootfs.iso9660") mkdir -p $(ISO9660_TARGET_DIR)
@@ -21,7 +17,7 @@ $(BINARIES_DIR)/rootfs.iso9660: host-cdrkit host-fakeroot linux rootfs-cpio grub cp $(GRUB_DIR)/stage2/stage2_eltorito $(ISO9660_TARGET_DIR)/boot/grub/ cp $(ISO9660_BOOT_MENU) $(ISO9660_TARGET_DIR)/boot/grub/menu.lst cp $(LINUX_IMAGE_PATH) $(ISO9660_TARGET_DIR)/kernel - cp $(BINARIES_DIR)/rootfs.cpio$(ISO9660_CPIO_EXT-y) $(ISO9660_TARGET_DIR)/initrd + cp $(BINARIES_DIR)/rootfs.cpio$(ROOTFS_CPIO_COMPRESS_EXT) $(ISO9660_TARGET_DIR)/initrd # Use fakeroot to pretend all target binaries are owned by root rm -f $(FAKEROOT_SCRIPT) echo "chown -R 0:0 $(ISO9660_TARGET_DIR)" >> $(FAKEROOT_SCRIPT)
Signature · 1 line
1.8.4.rc3
PATCH 5/7 rootfs-ext2: symlink with the compressed rootfs
In reply to Arnout Vandecappelle (Essensium/Mind)Previously, a symlink was created to the uncompressed filesystem, which made it a bit useless in case compression was chosen.
---
v2:
- Initial revision. This patch was introduced to enable the U-Boot image of the cpio rootfs.
--- fs/ext2/ext2.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext2/ext2.mk +1 -1
@@ -28,7 +28,7 @@ define ROOTFS_EXT2_CMD endef rootfs-ext2-symlink: - ln -sf rootfs.ext2 $(BINARIES_DIR)/rootfs.ext$(BR2_TARGET_ROOTFS_EXT2_GEN) + ln -sf rootfs.ext2$(ROOTFS_EXT2_COMPRESS_EXT) $(BINARIES_DIR)/rootfs.ext$(BR2_TARGET_ROOTFS_EXT2_GEN)$(ROOTFS_EXT2_COMPRESS_EXT) ifneq ($(BR2_TARGET_ROOTFS_EXT2_GEN),2) ROOTFS_EXT2_POST_TARGETS += rootfs-ext2-symlink
Signature · 1 line
1.8.4.rc3
PATCH 6/7 rootfs-cpio: add U-Boot image support
In reply to Arnout Vandecappelle (Essensium/Mind)Adds U-Boot image support for cpio root filesystems. This allows you to use the bootm command in U-Boot to load the rootfs. It makes it possible to verify the CRC of the initramfs before booting the kernel.
---
v2: patch taken over by Arnout
- Rewrote help text.
- Moved implementation to cpio.mk, because it will be the only one to ever use it.
- Implement as a post-target instead of post-hook.
- Removed compression type flag. It is not very useful to let U-Boot do decompression, especially because not all U-Boot configs support all possible decompression methods.
- Reordered the Config.in options.
- use correct -A flag
Since almost no lines are still the same as in the original patch, I've claimed full authorship - sorry Spenser :-)
--- fs/cpio/Config.in | 13 ++++++++++++- fs/cpio/cpio.mk | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-)
fs/cpio/Config.in +12 -1
@@ -5,10 +5,11 @@ config BR2_TARGET_ROOTFS_CPIO used for an initial RAM filesystem that is passed to the kernel by the bootloader. +if BR2_TARGET_ROOTFS_CPIO + choice prompt "Compression method" default BR2_TARGET_ROOTFS_CPIO_NONE - depends on BR2_TARGET_ROOTFS_CPIO help Select compressor for cpio filesystem of the root filesystem. If you use the cpio archive as an initial RAM filesystem, make
@@ -47,3 +48,13 @@ config BR2_TARGET_ROOTFS_CPIO_XZ endchoice +config BR2_TARGET_ROOTFS_CPIO_UIMAGE + bool "Create U-Boot image of the root filesystem" + select BR2_PACKAGE_HOST_UBOOT_TOOLS + help + Add a U-Boot header to the cpio root filesystem. This allows + the initramfs to be loaded with the bootm command in U-Boot. + + The U-Boot image will be called rootfs.cpio.uboot + +endif # BR2_TARGET_ROOTFS_CPIO
fs/cpio/cpio.mk +21 -0
@@ -31,4 +31,25 @@ define ROOTFS_CPIO_CMD cd $(TARGET_DIR) && find . | cpio --quiet -o -H newc > $@ endef +# mkimage supports arm avr32 blackfin m68k microblaze mips mips64 nios2 powerpc ppc sh sparc sparc64 x86 +# KERNEL_ARCH can be arm64 arc arm avr32 blackfin m68k microblaze mips nios2 powerpc sh sparc i386 x86_64 xtensa +# For arm64, arc, xtensa we'll just keep KERNEL_ARCH +# For mips64, we'll just keep mips +# For i386 and x86_64, we need to convert +ifeq ($(KERNEL_ARCH),x86_64) +UIMAGE_ARCH = x86 +else ifeq ($(KERNEL_ARCH),i386) +UIMAGE_ARCH = x86 +else +UIMAGE_ARCH = $(KERNEL_ARCH) +endif + +$(BINARIES_DIR)/rootfs.cpio.uboot: $(BINARIES_DIR)/rootfs.cpio host-uboot-tools + $(HOST_DIR)/usr/bin/mkimage -A $(UIMAGE_ARCH) -T ramdisk \ + -C none -d $<$(ROOTFS_CPIO_COMPRESS_EXT) $@ + +ifeq ($(BR2_TARGET_ROOTFS_CPIO_UIMAGE),y) +ROOTFS_CPIO_POST_TARGETS += $(BINARIES_DIR)/rootfs.cpio.uboot +endif + $(eval $(call ROOTFS_TARGET,cpio))
Signature · 1 line
1.8.4.rc3
PATCH 7/7 uboot-tools: factor out common mkimage infrastructure
In reply to Arnout Vandecappelle (Essensium/Mind)---
v2:
- Initial revision. This patch was introduced as cleanup of the patch that introduced the U-Boot image of the cpio rootfs.
--- fs/cpio/cpio.mk | 15 +-------------- linux/linux.mk | 4 ++-- package/uboot-tools/uboot-tools.mk | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 16 deletions(-)
fs/cpio/cpio.mk +1 -14
@@ -31,21 +31,8 @@ define ROOTFS_CPIO_CMD cd $(TARGET_DIR) && find . | cpio --quiet -o -H newc > $@ endef -# mkimage supports arm avr32 blackfin m68k microblaze mips mips64 nios2 powerpc ppc sh sparc sparc64 x86 -# KERNEL_ARCH can be arm64 arc arm avr32 blackfin m68k microblaze mips nios2 powerpc sh sparc i386 x86_64 xtensa -# For arm64, arc, xtensa we'll just keep KERNEL_ARCH -# For mips64, we'll just keep mips -# For i386 and x86_64, we need to convert -ifeq ($(KERNEL_ARCH),x86_64) -UIMAGE_ARCH = x86 -else ifeq ($(KERNEL_ARCH),i386) -UIMAGE_ARCH = x86 -else -UIMAGE_ARCH = $(KERNEL_ARCH) -endif - $(BINARIES_DIR)/rootfs.cpio.uboot: $(BINARIES_DIR)/rootfs.cpio host-uboot-tools - $(HOST_DIR)/usr/bin/mkimage -A $(UIMAGE_ARCH) -T ramdisk \ + $(MKIMAGE) -A $(MKIMAGE_ARCH) -T ramdisk \ -C none -d $<$(ROOTFS_CPIO_COMPRESS_EXT) $@ ifeq ($(BR2_TARGET_ROOTFS_CPIO_UIMAGE),y)
linux/linux.mk +2 -2
@@ -231,9 +231,9 @@ ifeq ($(BR2_LINUX_KERNEL_APPENDED_UIMAGE),y) # of the image. To do so, we first need to retrieve both load # address and entry point for the kernel from the already # generate uboot image before using mkimage -l. -LINUX_APPEND_DTB += $(sep) MKIMAGE_ARGS=`$(HOST_DIR)/usr/bin/mkimage -l $(LINUX_IMAGE_PATH) |\ +LINUX_APPEND_DTB += $(sep) MKIMAGE_ARGS=`$(MKIMAGE) -l $(LINUX_IMAGE_PATH) |\ sed -n -e 's/Image Name:[ ]*\(.*\)/-n \1/p' -e 's/Load Address:/-a/p' -e 's/Entry Point:/-e/p'`; \ - $(HOST_DIR)/usr/bin/mkimage -A $(KERNEL_ARCH) -O linux \ + $(MKIMAGE) -A $(MKIMAGE_ARCH) -O linux \ -T kernel -C none $${MKIMAGE_ARGS} \ -d $(KERNEL_ARCH_PATH)/boot/zImage $(LINUX_IMAGE_PATH); endif
package/uboot-tools/uboot-tools.mk +18 -0
@@ -64,3 +64,21 @@ endef $(eval $(generic-package)) $(eval $(host-generic-package)) + +# Convenience variables for other mk files that make use of mkimage + +MKIMAGE = $(HOST_DIR)/usr/bin/mkimage + +# mkimage supports arm avr32 blackfin m68k microblaze mips mips64 nios2 powerpc ppc sh sparc sparc64 x86 +# KERNEL_ARCH can be arm64 arc arm avr32 blackfin m68k microblaze mips nios2 powerpc sh sparc i386 x86_64 xtensa +# For arm64, arc, xtensa we'll just keep KERNEL_ARCH +# For mips64, we'll just keep mips +# For i386 and x86_64, we need to convert +ifeq ($(KERNEL_ARCH),x86_64) +MKIMAGE_ARCH = x86 +else ifeq ($(KERNEL_ARCH),i386) +MKIMAGE_ARCH = x86 +else +MKIMAGE_ARCH = $(KERNEL_ARCH) +endif +
Signature · 1 line
1.8.4.rc3
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Arnout" == Arnout Vandecappelle (Essensium/Mind) <[email protected]> writes:
This patch series is based on Spenser Gilliland's patch that adds U-Boot
image support to the root filesystem images. It was decided at the BR developer meeting that this is only ever going to be useful for cpio images (to be used as an initramfs), so I rewrote the patch to that end. But then I saw lots and lots of refactoring opportunities, which in the end led to this 7-patch series.I have only compile-tested the cpio image, Spenser can you do a runtime
test on the Zedboard? Your defconfig should still work.
Committed series, thanks.
Signature · 1 line
Bye, Peter Korsgaard