1 # Build commands that can be called from Device/* templates
3 IMAGE_KERNEL
= $(word 1,$^
)
4 IMAGE_ROOTFS
= $(word 2,$^
)
7 mkimage
-A
$(LINUX_KARCH
) \
9 -C
$(1) -a
$(KERNEL_LOADADDR
) -e
$(if
$(KERNEL_ENTRY
),$(KERNEL_ENTRY
),$(KERNEL_LOADADDR
)) \
10 -n
'$(if $(UIMAGE_NAME),$(UIMAGE_NAME),$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION))' -d
$@
$@.new
14 define Build
/buffalo-enc
15 $(eval product
=$(word 1,$(1)))
16 $(eval version
=$(word 2,$(1)))
17 $(eval args
=$(wordlist
3,$(words $(1)),$(1)))
18 $(STAGING_DIR_HOST
)/bin
/buffalo-enc \
19 -p
$(product
) -v
$(version
) $(args
) \
24 define Build
/buffalo-enc-tag
25 $(call Build
/buffalo-enc
,'' '' -S
152 $(1))
28 define Build
/buffalo-tag-dhp
29 $(eval product
=$(word 1,$(1)))
30 $(eval region
=$(word 2,$(1)))
31 $(eval language
=$(word 3,$(1)))
32 $(STAGING_DIR_HOST
)/bin
/buffalo-tag \
34 -a
$(BUFFALO_TAG_PLATFORM
) \
35 -v
$(BUFFALO_TAG_VERSION
) -m
$(BUFFALO_TAG_MINOR
) \
36 -b
$(product
) -p
$(product
) \
37 -r
$(region
) -r
$(region
) -l
$(language
) \
42 define Build
/buffalo-dhp-image
43 $(STAGING_DIR_HOST
)/bin
/mkdhpimg
$@
$@.new
47 define Build
/eva-image
48 $(STAGING_DIR_HOST
)/bin
/lzma2eva
$(KERNEL_LOADADDR
) $(KERNEL_LOADADDR
) $@
$@.new
53 $(STAGING_DIR_HOST
)/bin
/seama
-i
$@ \
54 -m
"dev=/dev/mtdblock/$(SEAMA_MTDBLOCK)" -m
"type=firmware"
58 define Build
/seama-seal
59 $(STAGING_DIR_HOST
)/bin
/seama
-i
$@
-s
$@.seama \
60 -m
"signature=$(SEAMA_SIGNATURE)"
64 define Build
/zyxel-ras-image
66 newsize
="$(subst k,* 1024,$(RAS_ROOTFS_SIZE))"; \
67 $(STAGING_DIR_HOST
)/bin
/mkrasimage \
73 $(if
$(findstring separate-kernel
,$(word 1,$(1))),-k
$(IMAGE_KERNEL
)) \
77 define Build
/netgear-chk
78 $(STAGING_DIR_HOST
)/bin
/mkchkimg \
81 -b
$(NETGEAR_BOARD_ID
) \
82 $(if
$(NETGEAR_REGION
),-r
$(NETGEAR_REGION
),)
86 define Build
/netgear-dni
87 $(STAGING_DIR_HOST
)/bin
/mkdniimg \
88 -B
$(NETGEAR_BOARD_ID
) -v
$(VERSION_DIST
).
$(firstword $(subst -, ,$(REVISION
))) \
89 $(if
$(NETGEAR_HW_ID
),-H
$(NETGEAR_HW_ID
)) \
95 define Build
/append-squashfs-fakeroot-be
96 rm -rf
$@.fakefs
$@.fakesquashfs
98 $(STAGING_DIR_HOST
)/bin
/mksquashfs-lzma \
99 $@.fakefs
$@.fakesquashfs \
100 -noappend
-root-owned
-be
-nopad
-b
65536 \
101 $(if
$(SOURCE_DATE_EPOCH
),-fixed-time
$(SOURCE_DATE_EPOCH
))
102 cat
$@.fakesquashfs
>> $@
105 define Build
/append-string
109 # append a fake/empty uImage header, to fool bootloaders rootfs integrity check
111 define Build
/append-uImage-fakehdr
113 $(STAGING_DIR_HOST
)/bin
/mkimage \
114 -A
$(LINUX_KARCH
) -O linux
-T
$(1) -C none \
115 -n
'$(VERSION_DIST) fake $(1)' \
122 define Build
/tplink-safeloader
123 -$(STAGING_DIR_HOST
)/bin
/tplink-safeloader \
124 -B
$(TPLINK_BOARD_ID
) \
130 $(wordlist
2,$(words $(1)),$(1)) \
131 $(if
$(findstring sysupgrade
,$(word 1,$(1))),-S
) && mv
$@.new
$@ ||
rm -f
$@
134 define Build
/append-dtb
135 cat
$(KDIR
)/image-
$(firstword $(DEVICE_DTS
)).dtb
>> $@
138 define Build
/install-dtb
139 $(foreach dts
,$(DEVICE_DTS
), \
141 $(DTS_DIR
)/$(dts
).dtb \
142 $(BIN_DIR
)/$(IMG_PREFIX
)-$(dts
).dtb
; \
147 $(TOPDIR
)/scripts
/mkits.sh \
148 -D
$(DEVICE_NAME
) -o
$@.its
-k
$@ \
149 $(if
$(word 2,$(1)),-d
$(word 2,$(1))) -C
$(word 1,$(1)) \
150 -a
$(KERNEL_LOADADDR
) -e
$(if
$(KERNEL_ENTRY
),$(KERNEL_ENTRY
),$(KERNEL_LOADADDR
)) \
151 -c
$(if
$(DEVICE_DTS_CONFIG
),$(DEVICE_DTS_CONFIG
),"config@1") \
152 -A
$(LINUX_KARCH
) -v
$(LINUX_VERSION
)
153 PATH
=$(LINUX_DIR
)/scripts
/dtc
:$(PATH
) mkimage
-f
$@.its
$@.new
158 $(call Build
/lzma-no-dict
,-lc1
-lp2
-pb2
$(1))
161 define Build
/lzma-no-dict
162 $(STAGING_DIR_HOST
)/bin
/lzma e
$@
$(1) $@.new
167 gzip
-f
-9n
-c
$@
$(1) > $@.new
176 $(if
$(SOURCE_DATE_EPOCH
),--mtime
="$(SOURCE_DATE_EPOCH)") \
177 $@
$@.tmp
/$(if
$(1),$(1),$@
)
182 rm -rf
$(KDIR_TMP
)/$(DEVICE_NAME
)/jffs2
&& \
183 mkdir
-p
$(KDIR_TMP
)/$(DEVICE_NAME
)/jffs2
/$$(dirname
$(1)) && \
184 cp
$@
$(KDIR_TMP
)/$(DEVICE_NAME
)/jffs2
/$(1) && \
185 $(STAGING_DIR_HOST
)/bin
/mkfs.jffs2
--pad \
186 $(if
$(CONFIG_BIG_ENDIAN
),--big-endian
,--little-endian
) \
187 --squash-uids
-v
-e
$(patsubst %k
,%KiB
,$(BLOCKSIZE
)) \
189 -d
$(KDIR_TMP
)/$(DEVICE_NAME
)/jffs2 \
190 2>&1 1>/dev
/null | awk
'/^.+$$$$/' && \
191 $(STAGING_DIR_HOST
)/bin
/padjffs2
$@.new
-J
$(patsubst %k
,,$(BLOCKSIZE
))
192 -rm -rf
$(KDIR_TMP
)/$(DEVICE_NAME
)/jffs2
/
196 define Build
/kernel-bin
201 define Build
/patch-cmdline
202 $(STAGING_DIR_HOST
)/bin
/patch-cmdline
$@
'$(CMDLINE)'
205 define Build
/append-kernel
206 dd if
=$(IMAGE_KERNEL
) >> $@
209 define Build
/append-rootfs
210 dd if
=$(IMAGE_ROOTFS
) >> $@
213 define Build
/append-ubi
214 sh
$(TOPDIR
)/scripts
/ubinize-image.sh \
215 $(if
$(UBOOTENV_IN_UBI
),--uboot-env
) \
216 $(if
$(KERNEL_IN_UBI
),--kernel
$(IMAGE_KERNEL
)) \
217 $(foreach part
,$(UBINIZE_PARTS
),--part
$(part
)) \
220 -p
$(BLOCKSIZE
:%k
=%KiB
) -m
$(PAGESIZE
) \
221 $(if
$(SUBPAGESIZE
),-s
$(SUBPAGESIZE
)) \
222 $(if
$(VID_HDR_OFFSET
),-O
$(VID_HDR_OFFSET
)) \
228 define Build
/append-uboot
229 dd if
=$(UBOOT_PATH
) >> $@
233 dd if
=$@ of
=$@.new bs
=$(1) conv
=sync
237 define Build
/pad-extra
238 dd if
=/dev
/zero bs
=$(1) count
=1 >> $@
241 define Build
/pad-rootfs
242 $(STAGING_DIR_HOST
)/bin
/padjffs2
$@
$(1) \
243 $(if
$(BLOCKSIZE
),$(BLOCKSIZE
:%k
=%),4 8 16 64 128 256)
246 define Build
/pad-offset
248 size
="$$(stat -c%s $@)" \
249 pad
="$(subst k,* 1024,$(word 1, $(1)))" \
250 offset
="$(subst k,* 1024,$(word 2, $(1)))" \
251 pad
="(pad - ((size + offset) % pad)) % pad" \
252 newsize
='size + pad'; \
253 dd if
=$@ of
=$@.new bs
=$$newsize count
=1 conv
=sync
257 define Build
/xor-image
258 $(STAGING_DIR_HOST
)/bin
/xorimage
-i
$@
-o
$@.xor
$(1)
262 define Build
/check-size
263 @
[ $$(($(subst k
,* 1024,$(subst m
, * 1024k
,$(1))))) -ge
"$$(stat -c%s $@)" ] ||
{ \
264 echo
"WARNING: Image file $@ is too big" >&2; \
269 define Build
/combined-image
270 -sh
$(TOPDIR
)/scripts
/combined-image.sh \
277 define Build
/linksys-image
278 $(TOPDIR
)/scripts
/linksys-image.sh \
279 "$(call param_get_default,type,$(1),$(DEVICE_NAME))" \
284 define Build
/openmesh-image
285 $(TOPDIR
)/scripts
/om-fwupgradecfg-gen.sh \
286 "$(call param_get_default,ce_type,$(1),$(DEVICE_NAME))" \
288 "$(call param_get_default,kernel,$(1),$(IMAGE_KERNEL))" \
289 "$(call param_get_default,rootfs,$(1),$@)"
290 $(TOPDIR
)/scripts
/combined-ext-image.sh \
291 "$(call param_get_default,ce_type,$(1),$(DEVICE_NAME))" "$@" \
292 "$@-fwupgrade.cfg" "fwupgrade.cfg" \
293 "$(call param_get_default,kernel,$(1),$(IMAGE_KERNEL))" "kernel" \
294 "$(call param_get_default,rootfs,$(1),$@)" "rootfs"
297 define Build
/qsdk-ipq-factory-nand
298 $(TOPDIR
)/scripts
/mkits-qsdk-ipq-image.sh \
300 PATH
=$(LINUX_DIR
)/scripts
/dtc
:$(PATH
) mkimage
-f
$@.its
$@.new
304 define Build
/qsdk-ipq-factory-nor
305 $(TOPDIR
)/scripts
/mkits-qsdk-ipq-image.sh \
306 $@.its hlos
$(IMAGE_KERNEL
) rootfs
$(IMAGE_ROOTFS
)
307 PATH
=$(LINUX_DIR
)/scripts
/dtc
:$(PATH
) mkimage
-f
$@.its
$@.new
311 define Build
/senao-header
312 $(STAGING_DIR_HOST
)/bin
/mksenaofw
$(1) -e
$@
-o
$@.new
316 define Build
/sysupgrade-tar
317 sh
$(TOPDIR
)/scripts
/sysupgrade-tar.sh \
318 --board
$(if
$(BOARD_NAME
),$(BOARD_NAME
),$(DEVICE_NAME
)) \
319 --kernel
$(call param_get_default
,kernel
,$(1),$(IMAGE_KERNEL
)) \
320 --rootfs
$(call param_get_default
,rootfs
,$(1),$(IMAGE_ROOTFS
)) \
324 define Build
/tplink-v1-header
325 $(STAGING_DIR_HOST
)/bin
/mktplinkfw \
326 -c
-H
$(TPLINK_HWID
) -W
$(TPLINK_HWREV
) -L
$(KERNEL_LOADADDR
) \
327 -E
$(if
$(KERNEL_ENTRY
),$(KERNEL_ENTRY
),$(KERNEL_LOADADDR
)) \
328 -m
$(TPLINK_HEADER_VERSION
) -N
"$(VERSION_DIST)" -V
$(REVISION
) \
333 define Build
/tplink-v2-header
334 $(STAGING_DIR_HOST
)/bin
/mktplinkfw2 \
335 -c
-H
$(TPLINK_HWID
) -W
$(TPLINK_HWREV
) -L
$(KERNEL_LOADADDR
) \
336 -E
$(if
$(KERNEL_ENTRY
),$(KERNEL_ENTRY
),$(KERNEL_LOADADDR
)) \
337 -w
$(TPLINK_HWREVADD
) -F
"$(TPLINK_FLASHLAYOUT)" \
338 -T
$(TPLINK_HVERSION
) -V
"ver. 2.0" \
343 define Build
/tplink-v2-image
344 $(STAGING_DIR_HOST
)/bin
/mktplinkfw2 \
345 -H
$(TPLINK_HWID
) -W
$(TPLINK_HWREV
) \
346 -w
$(TPLINK_HWREVADD
) -F
"$(TPLINK_FLASHLAYOUT)" \
347 -T
$(TPLINK_HVERSION
) -V
"ver. 2.0" -a
0x4 -j \
348 -k
$(IMAGE_KERNEL
) -r
$(IMAGE_ROOTFS
) -o
$@.new
$(1)
353 json_quote
=$(subst ','\'',$(subst ",\",$(1)))
355 metadata_devices
=$(if
$(1),$(subst "$(space)","$(comma)",$(strip $(foreach v
,$(1),"$(call json_quote,$(v))"))))
357 '{ $(if $(IMAGE_METADATA),$(IMAGE_METADATA)$(comma)) \
358 "supported_devices":[$(call metadata_devices,$(1))], \
360 "dist": "$(call json_quote,$(VERSION_DIST))", \
361 "version": "$(call json_quote,$(VERSION_NUMBER))", \
362 "revision": "$(call json_quote,$(REVISION))", \
363 "board": "$(call json_quote,$(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)))" \
367 define Build
/append-metadata
368 $(if
$(SUPPORTED_DEVICES
),-echo
$(call metadata_json
,$(SUPPORTED_DEVICES
)) | fwtool
-I
- $@
)
369 [ ! -s
"$(BUILD_KEY)" -o
! -s
"$(BUILD_KEY).ucert" -o
! -s
"$@" ] ||
{ \
370 cp
"$(BUILD_KEY).ucert" "$@.ucert" ;\
371 usign
-S
-m
"$@" -s
"$(BUILD_KEY)" -x
"$@.sig" ;\
372 ucert
-A
-c
"$@.ucert" -x
"$@.sig" ;\
373 fwtool
-S
"$@.ucert" "$@" ;\
377 define Build
/kernel2minor
378 kernel2minor
-k
$@
-r
$@.new
$(1)