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