ramips: append metadata to images
[openwrt/staging/yousong.git] / target / linux / ramips / image / Makefile
index 52dde6780ec07c37a319290ab0157717cb2398da..42cd63b7d7136406c7fdb5b46b677a1637ef58b7 100644 (file)
@@ -37,7 +37,9 @@ 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 | pad-rootfs | check-size $$$$(IMAGE_SIZE)
+  SUPPORTED_DEVICES = $(1)
+  sysupgrade_bin := append-kernel | append-rootfs | pad-rootfs
+  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE)
 endef
 
 define Build/patch-dtb
@@ -49,8 +51,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
@@ -74,6 +76,29 @@ define MkCombineduImage
        $(call MkImage,lzma,$(KDIR)/vmlinux-$(2).bin.lzma.combined,$(call sysupname,$(1),$(2)),$(6))
 endef
 
+define Build/umedia-header
+       fix-u-media-header -T 0x46 -B $(1) -i $@ -o $@.new && mv $@.new $@
+endef
+
+define Build/edimax-header
+       $(STAGING_DIR_HOST)/bin/mkedimaximg -i $@ -o $@.new $(1)
+       @mv $@.new $@
+endef
+
+define Build/senao-header
+       $(STAGING_DIR_HOST)/bin/mksenaofw $(1) -e $@ -o $@.new
+       mv $@.new $@
+endef
+
+define Build/seama
+       $(STAGING_DIR_HOST)/bin/seama -i $@ $(1)
+       mv $@.seama $@
+endef
+
+define Build/seama-seal
+       $(call Build/seama,-s $@.seama $(1))
+endef
+
 #
 # The real magic happens inside these templates
 #
@@ -192,38 +217,6 @@ define BuildFirmware/DefaultDualSize/initramfs
        $(call BuildFirmware/OF/initramfs,$(1),$(2)-8M,$(3)-8M)
 endef
 
-# build Seama header images
-define BuildFirmware/Seama/squashfs
-       $(call MkImageLzmaDtb,$(2),$(3),$(5))
-       $(eval output_name=$(IMG_PREFIX)-$(2)-$(1)-sysupgrade.bin)
-       cat $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/root.$(1) > $(KDIR)/img_$(2).$(1).tmp
-       if [ `stat -c%s "$(KDIR)/img_$(2).$(1).tmp"` -gt $$$$(($(5) - 64)) ]; then \
-               echo "Warning: $(KDIR)/img_$(2).$(1).tmp is too big" >&2; \
-       else \
-               dd if=$(KDIR)/vmlinux-$(2).bin.lzma of=$(KDIR)/vmlinux-$(2).bin.lzma.padded bs=64k conv=sync; \
-               ( \
-                       dd if=$(KDIR)/vmlinux-$(2).bin.lzma.padded bs=1 count=`expr \`stat -c%s $(KDIR)/vmlinux-$(2).bin.lzma.padded\` - 64`; \
-                       dd if=$(KDIR)/root.$(1) bs=64k conv=sync; \
-               ) > $(KDIR)/vmlinux-$(2).tmp; \
-               $(STAGING_DIR_HOST)/bin/seama \
-                       -i $(KDIR)/vmlinux-$(2).tmp \
-                       -m "dev=/dev/mtdblock/2" -m "type=firmware"; \
-               $(STAGING_DIR_HOST)/bin/seama \
-                       -s $(call imgname,$(1),$(2))-factory.bin \
-                       -m "signature=$(4)" \
-                       -i $(KDIR)/vmlinux-$(2).tmp.seama; \
-               dd if=$(KDIR)/vmlinux-$(2).bin.lzma.padded bs=1 count=`expr \`stat -c%s $(KDIR)/vmlinux-$(2).bin.lzma.padded\` - 64` of=$(KDIR)/vmlinux-$(2)-sysupgrade.tmp; \
-               $(STAGING_DIR_HOST)/bin/seama \
-                       -i $(KDIR)/vmlinux-$(2)-sysupgrade.tmp \
-                       -m "dev=/dev/mtdblock/2" -m "type=firmware"; \
-               ( \
-                       dd if=$(KDIR)/vmlinux-$(2)-sysupgrade.tmp.seama; \
-                       dd if=$(KDIR)/root.$(1) bs=64k conv=sync; \
-               ) > $(BIN_DIR)/$(output_name); \
-       fi
-endef
-BuildFirmware/Seama/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3))
-
 define BuildFirmware/PorayDualSize/squashfs
        $(call BuildFirmware/DefaultDualSize/$(1),$(1),$(2),$(3))
        if [ -e "$(call sysupname,$(1),$(2)-4M)" ]; then \
@@ -246,6 +239,7 @@ endif
 
 ifeq ($(SUBTARGET),rt305x)
 include rt305x.mk
+include rt305x-legacy.mk
 endif
 
 ifeq ($(SUBTARGET),rt3883)
@@ -268,8 +262,7 @@ ifeq ($(SUBTARGET),mt7688)
 include mt7688.mk
 endif
 
-
-ifndef TARGET_DEVICES
+ifdef LEGACY_DEVICES
 #
 # Generic Targets - only needed for legacy image building code
 #
@@ -293,8 +286,13 @@ endef
 define Image/Build
        $(call Image/Build/$(1))
        dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
-       $(call Image/Build/Profile/$(PROFILE),$(1))
 endef
+
+define Image/Build/Profile
+       $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(call Image/Build/Profile/$(1),initramfs))
+       $(call Image/Build/Profile/$(1),$(2))
+endef
+
 endif
 
 $(eval $(call BuildImage))