summaryrefslogtreecommitdiffstats
path: root/include/image-commands.mk
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2021-02-21 14:19:26 +0000
committerDaniel Golle <daniel@makrotopia.org>2021-02-24 01:35:20 +0000
commit330bd380e8b691833c8dcc9b579b51851cbd4b0f (patch)
treea6e6859d1888644af99fe332eef67eead435aa9c /include/image-commands.mk
parente6aac8d98f5663be99163f9e61dad23ad657b7ed (diff)
downloadopenwrt-330bd380e8b691833c8dcc9b579b51851cbd4b0f.tar.gz
openwrt-330bd380e8b691833c8dcc9b579b51851cbd4b0f.tar.bz2
openwrt-330bd380e8b691833c8dcc9b579b51851cbd4b0f.zip
image: allow building FIT and uImage with ramdisk
Instead of embedding the initrd cpio archive into the kernel, allow for having an external ramdisk added to the FIT or uImage. This is useful to overcome kernel size limitations present in many stock bootloaders, as the ramdisk is then loaded seperately and doesn't add to the kernel size. Hence we can have larger ramdisks to host ie. installers with all binaries to flash included (or a web-based firmware selector). In terms of performance and total size the differences are neglectible. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'include/image-commands.mk')
-rw-r--r--include/image-commands.mk27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/image-commands.mk b/include/image-commands.mk
index 3377680a07..d4ec51ca7c 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -196,11 +196,22 @@ define Build/eva-image
mv $@.new $@
endef
+define Build/initrd_compression
+ $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_BZIP2),.bzip2) \
+ $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_GZIP),.gzip) \
+ $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZMA),.lzma) \
+ $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_XZ),.xz) \
+ $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_ZSTD),.zstd)
+endef
+
define Build/fit
$(TOPDIR)/scripts/mkits.sh \
-D $(DEVICE_NAME) -o $@.its -k $@ \
$(if $(word 2,$(1)),-d $(word 2,$(1))) -C $(word 1,$(1)) \
$(if $(findstring with-rootfs,$(word 3,$(1))),-r $(IMAGE_ROOTFS)) \
+ $(if $(findstring with-initrd,$(word 3,$(1))), \
+ $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS_SEPERATE), \
+ -i $(KERNEL_BUILD_DIR)/initrd.cpio$(strip $(call Build/initrd_compression)))) \
-a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
$(if $(DEVICE_FDT_NUM),-n $(DEVICE_FDT_NUM)) \
-c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config@1") \
@@ -450,6 +461,22 @@ define Build/uImage
mv $@.new $@
endef
+define Build/uImage-with-ramdisk
+ mkimage \
+ -A $(LINUX_KARCH) \
+ -O linux \
+ -T kernel \
+ -C $(word 1,$(1)) \
+ -a $(KERNEL_LOADADDR) \
+ -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
+ -i $(KERNEL_BUILD_DIR)/initrd.cpio.$(strip $(call Build/initrd_compression)) \
+ -n '$(if $(UIMAGE_NAME),$(UIMAGE_NAME),$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION))' \
+ $(if $(UIMAGE_MAGIC),-M $(UIMAGE_MAGIC)) \
+ $(wordlist 2,$(words $(1)),$(1)) \
+ -d $@ $@.new
+ mv $@.new $@
+endef
+
define Build/xor-image
$(STAGING_DIR_HOST)/bin/xorimage -i $@ -o $@.xor $(1)
mv $@.xor $@