2 # Copyright (C) 2012-2015 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
12 JFFS2_BLOCKSIZE = 128k
17 UIMAGE:=$(BIN_DIR)/$(IMG_PREFIX)-uImage
19 define Image/Build/DTB
20 cp $(KDIR)/zImage$(2) $(KDIR)/zImage$(2)-$(1);
21 cat $(DTS_DIR)/$(1).dtb >> $(KDIR)/zImage$(2)-$(1);
22 $(call Image/BuildKernel/MkuImage, \
23 none, $(LOADADDR), $(LOADADDR), \
24 $(KDIR)/zImage$(2)-$(1), $(KDIR)/uImage$(2)-$(1))
29 # $(3): Erase Block Size
31 # $(5): Sub-Page Size (optional)
32 # $(6): VID offset (optional)
34 define Image/BuildKernel/Profile/$(1)
35 $(call Image/Build/DTB,$(2))
36 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
37 $(call Image/Build/Profile,$(1)/Initramfs)
41 define Image/Build/Profile/$(1)/BuildSysupgrade
42 $(call Image/Build/SysupgradeNAND,$(2),$$(1),$(KDIR)/uImage-$(2))
45 define Image/Build/Profile/$(1)/Initramfs
46 $(call Image/Build/DTB,$(2),-initramfs)
49 define Image/Build/Profile/$(1)/squashfs
50 $(call Image/Build/UbinizeImage,$(2),,squashfs, -p $(3) -m $(4) $(if $(5),-s $(5)) $(if $(6),-O $(6)))
58 # $(3): Erase Block Size
60 define Image/BuildKernel/Profile/$(1)
61 $(call Image/Build/DTB,$(2))
62 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
63 $(call Image/Build/Profile,$(1)/Initramfs)
67 define Image/Build/Profile/$(1)/Initramfs
68 $(call Image/Build/DTB,$(2),-initramfs)
71 define Image/Build/Profile/$(1)/squashfs
72 $(call Image/Build/UbinizeImage,$(2),,squashfs, -p $(3) -m 1)
80 # $(3): Erase Block Size
82 define Image/BuildKernel/Profile/$(1)
83 $(call Image/Build/DTB,$(2))
84 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
85 $(call Image/Build/Profile,$(1)/Initramfs)
89 define Image/Build/Profile/$(1)/Initramfs
90 $(call Image/Build/DTB,$(2),-initramfs)
93 define Image/Build/Profile/$(1)/squashfs
95 dd if=$(KDIR)/uImage-$(2) bs=$(3) conv=sync; \
96 dd if=$(KDIR)/root.squashfs bs=$(3) conv=sync; \
97 ) > $$(BIN_DIR)/$$(IMG_PREFIX)-$(2)-squashfs-firmware.bin
100 PROFILES_LIST += $(1)
104 # $(2): Sub Profiles list
106 define Image/BuildKernel/Profile/$(1)
107 $(foreach profile, $(2),
108 $(call Image/BuildKernel/Profile/$(profile)))
111 define Image/Build/Profile/$(1)/BuildSysupgrade
112 $(foreach profile, $(2),
113 $(call Image/Build/Profile/$(profile)/BuildSysupgrade,$$(1)))
116 define Image/Build/Profile/$(1)/Initramfs
117 $(foreach profile, $(2),
118 $(call Image/Build/Profile/$(profile)/Initramfs))
121 define Image/Build/Profile/$(1)/squashfs
122 $(foreach profile, $(2),
123 $(call Image/Build/Profile/$(profile)/squashfs))
127 # Boards with NAND, without subpages
128 $(eval $(call NANDProfile,370-DB,armada-370-db,512KiB,4096))
129 $(eval $(call NANDProfile,370-RD,armada-370-rd,512KiB,4096))
130 $(eval $(call NANDProfile,385-DB-AP,armada-385-db-ap,256KiB,4096))
131 $(eval $(call NANDProfile,Mirabox,armada-370-mirabox,512KiB,4096))
132 $(eval $(call NANDProfile,XP-DB,armada-xp-db,512KiB,4096))
133 $(eval $(call NANDProfile,XP-GP,armada-xp-gp,512KiB,4096))
135 # Boards with NAND, with subpages
136 $(eval $(call NANDProfile,Mamba,armada-xp-linksys-mamba,128KiB,2048,512,2048))
138 # Boards with large NOR, where we want to use UBI
139 $(eval $(call UBINORProfile,OpenBlocks-AX-3-4,armada-xp-openblocks-ax3-4,128KiB))
141 # Boards with small NOR, where UBI doesn't make sense
142 $(eval $(call NORProfile,385-RD,armada-385-rd,256KiB))
144 define Image/Build/Profile/Mamba/squashfs
145 $(call Image/Build/UbinizeImage,armada-xp-linksys-mamba,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
147 dd if=$(KDIR)/uImage-armada-xp-linksys-mamba bs=3072k conv=sync; \
148 dd if=$(KDIR)/$(IMG_PREFIX)-armada-xp-linksys-mamba-squashfs-ubinized.bin \
150 ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-xp-linksys-mamba-squashfs-factory.img
153 define Image/Build/Profile/385-DB-AP/squashfs
154 $(call Image/Build/UbinizeImage,armada-385-db-ap,,squashfs, -p 256KiB -m 4096)
156 dd if=$(KDIR)/uImage-armada-385-db-ap bs=8M conv=sync; \
157 dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-db-ap-squashfs-ubinized.bin \
159 ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-db-ap-squashfs-factory.img
162 # The Default profile should build everything
163 $(eval $(call MultiProfile,Default,$(PROFILES_LIST)))
165 define Image/BuildKernel
166 $(call Image/BuildKernel/Profile/$(PROFILE))
169 define Image/Build/squashfs
170 # Align the squashfs image size before calling the profiles,
171 # otherwise the size would keep growing
172 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
173 $(call Image/Build/Profile/$(PROFILE)/squashfs)
177 $(call Image/Build/$(1))
178 $(call Image/Build/Profile/$(PROFILE)/BuildSysupgrade,$(1))
179 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
180 $(call Image/Build/Profile/$(PROFILE)/Initramfs)
184 $(eval $(call BuildImage))