mvebu: unify boot.scr creation
[openwrt/openwrt.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 SIGNATURE:=$(shell printf "%.8s" $(SOURCE_DATE_EPOCH))
17
18 define Build/dtb
19 $(call Image/BuildDTB,$(DTS_DIR)/$(DEVICE_DTS).dts,$@.dtb)
20 endef
21
22 # SD-Card Images:
23 # these values are optimized for a 4GB labeled sdcard that actually holds 7744512 sectors of 512 byte
24 # MBR: 2048 sectors
25 # Partition 1: 32768 sectors
26 # Partition 2: 98304 sectors (configurable)
27
28 define Build/boot-scr
29 rm -f $@-boot.scr
30 mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d $(DEVICE_NAME).bootscript $@-boot.scr
31 endef
32
33 define Build/boot-img
34 rm -f $@.boot
35 mkfs.fat -C $@.boot 16384
36 $(foreach dts,$(DEVICE_DTS), mcopy -i $@.boot $(DTS_DIR)/$(dts).dtb ::$(dts).dtb;)
37 mcopy -i $@.boot $(IMAGE_KERNEL) ::zImage
38 -mcopy -i $@.boot $@-boot.scr ::boot.scr
39 endef
40
41 define Build/sdcard-img
42 if [ -n "$(UBOOT)" ]; then UBOOT="$(STAGING_DIR_IMAGE)/$(UBOOT)"; fi; \
43 ROOTFS_SIZE=$$(( $(CONFIG_TARGET_ROOTFS_PARTSIZE) * 1024 * 2 )); \
44 SIGNATURE="$(SIGNATURE)" \
45 ./gen_mvebu_sdcard_img.sh $@ \
46 $$UBOOT \
47 c 32768 $@.boot \
48 83 $$ROOTFS_SIZE $(IMAGE_ROOTFS)
49 endef
50
51 define Device/Default
52 PROFILES := Default
53 DEVICE_DTS := $(1)
54 BOARD_NAME = $$(DEVICE_DTS)
55 KERNEL_NAME := zImage
56 KERNEL := kernel-bin | append-dtb | uImage none
57 SUPPORTED_DEVICES = $$(DEVICE_DTS)
58 endef
59
60 define Device/UBI
61 IMAGES := sysupgrade.bin
62 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
63 endef
64
65 define Device/UBI-factory
66 $(Device/UBI)
67 UBINIZE_OPTS := -E 5
68 IMAGES += factory.img
69 IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE)
70 endef
71
72 define Device/NAND-128K
73 $(Device/UBI)
74 BLOCKSIZE := 128k
75 PAGESIZE := 2048
76 SUBPAGESIZE := 512
77 VID_HDR_OFFSET := 2048
78 endef
79
80 define Device/NAND-256K
81 $(Device/UBI)
82 BLOCKSIZE := 256k
83 PAGESIZE := 4096
84 endef
85
86 define Device/NAND-512K
87 $(Device/UBI)
88 BLOCKSIZE := 512k
89 PAGESIZE := 4096
90 endef
91
92 define Device/linksys
93 DEVICE_TITLE := Linksys $(1)
94 DEVICE_PACKAGES := kmod-mwlwifi wpad-mini swconfig
95 endef
96
97 define Device/armada-385-linksys
98 $(Device/NAND-128K)
99 $(Device/UBI-factory)
100 KERNEL_SIZE := 6144k
101 endef
102
103 define Device/linksys-wrt1200ac
104 $(call Device/linksys,WRT1200AC (Caiman))
105 $(Device/armada-385-linksys)
106 DEVICE_DTS := armada-385-linksys-caiman
107 DEVICE_PACKAGES += mwlwifi-firmware-88w8864
108 endef
109 TARGET_DEVICES += linksys-wrt1200ac
110
111 define Device/linksys-wrt1900acv2
112 $(call Device/linksys,WRT1900ACv2 (Cobra))
113 $(Device/armada-385-linksys)
114 DEVICE_DTS := armada-385-linksys-cobra
115 DEVICE_PACKAGES += mwlwifi-firmware-88w8864
116 endef
117 TARGET_DEVICES += linksys-wrt1900acv2
118
119 define Device/linksys-wrt3200acm
120 $(call Device/linksys,WRT3200ACM (Rango))
121 $(Device/armada-385-linksys)
122 DEVICE_DTS := armada-385-linksys-rango
123 DEVICE_PACKAGES += kmod-btmrvl kmod-mwifiex-sdio mwlwifi-firmware-88w8964
124 endef
125 TARGET_DEVICES += linksys-wrt3200acm
126
127 define Device/linksys-wrt1900acs
128 $(call Device/linksys,WRT1900ACS (Shelby))
129 $(Device/armada-385-linksys)
130 DEVICE_DTS := armada-385-linksys-shelby
131 DEVICE_PACKAGES += mwlwifi-firmware-88w8864
132 endef
133 TARGET_DEVICES += linksys-wrt1900acs
134
135 define Device/linksys-wrt1900ac
136 $(call Device/linksys,WRT1900AC (Mamba))
137 DEVICE_DTS := armada-xp-linksys-mamba
138 DEVICE_PACKAGES += mwlwifi-firmware-88w8864
139 $(Device/NAND-128K)
140 $(Device/UBI-factory)
141 KERNEL_SIZE := 3072k
142 endef
143 TARGET_DEVICES += linksys-wrt1900ac
144
145 define Device/openblocks-ax3-4
146 $(Device/UBI-factory)
147 DEVICE_DTS := armada-xp-openblocks-ax3-4
148 SUPPORTED_DEVICES := $(1)
149 BLOCKSIZE := 128k
150 PAGESIZE := 1
151 IMAGE/factory.img := append-kernel | pad-to $$(BLOCKSIZE) | append-ubi
152 DEVICE_TITLE := Plat'Home OpenBlocks AX3
153 endef
154 TARGET_DEVICES += openblocks-ax3-4
155
156 define Device/armada-385-db-ap
157 $(Device/NAND-256K)
158 $(Device/UBI-factory)
159 KERNEL_SIZE := 8192k
160 DEVICE_TITLE := Marvell Armada 385 DB AP (DB-88F6820-AP)
161 endef
162 TARGET_DEVICES += armada-385-db-ap
163
164 define Device/marvell-nand
165 $(Device/NAND-512K)
166 DEVICE_TITLE := Marvell Armada $(1)
167 endef
168
169 define Device/armada-370-db
170 $(call Device/marvell-nand,370 DB (DB-88F6710-BP-DDR3))
171 endef
172 TARGET_DEVICES += armada-370-db
173
174 define Device/armada-370-rd
175 $(call Device/marvell-nand,370 RD (RD-88F6710-A1))
176 endef
177 TARGET_DEVICES += armada-370-rd
178
179 define Device/armada-xp-db
180 $(call Device/marvell-nand,XP DB (DB-78460-BP))
181 endef
182 TARGET_DEVICES += armada-xp-db
183
184 define Device/armada-xp-gp
185 $(call Device/marvell-nand,XP GP (DB-MV784MP-GP))
186 endef
187 TARGET_DEVICES += armada-xp-gp
188
189 define Device/armada-388-rd
190 DEVICE_TITLE := Marvell Armada 388 RD (RD-88F6820-AP)
191 IMAGES := firmware.bin
192 IMAGE/firmware.bin := append-kernel | pad-to 256k | append-rootfs | pad-rootfs
193 endef
194 TARGET_DEVICES += armada-388-rd
195
196 define Device/armada-388-clearfog-pro
197 KERNEL_INSTALL := 1
198 KERNEL := kernel-bin
199 DEVICE_TITLE := SolidRun ClearFog Pro
200 DEVICE_PACKAGES := mkf2fs e2fsprogs swconfig kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1
201 IMAGES := sdcard.img.gz
202 IMAGE/sdcard.img.gz := boot-scr | boot-img | sdcard-img | gzip | append-metadata
203 DEVICE_DTS := armada-388-clearfog-pro armada-388-clearfog-base
204 SUPPORTED_DEVICES := armada-388-clearfog-pro armada-388-clearfog
205 UBOOT := clearfog-u-boot-spl.kwb
206 endef
207 TARGET_DEVICES += armada-388-clearfog-pro
208
209 define Device/armada-388-clearfog-base
210 KERNEL_INSTALL := 1
211 KERNEL := kernel-bin
212 DEVICE_TITLE := SolidRun ClearFog Base
213 DEVICE_PACKAGES := mkf2fs e2fsprogs kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1
214 IMAGES := sdcard.img.gz
215 IMAGE/sdcard.img.gz := boot-scr | boot-img | sdcard-img | gzip | append-metadata
216 DEVICE_DTS := armada-388-clearfog-pro armada-388-clearfog-base
217 UBOOT := clearfog-u-boot-spl.kwb
218 endef
219 TARGET_DEVICES += armada-388-clearfog-base
220
221 define Device/globalscale-mirabox
222 $(Device/NAND-512K)
223 DEVICE_DTS := armada-370-mirabox
224 SUPPORTED_DEVICES := mirabox
225 DEVICE_TITLE := Globalscale Mirabox
226 endef
227 TARGET_DEVICES += globalscale-mirabox
228
229 $(eval $(call BuildImage))