ipq40xx: only include ath10k-board-qca4019 for the generic subtarget
[openwrt/staging/chunkeey.git] / target / linux / bcm47xx / image / Makefile
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # Copyright (C) 2006-2016 OpenWrt.org
4
5 include $(TOPDIR)/rules.mk
6 include $(INCLUDE_DIR)/image.mk
7
8 USB1_PACKAGES := kmod-usb-ohci
9 USB2_PACKAGES := $(USB1_PACKAGES) kmod-usb2
10
11 define Build/Clean
12 $(MAKE) -C lzma-loader clean
13 endef
14
15 define Image/Prepare
16 # Optimized LZMA compression (with dictionary), handled by lzma-loader.
17 cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
18
19 # Less optimal LZMA compression (no dictionary), handled by CFE.
20 $(STAGING_DIR_HOST)/bin/lzma e -so -d16 $(KDIR)/vmlinux > $(KDIR)/vmlinux-nodictionary.lzma
21
22 gzip -nc9 $(KDIR)/vmlinux > $(KDIR)/vmlinux.gz
23 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
24 cat $(KDIR)/vmlinux-initramfs | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux-initramfs.lzma
25 $(STAGING_DIR_HOST)/bin/lzma e -so -d16 $(KDIR)/vmlinux-initramfs > $(KDIR)/vmlinux-initramfs-nodictionary.lzma
26 endif
27 rm -f $(KDIR)/loader.gz
28 $(MAKE) -C lzma-loader \
29 BUILD_DIR="$(KDIR)" \
30 TARGET="$(KDIR)" \
31 clean install
32 echo -ne "\\x00" >> $(KDIR)/loader.gz
33 rm -f $(KDIR)/fs_mark
34 echo -ne '\xde\xad\xc0\xde' > $(KDIR)/fs_mark
35 $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
36 endef
37
38 define trxalign/jffs2-128k
39 -a 0x20000 -f $(KDIR)/root.$(1)
40 endef
41 define trxalign/jffs2-64k
42 -a 0x10000 -f $(KDIR)/root.$(1)
43 endef
44 define trxalign/squashfs
45 -a 1024 -f $(1) $(if $(2),-f $(2)) -a 0x10000 -A $(KDIR)/fs_mark
46 endef
47
48 #################################################
49 # Images
50 #################################################
51
52 define Build/trx-with-loader
53 $(STAGING_DIR_HOST)/bin/trx \
54 -m 33554432 \
55 -o $@.new \
56 -f $(KDIR)/loader.gz \
57 -f $(IMAGE_KERNEL) \
58 $(call trxalign/$(FILESYSTEM),$@)
59 mv $@.new $@
60 endef
61
62 define Build/trx-v2-with-loader
63 $(STAGING_DIR_HOST)/bin/trx \
64 -2 \
65 -m 33554432 \
66 -o $@.new \
67 -f $(KDIR)/loader.gz \
68 -f $(KDIR)/vmlinux.lzma \
69 $(call trxalign/$(FILESYSTEM),$@,$@.pattern)
70 mv $@.new $@
71 endef
72
73 define Build/trx-without-loader
74 $(STAGING_DIR_HOST)/bin/trx \
75 -m 33554432 \
76 -o $@.new \
77 -f $(IMAGE_KERNEL) \
78 $(call trxalign/$(FILESYSTEM),$@)
79 mv $@.new $@
80 endef
81
82 define Build/asus-trx
83 $(STAGING_DIR_HOST)/bin/asustrx -p $(PRODUCTID) -i $@ -o $@.new
84 mv $@.new $@
85 endef
86
87 define Build/edimax-bin
88 $(STAGING_DIR_HOST)/bin/trx2edips $@ $@.new
89 mv $@.new $@
90 endef
91
92 define Build/huawei-bin
93 dd if=/dev/zero of=$@.new bs=92 count=1
94 echo -ne 'HDR0\x08\x00\x00\x00' >> $@.new
95 cat $@ >> $@.new
96 mv $@.new $@
97 endef
98
99 define Build/linksys-bin
100 $(STAGING_DIR_HOST)/bin/addpattern -4 -p $(DEVICE_ID) -v v$(VERSION) $(if $(SERIAL),-s $(SERIAL)) -i $@ -o $@.new
101 mv $@.new $@
102 endef
103
104 define Build/linksys-pattern-partition
105 $(STAGING_DIR_HOST)/bin/addpattern -5 -p $(DEVICE_ID) -v v$(VERSION) $(if $(SERIAL),-s $(SERIAL)) -i /dev/null -o $@.pattern
106 endef
107
108 define Build/motorola-bin
109 $(STAGING_DIR_HOST)/bin/motorola-bin -$(MOTOROLA_DEVICE) $@ $@.new
110 mv $@.new $@
111 endef
112
113 define Build/prepend-with-elf
114 mv $@ $@.old
115 dd if=$(KDIR)/loader.elf of=$@ bs=131072 conv=sync
116 cat $@.old >> $@
117 endef
118
119 define Build/tailed-bin
120 echo $(BIN_TAIL) >> $@
121 endef
122
123 define Build/usrobotics-bin
124 $(STAGING_DIR_HOST)/bin/trx2usr $@ $@.new
125 mv $@.new $@
126 endef
127
128 #################################################
129 # Devices
130 #################################################
131
132 DEVICE_VARS += PRODUCTID
133 DEVICE_VARS += DEVICE_ID VERSION SERIAL
134 DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_REGION
135 DEVICE_VARS += MOTOROLA_DEVICE
136 DEVICE_VARS += BIN_TAIL
137
138 define Device/Default
139 KERNEL := kernel-bin
140 DEVICE_IMG_NAME = $$(DEVICE_IMG_PREFIX)-$$(1).$$(2)
141 KERNEL_NAME = vmlinux.lzma
142 KERNEL_INITRAMFS_NAME = vmlinux-initramfs.lzma
143 FILESYSTEMS := $(FS_64K)
144 IMAGES := trx
145 IMAGE/trx := append-rootfs | trx-with-loader
146 endef
147
148 define Device/standard
149 DEVICE_VENDOR := Generic
150 DEVICE_MODEL := Image with LZMA loader and LZMA compressed kernel
151 endef
152
153 define Device/standard-noloader-gz
154 DEVICE_VENDOR := Generic
155 DEVICE_MODEL := Image with gzipped kernel
156 KERNEL_NAME = vmlinux.gz
157 IMAGE/trx := append-rootfs | trx-without-loader
158 endef
159
160 define Device/standard-noloader-nodictionarylzma
161 DEVICE_VENDOR := Generic
162 DEVICE_MODEL := Image with LZMA compressed kernel matching CFE decompressor
163 KERNEL_NAME = vmlinux-nodictionary.lzma
164 IMAGE/trx := append-rootfs | trx-without-loader
165 endef
166
167 define Device/asus
168 DEVICE_VENDOR := ASUS
169 IMAGES := trx
170 IMAGE/trx := append-rootfs | trx-with-loader | asus-trx
171 endef
172
173 define Device/linksys
174 DEVICE_VENDOR := Linksys
175 IMAGES := bin
176 IMAGE/bin := append-rootfs | trx-with-loader | linksys-bin
177 endef
178
179 define Device/motorola
180 DEVICE_VENDOR := Motorola
181 IMAGES := bin
182 IMAGE/bin := append-rootfs | trx-with-loader | motorola-bin
183 endef
184
185 define Device/netgear
186 DEVICE_VENDOR := NETGEAR
187 IMAGES := chk
188 IMAGE/chk := append-rootfs | trx-with-loader | netgear-chk
189 endef
190
191 #################################################
192 # Subtarget devices
193 #################################################
194
195 include $(SUBTARGET).mk
196
197 #################################################
198 # Shared BuildImage defines
199 #################################################
200
201 define Image/Build/Initramfs
202 $(STAGING_DIR_HOST)/bin/trx \
203 -m 33554432 \
204 -o $(BIN_DIR)/$(IMG_PREFIX)-initramfs.trx \
205 -f $(KDIR)/loader.gz \
206 -f $(KDIR)/vmlinux-initramfs.lzma
207 $(STAGING_DIR_HOST)/bin/trx \
208 -m 33554432 \
209 -o $(BIN_DIR)/$(IMG_PREFIX)-initramfs-noloader-nodictionary.trx \
210 -f $(KDIR)/vmlinux-initramfs-nodictionary.lzma
211 endef
212
213 # $(1): filesystem type.
214 define Image/Build
215 # TODO: Move it to Device/*
216 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
217 $(call Image/Build/Initramfs)
218 endif
219 endef
220
221 $(eval $(call BuildImage))