image-commands.mk 15 KB

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