052900053e1101cfd07c020b4a9a97d3a71a5020
[openwrt/staging/yousong.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 Device/linksys
104 IMAGES := trx
105 IMAGE/trx := trx-nand
106 endef
107
108 define LinksysDevice
109 define Device/linksys-$(1)
110 $$(Device/linksys)
111 endef
112 TARGET_DEVICES += linksys-$(1)
113 endef
114
115 define Device/dlink
116 IMAGES := bin
117 IMAGE/bin := seama-nand
118 endef
119
120 define DLinkDevice
121 define Device/dlink-$(1)
122 $$(Device/dlink)
123 SIGNATURE := $(2)
124 endef
125 TARGET_DEVICES += dlink-$(1)
126 endef
127
128 define Device/netgear
129 IMAGES := chk
130 IMAGE/chk := trx-nand | netgear-chk
131 NETGEAR_REGION := 1
132 endef
133
134 define NetgearDevice
135 define Device/netgear-$(1)
136 $$(Device/netgear)
137 NETGEAR_BOARD_ID := $(2)
138 endef
139 TARGET_DEVICES += netgear-$(1)
140 endef
141
142 define Device/netgear-r6250
143 $(Device/netgear)
144 NETGEAR_BOARD_ID := U12H245T00_NETGEAR
145 endef
146
147 define Device/netgear-r6300-v2
148 $(Device/netgear)
149 NETGEAR_BOARD_ID := U12H240T00_NETGEAR
150 endef
151
152 define Device/netgear-r8000
153 $(Device/netgear)
154 NETGEAR_BOARD_ID := U12H315T00_NETGEAR
155 endef
156
157 define Device/smartrg-sr400ac
158 IMAGES := trx
159 IMAGE/trx := trx-serial
160 endef
161
162 TARGET_DEVICES += \
163 buffalo-wzr-1750dhp buffalo-wzr-600dhp2 buffalo-wzr-900dhp \
164 buffalo-wxr-1900dhp \
165 netgear-r6250 netgear-r6300-v2 netgear-r8000 \
166 smartrg-sr400ac
167
168 $(eval $(call AsusDevice,rt-ac56u,RT-AC56U))
169 $(eval $(call AsusDevice,rt-ac68u,RT-AC68U))
170 $(eval $(call AsusDevice,rt-ac87u,RT-AC87U))
171 $(eval $(call AsusDevice,rt-n18u,RT-N18U))
172 $(eval $(call DLinkDevice,dir-885l,wrgac42_dlink.2015_dir885l))
173 $(eval $(call LinksysDevice,ea6300-v1))
174 $(eval $(call NetgearDevice,r7000,U12H270T00_NETGEAR))
175 $(eval $(call NetgearDevice,r7900,U12H315T30_NETGEAR))
176 # $(eval $(call NetgearDevice,r8500,U12H334T00_NETGEAR))
177
178 $(eval $(call BuildImage))