image-commands.mk 15 KB

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