2
0

image-commands.mk 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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/fit
  37. $(TOPDIR)/scripts/mkits.sh \
  38. -D $(DEVICE_NAME) -o [email protected] -k $@ \
  39. $(if $(word 2,$(1)),-d $(word 2,$(1))) -C $(word 1,$(1)) \
  40. -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
  41. -A $(ARCH) -v $(LINUX_VERSION)
  42. PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f [email protected] [email protected]
  43. @mv [email protected] $@
  44. endef
  45. define Build/lzma
  46. $(call Build/lzma-no-dict,-lc1 -lp2 -pb2 $(1))
  47. endef
  48. define Build/lzma-no-dict
  49. $(STAGING_DIR_HOST)/bin/lzma e $@ $(1) [email protected]
  50. @mv [email protected] $@
  51. endef
  52. define Build/gzip
  53. gzip -9n -c $@ $(1) > [email protected]
  54. @mv [email protected] $@
  55. endef
  56. define Build/jffs2
  57. rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 && \
  58. mkdir -p $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$$(dirname $(1)) && \
  59. cp $@ $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$(1) && \
  60. $(STAGING_DIR_HOST)/bin/mkfs.jffs2 --pad \
  61. $(if $(CONFIG_BIG_ENDIAN),--big-endian,--little-endian) \
  62. --squash-uids -v -e $(patsubst %k,%KiB,$(BLOCKSIZE)) \
  63. -o [email protected] \
  64. -d $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 \
  65. 2>&1 1>/dev/null | awk '/^.+$$$$/' && \
  66. $(STAGING_DIR_HOST)/bin/padjffs2 [email protected] -J $(patsubst %k,,$(BLOCKSIZE))
  67. -rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/
  68. @mv [email protected] $@
  69. endef
  70. define Build/kernel-bin
  71. rm -f $@
  72. cp $< $@
  73. endef
  74. define Build/patch-cmdline
  75. $(STAGING_DIR_HOST)/bin/patch-cmdline $@ '$(CMDLINE)'
  76. endef
  77. define Build/append-kernel
  78. dd if=$(word 1,$^) $(if $(1),bs=$(1) conv=sync) >> $@
  79. endef
  80. define Build/append-rootfs
  81. dd if=$(word 2,$^) $(if $(1),bs=$(1) conv=sync) >> $@
  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 $(word 1,$^)) \
  87. $(word 2,$^) \
  88. [email protected] \
  89. -p $(BLOCKSIZE) -m $(PAGESIZE) -E 5 \
  90. $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE))
  91. cat [email protected] >> $@
  92. rm [email protected]
  93. endef
  94. define Build/pad-to
  95. dd if=$@ [email protected] bs=$(1) conv=sync
  96. mv [email protected] $@
  97. endef
  98. define Build/pad-rootfs
  99. $(STAGING_DIR_HOST)/bin/padjffs2 $@ $(1) 4 8 16 64 128 256
  100. endef
  101. define Build/pad-offset
  102. let \
  103. size="$$(stat -c%s $@)" \
  104. pad="$(word 1, $(1))" \
  105. offset="$(word 2, $(1))" \
  106. pad="(pad - ((size + offset) % pad)) % pad" \
  107. newsize='size + pad'; \
  108. dd if=$@ [email protected] bs=$$newsize count=1 conv=sync
  109. mv [email protected] $@
  110. endef
  111. define Build/check-size
  112. @[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(1))))) -ge "$$(stat -c%s $@)" ] || { \
  113. echo "WARNING: Image file $@ is too big" >&2; \
  114. rm -f $@; \
  115. }
  116. endef
  117. define Build/combined-image
  118. -sh $(TOPDIR)/scripts/combined-image.sh \
  119. "$(word 1,$^)" \
  120. "$@" \
  121. "[email protected]"
  122. @mv [email protected] $@
  123. endef
  124. define Build/sysupgrade-nand
  125. sh $(TOPDIR)/scripts/sysupgrade-nand.sh \
  126. --board $(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)) \
  127. --kernel $(word 1,$^) \
  128. --rootfs $(word 2,$^) \
  129. $@
  130. endef