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