Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #
  2. # Copyright (C) 2013 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. include $(INCLUDE_DIR)/image.mk
  9. define Image/Prepare
  10. $(CP) $(DTS_DIR)/*.dtb $(KDIR)/
  11. rm -f $(KDIR)/fs_mark
  12. echo -ne '\xde\xad\xc0\xde' > $(KDIR)/fs_mark
  13. $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
  14. # For UBI we want only one extra block
  15. rm -f $(KDIR)/ubi_mark
  16. echo -ne '\xde\xad\xc0\xde' > $(KDIR)/ubi_mark
  17. $(CP) ./ubinize.cfg $(KDIR)
  18. endef
  19. define Build/append-dtb
  20. cat $(KDIR)/$(DT).dtb >> $@
  21. endef
  22. define Build/lzma-d16
  23. $(STAGING_DIR_HOST)/bin/lzma e $@ -d16 $(1) $@.new
  24. @mv $@.new $@
  25. endef
  26. define Build/mkfs/squashfs
  27. ( cd $(KDIR); $(STAGING_DIR_HOST)/bin/ubinize -p 128KiB -m 2048 -o $(KDIR)/root-block-0x20000-min-0x800.ubi ubinize.cfg )
  28. endef
  29. define Build/trx-serial
  30. $(STAGING_DIR_HOST)/bin/trx \
  31. -o $@ \
  32. -m 33554432 \
  33. -f $(word 1,$^) -a 1024 \
  34. -f $(KDIR)/root.squashfs -a 0x10000 -A $(KDIR)/fs_mark
  35. endef
  36. define Build/trx-nand
  37. # kernel: always use 4 MiB (-28 B or TRX header) to allow upgrades even
  38. # if it grows up between releases
  39. # root: UBI with one extra block containing UBI mark to trigger erasing
  40. # rest of partition
  41. $(STAGING_DIR_HOST)/bin/trx \
  42. -o $@ \
  43. -m 33554432 \
  44. -f $(word 1,$^) -a 0x20000 -b 0x400000 \
  45. -f $(KDIR)/root-block-0x20000-min-0x800.ubi \
  46. -A $(KDIR)/ubi_mark -a 0x20000
  47. endef
  48. define Build/asus-trx
  49. $(STAGING_DIR_HOST)/bin/asustrx \
  50. -p $(PRODUCTID) -i $@ -o $@.new
  51. mv $@.new $@
  52. endef
  53. define Build/netgear-chk
  54. $(STAGING_DIR_HOST)/bin/mkchkimg \
  55. -o $@.new -k $@ -b $(BOARD_ID) -r $(REGION)
  56. mv $@.new $@
  57. endef
  58. define Build/seama-nand
  59. # Seama entity
  60. $(STAGING_DIR_HOST)/bin/oseama \
  61. entity $@.entity \
  62. -m "dev=/dev/mtdblock/7" \
  63. -m "type=firmware" \
  64. -f $(word 1,$^) \
  65. -b 0x400000 \
  66. -f $(KDIR)/root-block-0x20000-min-0x800.ubi \
  67. -f $(KDIR)/ubi_mark
  68. # Seama container
  69. $(STAGING_DIR_HOST)/bin/seama \
  70. -s $@ \
  71. -m "signature=$(SIGNATURE)" \
  72. -i $@.entity
  73. endef
  74. DEVICE_VARS += DT PRODUCTID SIGNATURE BOARD_ID REGION
  75. define Device/Default
  76. # .dtb files are prefixed by SoC type, e.g. bcm4708- which is not included in device/image names
  77. # extract the full dtb name based on the device info
  78. DT := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb)))
  79. KERNEL := kernel-bin | append-dtb | lzma-d16
  80. FILESYSTEMS := squashfs
  81. KERNEL_NAME := zImage
  82. IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
  83. IMAGES := trx
  84. IMAGE/trx := trx-nand
  85. endef
  86. define Device/asus
  87. IMAGES := trx
  88. IMAGE/trx := trx-nand | asus-trx
  89. endef
  90. define AsusDevice
  91. define Device/asus-$(1)
  92. $$(Device/asus)
  93. PRODUCTID := $(2)
  94. endef
  95. TARGET_DEVICES += asus-$(1)
  96. endef
  97. define Device/dlink
  98. IMAGES := bin
  99. IMAGE/bin := seama-nand
  100. endef
  101. define DLinkDevice
  102. define Device/dlink-$(1)
  103. $$(Device/dlink)
  104. SIGNATURE := $(2)
  105. endef
  106. TARGET_DEVICES += dlink-$(1)
  107. endef
  108. define Device/netgear
  109. IMAGES := chk
  110. IMAGE/chk := trx-nand | netgear-chk
  111. REGION := 1
  112. endef
  113. define NetgearDevice
  114. define Device/netgear-$(1)
  115. $$(Device/netgear)
  116. BOARD_ID := $(2)
  117. endef
  118. TARGET_DEVICES += netgear-$(1)
  119. endef
  120. define Device/netgear-r6250
  121. $(Device/netgear)
  122. BOARD_ID := U12H245T00_NETGEAR
  123. endef
  124. define Device/netgear-r6300-v2
  125. $(Device/netgear)
  126. BOARD_ID := U12H240T00_NETGEAR
  127. endef
  128. define Device/netgear-r8000
  129. $(Device/netgear)
  130. BOARD_ID := U12H315T00_NETGEAR
  131. endef
  132. define Device/smartrg-sr400ac
  133. IMAGES := trx
  134. IMAGE/trx := trx-serial
  135. endef
  136. TARGET_DEVICES += \
  137. buffalo-wzr-1750dhp buffalo-wzr-600dhp2 buffalo-wzr-900dhp \
  138. buffalo-wxr-1900dhp \
  139. netgear-r6250 netgear-r6300-v2 netgear-r8000 \
  140. smartrg-sr400ac
  141. $(eval $(call AsusDevice,rt-ac56u,RT-AC56U))
  142. $(eval $(call AsusDevice,rt-ac68u,RT-AC68U))
  143. $(eval $(call AsusDevice,rt-ac87u,RT-AC87U))
  144. $(eval $(call AsusDevice,rt-n18u,RT-N18U))
  145. # $(eval $(call DLinkDevice,dir-885l,wrgac42_dlink.2015_dir885l))
  146. $(eval $(call NetgearDevice,r7000,U12H270T00_NETGEAR))
  147. # $(eval $(call NetgearDevice,r8500,U12H334T00_NETGEAR))
  148. $(eval $(call BuildImage))