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