ipq40xx: convert IMAGE_SIZE/KERNEL_SIZE/BLOCKSIZE to kiB
[oweals/openwrt.git] / target / linux / ipq40xx / image / Makefile
1 include $(TOPDIR)/rules.mk
2 include $(INCLUDE_DIR)/image.mk
3
4 DEVICE_VARS += RAS_BOARD RAS_ROOTFS_SIZE RAS_VERSION
5
6 define Device/Default
7         PROFILES := Default
8         KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
9         KERNEL_INITRAMFS_PREFIX := $$(IMG_PREFIX)-$(1)-initramfs
10         KERNEL_PREFIX := $$(IMAGE_PREFIX)
11         KERNEL_LOADADDR := 0x80208000
12         SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
13         IMAGE/sysupgrade.bin = sysupgrade-tar | append-metadata
14         IMAGE/sysupgrade.bin/squashfs :=
15 endef
16
17 define Device/FitImage
18         KERNEL_SUFFIX := -fit-uImage.itb
19         KERNEL = kernel-bin | gzip | fit gzip $$(DTS_DIR)/$$(DEVICE_DTS).dtb
20         KERNEL_NAME := Image
21 endef
22
23 define Device/FitImageLzma
24         KERNEL_SUFFIX := -fit-uImage.itb
25         KERNEL = kernel-bin | lzma | fit lzma $$(DTS_DIR)/$$(DEVICE_DTS).dtb
26         KERNEL_NAME := Image
27 endef
28
29 define Device/FitzImage
30         KERNEL_SUFFIX := -fit-zImage.itb
31         KERNEL = kernel-bin | fit none $$(DTS_DIR)/$$(DEVICE_DTS).dtb
32         KERNEL_NAME := zImage
33 endef
34
35 define Device/UbiFit
36         KERNEL_IN_UBI := 1
37         IMAGES := nand-factory.ubi nand-sysupgrade.bin
38         IMAGE/nand-factory.ubi := append-ubi
39         IMAGE/nand-sysupgrade.bin := sysupgrade-tar | append-metadata
40 endef
41
42 define Device/DniImage
43         KERNEL_SUFFIX := -fit-uImage.itb
44         KERNEL = kernel-bin | gzip | fit gzip $$(DTS_DIR)/$$(DEVICE_DTS).dtb
45         KERNEL_NAME := Image
46         NETGEAR_BOARD_ID :=
47         NETGEAR_HW_ID :=
48         IMAGES := factory.img sysupgrade.bin
49         IMAGE/factory.img := append-kernel | pad-offset 64k 64 | append-uImage-fakehdr filesystem | append-rootfs | pad-rootfs | netgear-dni
50         IMAGE/sysupgrade.bin := append-kernel | pad-offset 64k 64 | append-uImage-fakehdr filesystem | append-rootfs | pad-rootfs | append-metadata
51 endef
52 DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_HW_ID
53
54 define Build/SenaoFW
55         -$(STAGING_DIR_HOST)/bin/mksenaofw \
56                 -n $(BOARD_NAME) -r $(VENDOR_ID) -p $(1) \
57                 -c $(DATECODE) -w $(2) -x $(CW_VER) -t 0 \
58                 -e $@ \
59                 -o $@.new
60         @cp $@.new $@
61 endef
62
63 define Device/8dev_jalapeno
64         $(call Device/FitImage)
65         $(call Device/UbiFit)
66         DEVICE_VENDOR := 8devices
67         DEVICE_MODEL := Jalapeno
68         DEVICE_DTS := qcom-ipq4018-jalapeno
69         BLOCKSIZE := 128k
70         PAGESIZE := 2048
71 endef
72 TARGET_DEVICES += 8dev_jalapeno
73
74 define Device/alfa-network_ap120c-ac
75         $(call Device/FitImage)
76         $(call Device/UbiFit)
77         DEVICE_VENDOR := ALFA Network
78         DEVICE_MODEL := AP120C-AC
79         DEVICE_DTS := qcom-ipq4018-ap120c-ac
80         DEVICE_PACKAGES := kmod-usb-acm \
81                 kmod-tpm-i2c-atmel uboot-envtools
82         BLOCKSIZE := 128k
83         PAGESIZE := 2048
84         IMAGE_SIZE := 65536k
85         IMAGES := nand-factory.bin nand-sysupgrade.bin
86         IMAGE/nand-factory.bin := append-ubi | qsdk-ipq-factory-nand
87 endef
88 TARGET_DEVICES += alfa-network_ap120c-ac
89
90 define Device/asus_map-ac2200
91         $(call Device/FitImageLzma)
92         DEVICE_VENDOR := ASUS
93         DEVICE_MODEL := Lyra (MAP-AC2200)
94         DEVICE_DTS := qcom-ipq4019-map-ac2200
95         IMAGES := sysupgrade.bin
96         DEVICE_PACKAGES := ath10k-firmware-qca9888-ct kmod-ath3k
97 endef
98 TARGET_DEVICES += asus_map-ac2200
99
100 define Device/asus_rt-ac58u
101         $(call Device/FitImageLzma)
102         DEVICE_VENDOR := ASUS
103         DEVICE_MODEL := RT-AC58U
104         DEVICE_DTS := qcom-ipq4018-rt-ac58u
105         BLOCKSIZE := 128k
106         PAGESIZE := 2048
107         DTB_SIZE := 65536
108         IMAGE_SIZE := 20439364
109         FILESYSTEMS := squashfs
110 #       Someone - in their infinite wisdom - decided to put the firmware
111 #       version in front of the image name \03\00\00\04 => Version 3.0.0.4
112 #       Since u-boot works with strings we either need another fixup step
113 #       to add a version... or we are very careful not to add '\0' into that
114 #       string and call it a day.... Yeah, we do the latter!
115         UIMAGE_NAME:=$(shell echo -e '\03\01\01\01RT-AC58U')
116         IMAGES := sysupgrade.bin
117         DEVICE_PACKAGES := kmod-usb-ledtrig-usbport
118 endef
119 TARGET_DEVICES += asus_rt-ac58u
120
121 define Device/avm_fritzbox-4040
122         $(call Device/FitImageLzma)
123         DEVICE_VENDOR := AVM
124         DEVICE_MODEL := FRITZ!Box 4040
125         DEVICE_DTS := qcom-ipq4018-fritz4040
126         BOARD_NAME := fritz4040
127         IMAGE_SIZE := 29056k
128         UBOOT_PATH := $(STAGING_DIR_IMAGE)/uboot-fritz4040.bin
129         UBOOT_PARTITION_SIZE := 524288
130         IMAGES = eva.bin sysupgrade.bin
131         IMAGE/eva.bin := append-uboot | pad-to $$$$(UBOOT_PARTITION_SIZE) | append-kernel | append-rootfs | pad-rootfs
132         IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata
133         DEVICE_PACKAGES := fritz-tffs fritz-caldata
134 endef
135 TARGET_DEVICES += avm_fritzbox-4040
136
137 define Device/avm_fritzbox-7530
138         $(call Device/FitImageLzma)
139         DEVICE_VENDOR := AVM
140         DEVICE_MODEL := FRITZ!Box 7530
141         DEVICE_DTS := qcom-ipq4019-fritzbox-7530
142         DEVICE_PACKAGES := fritz-caldata fritz-tffs-nand
143         IMAGES := sysupgrade.bin
144 endef
145 TARGET_DEVICES += avm_fritzbox-7530
146
147 define Device/avm_fritzrepeater-1200
148         $(call Device/FitImageLzma)
149         DEVICE_VENDOR := AVM
150         DEVICE_MODEL := FRITZ!Repeater 1200
151         DEVICE_DTS := qcom-ipq4019-fritzrepeater-1200
152         DEVICE_PACKAGES := fritz-caldata fritz-tffs-nand ipq-wifi-avm_fritzrepeater-1200
153         IMAGES := sysupgrade.bin
154 endef
155 TARGET_DEVICES += avm_fritzrepeater-1200
156
157 define Device/avm_fritzrepeater-3000
158         $(call Device/FitImageLzma)
159         DEVICE_VENDOR := AVM
160         DEVICE_MODEL := FRITZ!Repeater 3000
161         DEVICE_DTS := qcom-ipq4019-fritzrepeater-3000
162         DEVICE_PACKAGES := ath10k-firmware-qca9984-ct fritz-caldata fritz-tffs-nand
163         IMAGES := sysupgrade.bin
164 endef
165 TARGET_DEVICES += avm_fritzrepeater-3000
166
167 define Device/compex_wpj419
168         $(call Device/FitImage)
169         $(call Device/UbiFit)
170         DEVICE_VENDOR := Compex
171         DEVICE_MODEL := WPJ419
172         DEVICE_DTS := qcom-ipq4019-wpj419
173         DEVICE_DTS_CONFIG := config@12
174         KERNEL_INSTALL := 1
175         BLOCKSIZE := 128k
176         PAGESIZE := 2048
177         FILESYSTEMS := squashfs
178 endef
179 TARGET_DEVICES += compex_wpj419
180
181 define Device/compex_wpj428
182         $(call Device/FitImage)
183         DEVICE_VENDOR := Compex
184         DEVICE_MODEL := WPJ428
185         DEVICE_DTS := qcom-ipq4028-wpj428
186         DEVICE_DTS_CONFIG := config@4
187         BLOCKSIZE := 64k
188         IMAGE_SIZE := 31232k
189         KERNEL_SIZE := 4096k
190         IMAGES = sysupgrade.bin
191         IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata
192         DEVICE_PACKAGES := kmod-gpio-beeper
193 endef
194 TARGET_DEVICES += compex_wpj428
195
196 define Device/engenius_eap1300
197         $(call Device/FitImage)
198         DEVICE_VENDOR := EnGenius
199         DEVICE_MODEL := EAP1300
200         DEVICE_DTS_CONFIG := config@4
201         BOARD_NAME := eap1300
202         DEVICE_DTS := qcom-ipq4018-eap1300
203         KERNEL_SIZE := 5120k
204         IMAGE_SIZE := 25344k
205         IMAGES := sysupgrade.bin
206         IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata
207 endef
208 TARGET_DEVICES += engenius_eap1300
209
210 define Device/engenius_ens620ext
211         $(call Device/FitImage)
212         DEVICE_VENDOR := EnGenius
213         DEVICE_MODEL := ENS620EXT
214         DEVICE_DTS := qcom-ipq4018-ens620ext
215         DEVICE_DTS_CONFIG := config@4
216         BLOCKSIZE := 64k
217         PAGESIZE := 256
218         BOARD_NAME := ENS620EXT
219         VENDOR_ID := 0x0101
220         PRODUCT_ID := 0x79
221         PRODUCT_ID_NEW := 0xA4
222         DATECODE := 190507
223         FW_VER := 3.1.2
224         FW_VER_NEW := 3.5.6
225         CW_VER := 1.8.99
226         IMAGE_SIZE := 21312k
227         KERNEL_SIZE := 5120k
228         FILESYSTEMS := squashfs
229         IMAGES := sysupgrade.bin factory_30.bin factory_35.bin
230         IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE) | append-metadata
231         IMAGE/factory_30.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE) | SenaoFW $$$$(PRODUCT_ID) $$$$(FW_VER)
232         IMAGE/factory_35.bin := qsdk-ipq-factory-nor | check-size $$$$(IMAGE_SIZE) | SenaoFW $$$$(PRODUCT_ID_NEW) $$$$(FW_VER_NEW)
233 endef
234 TARGET_DEVICES += engenius_ens620ext
235
236 define Device/glinet_gl-b1300
237         $(call Device/FitImage)
238         DEVICE_VENDOR := GL.iNet
239         DEVICE_MODEL := GL-B1300
240         BOARD_NAME := gl-b1300
241         DEVICE_DTS := qcom-ipq4029-gl-b1300
242         KERNEL_SIZE := 4096k
243         IMAGE_SIZE := 26624k
244         IMAGES := sysupgrade.bin
245         IMAGE/sysupgrade.bin := append-kernel |append-rootfs | pad-rootfs | append-metadata
246 endef
247 TARGET_DEVICES += glinet_gl-b1300
248
249 define Device/linksys_ea6350v3
250         # The Linksys EA6350v3 has a uboot bootloader that does not
251         # support either booting lzma kernel images nor booting UBI
252         # partitions. This uboot, however, supports raw kernel images and
253         # gzipped images.
254         #
255         # As for the time of writing this, the device will boot the kernel
256         # from a fixed address with a fixed length of 3MiB. Also, the
257         # device has a hard-coded kernel command line that requieres the
258         # rootfs and alt_rootfs to be in mtd11 and mtd13 respectively.
259         # Oh... and the kernel partition overlaps with the rootfs
260         # partition (the same for alt_kernel and alt_rootfs).
261         #
262         # If you are planing re-partitioning the device, you may want to
263         # keep those details in mind:
264         # 1. The kernel adresses you should honor are 0x00000000 and
265         #    0x02800000 respectively.
266         # 2. The kernel size (plus the dtb) cannot exceed 3.00MiB in size.
267         # 3. You can use 'zImage', but not a raw 'Image' packed with lzma.
268         # 4. The kernel command line from uboot is harcoded to boot with
269         #    rootfs either in mtd11 or mtd13.
270         $(call Device/FitzImage)
271         DEVICE_VENDOR := Linksys
272         DEVICE_MODEL := EA6350
273         DEVICE_VARIANT := v3
274         DEVICE_DTS := qcom-ipq4018-ea6350v3
275         BLOCKSIZE := 128k
276         PAGESIZE := 2048
277         KERNEL_SIZE := 3072k
278         IMAGE_SIZE := 37888k
279         UBINIZE_OPTS := -E 5
280         IMAGES := factory.bin sysupgrade.bin
281         IMAGE/factory.bin := append-kernel | append-uImage-fakehdr filesystem | pad-to $$$${KERNEL_SIZE} | append-ubi | linksys-image type=EA6350v3
282         DEVICE_PACKAGES := uboot-envtools
283 endef
284 TARGET_DEVICES += linksys_ea6350v3
285
286 define Device/linksys_ea8300
287         $(call Device/FitzImage)
288         DEVICE_VENDOR := Linksys
289         DEVICE_MODEL := EA8300
290         DEVICE_DTS := qcom-ipq4019-linksys_ea8300
291         KERNEL_SIZE := 3072k
292         IMAGE_SIZE := 87040k
293         BLOCKSIZE := 128k
294         PAGESIZE := 2048
295         UBINIZE_OPTS := -E 5    # EOD marks to "hide" factory sig at EOF
296         IMAGES := sysupgrade.bin factory.bin
297         IMAGE/factory.bin  := append-kernel | pad-to $$$${KERNEL_SIZE} | append-ubi | linksys-image type=EA8300
298         DEVICE_PACKAGES := uboot-envtools ath10k-firmware-qca9888-ct ipq-wifi-linksys_ea8300 kmod-usb-ledtrig-usbport
299 endef
300 TARGET_DEVICES += linksys_ea8300
301
302 define Device/meraki_mr33
303         $(call Device/FitImage)
304         DEVICE_VENDOR := Cisco Meraki
305         DEVICE_MODEL := MR33
306         DEVICE_DTS := qcom-ipq4029-mr33
307         BLOCKSIZE := 128k
308         PAGESIZE := 2048
309         IMAGES = sysupgrade.bin
310         DEVICE_PACKAGES := -swconfig ath10k-firmware-qca9887-ct
311 endef
312 TARGET_DEVICES += meraki_mr33
313
314 define Device/netgear_ex61x0v2
315         $(call Device/DniImage)
316         DEVICE_DTS_CONFIG := config@4
317         NETGEAR_BOARD_ID := EX6150v2series
318         NETGEAR_HW_ID := 29765285+16+0+128+2x2
319 endef
320
321 define Device/netgear_ex6100v2
322         $(call Device/netgear_ex61x0v2)
323         DEVICE_VENDOR := Netgear
324         DEVICE_MODEL := EX6100
325         DEVICE_VARIANT := v2
326         DEVICE_DTS := qcom-ipq4018-ex6100v2
327 endef
328 TARGET_DEVICES += netgear_ex6100v2
329
330 define Device/netgear_ex6150v2
331         $(call Device/netgear_ex61x0v2)
332         DEVICE_VENDOR := Netgear
333         DEVICE_MODEL := EX6150
334         DEVICE_VARIANT := v2
335         DEVICE_DTS := qcom-ipq4018-ex6150v2
336 endef
337 TARGET_DEVICES += netgear_ex6150v2
338
339 define Device/openmesh_a42
340         $(call Device/FitImageLzma)
341         DEVICE_VENDOR := OpenMesh
342         DEVICE_MODEL := A42
343         DEVICE_DTS := qcom-ipq4018-a42
344         DEVICE_DTS_CONFIG := config@om.a42
345         BLOCKSIZE := 64k
346         KERNEL = kernel-bin | lzma | fit lzma $$(DTS_DIR)/$$(DEVICE_DTS).dtb | pad-to $$(BLOCKSIZE)
347         IMAGE_SIZE := 15616k
348         IMAGES = factory.bin sysupgrade.bin
349         IMAGE/factory.bin := append-rootfs | pad-rootfs | openmesh-image ce_type=A42
350         IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-rootfs | sysupgrade-tar rootfs=$$$$@ | append-metadata
351         DEVICE_PACKAGES := uboot-envtools
352 endef
353 TARGET_DEVICES += openmesh_a42
354
355 define Device/openmesh_a62
356         $(call Device/FitImageLzma)
357         DEVICE_VENDOR := OpenMesh
358         DEVICE_MODEL := A62
359         DEVICE_DTS := qcom-ipq4019-a62
360         DEVICE_DTS_CONFIG := config@om.a62
361         BLOCKSIZE := 64k
362         KERNEL = kernel-bin | lzma | fit lzma $$(DTS_DIR)/$$(DEVICE_DTS).dtb | pad-to $$(BLOCKSIZE)
363         IMAGE_SIZE := 15552k
364         IMAGES = factory.bin sysupgrade.bin
365         IMAGE/factory.bin := append-rootfs | pad-rootfs | openmesh-image ce_type=A62
366         IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-rootfs | sysupgrade-tar rootfs=$$$$@ | append-metadata
367         DEVICE_PACKAGES := ath10k-firmware-qca9888-ct uboot-envtools
368 endef
369
370 TARGET_DEVICES += openmesh_a62
371
372 define Device/qcom_ap-dk01.1-c1
373         DEVICE_VENDOR := Qualcomm Atheros
374         DEVICE_MODEL := AP-DK01.1
375         DEVICE_VARIANT := C1
376         BOARD_NAME := ap-dk01.1-c1
377         DEVICE_DTS := qcom-ipq4019-ap.dk01.1-c1
378         KERNEL_INSTALL := 1
379         KERNEL_SIZE := 4096k
380         IMAGE_SIZE := 26624k
381         $(call Device/FitImage)
382         IMAGES := sysupgrade.bin
383         IMAGE/sysupgrade.bin := append-kernel | pad-to $$$${KERNEL_SIZE} | append-rootfs | pad-rootfs | append-metadata
384 endef
385 TARGET_DEVICES += qcom_ap-dk01.1-c1
386
387 define Device/qcom_ap-dk04.1-c1
388         $(call Device/FitImage)
389         $(call Device/UbiFit)
390         DEVICE_VENDOR := Qualcomm Atheros
391         DEVICE_MODEL := AP-DK04.1
392         DEVICE_VARIANT := C1
393         DEVICE_DTS := qcom-ipq4019-ap.dk04.1-c1
394         KERNEL_INSTALL := 1
395         KERNEL_SIZE := 4048k
396         BLOCKSIZE := 128k
397         PAGESIZE := 2048
398         BOARD_NAME := ap-dk04.1-c1
399 endef
400 TARGET_DEVICES += qcom_ap-dk04.1-c1
401
402 define Device/qxwlan_e2600ac-c1
403         $(call Device/FitImage)
404         DEVICE_VENDOR := Qxwlan
405         DEVICE_MODEL := E2600AC
406         DEVICE_VARIANT := C1
407         BOARD_NAME := e2600ac-c1
408         DEVICE_DTS := qcom-ipq4019-qxwlan-e2600ac-c1
409         KERNEL_SIZE := 4096k
410         IMAGE_SIZE := 31232k
411         IMAGES := sysupgrade.bin
412         IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata
413         DEVICE_PACKAGES := ipq-wifi-qxwlan_e2600ac
414 endef
415 TARGET_DEVICES += qxwlan_e2600ac-c1
416
417 define Device/qxwlan_e2600ac-c2
418         $(call Device/FitImage)
419         $(call Device/UbiFit)
420         DEVICE_VENDOR := Qxwlan
421         DEVICE_MODEL := E2600AC
422         DEVICE_VARIANT := C2
423         DEVICE_DTS := qcom-ipq4019-qxwlan-e2600ac-c2
424         KERNEL_INSTALL := 1
425         BLOCKSIZE := 128k
426         PAGESIZE := 2048
427         DEVICE_PACKAGES := ipq-wifi-qxwlan_e2600ac
428 endef
429 TARGET_DEVICES += qxwlan_e2600ac-c2
430
431 define Device/unielec_u4019-32m
432         $(call Device/FitImage)
433         DEVICE_VENDOR := Unielec
434         DEVICE_MODEL := U4019
435         DEVICE_VARIANT := 32M
436         BOARD_NAME := u4019-32m
437         DEVICE_DTS := qcom-ipq4019-unielec-u4019-32m
438         KERNEL_SIZE := 4096k
439         IMAGE_SIZE := 31232k
440         IMAGES := sysupgrade.bin
441         IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata
442 endef
443 TARGET_DEVICES += unielec_u4019-32m
444
445 define Device/zyxel_nbg6617
446         $(call Device/FitImageLzma)
447         DEVICE_VENDOR := ZyXEL
448         DEVICE_MODEL := NBG6617
449         DEVICE_DTS := qcom-ipq4018-nbg6617
450         ROOTFS_SIZE := 24960k
451         RAS_BOARD := NBG6617
452         RAS_ROOTFS_SIZE := 19840k
453         RAS_VERSION := "$(VERSION_DIST) $(REVISION)"
454         IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata
455         IMAGES := sysupgrade.bin factory.bin
456 #       The ZyXEL firmware allows flashing thru the web-gui only when the rootfs is
457 #       at least as large as the one of the initial firmware image (not the current
458 #       one on the device). This only applies to the Web-UI, the bootlaoder ignores
459 #       this minimum-size. However, the larger image can be flashed both ways.
460         IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to 64k | check-size $$$$(ROOTFS_SIZE) | zyxel-ras-image separate-kernel
461         IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-rootfs | check-size $$$$(ROOTFS_SIZE) | sysupgrade-tar rootfs=$$$$@ | append-metadata
462         DEVICE_PACKAGES := uboot-envtools kmod-usb-ledtrig-usbport
463 endef
464 TARGET_DEVICES += zyxel_nbg6617
465
466 define Device/zyxel_wre6606
467         $(call Device/FitImage)
468         DEVICE_VENDOR := ZyXEL
469         DEVICE_MODEL := WRE6606
470         DEVICE_DTS_CONFIG := config@4
471         DEVICE_DTS := qcom-ipq4018-wre6606
472         IMAGES := sysupgrade.bin
473         IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata
474 endef
475 TARGET_DEVICES += zyxel_wre6606
476
477 $(eval $(call BuildImage))