image: add a helper variable for getting kernel/rootfs from within image Build/* templates
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
9201e88f51
commit
63b525dd6b
13 changed files with 54 additions and 51 deletions
|
@ -1,5 +1,8 @@
|
|||
# Build commands that can be called from Device/* templates
|
||||
|
||||
IMAGE_KERNEL = $(word 1,$^)
|
||||
IMAGE_ROOTFS = $(word 2,$^)
|
||||
|
||||
define Build/uImage
|
||||
mkimage -A $(LINUX_KARCH) \
|
||||
-O linux -T kernel \
|
||||
|
@ -30,7 +33,7 @@ define Build/tplink-safeloader
|
|||
-$(STAGING_DIR_HOST)/bin/tplink-safeloader \
|
||||
-B $(TPLINK_BOARD_NAME) \
|
||||
-V $(REVISION) \
|
||||
-k $(word 1,$^) \
|
||||
-k $(IMAGE_KERNEL) \
|
||||
-r $@ \
|
||||
-o $@.new \
|
||||
-j \
|
||||
|
@ -92,18 +95,18 @@ define Build/patch-cmdline
|
|||
endef
|
||||
|
||||
define Build/append-kernel
|
||||
dd if=$(word 1,$^) $(if $(1),bs=$(1) conv=sync) >> $@
|
||||
dd if=$(IMAGE_KERNEL) $(if $(1),bs=$(1) conv=sync) >> $@
|
||||
endef
|
||||
|
||||
define Build/append-rootfs
|
||||
dd if=$(word 2,$^) $(if $(1),bs=$(1) conv=sync) >> $@
|
||||
dd if=$(IMAGE_ROOTFS) $(if $(1),bs=$(1) conv=sync) >> $@
|
||||
endef
|
||||
|
||||
define Build/append-ubi
|
||||
sh $(TOPDIR)/scripts/ubinize-image.sh \
|
||||
$(if $(UBOOTENV_IN_UBI),--uboot-env) \
|
||||
$(if $(KERNEL_IN_UBI),--kernel $(word 1,$^)) \
|
||||
$(word 2,$^) \
|
||||
$(if $(KERNEL_IN_UBI),--kernel $(IMAGE_KERNEL)) \
|
||||
$(IMAGE_ROOTFS) \
|
||||
$@.tmp \
|
||||
-p $(BLOCKSIZE) -m $(PAGESIZE) \
|
||||
$(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \
|
||||
|
@ -142,7 +145,7 @@ endef
|
|||
|
||||
define Build/combined-image
|
||||
-sh $(TOPDIR)/scripts/combined-image.sh \
|
||||
"$(word 1,$^)" \
|
||||
"$(IMAGE_KERNEL)" \
|
||||
"$@" \
|
||||
"$@.new"
|
||||
@mv $@.new $@
|
||||
|
@ -151,7 +154,7 @@ endef
|
|||
define Build/sysupgrade-tar
|
||||
sh $(TOPDIR)/scripts/sysupgrade-tar.sh \
|
||||
--board $(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)) \
|
||||
--kernel $(call param_get_default,kernel,$(1),$(word 1,$^)) \
|
||||
--rootfs $(call param_get_default,rootfs,$(1),$(word 2,$^)) \
|
||||
--kernel $(call param_get_default,kernel,$(1),$(IMAGE_KERNEL)) \
|
||||
--rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \
|
||||
$@
|
||||
endef
|
||||
|
|
|
@ -179,7 +179,7 @@ define Build/boot-img
|
|||
|
||||
$(CP) $@.scr $@.bootdir/boot/boot.scr
|
||||
$(CP) $@.dtb $@.bootdir/boot/$(DEVICE_DTB)
|
||||
$(CP) $(word 1,$^) $@.bootdir/boot/uImage
|
||||
$(CP) $(IMAGE_KERNEL) $@.bootdir/boot/uImage
|
||||
|
||||
genext2fs --block-size $(BLOCKSIZE) --size-in-blocks $$((1024 * $(BOOT_SIZE))) --root $@.bootdir $@.boot
|
||||
|
||||
|
@ -189,7 +189,7 @@ define Build/boot-img
|
|||
endef
|
||||
|
||||
define Build/hdd-img
|
||||
./mbl_gen_hdd_img.sh $@ $@.boot $(word 2,$^)
|
||||
./mbl_gen_hdd_img.sh $@ $@.boot $(IMAGE_ROOTFS)
|
||||
$(if $(CONFIG_TARGET_IMAGES_GZIP),gzip -9n -c $@ > $(BIN_DIR)/$(notdir $@).gz)
|
||||
endef
|
||||
|
||||
|
@ -204,9 +204,9 @@ endef
|
|||
define Build/recovery-tar
|
||||
sh ./mbl_gen_recovery_tar.sh \
|
||||
--profile $(DEVICE_PROFILE) \
|
||||
--dtb $(word 1,$^).dtb \
|
||||
--dtb $(IMAGE_KERNEL).dtb \
|
||||
--dtbname $(DEVICE_DTB) \
|
||||
--kernel $(word 1,$^) \
|
||||
--kernel $(IMAGE_KERNEL) \
|
||||
--rootfs $@ \
|
||||
$@
|
||||
endef
|
||||
|
|
|
@ -476,8 +476,8 @@ TARGET_DEVICES += hiwifi-hc6361
|
|||
# - 28 bytes seama_header
|
||||
# - 36 bytes of META data (4-bytes aligned)
|
||||
define Build/seama-factory
|
||||
( dd if=/dev/zero bs=64 count=1; cat $(word 1,$^) ) >$@.loader.tmp
|
||||
( dd if=$@.loader.tmp bs=64k conv=sync; dd if=$(word 2,$^) ) >$@.tmp.0
|
||||
( dd if=/dev/zero bs=64 count=1; cat $(IMAGE_KERNEL) ) >$@.loader.tmp
|
||||
( dd if=$@.loader.tmp bs=64k conv=sync; dd if=$(IMAGE_ROOTFS) ) >$@.tmp.0
|
||||
tail -c +65 $@.tmp.0 >$@.tmp.1
|
||||
$(STAGING_DIR_HOST)/bin/seama \
|
||||
-i $@.tmp.1 \
|
||||
|
@ -491,10 +491,10 @@ endef
|
|||
|
||||
define Build/seama-sysupgrade
|
||||
$(STAGING_DIR_HOST)/bin/seama \
|
||||
-i $(word 1,$^) \
|
||||
-i $(IMAGE_KERNEL) \
|
||||
-m "dev=/dev/mtdblock/1" -m "type=firmware"
|
||||
( dd if=$(word 1,$^).seama bs=64k conv=sync; dd if=$(word 2,$^) ) >$@
|
||||
rm -f $(word 1,$^).seama
|
||||
( dd if=$(IMAGE_KERNEL).seama bs=64k conv=sync; dd if=$(IMAGE_ROOTFS) ) >$@
|
||||
rm -f $(IMAGE_KERNEL).seama
|
||||
endef
|
||||
|
||||
define Build/seama-initramfs
|
||||
|
@ -505,7 +505,7 @@ define Build/seama-initramfs
|
|||
endef
|
||||
|
||||
define Build/seama-pad-rootfs
|
||||
$(STAGING_DIR_HOST)/bin/padjffs2 $(word 2,$^) -c 64 >>$@
|
||||
$(STAGING_DIR_HOST)/bin/padjffs2 $(IMAGE_ROOTFS) -c 64 >>$@
|
||||
endef
|
||||
|
||||
define Device/seama
|
||||
|
|
|
@ -12,7 +12,7 @@ define Build/mktplinkfw
|
|||
-$(STAGING_DIR_HOST)/bin/mktplinkfw \
|
||||
-H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) -N OpenWrt -V $(REVISION) \
|
||||
-m $(TPLINK_HEADER_VERSION) \
|
||||
-k $(word 1,$^) \
|
||||
-k $(IMAGE_KERNEL) \
|
||||
-r $@ \
|
||||
-o $@.new \
|
||||
-j -X 0x40000 \
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
define Build/mkubntimage
|
||||
$(STAGING_DIR_HOST)/bin/mkfwimage \
|
||||
-B $(UBNT_BOARD) -v $(UBNT_TYPE).$(UBNT_CHIP).v6.0.0-OpenWrt-$(REVISION) \
|
||||
-k $(word 1,$^) \
|
||||
-k $(IMAGE_KERNEL) \
|
||||
-r $@ \
|
||||
-o $@
|
||||
endef
|
||||
|
|
|
@ -10,24 +10,24 @@ include $(INCLUDE_DIR)/image.mk
|
|||
define Build/mkfwimage
|
||||
$(STAGING_DIR_HOST)/bin/mkfwimage \
|
||||
-B $(1).OpenWrt.$(REVISION) \
|
||||
-k $(word 1,$^) \
|
||||
-r $(word 2,$^) \
|
||||
-k $(IMAGE_KERNEL) \
|
||||
-r $(IMAGE_ROOTFS) \
|
||||
-o $@.new && \
|
||||
mv $@.new $@
|
||||
endef
|
||||
|
||||
define Build/combined-image
|
||||
-sh $(TOPDIR)/scripts/combined-image.sh \
|
||||
"$(word 1,$^)" \
|
||||
"$(word 2,$^)" \
|
||||
"$(IMAGE_KERNEL)" \
|
||||
"$(IMAGE_ROOTFS)" \
|
||||
"$@.new" && \
|
||||
mv $@.new $@
|
||||
endef
|
||||
|
||||
define Build/mkmylofw
|
||||
$(STAGING_DIR_HOST)/bin/mkmylofw -B $(1) \
|
||||
-p0x020000:0x130000:ah:0x80041000:linux:$(word 1,$^) \
|
||||
-p0x150000:0x2a0000:::rootfs:$(word 2,$^) \
|
||||
-p0x020000:0x130000:ah:0x80041000:linux:$(IMAGE_KERNEL) \
|
||||
-p0x150000:0x2a0000:::rootfs:$(IMAGE_ROOTFS) \
|
||||
$@.new && \
|
||||
mv $@.new $@
|
||||
endef
|
||||
|
|
|
@ -26,7 +26,7 @@ define Build/trx-serial
|
|||
$(STAGING_DIR_HOST)/bin/trx \
|
||||
-o $@.new \
|
||||
-m 33554432 \
|
||||
-f $(word 1,$^) -a 1024 \
|
||||
-f $(IMAGE_KERNEL) -a 1024 \
|
||||
-f $@ -a 0x10000 -A $(KDIR)/fs_mark
|
||||
mv $@.new $@
|
||||
endef
|
||||
|
@ -39,7 +39,7 @@ define Build/trx-nand
|
|||
$(STAGING_DIR_HOST)/bin/trx \
|
||||
-o $@.new \
|
||||
-m 33554432 \
|
||||
-f $(word 1,$^) -a 0x20000 -b 0x400000 \
|
||||
-f $(IMAGE_KERNEL) -a 0x20000 -b 0x400000 \
|
||||
-f $@ \
|
||||
-A $(KDIR)/ubi_mark -a 0x20000
|
||||
mv $@.new $@
|
||||
|
@ -57,7 +57,7 @@ define Build/seama-nand
|
|||
entity $@.entity \
|
||||
-m "dev=/dev/mtdblock/7" \
|
||||
-m "type=firmware" \
|
||||
-f $(word 1,$^) \
|
||||
-f $(IMAGE_KERNEL) \
|
||||
-b 0x400000 \
|
||||
-f $@ \
|
||||
-f $(KDIR)/ubi_mark
|
||||
|
|
|
@ -30,7 +30,7 @@ define Build/boot-img
|
|||
mcopy -i $@.boot $(KDIR)/fixup_cd.dat ::
|
||||
mcopy -i $@.boot cmdline.txt ::
|
||||
mcopy -i $@.boot config.txt ::
|
||||
mcopy -i $@.boot $(word 1,$^) ::kernel.img
|
||||
mcopy -i $@.boot $(IMAGE_KERNEL) ::kernel.img
|
||||
$(foreach dts,$(shell echo $(DEVICE_DTS)),mcopy -i $@.boot $(DTS_DIR)/$(dts).dtb ::;)
|
||||
mmd -i $@.boot ::/overlays
|
||||
mcopy -i $@.boot $(DTS_DIR)/overlays/*.dtbo ::/overlays/
|
||||
|
@ -38,7 +38,7 @@ define Build/boot-img
|
|||
endef
|
||||
|
||||
define Build/sdcard-img
|
||||
./gen_rpi_sdcard_img.sh $@ $@.boot $(word 2,$^) \
|
||||
./gen_rpi_sdcard_img.sh $@ $@.boot $(IMAGE_ROOTFS) \
|
||||
$(CONFIG_BRCM2708_SD_BOOT_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
|
||||
$(if $(CONFIG_TARGET_IMAGES_GZIP),gzip -9n -c $@ > $(BIN_DIR)/$(notdir $@).gz)
|
||||
endef
|
||||
|
|
|
@ -53,7 +53,7 @@ define Build/trx-with-loader
|
|||
-m 33554432 \
|
||||
-o $@ \
|
||||
-f $(KDIR)/loader.gz \
|
||||
-f $(word 1,$^) \
|
||||
-f $(IMAGE_KERNEL) \
|
||||
$(call trxalign/$(FILESYSTEM),$(FILESYSTEM))
|
||||
endef
|
||||
|
||||
|
@ -72,7 +72,7 @@ define Build/trx-without-loader
|
|||
$(STAGING_DIR_HOST)/bin/trx \
|
||||
-m 33554432 \
|
||||
-o $@ \
|
||||
-f $(word 1,$^) \
|
||||
-f $(IMAGE_KERNEL) \
|
||||
$(call trxalign/$(FILESYSTEM),$(FILESYSTEM))
|
||||
endef
|
||||
|
||||
|
|
|
@ -102,12 +102,12 @@ $(subst root.,,$(notdir $(1)))
|
|||
endef
|
||||
|
||||
define Build/cfe-bin
|
||||
$(STAGING_DIR_HOST)/bin/imagetag -i $(word 1,$^) -f $(word 2,$^) \
|
||||
$(STAGING_DIR_HOST)/bin/imagetag -i $(IMAGE_KERNEL) -f $(IMAGE_ROOTFS) \
|
||||
--output $@ --boardid $(CFE_BOARD_ID) --chipid $(CFE_CHIP_ID) \
|
||||
--entry $(LOADER_ENTRY) --load-addr $(LOADER_ENTRY) \
|
||||
--info1 "$(call Image/LimitName16,$(DEVICE_NAME))" \
|
||||
--info2 "$(call Image/FileSystemStrip,$(word 2,$^))" \
|
||||
$(call rootfspad/$(call Image/FileSystemStrip,$(word 2,$^))) \
|
||||
--info2 "$(call Image/FileSystemStrip,$(IMAGE_ROOTFS))" \
|
||||
$(call rootfspad/$(call Image/FileSystemStrip,$(IMAGE_ROOTFS))) \
|
||||
$(CFE_EXTRAS) $(1)
|
||||
endef
|
||||
|
||||
|
@ -115,15 +115,15 @@ define Build/cfe-old-bin
|
|||
$(TOPDIR)/scripts/brcmImage.pl -t -p \
|
||||
-o $@ -b $(CFE_BOARD_ID) -c $(CFE_CHIP_ID) \
|
||||
-e $(LOADER_ENTRY) -a $(LOADER_ENTRY) \
|
||||
-k $(word 1,$^) -r $(word 2,$^) \
|
||||
-k $(IMAGE_KERNEL) -r $(IMAGE_ROOTFS) \
|
||||
$(CFE_EXTRAS)
|
||||
endef
|
||||
|
||||
define Build/cfe-spw303v-bin
|
||||
$(STAGING_DIR_HOST)/bin/imagetag -i $(word 1,$^) -f $(word 2,$^) \
|
||||
$(STAGING_DIR_HOST)/bin/imagetag -i $(IMAGE_KERNEL) -f $(IMAGE_ROOTFS) \
|
||||
--output $@ --boardid $(CFE_BOARD_ID) --chipid $(CFE_CHIP_ID) \
|
||||
--entry $(LOADER_ENTRY) --load-addr $(LOADER_ENTRY) \
|
||||
$(call rootfspad/$(call Image/FileSystemStrip,$(word 2,$^))) \
|
||||
$(call rootfspad/$(call Image/FileSystemStrip,$(IMAGE_ROOTFS))) \
|
||||
$(CFE_EXTRAS) $(1)
|
||||
endef
|
||||
|
||||
|
@ -144,20 +144,20 @@ endef
|
|||
|
||||
define Build/redboot-bin
|
||||
# Prepare kernel and rootfs
|
||||
dd if=$(word 1,$^) of=$(BIN_DIR)/$(REDBOOT_PREFIX)-vmlinux.gz bs=65536 conv=sync
|
||||
dd if=$(word 2,$^) of=$(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(word 2,$^)) bs=64k conv=sync
|
||||
echo -ne \\xDE\\xAD\\xC0\\xDE >> $(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(word 2,$^))
|
||||
dd if=$(IMAGE_KERNEL) of=$(BIN_DIR)/$(REDBOOT_PREFIX)-vmlinux.gz bs=65536 conv=sync
|
||||
dd if=$(IMAGE_ROOTFS) of=$(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(IMAGE_ROOTFS)) bs=64k conv=sync
|
||||
echo -ne \\xDE\\xAD\\xC0\\xDE >> $(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(IMAGE_ROOTFS))
|
||||
# Generate the scripted image
|
||||
$(TOPDIR)/scripts/redboot-script.pl \
|
||||
-k $(BIN_DIR)/$(REDBOOT_PREFIX)-vmlinux.gz \
|
||||
-r $(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(word 2,$^)) \
|
||||
-r $(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(IMAGE_ROOTFS)) \
|
||||
-a $(strip $(LOADADDR)) -f 0xbe430000 -l 0x7c0000 \
|
||||
-s 0x1000 -t 20 -o $@.redbootscript
|
||||
dd if="$@.redbootscript" of="$@.redbootscript.padded" bs=4096 conv=sync
|
||||
cat \
|
||||
"$@.redbootscript.padded" \
|
||||
"$(BIN_DIR)/$(REDBOOT_PREFIX)-vmlinux.gz" \
|
||||
"$(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(word 2,$^))" \
|
||||
"$(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(IMAGE_ROOTFS))" \
|
||||
> "$@"
|
||||
endef
|
||||
|
||||
|
|
|
@ -152,21 +152,21 @@ define Build/mkbrncmdline
|
|||
endef
|
||||
|
||||
define Build/mkbrnimg
|
||||
mkbrnimg -s $(SIGNATURE) -m $(MAGIC) -p $(CRC32_POLY) -o $@ $(word 1,$^) $(word 2,$^)
|
||||
mkbrnimg -s $(SIGNATURE) -m $(MAGIC) -p $(CRC32_POLY) -o $@ $(IMAGE_KERNEL) $(IMAGE_ROOTFS)
|
||||
endef
|
||||
|
||||
define Build/fullimage
|
||||
mkimage -A mips -O linux -C lzma -T filesystem -a 0x00 \
|
||||
-e 0x00 -n 'LEDE RootFS' \
|
||||
-d $(word 2,$^) $(word 2,$^).new
|
||||
-d $(IMAGE_ROOTFS) $(IMAGE_ROOTFS).new
|
||||
|
||||
cat $(word 1,$^) $(word 2,$^).new > $@.tmp
|
||||
cat $(IMAGE_KERNEL) $(IMAGE_ROOTFS).new > $@.tmp
|
||||
|
||||
mkimage -A mips -O linux -T multi -a 0x00 -C none \
|
||||
-e 0x00 -n 'OpenWrt fullimage' \
|
||||
-d $@.tmp $@
|
||||
|
||||
rm $(word 2,$^).new
|
||||
rm $(IMAGE_ROOTFS).new
|
||||
rm $@.tmp
|
||||
endef
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ endef
|
|||
|
||||
define Build/mktplinkfw2
|
||||
mktplinkfw2 -B $(BOARD_ID) -s -a 0x4 -j \
|
||||
-k $(word 1,$^) -r $(word 2,$^) \
|
||||
-k $(IMAGE_KERNEL) -r $(IMAGE_ROOTFS) \
|
||||
-o $@
|
||||
endef
|
||||
DEVICE_VARS += BOARD_ID
|
||||
|
|
|
@ -49,8 +49,8 @@ define Build/trx
|
|||
$(STAGING_DIR_HOST)/bin/trx \
|
||||
-o $@ \
|
||||
-m $(IMAGE_SIZE) \
|
||||
-f $(word 1,$^) \
|
||||
-a 4 -f $(word 2,$^)
|
||||
-f $(IMAGE_KERNEL) \
|
||||
-a 4 -f $(IMAGE_ROOTFS)
|
||||
endef
|
||||
|
||||
define Build/relocate-kernel
|
||||
|
|
Loading…
Reference in a new issue