ac85456c753789d3a0014782d8a6b804e28e3438
[15.05/openwrt.git] / target / linux / mvebu / image / Makefile
1 #
2 # Copyright (C) 2012-2015 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9
10 LOADADDR:=0x00008000
11
12 JFFS2_BLOCKSIZE = 128k
13
14 KDIR_TMP:=$(KDIR)/tmp
15
16
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))
23 endef
24
25 # $(1): Profile Name
26 # $(2): DTB Name
27 # $(3): Erase Block Size
28 # $(4): Page Size
29 # $(5): Sub-Page Size (optional)
30 # $(6): VID offset (optional)
31 define NANDProfile
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)
36     endif
37   endef
38
39   define Image/Build/Profile/$(1)/BuildSysupgrade
40         $(call Image/Build/SysupgradeNAND,$(2),$$(1),$(KDIR)/uImage-$(2))
41   endef
42
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
46   endef
47
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)))
50   endef
51
52   PROFILES_LIST += $(1)
53 endef
54
55 # $(1): Profile Name
56 # $(2): DTB Name
57 # $(3): Erase Block Size
58 define UBINORProfile
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)
63     endif
64   endef
65
66   define Image/Build/Profile/$(1)/Initramfs
67         $(call Image/Build/DTB,$(2),-initramfs)
68   endef
69
70   define Image/Build/Profile/$(1)/squashfs
71         $(call Image/Build/UbinizeImage,$(2),,squashfs, -p $(3) -m 1)
72   endef
73
74   PROFILES_LIST += $(1)
75 endef
76
77 # $(1): Profile Name
78 # $(2): DTB Name
79 # $(3): Erase Block Size
80 define NORProfile
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)
85     endif
86   endef
87
88   define Image/Build/Profile/$(1)/Initramfs
89         $(call Image/Build/DTB,$(2),-initramfs)
90   endef
91
92   define Image/Build/Profile/$(1)/squashfs
93         ( \
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
97   endef
98
99   PROFILES_LIST += $(1)
100 endef
101
102 # $(1): Profile Name
103 # $(2): DTB Name
104 define MMCProfile
105   define Image/BuildKernel/Profile/$(1)
106         $(call Image/Build/DTB,$(2))
107         cp $(KDIR)/zImage-$(2) $(BIN_DIR)/zImage-$(1);
108         cp $(DTS_DIR)/$(2).dtb $(BIN_DIR)/$(1).dtb;
109     ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
110         $(call Image/Build/Profile,$(1)/Initramfs)
111     endif
112   endef
113
114   define Image/Build/Profile/$(1)/Initramfs
115         $(call Image/Build/DTB,$(2),-initramfs)
116         cp $(KDIR)/uImage-initramfs-$(2) $(BIN_DIR)/$(IMG_PREFIX)-$(2)-initramfs
117   endef
118
119   PROFILES_LIST += $(1)
120 endef
121
122 # $(1): Profile Name
123 # $(2): Sub Profiles list
124 define MultiProfile
125   define Image/BuildKernel/Profile/$(1)
126         $(foreach profile, $(2),
127                 $(call Image/BuildKernel/Profile/$(profile)))
128   endef
129
130   define Image/Build/Profile/$(1)/BuildSysupgrade
131         $(foreach profile, $(2),
132                 $(call Image/Build/Profile/$(profile)/BuildSysupgrade,$$(1)))
133   endef
134
135   define Image/Build/Profile/$(1)/Initramfs
136         $(foreach profile, $(2),
137                 $(call Image/Build/Profile/$(profile)/Initramfs))
138   endef
139
140   define Image/Build/Profile/$(1)/squashfs
141         $(foreach profile, $(2),
142                 $(call Image/Build/Profile/$(profile)/squashfs))
143   endef
144 endef
145
146 # Boards with NAND, without subpages
147 $(eval $(call NANDProfile,370-DB,armada-370-db,512KiB,4096))
148 $(eval $(call NANDProfile,370-RD,armada-370-rd,512KiB,4096))
149 $(eval $(call NANDProfile,385-DB-AP,armada-385-db-ap,256KiB,4096))
150 $(eval $(call NANDProfile,Mirabox,armada-370-mirabox,512KiB,4096))
151 $(eval $(call NANDProfile,XP-DB,armada-xp-db,512KiB,4096))
152 $(eval $(call NANDProfile,XP-GP,armada-xp-gp,512KiB,4096))
153
154 # Boards with NAND, with subpages
155 $(eval $(call NANDProfile,Mamba,armada-xp-linksys-mamba,128KiB,2048,512,2048))
156 $(eval $(call NANDProfile,Caiman,armada-385-linksys-caiman,128KiB,2048,512,2048))
157 $(eval $(call NANDProfile,Cobra,armada-385-linksys-cobra,128KiB,2048,512,2048))
158 $(eval $(call NANDProfile,Rango,armada-385-linksys-rango,128KiB,2048,512,2048))
159 $(eval $(call NANDProfile,Shelby,armada-385-linksys-shelby,128KiB,2048,512,2048))
160
161 # Boards with large NOR, where we want to use UBI
162 $(eval $(call UBINORProfile,OpenBlocks-AX-3-4,armada-xp-openblocks-ax3-4,128KiB))
163
164 # Boards with small NOR, where UBI doesn't make sense
165 $(eval $(call NORProfile,385-RD,armada-385-rd,256KiB))
166
167 $(eval $(call MMCProfile,Solidrun-Clearfog-A1,armada-388-clearfog))
168
169 ###
170 ### Linksys
171 ###
172
173 # Caiman: Linksys WRT1200AC
174 define Image/Build/Profile/Caiman/squashfs
175         $(call Image/Build/UbinizeImage,armada-385-linksys-caiman,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
176         ( \
177                 dd if=$(KDIR)/uImage-armada-385-linksys-caiman bs=6M conv=sync; \
178                 dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-linksys-caiman-squashfs-ubinized.bin \
179                 bs=2048 conv=sync; \
180         ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-linksys-caiman-squashfs-factory.img
181 endef
182
183 # Cobra: Linksys WRT1900ACv2
184 define Image/Build/Profile/Cobra/squashfs
185         $(call Image/Build/UbinizeImage,armada-385-linksys-cobra,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
186         ( \
187                 dd if=$(KDIR)/uImage-armada-385-linksys-cobra bs=6M conv=sync; \
188                 dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-linksys-cobra-squashfs-ubinized.bin \
189                 bs=2048 conv=sync; \
190         ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-linksys-cobra-squashfs-factory.img
191 endef
192
193 # Mamba: Linksys WRT1900AC
194 define Image/Build/Profile/Mamba/squashfs
195         $(call Image/Build/UbinizeImage,armada-xp-linksys-mamba,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
196         ( \
197                 dd if=$(KDIR)/uImage-armada-xp-linksys-mamba bs=3072k conv=sync; \
198                 dd if=$(KDIR)/$(IMG_PREFIX)-armada-xp-linksys-mamba-squashfs-ubinized.bin \
199                 bs=2048 conv=sync; \
200         ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-xp-linksys-mamba-squashfs-factory.img
201 endef
202
203 # Shelby: Linksys WRT1900ACS
204 define Image/Build/Profile/Shelby/squashfs
205         $(call Image/Build/UbinizeImage,armada-385-linksys-shelby,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
206         ( \
207                 dd if=$(KDIR)/uImage-armada-385-linksys-shelby bs=6M conv=sync; \
208                 dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-linksys-shelby-squashfs-ubinized.bin \
209                 bs=2048 conv=sync; \
210         ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-linksys-shelby-squashfs-factory.img
211 endef
212
213 # Rango: Linksys WRT3200ACM
214 define Image/Build/Profile/Rango/squashfs
215         $(call Image/Build/UbinizeImage,armada-385-linksys-rango,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
216         ( \
217                 dd if=$(KDIR)/uImage-armada-385-linksys-rango bs=6144k conv=sync; \
218                 dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-linksys-rango-squashfs-ubinized.bin \
219                 bs=2048 conv=sync; \
220         ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-linksys-rango-squashfs-factory.img
221 endef
222
223 ###
224 ### Marvell
225 ###
226
227 # Marvell Armada 385 Access Point Development board (DB-88F6820-AP)
228 define Image/Build/Profile/385-DB-AP/squashfs
229         $(call Image/Build/UbinizeImage,armada-385-db-ap,,squashfs, -p 256KiB -m 4096)
230         ( \
231                 dd if=$(KDIR)/uImage-armada-385-db-ap bs=8M conv=sync; \
232                 dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-db-ap-squashfs-ubinized.bin \
233                 bs=4096 conv=sync; \
234         ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-db-ap-squashfs-factory.img
235 endef
236
237
238 # The Default profile should build everything
239 $(eval $(call MultiProfile,Default,$(PROFILES_LIST)))
240
241 define Image/BuildKernel
242         $(call Image/BuildKernel/Profile/$(PROFILE))
243 endef
244
245 define Image/Build/squashfs
246         # Align the squashfs image size before calling the profiles,
247         # otherwise the size would keep growing
248         $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
249         $(call Image/Build/Profile/$(PROFILE)/squashfs)
250 endef
251
252 define Image/Build
253         $(call Image/Build/$(1))
254         $(call Image/Build/Profile/$(PROFILE)/BuildSysupgrade,$(1))
255 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
256         $(call Image/Build/Profile/$(PROFILE)/Initramfs)
257 endif
258 endef
259
260 $(eval $(call BuildImage))