mvebu: use image metadata for firmware validation
[librecmc/librecmc.git] / target / linux / mvebu / image / Makefile
1 #
2 # Copyright (C) 2012-2016 OpenWrt.org
3 # Copyright (C) 2016 LEDE-project.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 JFFS2_BLOCKSIZE = 128k
10
11 include $(TOPDIR)/rules.mk
12 include $(INCLUDE_DIR)/image.mk
13
14 KERNEL_LOADADDR := 0x00008000
15
16 define Build/dtb
17         $(call Image/BuildDTB,$(DTS_DIR)/$(DEVICE_DTS).dts,$@.dtb)
18 endef
19
20 define Build/clearfog-bundle
21         rm -f $@.new
22         $(TAR) -cp --numeric-owner --owner=0 --group=0 --sort=name \
23                 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
24                 --file=$@.new -C $(TARGET_DIR)/ .
25         $(TAR) -rp --numeric-owner --owner=0 --group=0 --sort=name \
26                 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
27                 --file=$@.new -C $(dir $(IMAGE_KERNEL)) $(notdir $(IMAGE_KERNEL)) $(notdir $(IMAGE_KERNEL).dtb)
28         gzip -9n -c $@.new > $@
29 endef
30
31 # SD-Card Images:
32 # these values are optimized for a 4GB labeled sdcard that actually holds 7744512 sectors of 512 byte
33 # MBR:            2048 sectors
34 # Partition 1:   32768 sectors
35 # Partition 2:   98304 sectors (configurable)
36
37 define Build/boot-scr
38         rm -f $@.bootscript
39         mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d boot.script $@.bootscript
40 endef
41
42 define Build/boot-img
43         rm -f $@.boot
44         mkfs.fat -C $@.boot 16384
45         $(foreach dts,$(DEVICE_DTS), mcopy -i $@.boot $(DTS_DIR)/$(dts).dtb ::$(dts).dtb)
46         mcopy -i $@.boot $(IMAGE_KERNEL) ::zImage
47         mcopy -i $@.boot $@.bootscript ::boot.scr
48 endef
49
50 define Build/sdcard-img
51         ROOTFS_SIZE=$$(( $(CONFIG_TARGET_ROOTFS_PARTSIZE) * 1024 * 2 )); \
52         ./gen_mvebu_sdcard_img.sh $@ \
53                 "$(KDIR)/openwrt-mvebu-clearfog-u-boot-spl.kwb" \
54                 c 32768 $@.boot \
55                 83 $$ROOTFS_SIZE $(IMAGE_ROOTFS)
56 endef
57
58 define Device/Default
59   PROFILES := Default
60   DEVICE_DTS := $(1)
61   BOARD_NAME = $$(DEVICE_DTS)
62   KERNEL_NAME := zImage
63   KERNEL := kernel-bin | append-dtb | uImage none
64   SUPPORTED_DEVICES = $$(DEVICE_DTS)
65 endef
66
67 define Device/UBI
68   IMAGES := sysupgrade.bin
69   IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
70 endef
71
72 define Device/UBI-factory
73   $(Device/UBI)
74   UBINIZE_OPTS := -E 5
75   IMAGES += factory.img
76   IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE)
77 endef
78
79 define Device/NAND-128K
80   $(Device/UBI)
81   BLOCKSIZE := 128k
82   PAGESIZE := 2048
83   SUBPAGESIZE := 512
84   VID_HDR_OFFSET := 2048
85 endef
86
87 define Device/NAND-256K
88   $(Device/UBI)
89   BLOCKSIZE := 256k
90   PAGESIZE := 4096
91 endef
92
93 define Device/NAND-512K
94   $(Device/UBI)
95   BLOCKSIZE := 512k
96   PAGESIZE := 4096
97 endef
98
99 define Device/linksys
100   DEVICE_TITLE := Linksys $(1)
101   DEVICE_PACKAGES := kmod-mwlwifi wpad-mini swconfig
102 endef
103
104 define Device/armada-385-linksys
105   $(Device/NAND-128K)
106   $(Device/UBI-factory)
107   KERNEL_SIZE := 6144k
108 endef
109
110 define Device/linksys-wrt1200ac
111   $(call Device/linksys,WRT1200AC (Caiman))
112   $(Device/armada-385-linksys)
113   DEVICE_DTS := armada-385-linksys-caiman
114 endef
115 TARGET_DEVICES += linksys-wrt1200ac
116
117 define Device/linksys-wrt1900acv2
118   $(call Device/linksys,WRT1900ACv2 (Cobra))
119   $(Device/armada-385-linksys)
120   DEVICE_DTS := armada-385-linksys-cobra
121 endef
122 TARGET_DEVICES += linksys-wrt1900acv2
123
124 define Device/linksys-wrt3200acm
125   $(call Device/linksys,WRT3200ACM (Rango))
126   $(Device/armada-385-linksys)
127   DEVICE_DTS := armada-385-linksys-rango
128 endef
129 TARGET_DEVICES += linksys-wrt3200acm
130
131 define Device/linksys-wrt1900acs
132   $(call Device/linksys,WRT1900ACS (Shelby))
133   $(Device/armada-385-linksys)
134   DEVICE_DTS := armada-385-linksys-shelby
135 endef
136 TARGET_DEVICES += linksys-wrt1900acs
137
138 define Device/linksys-wrt1900ac
139   $(call Device/linksys,WRT1900AC (Mamba))
140   DEVICE_DTS := armada-xp-linksys-mamba
141   $(Device/NAND-128K)
142   $(Device/UBI-factory)
143   KERNEL_SIZE := 3072k
144 endef
145 TARGET_DEVICES += linksys-wrt1900ac
146
147 define Device/openblocks-ax3
148   $(Device/UBI-factory)
149   DEVICE_DTS := armada-xp-openblocks-ax3-4
150   SUPPORTED_DEVCES := $(1)
151   BLOCKSIZE := 128k
152   PAGESIZE := 1
153   IMAGE/factory.img := append-kernel | pad-to $$(BLOCKSIZE) | append-ubi
154   DEVICE_TITLE := Plat'Home OpenBlocks AX3
155 endef
156 TARGET_DEVICES += openblocks-ax3
157
158 define Device/armada-385-db-ap
159   $(Device/NAND-256K)
160   $(Device/UBI-factory)
161   KERNEL_SIZE := 8192k
162   DEVICE_TITLE := Marvell Armada 385 DB AP (DB-88F6820-AP)
163 endef
164 TARGET_DEVICES += armada-385-db-ap
165
166 define Device/marvell-nand
167   $(Device/NAND-512K)
168   DEVICE_TITLE := Marvell Armada $(1)
169 endef
170
171 Device/armada-370-db = $(call Device/marvell-nand,370 DB (DB-88F6710-BP-DDR3))
172 Device/armada-370-rd = $(call Device/marvell-nand,370 RD (RD-88F6710-A1))
173 Device/armada-xp-db = $(call Device/marvell-nand,XP DB (DB-78460-BP))
174 Device/armada-xp-gp = $(call Device/marvell-nand,XP GP (DB-MV784MP-GP))
175 TARGET_DEVICES += armada-370-db armada-370-rd armada-xp-db armada-xp-gp
176
177 define Device/armada-388-rd
178   DEVICE_TITLE := Marvell Armada 388 RD (RD-88F6820-AP)
179   IMAGES := firmware.bin
180   IMAGE/firmware.bin := append-kernel | pad-to 256k | append-rootfs | pad-rootfs
181 endef
182 TARGET_DEVICES += armada-388-rd
183
184 define Device/armada-388-clearfog
185   KERNEL_INSTALL := 1
186   KERNEL := dtb | kernel-bin
187   DEVICE_TITLE := SolidRun ClearFog
188   DEVICE_PACKAGES := mkf2fs e2fsprogs swconfig kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1
189   IMAGES := bundle.tar.gz sdcard.img.gz
190   IMAGE/bundle.tar.gz := clearfog-bundle
191   IMAGE/sdcard.img.gz := boot-scr | boot-img | sdcard-img | gzip
192   IMAGE_NAME = $$(IMAGE_PREFIX)-$$(2)
193 endef
194 TARGET_DEVICES += armada-388-clearfog
195
196 define Device/globalscale-mirabox
197   $(Device/NAND-512K)
198   DEVICE_DTS := armada-370-mirabox
199   SUPPORTED_DEVCES := mirabox
200   DEVICE_TITLE := Globalscale Mirabox
201 endef
202 TARGET_DEVICES += globalscale-mirabox
203
204 $(eval $(call BuildImage))