bcm53xx: bump maximum TRX size for devices with serial flash
[oweals/openwrt.git] / target / linux / bcm53xx / image / Makefile
1 #
2 # Copyright (C) 2013 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9
10 define Image/Prepare
11         $(CP) $(DTS_DIR)/*.dtb $(KDIR)/
12
13         rm -f $(KDIR)/fs_mark
14         echo -ne '\xde\xad\xc0\xde' > $(KDIR)/fs_mark
15         $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
16
17         # For UBI we want only one extra block
18         rm -f $(KDIR)/ubi_mark
19         echo -ne '\xde\xad\xc0\xde' > $(KDIR)/ubi_mark
20
21         $(CP) ./ubinize.cfg $(KDIR)
22 endef
23
24 define Build/append-dtb
25         cat $(KDIR)/$(DT).dtb >> $@
26 endef
27
28 define Build/lzma-d16
29         $(STAGING_DIR_HOST)/bin/lzma e $@ -d16 $(1) $@.new
30         @mv $@.new $@
31 endef
32
33 define Build/mkfs/squashfs
34         ( cd $(KDIR); $(STAGING_DIR_HOST)/bin/ubinize -p 128KiB -m 2048 -o $(KDIR)/root-block-0x20000-min-0x800.ubi ubinize.cfg )
35 endef
36
37 define Build/trx-serial
38         $(STAGING_DIR_HOST)/bin/trx \
39                 -o $@ \
40                 -m 33554432 \
41                 -f $(word 1,$^) -a 1024 \
42                 -f $(KDIR)/root.squashfs -a 0x10000 -A $(KDIR)/fs_mark
43 endef
44
45 define Build/trx-nand
46         # kernel: always use 4 MiB (-28 B or TRX header) to allow upgrades even
47         #         if it grows up between releases
48         # root: UBI with one extra block containing UBI mark to trigger erasing
49         #       rest of partition
50         $(STAGING_DIR_HOST)/bin/trx \
51                 -o $@ \
52                 -m 33554432 \
53                 -f $(word 1,$^) -a 0x20000 -b 0x400000 \
54                 -f $(KDIR)/root-block-0x20000-min-0x800.ubi \
55                 -A $(KDIR)/ubi_mark -a 0x20000
56 endef
57
58 define Build/asus-trx
59         $(STAGING_DIR_HOST)/bin/asustrx \
60                 -p $(PRODUCTID) -i $@ -o $@.new
61         mv $@.new $@
62 endef
63
64 define Build/seama-nand
65         # Seama entity
66         $(STAGING_DIR_HOST)/bin/oseama \
67                 entity $@.entity \
68                 -m "dev=/dev/mtdblock/7" \
69                 -m "type=firmware" \
70                 -f $(word 1,$^) \
71                 -b 0x400000 \
72                 -f $(KDIR)/root-block-0x20000-min-0x800.ubi \
73                 -f $(KDIR)/ubi_mark
74         # Seama container
75         $(STAGING_DIR_HOST)/bin/seama \
76                 -s $@ \
77                 -m "signature=$(SIGNATURE)" \
78                 -i $@.entity
79 endef
80
81 DEVICE_VARS += DT PRODUCTID SIGNATURE NETGEAR_BOARD_ID NETGEAR_REGION
82
83 define Device/Default
84   # .dtb files are prefixed by SoC type, e.g. bcm4708- which is not included in device/image names
85   # extract the full dtb name based on the device info
86   DT := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb)))
87   KERNEL := kernel-bin | append-dtb | lzma-d16
88   KERNEL_DEPENDS = $$(wildcard $(KDIR)/$$(DT).dts)
89   FILESYSTEMS := squashfs
90   KERNEL_NAME := zImage
91   IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
92   IMAGES := trx
93   IMAGE/trx := trx-nand
94 endef
95
96 define Device/asus
97   IMAGES := trx
98   IMAGE/trx := trx-nand | asus-trx
99 endef
100
101 define AsusDevice
102   define Device/asus-$(1)
103         $$(Device/asus)
104         PRODUCTID := $(2)
105   endef
106   TARGET_DEVICES += asus-$(1)
107 endef
108
109 define Device/linksys
110   IMAGES := trx
111   IMAGE/trx := trx-nand
112 endef
113
114 define LinksysDevice
115   define Device/linksys-$(1)
116         $$(Device/linksys)
117   endef
118   TARGET_DEVICES += linksys-$(1)
119 endef
120
121 define Device/dlink
122   IMAGES := bin
123   IMAGE/bin := seama-nand
124 endef
125
126 define DLinkDevice
127   define Device/dlink-$(1)
128         $$(Device/dlink)
129         SIGNATURE := $(2)
130   endef
131   TARGET_DEVICES += dlink-$(1)
132 endef
133
134 define Device/netgear
135   IMAGES := chk
136   IMAGE/chk := trx-nand | netgear-chk
137   NETGEAR_REGION := 1
138 endef
139
140 define NetgearDevice
141   define Device/netgear-$(1)
142         $$(Device/netgear)
143         NETGEAR_BOARD_ID := $(2)
144   endef
145   TARGET_DEVICES += netgear-$(1)
146 endef
147
148 define Device/netgear-r6250
149   $(Device/netgear)
150   NETGEAR_BOARD_ID := U12H245T00_NETGEAR
151 endef
152
153 define Device/netgear-r6300-v2
154   $(Device/netgear)
155   NETGEAR_BOARD_ID := U12H240T00_NETGEAR
156 endef
157
158 define Device/netgear-r8000
159   $(Device/netgear)
160   NETGEAR_BOARD_ID := U12H315T00_NETGEAR
161 endef
162
163 define Device/smartrg-sr400ac
164   IMAGES := trx
165   IMAGE/trx := trx-serial
166 endef
167
168 TARGET_DEVICES += \
169         buffalo-wzr-1750dhp buffalo-wzr-600dhp2 buffalo-wzr-900dhp \
170         buffalo-wxr-1900dhp \
171         netgear-r6250 netgear-r6300-v2 netgear-r8000 \
172         smartrg-sr400ac
173
174 $(eval $(call AsusDevice,rt-ac56u,RT-AC56U))
175 $(eval $(call AsusDevice,rt-ac68u,RT-AC68U))
176 $(eval $(call AsusDevice,rt-ac87u,RT-AC87U))
177 $(eval $(call AsusDevice,rt-n18u,RT-N18U))
178 $(eval $(call DLinkDevice,dir-885l,wrgac42_dlink.2015_dir885l))
179 $(eval $(call LinksysDevice,ea6300-v1))
180 $(eval $(call NetgearDevice,r7000,U12H270T00_NETGEAR))
181 $(eval $(call NetgearDevice,r7900,U12H315T30_NETGEAR))
182 # $(eval $(call NetgearDevice,r8500,U12H334T00_NETGEAR))
183
184 $(eval $(call BuildImage))