image-commands.mk 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  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 printf %.16s "$(word 2, $(subst _, ,$(1)))")
  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/package-kernel-ubifs
  23. mkdir [email protected]
  24. cp $@ [email protected]/kernel
  25. $(STAGING_DIR_HOST)/bin/mkfs.ubifs \
  26. $(KERNEL_UBIFS_OPTS) \
  27. -r [email protected] $@
  28. rm -r [email protected]
  29. endef
  30. define Build/append-image
  31. cp "$(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(1)" "[email protected]"
  32. fwtool -s /dev/null -t "[email protected]" || :
  33. fwtool -i /dev/null -t "[email protected]" || :
  34. dd if="[email protected]" >> "$@"
  35. rm "[email protected]"
  36. endef
  37. ifdef IB
  38. define Build/append-image-stage
  39. dd if=$(STAGING_DIR_IMAGE)/$(BOARD)-$(SUBTARGET)-$(DEVICE_NAME)-$(1) >> $@
  40. endef
  41. else
  42. define Build/append-image-stage
  43. cp "$(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(1)" "[email protected]"
  44. fwtool -s /dev/null -t "[email protected]" || :
  45. fwtool -i /dev/null -t "[email protected]" || :
  46. mkdir -p "$(STAGING_DIR_IMAGE)"
  47. dd if="[email protected]" of="$(STAGING_DIR_IMAGE)/$(BOARD)-$(SUBTARGET)-$(DEVICE_NAME)-$(1)"
  48. dd if="[email protected]" >> "$@"
  49. rm "[email protected]"
  50. endef
  51. endif
  52. compat_version=$(if $(DEVICE_COMPAT_VERSION),$(DEVICE_COMPAT_VERSION),1.0)
  53. json_quote=$(subst ','\'',$(subst ",\",$(1)))
  54. #")')
  55. legacy_supported_message=$(SUPPORTED_DEVICES) - Image version mismatch: image $(compat_version), \
  56. device 1.0. Please wipe config during upgrade (force required) or reinstall. \
  57. $(if $(DEVICE_COMPAT_MESSAGE),Reason: $(DEVICE_COMPAT_MESSAGE),Please check documentation ...)
  58. metadata_devices=$(if $(1),$(subst "$(space)","$(comma)",$(strip $(foreach v,$(1),"$(call json_quote,$(v))"))))
  59. metadata_json = \
  60. '{ $(if $(IMAGE_METADATA),$(IMAGE_METADATA)$(comma)) \
  61. "metadata_version": "1.1", \
  62. "compat_version": "$(call json_quote,$(compat_version))", \
  63. $(if $(DEVICE_COMPAT_MESSAGE),"compat_message": "$(call json_quote,$(DEVICE_COMPAT_MESSAGE))"$(comma)) \
  64. $(if $(filter-out 1.0,$(compat_version)),"new_supported_devices": \
  65. [$(call metadata_devices,$(SUPPORTED_DEVICES))]$(comma) \
  66. "supported_devices": ["$(call json_quote,$(legacy_supported_message))"]$(comma)) \
  67. $(if $(filter 1.0,$(compat_version)),"supported_devices":[$(call metadata_devices,$(SUPPORTED_DEVICES))]$(comma)) \
  68. "version": { \
  69. "dist": "$(call json_quote,$(VERSION_DIST))", \
  70. "version": "$(call json_quote,$(VERSION_NUMBER))", \
  71. "revision": "$(call json_quote,$(REVISION))", \
  72. "target": "$(call json_quote,$(TARGETID))", \
  73. "board": "$(call json_quote,$(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)))" \
  74. } \
  75. }'
  76. define Build/append-metadata
  77. $(if $(SUPPORTED_DEVICES),-echo $(call metadata_json) | fwtool -I - $@)
  78. sha256sum "$@" | cut -d" " -f1 > "[email protected]"
  79. [ ! -s "$(BUILD_KEY)" -o ! -s "$(BUILD_KEY).ucert" -o ! -s "$@" ] || { \
  80. cp "$(BUILD_KEY).ucert" "[email protected]" ;\
  81. usign -S -m "$@" -s "$(BUILD_KEY)" -x "[email protected]" ;\
  82. ucert -A -c "[email protected]" -x "[email protected]" ;\
  83. fwtool -S "[email protected]" "$@" ;\
  84. }
  85. endef
  86. metadata_gl_json = \
  87. '{ $(if $(IMAGE_METADATA),$(IMAGE_METADATA)$(comma)) \
  88. "metadata_version": "1.1", \
  89. "compat_version": "$(call json_quote,$(compat_version))", \
  90. $(if $(DEVICE_COMPAT_MESSAGE),"compat_message": "$(call json_quote,$(DEVICE_COMPAT_MESSAGE))"$(comma)) \
  91. $(if $(filter-out 1.0,$(compat_version)),"new_supported_devices": \
  92. [$(call metadata_devices,$(SUPPORTED_DEVICES))]$(comma) \
  93. "supported_devices": ["$(call json_quote,$(legacy_supported_message))"]$(comma)) \
  94. $(if $(filter 1.0,$(compat_version)),"supported_devices":[$(call metadata_devices,$(SUPPORTED_DEVICES))]$(comma)) \
  95. "version": { \
  96. "release": "$(call json_quote,$(VERSION_NUMBER))", \
  97. "date": "$(shell TZ='Asia/Chongqing' date '+%Y%m%d%H%M%S')", \
  98. "dist": "$(call json_quote,$(VERSION_DIST))", \
  99. "version": "$(call json_quote,$(VERSION_NUMBER))", \
  100. "revision": "$(call json_quote,$(REVISION))", \
  101. "target": "$(call json_quote,$(TARGETID))", \
  102. "board": "$(call json_quote,$(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)))" \
  103. } \
  104. }'
  105. define Build/append-gl-metadata
  106. $(if $(SUPPORTED_DEVICES),-echo $(call metadata_gl_json,$(SUPPORTED_DEVICES)) | fwtool -I - $@)
  107. sha256sum "$@" | cut -d" " -f1 > "[email protected]"
  108. [ ! -s "$(BUILD_KEY)" -o ! -s "$(BUILD_KEY).ucert" -o ! -s "$@" ] || { \
  109. cp "$(BUILD_KEY).ucert" "[email protected]" ;\
  110. usign -S -m "$@" -s "$(BUILD_KEY)" -x "[email protected]" ;\
  111. ucert -A -c "[email protected]" -x "[email protected]" ;\
  112. fwtool -S "[email protected]" "$@" ;\
  113. }
  114. endef
  115. define Build/append-teltonika-metadata
  116. echo \
  117. '{$(if $(IMAGE_METADATA),$(IMAGE_METADATA)$(comma)) \
  118. "metadata_version": "1.1", \
  119. "compat_version": "$(call json_quote,$(compat_version))", \
  120. "version":"$(call json_quote,$(VERSION_DIST))-$(call json_quote,$(VERSION_NUMBER))-$(call json_quote,$(REVISION))", \
  121. "device_code": [".*"], \
  122. "hwver": [".*"], \
  123. "batch": [".*"], \
  124. "serial": [".*"], \
  125. $(if $(DEVICE_COMPAT_MESSAGE),"compat_message": "$(call json_quote,$(DEVICE_COMPAT_MESSAGE))"$(comma)) \
  126. $(if $(filter-out 1.0,$(compat_version)),"new_supported_devices": \
  127. [$(call metadata_devices,$(SUPPORTED_TELTONIKA_DEVICES))]$(comma) \
  128. "supported_devices": ["$(call json_quote,$(legacy_supported_message))"]$(comma)) \
  129. $(if $(filter 1.0,$(compat_version)),"supported_devices":[$(call metadata_devices,$(SUPPORTED_TELTONIKA_DEVICES))]$(comma)) \
  130. "version_wrt": { \
  131. "dist": "$(call json_quote,$(VERSION_DIST))", \
  132. "version": "$(call json_quote,$(VERSION_NUMBER))", \
  133. "revision": "$(call json_quote,$(REVISION))", \
  134. "target": "$(call json_quote,$(TARGETID))", \
  135. "board": "$(call json_quote,$(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)))" \
  136. }, \
  137. "hw_support": {}, \
  138. "hw_mods": {$(shell i=1; for mod in $(SUPPORTED_TELTONIKA_HW_MODS); do [ $$i -gt 1 ] && echo -n ,; echo -n "\"mod$$i\": \"$$mod\""; i=$$((i+1)); done)} \
  139. }' | fwtool -I - $@
  140. endef
  141. define Build/append-rootfs
  142. dd if=$(IMAGE_ROOTFS) >> $@
  143. endef
  144. define Build/append-squashfs-fakeroot-be
  145. rm -rf [email protected] [email protected]
  146. mkdir [email protected]
  147. $(STAGING_DIR_HOST)/bin/mksquashfs3-lzma \
  148. [email protected] [email protected] \
  149. -noappend -root-owned -be -nopad -b 65536 \
  150. $(if $(SOURCE_DATE_EPOCH),-fixed-time $(SOURCE_DATE_EPOCH))
  151. cat [email protected] >> $@
  152. endef
  153. define Build/append-squashfs4-fakeroot
  154. rm -rf [email protected] [email protected]
  155. mkdir [email protected]
  156. $(STAGING_DIR_HOST)/bin/mksquashfs4 \
  157. [email protected] [email protected] \
  158. -nopad -noappend -root-owned
  159. cat [email protected] >> $@
  160. endef
  161. define Build/append-string
  162. echo -n $(1) >> $@
  163. endef
  164. define Build/append-md5sum-ascii-salted
  165. cp $@ [email protected]
  166. echo -ne $(1) >> [email protected]
  167. $(STAGING_DIR_HOST)/bin/mkhash md5 [email protected] | head -c32 >> $@
  168. rm [email protected]
  169. endef
  170. UBI_NAND_SIZE_LIMIT = $(IMAGE_SIZE) - ($(NAND_SIZE)*20/1024 + 4*$(BLOCKSIZE))
  171. define Build/append-ubi
  172. sh $(TOPDIR)/scripts/ubinize-image.sh \
  173. $(if $(UBOOTENV_IN_UBI),--uboot-env) \
  174. $(if $(KERNEL_IN_UBI),--kernel $(IMAGE_KERNEL)) \
  175. $(foreach part,$(UBINIZE_PARTS),--part $(part)) \
  176. --rootfs $(IMAGE_ROOTFS) \
  177. [email protected] \
  178. -p $(BLOCKSIZE:%k=%KiB) -m $(PAGESIZE) \
  179. $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \
  180. $(if $(VID_HDR_OFFSET),-O $(VID_HDR_OFFSET)) \
  181. $(UBINIZE_OPTS)
  182. cat [email protected] >> $@
  183. rm [email protected]
  184. $(if $(and $(IMAGE_SIZE),$(NAND_SIZE)),\
  185. $(call Build/check-size,$(UBI_NAND_SIZE_LIMIT)))
  186. endef
  187. define Build/ubinize-image
  188. sh $(TOPDIR)/scripts/ubinize-image.sh \
  189. $(if $(UBOOTENV_IN_UBI),--uboot-env) \
  190. $(foreach part,$(UBINIZE_PARTS),--part $(part)) \
  191. --part $(word 1,$(1))="$(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(word 2,$(1))" \
  192. [email protected] \
  193. -p $(BLOCKSIZE:%k=%KiB) -m $(PAGESIZE) \
  194. $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \
  195. $(if $(VID_HDR_OFFSET),-O $(VID_HDR_OFFSET)) \
  196. $(UBINIZE_OPTS)
  197. cat [email protected] >> $@
  198. rm [email protected]
  199. endef
  200. define Build/ubinize-kernel
  201. cp $@ [email protected]
  202. sh $(TOPDIR)/scripts/ubinize-image.sh \
  203. --kernel [email protected] \
  204. $@ \
  205. -p $(BLOCKSIZE:%k=%KiB) -m $(PAGESIZE) \
  206. $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \
  207. $(if $(VID_HDR_OFFSET),-O $(VID_HDR_OFFSET)) \
  208. $(UBINIZE_OPTS)
  209. rm [email protected]
  210. endef
  211. define Build/append-uboot
  212. dd if=$(UBOOT_PATH) >> $@
  213. endef
  214. # append a fake/empty uImage header, to fool bootloaders rootfs integrity check
  215. # for example
  216. define Build/append-uImage-fakehdr
  217. $(eval type=$(word 1,$(1)))
  218. $(eval magic=$(word 2,$(1)))
  219. touch [email protected]
  220. $(STAGING_DIR_HOST)/bin/mkimage \
  221. -A $(LINUX_KARCH) -O linux -T $(type) -C none \
  222. -n '$(VERSION_DIST) fake $(type)' \
  223. $(if $(magic),-M $(magic)) \
  224. -d [email protected] \
  225. -s \
  226. [email protected]
  227. cat [email protected] >> $@
  228. endef
  229. define Build/buffalo-dhp-image
  230. $(STAGING_DIR_HOST)/bin/mkdhpimg $@ [email protected]
  231. mv [email protected] $@
  232. endef
  233. define Build/buffalo-enc
  234. $(eval product=$(word 1,$(1)))
  235. $(eval version=$(word 2,$(1)))
  236. $(eval args=$(wordlist 3,$(words $(1)),$(1)))
  237. $(STAGING_DIR_HOST)/bin/buffalo-enc \
  238. -p $(product) -v $(version) $(args) \
  239. -i $@ -o [email protected]
  240. mv [email protected] $@
  241. endef
  242. define Build/buffalo-enc-tag
  243. $(call Build/buffalo-enc,'' '' -S 152 $(1))
  244. endef
  245. define Build/buffalo-tag-dhp
  246. $(eval product=$(word 1,$(1)))
  247. $(eval region=$(word 2,$(1)))
  248. $(eval language=$(word 3,$(1)))
  249. $(STAGING_DIR_HOST)/bin/buffalo-tag \
  250. -d 0x01000000 -w 1 \
  251. -a $(BUFFALO_TAG_PLATFORM) \
  252. -v $(BUFFALO_TAG_VERSION) -m $(BUFFALO_TAG_MINOR) \
  253. -b $(product) -p $(product) \
  254. -r $(region) -r $(region) -l $(language) \
  255. -I $@ -o [email protected]
  256. mv [email protected] $@
  257. endef
  258. define Build/buffalo-trx
  259. $(eval magic=$(word 1,$(1)))
  260. $(eval kern_bin=$(if $(1),$(IMAGE_KERNEL),$@))
  261. $(eval rtfs_bin=$(word 2,$(1)))
  262. $(eval apnd_bin=$(word 3,$(1)))
  263. $(eval kern_size=$(if $(KERNEL_SIZE),$(KERNEL_SIZE),0x400000))
  264. $(if $(rtfs_bin),touch $(rtfs_bin))
  265. $(STAGING_DIR_HOST)/bin/otrx create [email protected] \
  266. $(if $(magic),-M $(magic),) \
  267. -f $(kern_bin) \
  268. $(if $(rtfs_bin),\
  269. -a 0x20000 \
  270. -b $$(( $(call exp_units,$(kern_size)) )) \
  271. -f $(rtfs_bin),) \
  272. $(if $(apnd_bin),\
  273. -A $(apnd_bin) \
  274. -a 0x20000)
  275. mv [email protected] $@
  276. endef
  277. define Build/check-size
  278. @imagesize="$$(stat -c%s $@)"; \
  279. limitsize="$$(($(call exp_units,$(if $(1),$(1),$(IMAGE_SIZE)))))"; \
  280. [ $$limitsize -ge $$imagesize ] || { \
  281. $(call ERROR_MESSAGE, WARNING: Image file $@ is too big: $$imagesize > $$limitsize); \
  282. rm -f $@; \
  283. }
  284. endef
  285. define Build/copy-file
  286. cat "$(1)" > "$@"
  287. endef
  288. # Create a header for a D-Link AI series recovery image and add it at the beginning of the image
  289. # Currently supported: AQUILA M30, EAGLE M32 and R32
  290. # Arguments:
  291. # 1: Start string of the header
  292. # 2: Firmware version
  293. # 3: Block start address
  294. # 4: Block length
  295. # 5: Device FMID
  296. define Build/dlink-ai-recovery-header
  297. $(eval header_start=$(word 1,$(1)))
  298. $(eval firmware_version=$(word 2,$(1)))
  299. $(eval block_start=$(word 3,$(1)))
  300. $(eval block_length=$(word 4,$(1)))
  301. $(eval device_fmid=$(word 5,$(1)))
  302. # create [email protected] without the checksum
  303. echo -en "$(header_start)\x00\x00" > "[email protected]"
  304. # Calculate checksum over data area ($@) and append it to the header.
  305. # The checksum is the 2byte-sum over the whole data area.
  306. # Every overflow during the checksum calculation must increment the current checksum value by 1.
  307. od -v -w2 -tu2 -An --endian little "$@" | awk '{ s+=$$1; } END { s%=65535; printf "%c%c",s%256,s/256; }' >> "[email protected]"
  308. echo -en "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00" >> "[email protected]"
  309. echo -en "$(firmware_version)" >> "[email protected]"
  310. # Only one block supported: Erase start/length is identical to data start/length
  311. echo -en "$(block_start)$(block_length)$(block_start)$(block_length)" >> "[email protected]"
  312. # Only zeros
  313. echo -en "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" >> "[email protected]"
  314. # Last 16 bytes, but without checksum
  315. echo -en "\x42\x48\x02\x00\x00\x00\x08\x00\x00\x00\x00\x00" >> "[email protected]"
  316. echo -en "$(device_fmid)" >> "[email protected]"
  317. # Calculate and append checksum: The checksum must be set so that the 2byte-sum of the whole header is 0.
  318. # Every overflow during the checksum calculation must increment the current checksum value by 1.
  319. od -v -w2 -tu2 -An --endian little "[email protected]" | awk '{s+=65535-$$1;}END{s%=65535;printf "%c%c",s%256,s/256;}' >> "[email protected]"
  320. cat "[email protected]" "$@" > "[email protected]"
  321. mv "[email protected]" "$@"
  322. rm "[email protected]"
  323. endef
  324. define Build/dlink-sge-image
  325. $(STAGING_DIR_HOST)/bin/dlink-sge-image $(1) $@ [email protected]
  326. mv [email protected] $@
  327. endef
  328. define Build/edimax-header
  329. $(STAGING_DIR_HOST)/bin/mkedimaximg -i $@ -o [email protected] $(1)
  330. @mv [email protected] $@
  331. endef
  332. define Build/elecom-product-header
  333. $(eval product=$(word 1,$(1)))
  334. $(eval fw=$(if $(word 2,$(1)),$(word 2,$(1)),$@))
  335. -( \
  336. echo -n -e "ELECOM\x00\x00$(product)" | dd bs=40 count=1 conv=sync; \
  337. echo -n "0.00" | dd bs=16 count=1 conv=sync; \
  338. dd if=$(fw); \
  339. ) > $(fw).new \
  340. && mv $(fw).new $(fw) || rm -f $(fw)
  341. endef
  342. define Build/elecom-wrc-gs-factory
  343. $(eval product=$(word 1,$(1)))
  344. $(eval version=$(word 2,$(1)))
  345. $(eval hash_opt=$(word 3,$(1)))
  346. $(MKHASH) md5 $(hash_opt) $@ >> $@
  347. ( \
  348. echo -n "ELECOM $(product) v$(version)" | \
  349. dd bs=32 count=1 conv=sync; \
  350. dd if=$@; \
  351. ) > [email protected]
  352. mv [email protected] $@
  353. endef
  354. define Build/elx-header
  355. $(eval hw_id=$(word 1,$(1)))
  356. $(eval xor_pattern=$(word 2,$(1)))
  357. ( \
  358. echo -ne "\x00\x00\x00\x00\x00\x00\x00\x03" | \
  359. dd bs=42 count=1 conv=sync; \
  360. hw_id="$(hw_id)"; \
  361. echo -ne "\x$${hw_id:0:2}\x$${hw_id:2:2}\x$${hw_id:4:2}\x$${hw_id:6:2}" | \
  362. dd bs=20 count=1 conv=sync; \
  363. echo -ne "$$(printf '%08x' $$(stat -c%s $@) | fold -s2 | xargs -I {} echo \\x{} | tr -d '\n')" | \
  364. dd bs=8 count=1 conv=sync; \
  365. echo -ne "$$($(MKHASH) md5 $@ | fold -s2 | xargs -I {} echo \\x{} | tr -d '\n')" | \
  366. dd bs=58 count=1 conv=sync; \
  367. ) > $(KDIR)/tmp/$(DEVICE_NAME).header
  368. -$(call Build/xor-image,-p $(xor_pattern) -x) \
  369. && cat $(KDIR)/tmp/$(DEVICE_NAME).header $@ > [email protected] \
  370. && mv [email protected] $@ \
  371. && rm -rf $(KDIR)/tmp/$(DEVICE_NAME).header
  372. endef
  373. define Build/eva-image
  374. $(STAGING_DIR_HOST)/bin/lzma2eva $(KERNEL_LOADADDR) $(KERNEL_LOADADDR) $@ [email protected]
  375. mv [email protected] $@
  376. endef
  377. define Build/initrd_compression
  378. $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_BZIP2),.bzip2) \
  379. $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_GZIP),.gzip) \
  380. $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZ4),.lz4) \
  381. $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZMA),.lzma) \
  382. $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZO),.lzo) \
  383. $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_XZ),.xz) \
  384. $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_ZSTD),.zstd)
  385. endef
  386. define Build/fit-its
  387. $(if $(findstring with-rootfs,$(word 3,$(1))), \
  388. $(call locked,dd if=$(IMAGE_ROOTFS) of=$(IMAGE_ROOTFS).pagesync bs=4096 conv=sync, \
  389. gen-cpio$(if $(TARGET_PER_DEVICE_ROOTFS),.$(ROOTFS_ID/$(DEVICE_NAME)))))
  390. $(TOPDIR)/scripts/mkits.sh \
  391. -D $(DEVICE_NAME) -o [email protected] -k $@ \
  392. -C $(word 1,$(1)) \
  393. $(if $(word 2,$(1)),\
  394. $(if $(findstring 11,$(if $(DEVICE_DTS_OVERLAY),1)$(if $(findstring $(KERNEL_BUILD_DIR)/image-,$(word 2,$(1))),,1)), \
  395. -d $(KERNEL_BUILD_DIR)/image-$$(basename $(word 2,$(1))), \
  396. -d $(word 2,$(1)))) \
  397. $(if $(findstring with-rootfs,$(word 3,$(1))),-r $(IMAGE_ROOTFS)) \
  398. $(if $(findstring with-initrd,$(word 3,$(1))), \
  399. $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS_SEPARATE), \
  400. -i $(KERNEL_BUILD_DIR)/initrd$(if $(TARGET_PER_DEVICE_ROOTFS),.$(ROOTFS_ID/$(DEVICE_NAME))).cpio$(strip $(call Build/initrd_compression)))) \
  401. -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
  402. $(if $(DEVICE_FDT_NUM),-n $(DEVICE_FDT_NUM)) \
  403. $(if $(DEVICE_DTS_DELIMITER),-l $(DEVICE_DTS_DELIMITER)) \
  404. $(if $(DEVICE_DTS_LOADADDR),-s $(DEVICE_DTS_LOADADDR)) \
  405. $(if $(DEVICE_DTS_OVERLAY),$(foreach dtso,$(DEVICE_DTS_OVERLAY), -O $(dtso):$(KERNEL_BUILD_DIR)/image-$(dtso).dtbo)) \
  406. -c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config-1") \
  407. -A $(LINUX_KARCH) -v $(LINUX_VERSION)
  408. endef
  409. define Build/fit-image
  410. $(call locked,PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage $(if $(findstring external,$(word 3,$(1))),\
  411. -E -B 0x1000 $(if $(findstring static,$(word 3,$(1))),-p 0x1000)) -f [email protected] [email protected], \
  412. gen-cpio$(if $(TARGET_PER_DEVICE_ROOTFS),.$(ROOTFS_ID/$(DEVICE_NAME))))
  413. @mv [email protected] $@
  414. endef
  415. define Build/fit
  416. $(call Build/fit-its,$(1))
  417. $(call Build/fit-image,$(1))
  418. endef
  419. define Build/libdeflate-gzip
  420. $(STAGING_DIR_HOST)/bin/libdeflate-gzip -f -12 -c $@ $(1) > [email protected]
  421. @mv [email protected] $@
  422. endef
  423. define Build/gzip
  424. $(STAGING_DIR_HOST)/bin/gzip -f -9n -c $@ $(1) > [email protected]
  425. @mv [email protected] $@
  426. endef
  427. define Build/gzip-filename
  428. @mkdir -p [email protected]
  429. @cp $@ [email protected]/$(word 1,$(1))
  430. $(if $(SOURCE_DATE_EPOCH),touch -hcd "@$(SOURCE_DATE_EPOCH)" [email protected]/$(word 1,$(1)) $(word 2,$(1)))
  431. $(STAGING_DIR_HOST)/bin/gzip -f -9 -N -c [email protected]/$(word 1,$(1)) $(word 2,$(1)) > [email protected]
  432. @mv [email protected] $@
  433. @rm -rf [email protected]
  434. endef
  435. define Build/install-dtb
  436. $(call locked, \
  437. $(foreach dts,$(DEVICE_DTS), \
  438. $(CP) \
  439. $(DTS_DIR)/$(dts).dtb \
  440. $(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb; \
  441. ), \
  442. install-dtb-$(IMG_PREFIX) \
  443. )
  444. endef
  445. define Build/iptime-crc32
  446. $(STAGING_DIR_HOST)/bin/iptime-crc32 $(1) $@ [email protected]
  447. mv [email protected] $@
  448. endef
  449. define Build/iptime-naspkg
  450. $(STAGING_DIR_HOST)/bin/iptime-naspkg $(1) $@ [email protected]
  451. mv [email protected] $@
  452. endef
  453. define Build/jffs2
  454. rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 && \
  455. mkdir -p $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$$(dirname $(word 1,$(1))) && \
  456. cp $@ $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$(word 1,$(1)) && \
  457. $(STAGING_DIR_HOST)/bin/mkfs.jffs2 --pad \
  458. $(if $(CONFIG_BIG_ENDIAN),--big-endian,--little-endian) \
  459. --squash-uids -v -e $(patsubst %k,%KiB,$(BLOCKSIZE)) \
  460. -o [email protected] \
  461. -d $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 \
  462. $(wordlist 2,$(words $(1)),$(1)) \
  463. 2>&1 1>/dev/null | awk '/^.+$$$$/' && \
  464. $(STAGING_DIR_HOST)/bin/padjffs2 [email protected] -J $(patsubst %k,,$(BLOCKSIZE))
  465. -rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/
  466. @mv [email protected] $@
  467. endef
  468. define Build/yaffs-filesystem
  469. let \
  470. kernel_size="$$(stat -c%s $@)" \
  471. kernel_chunks="(kernel_size / 1024) + 1" \
  472. filesystem_chunks="kernel_chunks + 3" \
  473. filesystem_blocks="(filesystem_chunks / 63) + 1" \
  474. filesystem_size="filesystem_blocks * 64 * 1024" \
  475. filesystem_size_with_reserve="(filesystem_blocks + 2) * 64 * 1024"; \
  476. head -c $$filesystem_size_with_reserve /dev/zero | tr "\000" "\377" > [email protected] \
  477. && yafut -d [email protected] -w -i $@ -o $(if $(findstring v7,$@),bootimage,kernel) -C 1040 -B 64k -E -P -S $(1) \
  478. && truncate -s $$filesystem_size [email protected] \
  479. && mv [email protected] $@
  480. endef
  481. define Build/kernel-bin
  482. rm -f $@
  483. cp $< $@
  484. endef
  485. define Build/gl-qsdk-factory
  486. $(eval GL_NAME := $(call param_get_default,type,$(1),$(DEVICE_NAME)))
  487. $(eval GL_IMGK := $(KDIR_TMP)/$(DEVICE_IMG_PREFIX)-squashfs-factory.img)
  488. $(eval GL_ITS := $(KDIR_TMP)/$(GL_NAME).its)
  489. $(eval GL_UBI := "ubi")
  490. $(CP) $(BOOT_SCRIPT) $(KDIR_TMP)/
  491. $(shell mv $(GL_IMGK) $(GL_IMGK).tmp)
  492. sed -i "s/rootfs_size/`wc -c $(GL_IMGK) | \
  493. cut -d " " -f 1 | xargs printf "0x%x"`/g" $(KDIR_TMP)/$(BOOT_SCRIPT);
  494. $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \
  495. $(GL_ITS) \
  496. $(BOOT_SCRIPT) \
  497. $(GL_UBI) \
  498. $(GL_IMGK)
  499. PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f \
  500. $(GL_ITS) \
  501. $(GL_IMGK)
  502. $(RM) \
  503. $(GL_ITS) \
  504. $(GL_IMGK).tmp \
  505. $(KDIR_TMP)/$(notdir $(BOOT_SCRIPT))
  506. endef
  507. define Build/kernel-pack-npk
  508. $(STAGING_DIR_HOST)/bin/npk_pack_kernel $@ [email protected]
  509. mv [email protected] $@
  510. endef
  511. define Build/linksys-image
  512. let \
  513. size="$$(stat -c%s $@)" \
  514. pad="$(call exp_units,$(PAGESIZE))" \
  515. offset="256" \
  516. pad="(pad - ((size + offset) % pad)) % pad"; \
  517. dd if=/dev/zero bs=$$pad count=1 | tr '\000' '\377' >> $@
  518. printf ".LINKSYS.01000409%-15s%08X%-8s%-16s" \
  519. "$(call param_get_default,type,$(1),$(DEVICE_NAME))" \
  520. "$$(cksum $@ | cut -d ' ' -f1)" \
  521. "0" "K0000000F0246434" >> $@
  522. dd if=/dev/zero bs=192 count=1 >> $@
  523. endef
  524. define Build/lzma
  525. $(call Build/lzma-no-dict,-lc1 -lp2 -pb2 $(1))
  526. endef
  527. define Build/lzma-no-dict
  528. $(STAGING_DIR_HOST)/bin/lzma e $@ $(1) [email protected]
  529. @mv [email protected] $@
  530. endef
  531. define Build/moxa-encode-fw
  532. $(TOPDIR)/scripts/moxa-encode-fw.py \
  533. --input $@ \
  534. --output $@ \
  535. --magic $(MOXA_MAGIC) \
  536. --hwid $(MOXA_HWID) \
  537. --buildid 00000000
  538. endef
  539. define Build/netgear-chk
  540. $(STAGING_DIR_HOST)/bin/mkchkimg \
  541. -o [email protected] \
  542. -k $@ \
  543. -b $(NETGEAR_BOARD_ID) \
  544. $(if $(NETGEAR_REGION),-r $(NETGEAR_REGION),)
  545. mv [email protected] $@
  546. endef
  547. define Build/netgear-dni
  548. $(STAGING_DIR_HOST)/bin/mkdniimg \
  549. -B $(NETGEAR_BOARD_ID) -v $(shell cat $(VERSION_DIST)| sed -e 's/[[:space:]]/-/g').$(firstword $(subst -, ,$(REVISION))) \
  550. $(if $(NETGEAR_HW_ID),-H $(NETGEAR_HW_ID)) \
  551. -r "$(1)" \
  552. -i $@ -o [email protected]
  553. mv [email protected] $@
  554. endef
  555. define Build/netgear-encrypted-factory
  556. $(TOPDIR)/scripts/netgear-encrypted-factory.py \
  557. --input-file $@ \
  558. --output-file $@ \
  559. --model $(NETGEAR_ENC_MODEL) \
  560. --region $(NETGEAR_ENC_REGION) \
  561. $(if $(NETGEAR_ENC_HW_ID_LIST),--hw-id-list "$(NETGEAR_ENC_HW_ID_LIST)") \
  562. $(if $(NETGEAR_ENC_MODEL_LIST),--model-list "$(NETGEAR_ENC_MODEL_LIST)") \
  563. --version V1.0.0.0.$(shell cat $(VERSION_DIST)| sed -e 's/[[:space:]]/-/g').$(firstword $(subst -, ,$(REVISION))) \
  564. --encryption-block-size 0x20000 \
  565. --openssl-bin "$(STAGING_DIR_HOST)/bin/openssl" \
  566. --key 6865392d342b4d212964363d6d7e7765312c7132613364316e26322a5a5e2538 \
  567. --iv 4a253169516c38243d6c6d2d3b384145
  568. endef
  569. define Build/openmesh-image
  570. $(TOPDIR)/scripts/om-fwupgradecfg-gen.sh \
  571. "$(call param_get_default,ce_type,$(1),$(DEVICE_NAME))" \
  572. "[email protected]" \
  573. "$(call param_get_default,kernel,$(1),$(IMAGE_KERNEL))" \
  574. "$(call param_get_default,rootfs,$(1),$@)"
  575. $(TOPDIR)/scripts/combined-ext-image.sh \
  576. "$(call param_get_default,ce_type,$(1),$(DEVICE_NAME))" "$@" \
  577. "[email protected]" "fwupgrade.cfg" \
  578. "$(call param_get_default,kernel,$(1),$(IMAGE_KERNEL))" "kernel" \
  579. "$(call param_get_default,rootfs,$(1),$@)" "rootfs"
  580. endef
  581. define Build/dualboot-datachk-nand-image
  582. $(TOPDIR)/scripts/nand-fwupgradecfg-gen.sh \
  583. "$(call param_get_default,ce_type,$(1),$(DEVICE_NAME))" \
  584. "[email protected]" \
  585. "$(call param_get_default,kernel,$(1),$(IMAGE_KERNEL))" \
  586. "$(call param_get_default,rootfs,$(1),$@)"
  587. $(TOPDIR)/scripts/combined-ext-image.sh \
  588. "$(call param_get_default,ce_type,$(1),$(DEVICE_NAME))" "$@" \
  589. "[email protected]" "fwupgrade.cfg" \
  590. "$(call param_get_default,kernel,$(1),$(IMAGE_KERNEL))" "kernel" \
  591. "$(call param_get_default,rootfs,$(1),$@)" "rootfs"
  592. endef
  593. define Build/pad-extra
  594. dd if=/dev/zero bs=$(1) count=1 >> $@
  595. endef
  596. define Build/pad-offset
  597. let \
  598. size="$$(stat -c%s $@)" \
  599. pad="$(call exp_units,$(word 1, $(1)))" \
  600. offset="$(call exp_units,$(word 2, $(1)))" \
  601. pad="(pad - ((size + offset) % pad)) % pad" \
  602. newsize='size + pad'; \
  603. dd if=$@ [email protected] bs=$$newsize count=1 conv=sync
  604. mv [email protected] $@
  605. endef
  606. define Build/pad-rootfs
  607. $(STAGING_DIR_HOST)/bin/padjffs2 $@ $(1) \
  608. $(if $(BLOCKSIZE),$(BLOCKSIZE:%k=%),4 8 16 64 128 256)
  609. endef
  610. define Build/pad-to
  611. $(call Image/pad-to,$@,$(1))
  612. endef
  613. define Build/patch-cmdline
  614. $(STAGING_DIR_HOST)/bin/patch-cmdline $@ '$(CMDLINE)'
  615. endef
  616. # Convert a raw image into a $1 type image.
  617. # E.g. | qemu-image vdi <optional extra arguments to qemu-img binary>
  618. define Build/qemu-image
  619. if command -v qemu-img; then \
  620. qemu-img convert -f raw -O $1 $@ [email protected]; \
  621. mv [email protected] $@; \
  622. else \
  623. echo "WARNING: Install qemu-img to create VDI/VMDK images" >&2; exit 1; \
  624. fi
  625. endef
  626. define Build/qsdk-ipq-factory-nand
  627. $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \
  628. [email protected] ubi $@
  629. PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f [email protected] [email protected]
  630. @mv [email protected] $@
  631. endef
  632. define Build/qsdk-ipq-factory-nor
  633. $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \
  634. [email protected] hlos $(IMAGE_KERNEL) rootfs $(IMAGE_ROOTFS)
  635. PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f [email protected] [email protected]
  636. @mv [email protected] $@
  637. endef
  638. define Build/seama
  639. $(STAGING_DIR_HOST)/bin/seama -i $@ \
  640. -m "dev=/dev/mtdblock/$(SEAMA_MTDBLOCK)" -m "type=firmware"
  641. mv [email protected] $@
  642. endef
  643. define Build/seama-seal
  644. $(STAGING_DIR_HOST)/bin/seama -i $@ -s [email protected] \
  645. -m "signature=$(SEAMA_SIGNATURE)"
  646. mv [email protected] $@
  647. endef
  648. define Build/senao-header
  649. -$(STAGING_DIR_HOST)/bin/mksenaofw $(1) -e $@ -o [email protected] \
  650. && mv [email protected] $@ || rm -f $@
  651. endef
  652. define Build/sysupgrade-tar
  653. $(eval dtb=$(call param_get,dtb,$(1)))
  654. sh $(TOPDIR)/scripts/sysupgrade-tar.sh \
  655. --board $(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)) \
  656. --kernel $(call param_get_default,kernel,$(1),$(IMAGE_KERNEL)) \
  657. --rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \
  658. $(if $(dtb),--dtb $(dtb)) \
  659. $@
  660. endef
  661. define Build/tplink-image-2022
  662. $(TOPDIR)/scripts/tplink-mkimage-2022.py \
  663. --create [email protected] \
  664. --rootfs $@ \
  665. --support "$(TPLINK_SUPPORT_STRING)"
  666. @mv [email protected] $@
  667. endef
  668. define Build/tplink-safeloader
  669. -$(STAGING_DIR_HOST)/bin/tplink-safeloader \
  670. -B $(TPLINK_BOARD_ID) \
  671. -V $(REVISION) \
  672. -k $(IMAGE_KERNEL) \
  673. -r $@ \
  674. -o [email protected] \
  675. -j \
  676. $(wordlist 2,$(words $(1)),$(1)) \
  677. $(if $(findstring sysupgrade,$(word 1,$(1))),-S) && mv [email protected] $@ || rm -f $@
  678. endef
  679. define Build/tplink-v1-header
  680. $(STAGING_DIR_HOST)/bin/mktplinkfw \
  681. -c -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -L $(KERNEL_LOADADDR) \
  682. -E $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
  683. -m $(TPLINK_HEADER_VERSION) -N "$(VERSION_DIST)" -V $(REVISION) \
  684. -k $@ -o [email protected] $(1)
  685. @mv [email protected] $@
  686. endef
  687. # combine kernel and rootfs into one image
  688. # mktplinkfw <type> <optional extra arguments to mktplinkfw binary>
  689. # <type> is "sysupgrade" or "factory"
  690. #
  691. # -a align the rootfs start on an <align> bytes boundary
  692. # -j add jffs2 end-of-filesystem markers
  693. # -s strip padding from end of the image
  694. # -X reserve <size> bytes in the firmware image (hexval prefixed with 0x)
  695. define Build/tplink-v1-image
  696. -$(STAGING_DIR_HOST)/bin/mktplinkfw \
  697. -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) \
  698. -N "$(VERSION_DIST)" -V $(REVISION) -m $(TPLINK_HEADER_VERSION) \
  699. -k $(IMAGE_KERNEL) -r $(IMAGE_ROOTFS) -o [email protected] -j -X 0x40000 \
  700. -a $(call rootfs_align,$(FILESYSTEM)) \
  701. $(wordlist 2,$(words $(1)),$(1)) \
  702. $(if $(findstring sysupgrade,$(word 1,$(1))),-s) && mv [email protected] $@ || rm -f $@
  703. endef
  704. define Build/tplink-v2-header
  705. -$(STAGING_DIR_HOST)/bin/mktplinkfw2 \
  706. -c -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -L $(KERNEL_LOADADDR) \
  707. -E $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
  708. -w $(TPLINK_HWREVADD) -F "$(TPLINK_FLASHLAYOUT)" \
  709. -T $(TPLINK_HVERSION) -V "ver. 2.0" \
  710. -k $@ -o [email protected] $(1) \
  711. && mv [email protected] $@ || rm -f $@
  712. endef
  713. define Build/tplink-v2-image
  714. -$(STAGING_DIR_HOST)/bin/mktplinkfw2 \
  715. -H $(TPLINK_HWID) -W $(TPLINK_HWREV) \
  716. -w $(TPLINK_HWREVADD) -F "$(TPLINK_FLASHLAYOUT)" \
  717. -T $(TPLINK_HVERSION) -V "ver. 2.0" -a 0x4 -j \
  718. -k $(IMAGE_KERNEL) -r $(IMAGE_ROOTFS) -o [email protected] $(1) \
  719. && cat [email protected] >> $@ && rm -rf [email protected] || rm -f $@
  720. endef
  721. define Build/uImage
  722. $(if $(UIMAGE_TIME),SOURCE_DATE_EPOCH="$(UIMAGE_TIME)") \
  723. mkimage \
  724. -A $(LINUX_KARCH) \
  725. -O linux \
  726. -T kernel \
  727. -C $(word 1,$(1)) \
  728. -a $(KERNEL_LOADADDR) \
  729. -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
  730. -n '$(if $(UIMAGE_NAME),$(UIMAGE_NAME),$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION))' \
  731. $(if $(UIMAGE_MAGIC),-M $(UIMAGE_MAGIC)) \
  732. $(wordlist 2,$(words $(1)),$(1)) \
  733. -d $@ [email protected]
  734. mv [email protected] $@
  735. endef
  736. define Build/multiImage
  737. $(if $(UIMAGE_TIME),SOURCE_DATE_EPOCH="$(UIMAGE_TIME)") \
  738. mkimage \
  739. -A $(LINUX_KARCH) \
  740. -O linux \
  741. -T multi \
  742. -C $(word 1,$(1)) \
  743. -a $(KERNEL_LOADADDR) \
  744. -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
  745. -n '$(if $(UIMAGE_NAME),$(UIMAGE_NAME),$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION))' \
  746. $(if $(UIMAGE_MAGIC),-M $(UIMAGE_MAGIC)) \
  747. -d $@:$(word 2,$(1)):$(word 3,$(1)) \
  748. $(wordlist 4,$(words $(1)),$(1)) \
  749. [email protected]
  750. mv [email protected] $@
  751. endef
  752. define Build/xor-image
  753. -$(STAGING_DIR_HOST)/bin/xorimage -i $@ -o [email protected] $(1) \
  754. && mv [email protected] $@ || rm -f $@
  755. endef
  756. define Build/zip
  757. rm -rf [email protected]
  758. mkdir [email protected]
  759. mv $@ [email protected]/$(word 1,$(1))
  760. TZ=UTC $(STAGING_DIR_HOST)/bin/zip -j -X \
  761. $(wordlist 2,$(words $(1)),$(1)) \
  762. $@ [email protected]/$(if $(word 1,$(1)),$(word 1,$(1)),$$(basename $@))
  763. rm -rf [email protected]
  764. endef
  765. define Build/zyimage
  766. $(STAGING_DIR_HOST)/bin/zyimage $(1) $@
  767. endef
  768. define Build/zyxel-ras-image
  769. let \
  770. newsize="$(call exp_units,$(RAS_ROOTFS_SIZE))"; \
  771. $(STAGING_DIR_HOST)/bin/mkrasimage \
  772. -b $(RAS_BOARD) \
  773. -v $(RAS_VERSION) \
  774. -r $@ \
  775. -s $$newsize \
  776. -o [email protected] \
  777. $(if $(findstring separate-kernel,$(word 1,$(1))),-k $(IMAGE_KERNEL)) \
  778. && mv [email protected] $@
  779. endef