image-commands.mk 15 KB

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