diff options
-rw-r--r-- | include/image.mk | 37 | ||||
-rw-r--r-- | target/linux/ramips/image/Makefile | 72 |
2 files changed, 67 insertions, 42 deletions
diff --git a/include/image.mk b/include/image.mk index cdb1e48540..e64020132f 100644 --- a/include/image.mk +++ b/include/image.mk @@ -322,31 +322,36 @@ define Device/Init KERNEL_SIZE:= CMDLINE:= - IMAGE_PREFIX := $(BIN_DIR)/$(IMG_PREFIX)-$(1) + IMAGE_PREFIX := $(IMG_PREFIX)-$(1) IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1)-$$(2) - KERNEL_PREFIX = $$(if $$(KERNEL_INSTALL),$$(IMAGE_PREFIX),$(KDIR)/$(1)) - KERNEL_INITRAMFS_PREFIX = $$(IMAGE_PREFIX)-initramfs + KERNEL_PREFIX = $(1) KERNEL_SUFFIX := -kernel.bin KERNEL_IMAGE = $$(KERNEL_PREFIX)$$(KERNEL_SUFFIX) + KERNEL_INITRAMFS_PREFIX = $$(IMAGE_PREFIX)-initramfs + KERNEL_INITRAMFS_IMAGE = $$(KERNEL_INITRAMFS_PREFIX)$$(KERNEL_SUFFIX) KERNEL_INSTALL := KERNEL_SIZE := FILESYSTEMS := $(TARGET_FILESYSTEMS) +endef + +define Device/ExportVar + $(1) : $(2):=$$($(2)) - BIN_KERNEL_IMAGE = $$(patsubst $$(KERNEL_PREFIX)%,$$(IMAGE_PREFIX)%,$$(KERNEL_IMAGE)) endef +Device/Export = $(foreach var,$(DEVICE_VARS) KERNEL,$(call Device/ExportVar,$(1),$(var))) define Device/Check _TARGET = $$(if $$(filter $(PROFILE),$$(PROFILES)),install,install-disabled) endef define Device/Build/initramfs - $$(_TARGET): $$(KERNEL_INITRAMFS_PREFIX)$$(KERNEL_SUFFIX) + $$(_TARGET): $(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE) - $$(KERNEL_INITRAMFS_PREFIX)$$(KERNEL_SUFFIX): $$(KERNEL_PREFIX)-initramfs$$(KERNEL_SUFFIX) + $(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/$$(KERNEL_INITRAMFS_IMAGE) cp $$^ $$@ - $$(KERNEL_PREFIX)-initramfs$$(KERNEL_SUFFIX): $(KDIR)/vmlinux-initramfs + $(KDIR)/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/vmlinux-initramfs @rm -f $$@ $$(call concat_cmd,$$(KERNEL_INITRAMFS)) endef @@ -359,22 +364,28 @@ define Device/Build/check_size endef define Device/Build/kernel - $$(_TARGET): $$(if $$(KERNEL_INSTALL),$$(BIN_KERNEL_IMAGE)) - $$(BIN_KERNEL_IMAGE): $$(KERNEL_IMAGE) + $$(_TARGET): $$(if $$(KERNEL_INSTALL),$(BIN_DIR)/$$(KERNEL_IMAGE)) + $(BIN_DIR)/$$(KERNEL_IMAGE): $(KDIR)/$$(KERNEL_IMAGE) cp $$^ $$@ - $$(KERNEL_IMAGE): $(KDIR)/vmlinux + $(KDIR)/$$(KERNEL_IMAGE): $(KDIR)/vmlinux @rm -f $$@ $$(call concat_cmd,$$(KERNEL)) $$(if $$(KERNEL_SIZE),$$(call Device/Build/check_size,$$(KERNEL_SIZE))) endef define Device/Build/image - $$(_TARGET): $(call IMAGE_NAME,$(1),$(2)) - $(call IMAGE_NAME,$(1),$(2)): $$(KERNEL_IMAGE) $(KDIR)/root.$(1) + $$(_TARGET): $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)) + $(eval $(call Device/Export,$(KDIR)/$(KERNEL_IMAGE))) + $(eval $(call Device/Export,$(KDIR)/$(KERNEL_INITRAMFS_IMAGE))) + $(eval $(call Device/Export,$(KDIR)/$(call IMAGE_NAME,$(1),$(2)))) + $(KDIR)/$(call IMAGE_NAME,$(1),$(2)): $(KDIR)/$$(KERNEL_IMAGE) $(KDIR)/root.$(1) @rm -f $$@ [ -f $$(word 1,$$^) -a -f $$(word 2,$$^) ] $$(call concat_cmd,$(if $(IMAGE/$(2)/$(1)),$(IMAGE/$(2)/$(1)),$(IMAGE/$(2)))) + $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)): $(KDIR)/$(call IMAGE_NAME,$(1),$(2)) + cp $$^ $$@ + endef define Device/Build @@ -383,7 +394,7 @@ define Device/Build $$(eval $$(foreach image,$$(IMAGES), \ $$(foreach fs,$$(filter $(TARGET_FILESYSTEMS),$$(FILESYSTEMS)), \ - $$(call Device/Build/image,$$(fs),$$(image))))) + $$(call Device/Build/image,$$(fs),$$(image),$(1))))) endef define Device diff --git a/target/linux/ramips/image/Makefile b/target/linux/ramips/image/Makefile index 18c1330bf6..82cadd742b 100644 --- a/target/linux/ramips/image/Makefile +++ b/target/linux/ramips/image/Makefile @@ -22,10 +22,35 @@ define Image/Build/Initramfs $(call Image/Build/Profile/$(PROFILE),initramfs) endef +DEVICE_VARS += DTS + loadaddr-y := 0x80000000 loadaddr-$(CONFIG_TARGET_ramips_rt288x) := 0x88000000 loadaddr-$(CONFIG_TARGET_ramips_mt7621) := 0x80001000 +KERNEL_LOADADDR := $(loadaddr-y) + +KERNEL_DTB = kernel-bin | patch-dtb | lzma +define Device/Default + KERNEL := $(KERNEL_DTB) | uImage lzma + IMAGES := sysupgrade.bin + IMAGE_SIZE := $(ralink_default_fw_size_8M) + IMAGE/sysupgrade.bin := append-kernel | append-rootfs | check-size $$$$(IMAGE_SIZE) | pad-rootfs +endef + +define Build/patch-dtb + $(LINUX_DIR)/scripts/dtc/dtc -O dtb -o $@.dtb ../dts/$(DTS).dts + $(STAGING_DIR_HOST)/bin/patch-dtb $@ $@.dtb +endef + +define Build/trx + $(STAGING_DIR_HOST)/bin/trx \ + -o $@ \ + -m $(IMAGE_SIZE) \ + -f $(word 1,$^) \ + -a 4 -f $(word 2,$^) +endef + define MkCombineduImage $(call PatchKernelLzma,$(2),$(3)) if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt `expr $(4) - 64` ]; then \ @@ -67,17 +92,6 @@ define MkImageSysupgrade/squashfs fi endef -define MkImageTrx/squashfs - $(eval output_name=$(IMG_PREFIX)-$(2)-$(1)-$(if $(4),$(4),sysupgrade).bin) - $(STAGING_DIR_HOST)/bin/trx \ - -o $(KDIR)/$(output_name) \ - -m $(3) \ - -f $(KDIR)/vmlinux-$(2).uImage \ - -a 4 -f $(KDIR)/root.$(1) - $(call prepare_generic_squashfs,$(KDIR)/$(output_name)) - $(CP) $(KDIR)/$(output_name) $(BIN_DIR)/$(output_name) -endef - define MkImageTpl/squashfs $(eval output_name=$(IMG_PREFIX)-$(2)-$(1)-$(if $(4),$(4),sysupgrade).bin) $(STAGING_DIR_HOST)/bin/mktplinkfw2 -V "ver. 2.0" -B "$(2)" -j \ @@ -124,11 +138,6 @@ define BuildFirmware/OF $(call MkImageSysupgrade/$(1),$(1),$(2),$(4),$(6)) endef -define BuildFirmware/OF/trx - $(call MkImageLzmaDtb,$(2),$(3),$(5)) - $(call MkImageTrx/$(1),$(1),$(2),$(4),$(6)) -endef - define BuildFirmware/OF/tplink $(call PatchKernelLzmaDtb,$(1),$(2),$(4)) $(call MkImageTpl/$(1),$(1),$(2),$(4),$(5)) @@ -167,8 +176,6 @@ BuildFirmware/Default4M/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$( ralink_default_fw_size_8M=8060928 BuildFirmware/Default8M/squashfs=$(call BuildFirmware/OF,$(1),$(2),$(3),$(ralink_default_fw_size_8M),$(4)) BuildFirmware/Default8M/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3),$(4)) -BuildFirmware/Trx8M/squashfs=$(call BuildFirmware/OF/trx,$(1),$(2),$(3),$(ralink_default_fw_size_8M),$(4)) -BuildFirmware/Trx8M/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3),$(4)) BuildFirmware/Tplink/squashfs=$(call BuildFirmware/OF/tplink,$(1),$(2),$(3),$(4)) BuildFirmware/Tplink/initramfs=$(call BuildFirmware/OF/tplink/initramfs,$(1),$(2),$(3),$(4)) @@ -862,18 +869,24 @@ endif # MT7621 Profiles # -Image/Build/Profile/MT7621=$(call BuildFirmware/Default4M/$(1),$(1),mt7621,MT7621) -Image/Build/Profile/WSR-600=$(call BuildFirmware/Default8M/$(1),$(1),wsr-600,WSR-600) -Image/Build/Profile/WSR-1166=$(call BuildFirmware/Trx8M/$(1),$(1),wsr-1166,WSR-1166) - ifeq ($(SUBTARGET),mt7621) -define Image/Build/Profile/Default - $(call Image/Build/Profile/MT7621,$(1)) - $(call Image/Build/Profile/WSR-600,$(1)) - $(call Image/Build/Profile/WSR-1166,$(1)) -endef + TARGET_DEVICES += mt7621 wsr-600 wsr-1166 endif +define Device/mt7621 + DTS := MT7621 + IMAGE_SIZE := $(ralink_default_fw_size_4M) +endef + +define Device/wsr-600 + DTS := WSR-600 +endef + +define Device/wsr-1166 + DTS := WSR-1166 + IMAGE/sysupgrade.bin := trx | pad-rootfs +endef + # # MT7628 Profiles # @@ -886,9 +899,9 @@ define Image/Build/Profile/Default endef endif - +ifndef TARGET_DEVICES # -# Generic Targets +# Generic Targets - only needed for legacy image building code # define Image/BuildKernel cp $(KDIR)/vmlinux.elf $(BIN_DIR)/$(VMLINUX).elf @@ -912,5 +925,6 @@ define Image/Build dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync $(call Image/Build/Profile/$(PROFILE),$(1)) endef +endif $(eval $(call BuildImage)) |