2
0

image-commands.mk 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. # Build commands that can be called from Device/* templates
  2. define Build/uImage
  3. mkimage -A $(LINUX_KARCH) \
  4. -O linux -T kernel \
  5. -C $(1) -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
  6. -n '$(call toupper,$(LINUX_KARCH)) LEDE Linux-$(LINUX_VERSION)' -d $@ [email protected]
  7. @mv [email protected] $@
  8. endef
  9. define Build/netgear-chk
  10. $(STAGING_DIR_HOST)/bin/mkchkimg \
  11. -o [email protected] \
  12. -k $@ \
  13. -b $(NETGEAR_BOARD_ID) \
  14. -r $(NETGEAR_REGION)
  15. mv [email protected] $@
  16. endef
  17. define Build/netgear-dni
  18. $(STAGING_DIR_HOST)/bin/mkdniimg \
  19. -B $(NETGEAR_BOARD_ID) -v LEDE.$(REVISION) \
  20. $(if $(NETGEAR_HW_ID),-H $(NETGEAR_HW_ID)) \
  21. -r "$(1)" \
  22. -i $@ -o [email protected]
  23. mv [email protected] $@
  24. endef
  25. define Build/tplink-safeloader
  26. -$(STAGING_DIR_HOST)/bin/tplink-safeloader \
  27. -B $(TPLINK_BOARD_NAME) \
  28. -V $(REVISION) \
  29. -k $(word 1,$^) \
  30. -r $@ \
  31. -o [email protected] \
  32. -j \
  33. $(wordlist 2,$(words $(1)),$(1)) \
  34. $(if $(findstring sysupgrade,$(word 1,$(1))),-S) && mv [email protected] $@ || rm -f $@
  35. endef
  36. define Build/append-dtb
  37. $(call Image/BuildDTB,$(if $(DEVICE_DTS_DIR),$(DEVICE_DTS_DIR),$(DTS_DIR))/$(DEVICE_DTS).dts,[email protected])
  38. cat [email protected] >> $@
  39. endef
  40. define Build/fit
  41. $(TOPDIR)/scripts/mkits.sh \
  42. -D $(DEVICE_NAME) -o [email protected] -k $@ \
  43. $(if $(word 2,$(1)),-d $(word 2,$(1))) -C $(word 1,$(1)) \
  44. -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
  45. -A $(ARCH) -v $(LINUX_VERSION)
  46. PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f [email protected] [email protected]
  47. @mv [email protected] $@
  48. endef
  49. define Build/lzma
  50. $(call Build/lzma-no-dict,-lc1 -lp2 -pb2 $(1))
  51. endef
  52. define Build/lzma-no-dict
  53. $(STAGING_DIR_HOST)/bin/lzma e $@ $(1) [email protected]
  54. @mv [email protected] $@
  55. endef
  56. define Build/gzip
  57. gzip -9n -c $@ $(1) > [email protected]
  58. @mv [email protected] $@
  59. endef
  60. define Build/jffs2
  61. rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 && \
  62. mkdir -p $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$$(dirname $(1)) && \
  63. cp $@ $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$(1) && \
  64. $(STAGING_DIR_HOST)/bin/mkfs.jffs2 --pad \
  65. $(if $(CONFIG_BIG_ENDIAN),--big-endian,--little-endian) \
  66. --squash-uids -v -e $(patsubst %k,%KiB,$(BLOCKSIZE)) \
  67. -o [email protected] \
  68. -d $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 \
  69. 2>&1 1>/dev/null | awk '/^.+$$$$/' && \
  70. $(STAGING_DIR_HOST)/bin/padjffs2 [email protected] -J $(patsubst %k,,$(BLOCKSIZE))
  71. -rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/
  72. @mv [email protected] $@
  73. endef
  74. define Build/kernel-bin
  75. rm -f $@
  76. cp $< $@
  77. endef
  78. define Build/patch-cmdline
  79. $(STAGING_DIR_HOST)/bin/patch-cmdline $@ '$(CMDLINE)'
  80. endef
  81. define Build/append-kernel
  82. dd if=$(word 1,$^) $(if $(1),bs=$(1) conv=sync) >> $@
  83. endef
  84. define Build/append-rootfs
  85. dd if=$(word 2,$^) $(if $(1),bs=$(1) conv=sync) >> $@
  86. endef
  87. define Build/append-ubi
  88. sh $(TOPDIR)/scripts/ubinize-image.sh \
  89. $(if $(UBOOTENV_IN_UBI),--uboot-env) \
  90. $(if $(KERNEL_IN_UBI),--kernel $(word 1,$^)) \
  91. $(word 2,$^) \
  92. [email protected] \
  93. -p $(BLOCKSIZE) -m $(PAGESIZE) \
  94. $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \
  95. $(if $(VID_HDR_OFFSET),-O $(VID_HDR_OFFSET)) \
  96. $(UBINIZE_OPTS)
  97. cat [email protected] >> $@
  98. rm [email protected]
  99. endef
  100. define Build/pad-to
  101. dd if=$@ [email protected] bs=$(1) conv=sync
  102. mv [email protected] $@
  103. endef
  104. define Build/pad-rootfs
  105. $(STAGING_DIR_HOST)/bin/padjffs2 $@ $(1) 4 8 16 64 128 256
  106. endef
  107. define Build/pad-offset
  108. let \
  109. size="$$(stat -c%s $@)" \
  110. pad="$(word 1, $(1))" \
  111. offset="$(word 2, $(1))" \
  112. pad="(pad - ((size + offset) % pad)) % pad" \
  113. newsize='size + pad'; \
  114. dd if=$@ [email protected] bs=$$newsize count=1 conv=sync
  115. mv [email protected] $@
  116. endef
  117. define Build/check-size
  118. @[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(1))))) -ge "$$(stat -c%s $@)" ] || { \
  119. echo "WARNING: Image file $@ is too big" >&2; \
  120. rm -f $@; \
  121. }
  122. endef
  123. define Build/combined-image
  124. -sh $(TOPDIR)/scripts/combined-image.sh \
  125. "$(word 1,$^)" \
  126. "$@" \
  127. "[email protected]"
  128. @mv [email protected] $@
  129. endef
  130. define Build/sysupgrade-tar
  131. sh $(TOPDIR)/scripts/sysupgrade-tar.sh \
  132. --board $(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)) \
  133. --kernel $(word 1,$^) \
  134. --rootfs $(word 2,$^) \
  135. $@
  136. endef