image: fix append-image when building multiple profiles
[openwrt/openwrt.git] / include / image-commands.mk
1 # Build commands that can be called from Device/* templates
2
3 IMAGE_KERNEL = $(word 1,$^)
4 IMAGE_ROOTFS = $(word 2,$^)
5
6 define ModelNameLimit16
7 $(shell expr substr "$(word 2, $(subst _, ,$(1)))" 1 16)
8 endef
9
10 define rootfs_align
11 $(patsubst %-256k,0x40000,$(patsubst %-128k,0x20000,$(patsubst %-64k,0x10000,$(patsubst squashfs%,0x4,$(patsubst root.%,%,$(1))))))
12 endef
13
14
15 define Build/append-dtb
16 cat $(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb >> $@
17 endef
18
19 define Build/append-dtb-elf
20 $(TARGET_CROSS)objcopy \
21 --set-section-flags=.appended_dtb=alloc,contents \
22 --update-section \
23 .appended_dtb=$(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb $@
24 endef
25
26 define Build/append-kernel
27 dd if=$(IMAGE_KERNEL) >> $@
28 endef
29
30 define Build/append-image
31 dd if=$(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(1) >> $@
32 endef
33
34 compat_version=$(if $(DEVICE_COMPAT_VERSION),$(DEVICE_COMPAT_VERSION),1.0)
35 json_quote=$(subst ','\'',$(subst ",\",$(1)))
36 #")')
37
38 legacy_supported_message=$(SUPPORTED_DEVICES) - Image version mismatch: image $(compat_version), \
39 device 1.0. Please wipe config during upgrade (force required) or reinstall. \
40 $(if $(DEVICE_COMPAT_MESSAGE),Reason: $(DEVICE_COMPAT_MESSAGE),Please check documentation ...)
41
42 metadata_devices=$(if $(1),$(subst "$(space)","$(comma)",$(strip $(foreach v,$(1),"$(call json_quote,$(v))"))))
43 metadata_json = \
44 '{ $(if $(IMAGE_METADATA),$(IMAGE_METADATA)$(comma)) \
45 "metadata_version": "1.1", \
46 "compat_version": "$(call json_quote,$(compat_version))", \
47 $(if $(DEVICE_COMPAT_MESSAGE),"compat_message": "$(call json_quote,$(DEVICE_COMPAT_MESSAGE))"$(comma)) \
48 $(if $(filter-out 1.0,$(compat_version)),"new_supported_devices": \
49 [$(call metadata_devices,$(SUPPORTED_DEVICES))]$(comma) \
50 "supported_devices": ["$(call json_quote,$(legacy_supported_message))"]$(comma)) \
51 $(if $(filter 1.0,$(compat_version)),"supported_devices":[$(call metadata_devices,$(SUPPORTED_DEVICES))]$(comma)) \
52 "version": { \
53 "dist": "$(call json_quote,$(VERSION_DIST))", \
54 "version": "$(call json_quote,$(VERSION_NUMBER))", \
55 "revision": "$(call json_quote,$(REVISION))", \
56 "target": "$(call json_quote,$(TARGETID))", \
57 "board": "$(call json_quote,$(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)))" \
58 } \
59 }'
60
61 define Build/append-metadata
62 $(if $(SUPPORTED_DEVICES),-echo $(call metadata_json) | fwtool -I - $@)
63 [ ! -s "$(BUILD_KEY)" -o ! -s "$(BUILD_KEY).ucert" -o ! -s "$@" ] || { \
64 cp "$(BUILD_KEY).ucert" "$@.ucert" ;\
65 usign -S -m "$@" -s "$(BUILD_KEY)" -x "$@.sig" ;\
66 ucert -A -c "$@.ucert" -x "$@.sig" ;\
67 fwtool -S "$@.ucert" "$@" ;\
68 }
69 endef
70
71 define Build/append-rootfs
72 dd if=$(IMAGE_ROOTFS) >> $@
73 endef
74
75 define Build/append-squashfs-fakeroot-be
76 rm -rf $@.fakefs $@.fakesquashfs
77 mkdir $@.fakefs
78 $(STAGING_DIR_HOST)/bin/mksquashfs-lzma \
79 $@.fakefs $@.fakesquashfs \
80 -noappend -root-owned -be -nopad -b 65536 \
81 $(if $(SOURCE_DATE_EPOCH),-fixed-time $(SOURCE_DATE_EPOCH))
82 cat $@.fakesquashfs >> $@
83 endef
84
85 define Build/append-string
86 echo -n $(1) >> $@
87 endef
88
89 define Build/append-ubi
90 sh $(TOPDIR)/scripts/ubinize-image.sh \
91 $(if $(UBOOTENV_IN_UBI),--uboot-env) \
92 $(if $(KERNEL_IN_UBI),--kernel $(IMAGE_KERNEL)) \
93 $(foreach part,$(UBINIZE_PARTS),--part $(part)) \
94 $(IMAGE_ROOTFS) \
95 $@.tmp \
96 -p $(BLOCKSIZE:%k=%KiB) -m $(PAGESIZE) \
97 $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \
98 $(if $(VID_HDR_OFFSET),-O $(VID_HDR_OFFSET)) \
99 $(UBINIZE_OPTS)
100 cat $@.tmp >> $@
101 rm $@.tmp
102 endef
103
104 define Build/append-uboot
105 dd if=$(UBOOT_PATH) >> $@
106 endef
107
108 # append a fake/empty uImage header, to fool bootloaders rootfs integrity check
109 # for example
110 define Build/append-uImage-fakehdr
111 $(eval type=$(word 1,$(1)))
112 $(eval magic=$(word 2,$(1)))
113 touch $@.fakehdr
114 $(STAGING_DIR_HOST)/bin/mkimage \
115 -A $(LINUX_KARCH) -O linux -T $(type) -C none \
116 -n '$(VERSION_DIST) fake $(type)' \
117 $(if $(magic),-M $(magic)) \
118 -d $@.fakehdr \
119 -s \
120 $@.fakehdr
121 cat $@.fakehdr >> $@
122 endef
123
124 define Build/buffalo-dhp-image
125 $(STAGING_DIR_HOST)/bin/mkdhpimg $@ $@.new
126 mv $@.new $@
127 endef
128
129 define Build/buffalo-enc
130 $(eval product=$(word 1,$(1)))
131 $(eval version=$(word 2,$(1)))
132 $(eval args=$(wordlist 3,$(words $(1)),$(1)))
133 $(STAGING_DIR_HOST)/bin/buffalo-enc \
134 -p $(product) -v $(version) $(args) \
135 -i $@ -o $@.new
136 mv $@.new $@
137 endef
138
139 define Build/buffalo-enc-tag
140 $(call Build/buffalo-enc,'' '' -S 152 $(1))
141 endef
142
143 define Build/buffalo-tag-dhp
144 $(eval product=$(word 1,$(1)))
145 $(eval region=$(word 2,$(1)))
146 $(eval language=$(word 3,$(1)))
147 $(STAGING_DIR_HOST)/bin/buffalo-tag \
148 -d 0x01000000 -w 1 \
149 -a $(BUFFALO_TAG_PLATFORM) \
150 -v $(BUFFALO_TAG_VERSION) -m $(BUFFALO_TAG_MINOR) \
151 -b $(product) -p $(product) \
152 -r $(region) -r $(region) -l $(language) \
153 -I $@ -o $@.new
154 mv $@.new $@
155 endef
156
157 define Build/check-size
158 @imagesize="$$(stat -c%s $@)"; \
159 limitsize="$$(($(subst k,* 1024,$(subst m, * 1024k,$(if $(1),$(1),$(IMAGE_SIZE))))))"; \
160 [ $$limitsize -ge $$imagesize ] || { \
161 echo "WARNING: Image file $@ is too big: $$imagesize > $$limitsize" >&2; \
162 rm -f $@; \
163 }
164 endef
165
166 define Build/elecom-product-header
167 $(eval product=$(word 1,$(1)))
168 $(eval fw=$(if $(word 2,$(1)),$(word 2,$(1)),$@))
169
170 ( \
171 echo -n -e "ELECOM\x00\x00$(product)" | dd bs=40 count=1 conv=sync; \
172 echo -n "0.00" | dd bs=16 count=1 conv=sync; \
173 dd if=$(fw); \
174 ) > $(fw).new
175 mv $(fw).new $(fw)
176 endef
177
178 define Build/elx-header
179 $(eval hw_id=$(word 1,$(1)))
180 $(eval xor_pattern=$(word 2,$(1)))
181 ( \
182 echo -ne "\x00\x00\x00\x00\x00\x00\x00\x03" | \
183 dd bs=42 count=1 conv=sync; \
184 hw_id="$(hw_id)"; \
185 echo -ne "\x$${hw_id:0:2}\x$${hw_id:2:2}\x$${hw_id:4:2}\x$${hw_id:6:2}" | \
186 dd bs=20 count=1 conv=sync; \
187 echo -ne "$$(printf '%08x' $$(stat -c%s $@) | fold -s2 | xargs -I {} echo \\x{} | tr -d '\n')" | \
188 dd bs=8 count=1 conv=sync; \
189 echo -ne "$$($(STAGING_DIR_HOST)/bin/mkhash md5 $@ | fold -s2 | xargs -I {} echo \\x{} | tr -d '\n')" | \
190 dd bs=58 count=1 conv=sync; \
191 ) > $(KDIR)/tmp/$(DEVICE_NAME).header
192 $(call Build/xor-image,-p $(xor_pattern) -x)
193 cat $(KDIR)/tmp/$(DEVICE_NAME).header $@ > $@.new
194 mv $@.new $@
195 rm -rf $(KDIR)/tmp/$(DEVICE_NAME).header
196 endef
197
198 define Build/eva-image
199 $(STAGING_DIR_HOST)/bin/lzma2eva $(KERNEL_LOADADDR) $(KERNEL_LOADADDR) $@ $@.new
200 mv $@.new $@
201 endef
202
203 define Build/initrd_compression
204 $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_BZIP2),.bzip2) \
205 $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_GZIP),.gzip) \
206 $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZMA),.lzma) \
207 $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_XZ),.xz) \
208 $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_ZSTD),.zstd)
209 endef
210
211 define Build/fit
212 $(TOPDIR)/scripts/mkits.sh \
213 -D $(DEVICE_NAME) -o $@.its -k $@ \
214 -C $(word 1,$(1)) $(if $(word 2,$(1)),\
215 $(if $(DEVICE_DTS_OVERLAY),-d $(KERNEL_BUILD_DIR)/image-$$(basename $(word 2,$(1))),\
216 -d $(word 2,$(1)))) \
217 $(if $(findstring with-rootfs,$(word 3,$(1))),-r $(IMAGE_ROOTFS)) \
218 $(if $(findstring with-initrd,$(word 3,$(1))), \
219 $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS_SEPARATE), \
220 -i $(KERNEL_BUILD_DIR)/initrd.cpio$(strip $(call Build/initrd_compression)))) \
221 -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
222 $(if $(DEVICE_FDT_NUM),-n $(DEVICE_FDT_NUM)) \
223 $(if $(DEVICE_DTS_OVERLAY),$(foreach dtso,$(DEVICE_DTS_OVERLAY), -O $(dtso):$(KERNEL_BUILD_DIR)/image-$(dtso).dtb)) \
224 -c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config-1") \
225 -A $(LINUX_KARCH) -v $(LINUX_VERSION)
226 PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage $(if $(findstring external,$(word 3,$(1))),\
227 -E -B 0x1000 $(if $(findstring static,$(word 3,$(1))),-p 0x1000)) -f $@.its $@.new
228 @mv $@.new $@
229 endef
230
231 define Build/gzip
232 gzip -f -9n -c $@ $(1) > $@.new
233 @mv $@.new $@
234 endef
235
236 define Build/install-dtb
237 $(call locked, \
238 $(foreach dts,$(DEVICE_DTS), \
239 $(CP) \
240 $(DTS_DIR)/$(dts).dtb \
241 $(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb; \
242 ), \
243 install-dtb-$(IMG_PREFIX) \
244 )
245 endef
246
247 define Build/jffs2
248 rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 && \
249 mkdir -p $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$$(dirname $(1)) && \
250 cp $@ $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$(1) && \
251 $(STAGING_DIR_HOST)/bin/mkfs.jffs2 --pad \
252 $(if $(CONFIG_BIG_ENDIAN),--big-endian,--little-endian) \
253 --squash-uids -v -e $(patsubst %k,%KiB,$(BLOCKSIZE)) \
254 -o $@.new \
255 -d $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 \
256 2>&1 1>/dev/null | awk '/^.+$$$$/' && \
257 $(STAGING_DIR_HOST)/bin/padjffs2 $@.new -J $(patsubst %k,,$(BLOCKSIZE))
258 -rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/
259 @mv $@.new $@
260 endef
261
262 define Build/kernel2minor
263 kernel2minor -k $@ -r $@.new $(1)
264 mv $@.new $@
265 endef
266
267 define Build/kernel-bin
268 rm -f $@
269 cp $< $@
270 endef
271
272 define Build/linksys-image
273 $(TOPDIR)/scripts/linksys-image.sh \
274 "$(call param_get_default,type,$(1),$(DEVICE_NAME))" \
275 $@ $@.new
276 mv $@.new $@
277 endef
278
279 define Build/lzma
280 $(call Build/lzma-no-dict,-lc1 -lp2 -pb2 $(1))
281 endef
282
283 define Build/lzma-no-dict
284 $(STAGING_DIR_HOST)/bin/lzma e $@ $(1) $@.new
285 @mv $@.new $@
286 endef
287
288 define Build/netgear-chk
289 $(STAGING_DIR_HOST)/bin/mkchkimg \
290 -o $@.new \
291 -k $@ \
292 -b $(NETGEAR_BOARD_ID) \
293 $(if $(NETGEAR_REGION),-r $(NETGEAR_REGION),)
294 mv $@.new $@
295 endef
296
297 define Build/netgear-dni
298 $(STAGING_DIR_HOST)/bin/mkdniimg \
299 -B $(NETGEAR_BOARD_ID) -v $(VERSION_DIST).$(firstword $(subst -, ,$(REVISION))) \
300 $(if $(NETGEAR_HW_ID),-H $(NETGEAR_HW_ID)) \
301 -r "$(1)" \
302 -i $@ -o $@.new
303 mv $@.new $@
304 endef
305
306 define Build/openmesh-image
307 $(TOPDIR)/scripts/om-fwupgradecfg-gen.sh \
308 "$(call param_get_default,ce_type,$(1),$(DEVICE_NAME))" \
309 "$@-fwupgrade.cfg" \
310 "$(call param_get_default,kernel,$(1),$(IMAGE_KERNEL))" \
311 "$(call param_get_default,rootfs,$(1),$@)"
312 $(TOPDIR)/scripts/combined-ext-image.sh \
313 "$(call param_get_default,ce_type,$(1),$(DEVICE_NAME))" "$@" \
314 "$@-fwupgrade.cfg" "fwupgrade.cfg" \
315 "$(call param_get_default,kernel,$(1),$(IMAGE_KERNEL))" "kernel" \
316 "$(call param_get_default,rootfs,$(1),$@)" "rootfs"
317 endef
318
319 define Build/pad-extra
320 dd if=/dev/zero bs=$(1) count=1 >> $@
321 endef
322
323 define Build/pad-offset
324 let \
325 size="$$(stat -c%s $@)" \
326 pad="$(subst k,* 1024,$(word 1, $(1)))" \
327 offset="$(subst k,* 1024,$(word 2, $(1)))" \
328 pad="(pad - ((size + offset) % pad)) % pad" \
329 newsize='size + pad'; \
330 dd if=$@ of=$@.new bs=$$newsize count=1 conv=sync
331 mv $@.new $@
332 endef
333
334 define Build/pad-rootfs
335 $(STAGING_DIR_HOST)/bin/padjffs2 $@ $(1) \
336 $(if $(BLOCKSIZE),$(BLOCKSIZE:%k=%),4 8 16 64 128 256)
337 endef
338
339 define Build/pad-to
340 $(call Image/pad-to,$@,$(1))
341 endef
342
343 define Build/patch-cmdline
344 $(STAGING_DIR_HOST)/bin/patch-cmdline $@ '$(CMDLINE)'
345 endef
346
347 # Convert a raw image into a $1 type image.
348 # E.g. | qemu-image vdi
349 define Build/qemu-image
350 if command -v qemu-img; then \
351 qemu-img convert -f raw -O $1 $@ $@.new; \
352 mv $@.new $@; \
353 else \
354 echo "WARNING: Install qemu-img to create VDI/VMDK images" >&2; exit 1; \
355 fi
356 endef
357
358 define Build/qsdk-ipq-factory-nand
359 $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \
360 $@.its ubi $@
361 PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
362 @mv $@.new $@
363 endef
364
365 define Build/qsdk-ipq-factory-nor
366 $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \
367 $@.its hlos $(IMAGE_KERNEL) rootfs $(IMAGE_ROOTFS)
368 PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
369 @mv $@.new $@
370 endef
371
372 define Build/seama
373 $(STAGING_DIR_HOST)/bin/seama -i $@ \
374 -m "dev=/dev/mtdblock/$(SEAMA_MTDBLOCK)" -m "type=firmware"
375 mv $@.seama $@
376 endef
377
378 define Build/seama-seal
379 $(STAGING_DIR_HOST)/bin/seama -i $@ -s $@.seama \
380 -m "signature=$(SEAMA_SIGNATURE)"
381 mv $@.seama $@
382 endef
383
384 define Build/senao-header
385 $(STAGING_DIR_HOST)/bin/mksenaofw $(1) -e $@ -o $@.new
386 mv $@.new $@
387 endef
388
389 define Build/sysupgrade-tar
390 sh $(TOPDIR)/scripts/sysupgrade-tar.sh \
391 --board $(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)) \
392 --kernel $(call param_get_default,kernel,$(1),$(IMAGE_KERNEL)) \
393 --rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \
394 $@
395 endef
396
397 define Build/tplink-safeloader
398 -$(STAGING_DIR_HOST)/bin/tplink-safeloader \
399 -B $(TPLINK_BOARD_ID) \
400 -V $(REVISION) \
401 -k $(IMAGE_KERNEL) \
402 -r $@ \
403 -o $@.new \
404 -j \
405 $(wordlist 2,$(words $(1)),$(1)) \
406 $(if $(findstring sysupgrade,$(word 1,$(1))),-S) && mv $@.new $@ || rm -f $@
407 endef
408
409 define Build/tplink-v1-header
410 $(STAGING_DIR_HOST)/bin/mktplinkfw \
411 -c -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -L $(KERNEL_LOADADDR) \
412 -E $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
413 -m $(TPLINK_HEADER_VERSION) -N "$(VERSION_DIST)" -V $(REVISION) \
414 -k $@ -o $@.new $(1)
415 @mv $@.new $@
416 endef
417
418 # combine kernel and rootfs into one image
419 # mktplinkfw <type> <optional extra arguments to mktplinkfw binary>
420 # <type> is "sysupgrade" or "factory"
421 #
422 # -a align the rootfs start on an <align> bytes boundary
423 # -j add jffs2 end-of-filesystem markers
424 # -s strip padding from end of the image
425 # -X reserve <size> bytes in the firmware image (hexval prefixed with 0x)
426 define Build/tplink-v1-image
427 -$(STAGING_DIR_HOST)/bin/mktplinkfw \
428 -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) \
429 -N "$(VERSION_DIST)" -V $(REVISION) -m $(TPLINK_HEADER_VERSION) \
430 -k $(IMAGE_KERNEL) -r $(IMAGE_ROOTFS) -o $@.new -j -X 0x40000 \
431 -a $(call rootfs_align,$(FILESYSTEM)) \
432 $(wordlist 2,$(words $(1)),$(1)) \
433 $(if $(findstring sysupgrade,$(word 1,$(1))),-s) && mv $@.new $@ || rm -f $@
434 endef
435
436 define Build/tplink-v2-header
437 $(STAGING_DIR_HOST)/bin/mktplinkfw2 \
438 -c -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -L $(KERNEL_LOADADDR) \
439 -E $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
440 -w $(TPLINK_HWREVADD) -F "$(TPLINK_FLASHLAYOUT)" \
441 -T $(TPLINK_HVERSION) -V "ver. 2.0" \
442 -k $@ -o $@.new $(1)
443 @mv $@.new $@
444 endef
445
446 define Build/tplink-v2-image
447 $(STAGING_DIR_HOST)/bin/mktplinkfw2 \
448 -H $(TPLINK_HWID) -W $(TPLINK_HWREV) \
449 -w $(TPLINK_HWREVADD) -F "$(TPLINK_FLASHLAYOUT)" \
450 -T $(TPLINK_HVERSION) -V "ver. 2.0" -a 0x4 -j \
451 -k $(IMAGE_KERNEL) -r $(IMAGE_ROOTFS) -o $@.new $(1)
452 cat $@.new >> $@
453 rm -rf $@.new
454 endef
455
456 define Build/uImage
457 mkimage \
458 -A $(LINUX_KARCH) \
459 -O linux \
460 -T kernel \
461 -C $(word 1,$(1)) \
462 -a $(KERNEL_LOADADDR) \
463 -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
464 -n '$(if $(UIMAGE_NAME),$(UIMAGE_NAME),$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION))' \
465 $(if $(UIMAGE_MAGIC),-M $(UIMAGE_MAGIC)) \
466 $(wordlist 2,$(words $(1)),$(1)) \
467 -d $@ $@.new
468 mv $@.new $@
469 endef
470
471 define Build/xor-image
472 $(STAGING_DIR_HOST)/bin/xorimage -i $@ -o $@.xor $(1)
473 mv $@.xor $@
474 endef
475
476 define Build/zip
477 mkdir $@.tmp
478 mv $@ $@.tmp/$(1)
479
480 zip -j -X \
481 $(if $(SOURCE_DATE_EPOCH),--mtime="$(SOURCE_DATE_EPOCH)") \
482 $@ $@.tmp/$(if $(1),$(1),$@)
483 rm -rf $@.tmp
484 endef
485
486 define Build/zyxel-ras-image
487 let \
488 newsize="$(subst k,* 1024,$(RAS_ROOTFS_SIZE))"; \
489 $(STAGING_DIR_HOST)/bin/mkrasimage \
490 -b $(RAS_BOARD) \
491 -v $(RAS_VERSION) \
492 -r $@ \
493 -s $$newsize \
494 -o $@.new \
495 $(if $(findstring separate-kernel,$(word 1,$(1))),-k $(IMAGE_KERNEL)) \
496 && mv $@.new $@
497 endef