# 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 \
-C $(1) -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
- -n '$(call toupper,$(LINUX_KARCH)) LEDE Linux-$(LINUX_VERSION)' -d $@ $@.new
+ -n '$(if $(UIMAGE_NAME),$(UIMAGE_NAME),$(call toupper,$(LINUX_KARCH)) LEDE Linux-$(LINUX_VERSION))' -d $@ $@.new
@mv $@.new $@
endef
-$(STAGING_DIR_HOST)/bin/tplink-safeloader \
-B $(TPLINK_BOARD_NAME) \
-V $(REVISION) \
- -k $(word 1,$^) \
+ -k $(IMAGE_KERNEL) \
-r $@ \
-o $@.new \
-j \
$(if $(findstring sysupgrade,$(word 1,$(1))),-S) && mv $@.new $@ || rm -f $@
endef
+define Build/append-dtb
+ $(call Image/BuildDTB,$(if $(DEVICE_DTS_DIR),$(DEVICE_DTS_DIR),$(DTS_DIR))/$(DEVICE_DTS).dts,$@.dtb)
+ cat $@.dtb >> $@
+endef
+
+define Build/install-dtb
+ $(foreach dts,$(DEVICE_DTS), \
+ $(CP) \
+ $(DTS_DIR)/$(dts).dtb \
+ $(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb; \
+ )
+endef
+
define Build/fit
$(TOPDIR)/scripts/mkits.sh \
-D $(DEVICE_NAME) -o $@.its -k $@ \
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) -E 5 \
- $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE))
+ -p $(BLOCKSIZE) -m $(PAGESIZE) \
+ $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \
+ $(if $(VID_HDR_OFFSET),-O $(VID_HDR_OFFSET)) \
+ $(UBINIZE_OPTS)
cat $@.tmp >> $@
rm $@.tmp
endef
define Build/combined-image
-sh $(TOPDIR)/scripts/combined-image.sh \
- "$(word 1,$^)" \
+ "$(IMAGE_KERNEL)" \
"$@" \
"$@.new"
@mv $@.new $@
endef
-define Build/sysupgrade-nand
- sh $(TOPDIR)/scripts/sysupgrade-nand.sh \
+define Build/sysupgrade-tar
+ sh $(TOPDIR)/scripts/sysupgrade-tar.sh \
--board $(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)) \
- --kernel $(word 1,$^) \
- --rootfs $(word 2,$^) \
+ --kernel $(call param_get_default,kernel,$(1),$(IMAGE_KERNEL)) \
+ --rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \
$@
endef