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. endef
  18. define Build/append-dtb
  19. cat $(KDIR)/$(DT).dtb >> $@
  20. endef
  21. define Build/lzma-d16
  22. $(STAGING_DIR_HOST)/bin/lzma e $@ -d16 $(1) $@.new
  23. mv $@.new $@
  24. endef
  25. define Build/trx-serial
  26. $(STAGING_DIR_HOST)/bin/trx \
  27. -o $@.new \
  28. -m 33554432 \
  29. -f $(word 1,$^) -a 1024 \
  30. -f $@ -a 0x10000 -A $(KDIR)/fs_mark
  31. mv $@.new $@
  32. endef
  33. define Build/trx-nand
  34. # kernel: always use 4 MiB (-28 B or TRX header) to allow upgrades even
  35. # if it grows up between releases
  36. # root: UBI with one extra block containing UBI mark to trigger erasing
  37. # rest of partition
  38. $(STAGING_DIR_HOST)/bin/trx \
  39. -o $@.new \
  40. -m 33554432 \
  41. -f $(word 1,$^) -a 0x20000 -b 0x400000 \
  42. -f $@ \
  43. -A $(KDIR)/ubi_mark -a 0x20000
  44. mv $@.new $@
  45. endef
  46. define Build/asus-trx
  47. $(STAGING_DIR_HOST)/bin/asustrx \
  48. -p $(PRODUCTID) -i $@ -o $@.new
  49. mv $@.new $@
  50. endef
  51. define Build/seama-nand
  52. # Seama entity
  53. $(STAGING_DIR_HOST)/bin/oseama \
  54. entity $@.entity \
  55. -m "dev=/dev/mtdblock/7" \
  56. -m "type=firmware" \
  57. -f $(word 1,$^) \
  58. -b 0x400000 \
  59. -f $@ \
  60. -f $(KDIR)/ubi_mark
  61. # Seama container
  62. $(STAGING_DIR_HOST)/bin/seama \
  63. -s $@ \
  64. -m "signature=$(SIGNATURE)" \
  65. -i $@.entity
  66. endef
  67. DEVICE_VARS += DT PRODUCTID SIGNATURE NETGEAR_BOARD_ID NETGEAR_REGION
  68. define Device/Default
  69. # .dtb files are prefixed by SoC type, e.g. bcm4708- which is not included in device/image names
  70. # extract the full dtb name based on the device info
  71. DT := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb)))
  72. KERNEL := kernel-bin | append-dtb | lzma-d16
  73. KERNEL_DEPENDS = $$(wildcard $(KDIR)/$$(DT).dts)
  74. FILESYSTEMS := squashfs
  75. KERNEL_NAME := zImage
  76. IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
  77. IMAGES := trx
  78. BLOCKSIZE := 128KiB
  79. PAGESIZE := 2048
  80. UBINIZE_OPTS :=
  81. IMAGE/trx := append-ubi | trx-nand
  82. endef
  83. define Device/asus
  84. IMAGES := trx
  85. IMAGE/trx := append-ubi | trx-nand | asus-trx
  86. endef
  87. define AsusDevice
  88. define Device/asus-$(1)
  89. $$(Device/asus)
  90. PRODUCTID := $(2)
  91. endef
  92. TARGET_DEVICES += asus-$(1)
  93. endef
  94. define LinksysDevice
  95. TARGET_DEVICES += linksys-$(1)
  96. endef
  97. define Device/dlink
  98. IMAGES := bin
  99. IMAGE/bin := append-ubi | 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 := append-ubi | trx-nand | netgear-chk
  111. NETGEAR_REGION := 1
  112. endef
  113. define NetgearDevice
  114. define Device/netgear-$(1)
  115. $$(Device/netgear)
  116. NETGEAR_BOARD_ID := $(2)
  117. endef
  118. TARGET_DEVICES += netgear-$(1)
  119. endef
  120. define Device/netgear-r6250
  121. $(Device/netgear)
  122. NETGEAR_BOARD_ID := U12H245T00_NETGEAR
  123. endef
  124. define Device/netgear-r6300-v2
  125. $(Device/netgear)
  126. NETGEAR_BOARD_ID := U12H240T00_NETGEAR
  127. endef
  128. define Device/netgear-r8000
  129. $(Device/netgear)
  130. NETGEAR_BOARD_ID := U12H315T00_NETGEAR
  131. endef
  132. define Device/smartrg-sr400ac
  133. IMAGES := trx
  134. IMAGE/trx := append-rootfs | 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 LinksysDevice,ea6300-v1))
  147. $(eval $(call NetgearDevice,r7000,U12H270T00_NETGEAR))
  148. $(eval $(call NetgearDevice,r7900,U12H315T30_NETGEAR))
  149. # $(eval $(call NetgearDevice,r8500,U12H334T00_NETGEAR))
  150. $(eval $(call BuildImage))