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 define Image/Build/DTB
18 cp $(KDIR)/zImage$(2) $(KDIR)/zImage$(2)-$(1);
19 cat $(DTS_DIR)/$(1).dtb >> $(KDIR)/zImage$(2)-$(1);
20 $(call Image/BuildKernel/MkuImage, \
21 none, $(LOADADDR), $(LOADADDR), \
22 $(KDIR)/zImage$(2)-$(1), $(KDIR)/uImage$(2)-$(1))
27 # $(3): Erase Block Size
29 # $(5): Sub-Page Size (optional)
30 # $(6): VID offset (optional)
32 define Image/BuildKernel/Profile/$(1)
33 $(call Image/Build/DTB,$(2))
34 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
35 $(call Image/Build/Profile,$(1)/Initramfs)
39 define Image/Build/Profile/$(1)/BuildSysupgrade
40 $(call Image/Build/SysupgradeNAND,$(2),$$(1),$(KDIR)/uImage-$(2))
43 define Image/Build/Profile/$(1)/Initramfs
44 $(call Image/Build/DTB,$(2),-initramfs)
45 cp $(KDIR)/uImage-initramfs-$(2) $(BIN_DIR)/$(IMG_PREFIX)-$(2)-initramfs
48 define Image/Build/Profile/$(1)/squashfs
49 $(call Image/Build/UbinizeImage,$(2),,squashfs, -p $(3) -m $(4) $(if $(5),-s $(5)) $(if $(6),-O $(6)))
57 # $(3): Erase Block Size
59 define Image/BuildKernel/Profile/$(1)
60 $(call Image/Build/DTB,$(2))
61 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
62 $(call Image/Build/Profile,$(1)/Initramfs)
66 define Image/Build/Profile/$(1)/Initramfs
67 $(call Image/Build/DTB,$(2),-initramfs)
70 define Image/Build/Profile/$(1)/squashfs
71 $(call Image/Build/UbinizeImage,$(2),,squashfs, -p $(3) -m 1)
79 # $(3): Erase Block Size
81 define Image/BuildKernel/Profile/$(1)
82 $(call Image/Build/DTB,$(2))
83 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
84 $(call Image/Build/Profile,$(1)/Initramfs)
88 define Image/Build/Profile/$(1)/Initramfs
89 $(call Image/Build/DTB,$(2),-initramfs)
92 define Image/Build/Profile/$(1)/squashfs
94 dd if=$(KDIR)/uImage-$(2) bs=$(3) conv=sync; \
95 dd if=$(KDIR)/root.squashfs bs=$(3) conv=sync; \
96 ) > $$(BIN_DIR)/$$(IMG_PREFIX)-$(2)-squashfs-firmware.bin
103 # $(2): Sub Profiles list
105 define Image/BuildKernel/Profile/$(1)
106 $(foreach profile, $(2),
107 $(call Image/BuildKernel/Profile/$(profile)))
110 define Image/Build/Profile/$(1)/BuildSysupgrade
111 $(foreach profile, $(2),
112 $(call Image/Build/Profile/$(profile)/BuildSysupgrade,$$(1)))
115 define Image/Build/Profile/$(1)/Initramfs
116 $(foreach profile, $(2),
117 $(call Image/Build/Profile/$(profile)/Initramfs))
120 define Image/Build/Profile/$(1)/squashfs
121 $(foreach profile, $(2),
122 $(call Image/Build/Profile/$(profile)/squashfs))
126 # Boards with NAND, without subpages
127 $(eval $(call NANDProfile,370-DB,armada-370-db,512KiB,4096))
128 $(eval $(call NANDProfile,370-RD,armada-370-rd,512KiB,4096))
129 $(eval $(call NANDProfile,385-DB-AP,armada-385-db-ap,256KiB,4096))
130 $(eval $(call NANDProfile,Mirabox,armada-370-mirabox,512KiB,4096))
131 $(eval $(call NANDProfile,XP-DB,armada-xp-db,512KiB,4096))
132 $(eval $(call NANDProfile,XP-GP,armada-xp-gp,512KiB,4096))
134 # Boards with NAND, with subpages
135 $(eval $(call NANDProfile,Mamba,armada-xp-linksys-mamba,128KiB,2048,512,2048))
136 $(eval $(call NANDProfile,Caiman,armada-385-linksys-caiman,128KiB,2048,512,2048))
137 $(eval $(call NANDProfile,Cobra,armada-385-linksys-cobra,128KiB,2048,512,2048))
138 $(eval $(call NANDProfile,Shelby,armada-385-linksys-shelby,128KiB,2048,512,2048))
140 # Boards with large NOR, where we want to use UBI
141 $(eval $(call UBINORProfile,OpenBlocks-AX-3-4,armada-xp-openblocks-ax3-4,128KiB))
143 # Boards with small NOR, where UBI doesn't make sense
144 $(eval $(call NORProfile,385-RD,armada-385-rd,256KiB))
150 # Caiman: Linksys WRT1200AC
151 define Image/Build/Profile/Caiman/squashfs
152 $(call Image/Build/UbinizeImage,armada-385-linksys-caiman,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
154 dd if=$(KDIR)/uImage-armada-385-linksys-caiman bs=6M conv=sync; \
155 dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-linksys-caiman-squashfs-ubinized.bin \
157 ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-linksys-caiman-squashfs-factory.img
160 # Cobra: Linksys WRT1900ACv2
161 define Image/Build/Profile/Cobra/squashfs
162 $(call Image/Build/UbinizeImage,armada-385-linksys-cobra,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
164 dd if=$(KDIR)/uImage-armada-385-linksys-cobra bs=6M conv=sync; \
165 dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-linksys-cobra-squashfs-ubinized.bin \
167 ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-linksys-cobra-squashfs-factory.img
170 # Mamba: Linksys WRT1900AC
171 define Image/Build/Profile/Mamba/squashfs
172 $(call Image/Build/UbinizeImage,armada-xp-linksys-mamba,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
174 dd if=$(KDIR)/uImage-armada-xp-linksys-mamba bs=3072k conv=sync; \
175 dd if=$(KDIR)/$(IMG_PREFIX)-armada-xp-linksys-mamba-squashfs-ubinized.bin \
177 ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-xp-linksys-mamba-squashfs-factory.img
180 # Shelby: Linksys WRT1900ACS
181 define Image/Build/Profile/Shelby/squashfs
182 $(call Image/Build/UbinizeImage,armada-385-linksys-shelby,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
184 dd if=$(KDIR)/uImage-armada-385-linksys-shelby bs=6M conv=sync; \
185 dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-linksys-shelby-squashfs-ubinized.bin \
187 ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-linksys-shelby-squashfs-factory.img
194 # Marvell Armada 385 Access Point Development board (DB-88F6820-AP)
195 define Image/Build/Profile/385-DB-AP/squashfs
196 $(call Image/Build/UbinizeImage,armada-385-db-ap,,squashfs, -p 256KiB -m 4096)
198 dd if=$(KDIR)/uImage-armada-385-db-ap bs=8M conv=sync; \
199 dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-db-ap-squashfs-ubinized.bin \
201 ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-db-ap-squashfs-factory.img
205 # The Default profile should build everything
206 $(eval $(call MultiProfile,Default,$(PROFILES_LIST)))
208 define Image/BuildKernel
209 $(call Image/BuildKernel/Profile/$(PROFILE))
212 define Image/Build/squashfs
213 # Align the squashfs image size before calling the profiles,
214 # otherwise the size would keep growing
215 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
216 $(call Image/Build/Profile/$(PROFILE)/squashfs)
220 $(call Image/Build/$(1))
221 $(call Image/Build/Profile/$(PROFILE)/BuildSysupgrade,$(1))
222 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
223 $(call Image/Build/Profile/$(PROFILE)/Initramfs)
227 $(eval $(call BuildImage))