Makefile 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. #
  2. # This is free software, licensed under the GNU General Public License v2.
  3. # See /LICENSE for more information.
  4. #
  5. include $(TOPDIR)/rules.mk
  6. include $(INCLUDE_DIR)/image.mk
  7. DEVICE_VARS += DEVICE_PROFILE IMAGE_SIZE DTB_SIZE
  8. define Device/Default
  9. PROFILES := Default
  10. KERNEL_DEPENDS = $$(wildcard ../dts/$$(DEVICE_DTS).dts)
  11. DEVICE_PROFILE :=
  12. DEVICE_DTS :=
  13. KERNEL_ENTRY := 0x00000000
  14. KERNEL_LOADADDR := 0x00000000
  15. DEVICE_DTS_DIR := ../dts
  16. endef
  17. define Build/dtb
  18. $(call Image/BuildDTB,../dts/$(DEVICE_DTS).dts,[email protected],,--space $(DTB_SIZE))
  19. endef
  20. define Build/export-dtb
  21. cp $(IMAGE_KERNEL).dtb $@
  22. endef
  23. ifeq ($(SUBTARGET),nand)
  24. define Image/cpiogz
  25. ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9n >$(KDIR_TMP)/$(IMG_PREFIX)-rootfs.cpio.gz )
  26. endef
  27. define Build/copy-file
  28. cat "$(1)" > "$@"
  29. endef
  30. define Build/MerakiAdd-dtb
  31. $(call Image/BuildDTB,../dts/$(DEVICE_DTS).dts,[email protected])
  32. ( \
  33. dd [email protected] bs=$(DTB_SIZE) conv=sync; \
  34. dd if=$@ bs=$(BLOCKSIZE) conv=sync; \
  35. ) > [email protected]
  36. @mv [email protected] $@
  37. endef
  38. define Build/MerakiAdd-initramfs
  39. $(call Image/cpiogz)
  40. -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) -O linux -T ramdisk \
  41. -C gzip -n "$(PROFILE) rootfs" \
  42. -d $(KDIR_TMP)/$(IMG_PREFIX)-rootfs.cpio.gz \
  43. $(KDIR_TMP)/$(IMG_PREFIX)-uramdisk.image.gz
  44. ( \
  45. dd if=$@ bs=1k conv=sync; \
  46. dd if=$(KDIR_TMP)/$(IMG_PREFIX)-uramdisk.image.gz bs=$(BLOCKSIZE) conv=sync; \
  47. ) > [email protected]
  48. @mv [email protected] $@
  49. endef
  50. define Build/MerakiNAND
  51. -$(STAGING_DIR_HOST)/bin/mkmerakifw \
  52. -B $(DEVICE_PROFILE) -s \
  53. -i $@ \
  54. -o [email protected]
  55. @cp [email protected] $@
  56. endef
  57. define Device/mr24
  58. DEVICE_TITLE := Cisco Meraki MR24
  59. DEVICE_PACKAGES := kmod-spi-gpio kmod-ath9k wpad-mini
  60. DEVICE_PROFILE := MR24
  61. DEVICE_DTS := MR24
  62. BLOCKSIZE := 63k
  63. IMAGES := sysupgrade.tar
  64. DTB_SIZE := 64512
  65. KERNEL_SIZE := 1984k
  66. IMAGE_SIZE := 8191k
  67. KERNEL := kernel-bin | lzma | uImage lzma | MerakiAdd-dtb | MerakiNAND
  68. KERNEL_INITRAMFS := copy-file $(KDIR)/vmlinux | lzma | uImage lzma | \
  69. check-size $$(KERNEL_SIZE) | \
  70. MerakiAdd-dtb | pad-to 2047k | MerakiAdd-initramfs | \
  71. MerakiNAND
  72. IMAGE/sysupgrade.tar := sysupgrade-tar
  73. UBINIZE_OPTS := -E 5
  74. endef
  75. TARGET_DEVICES += mr24
  76. define Device/mx60
  77. DEVICE_TITLE := Cisco Meraki MX60
  78. DEVICE_PACKAGES := kmod-spi-gpio swconfig kmod-usb-ledtrig-usbport \
  79. kmod-usb-dwc2 kmod-usb-storage block-mount
  80. DEVICE_PROFILE := MX60
  81. DEVICE_DTS := MX60
  82. BLOCKSIZE := 63k
  83. IMAGES := sysupgrade.tar
  84. DTB_SIZE := 64512
  85. # The kernel size will need to match the offset defined in mkmerakifw.c,
  86. # otherwise the final image will fail to boot. This is set within the
  87. # MX60 kernel header definition which is found at
  88. # ./tools/firmware-utils/src/mkmerakifw.c, line 103~
  89. KERNEL_SIZE := 2984k
  90. IMAGE_SIZE := 1021m
  91. KERNEL := kernel-bin | gzip | uImage gzip | MerakiAdd-dtb | MerakiNAND
  92. KERNEL_INITRAMFS := copy-file $(KDIR)/vmlinux | gzip | uImage gzip | \
  93. check-size $$(KERNEL_SIZE) | \
  94. MerakiAdd-dtb | pad-to 2047k | MerakiAdd-initramfs | \
  95. MerakiNAND
  96. IMAGE/sysupgrade.tar := sysupgrade-tar
  97. UBINIZE_OPTS := -E 5
  98. endef
  99. TARGET_DEVICES += mx60
  100. define Device/mx60w
  101. $(Device/mx60)
  102. DEVICE_TITLE := Cisco Meraki MX60W
  103. DEVICE_PACKAGES += kmod-ath9k wpad-mini
  104. endef
  105. TARGET_DEVICES += mx60w
  106. define Build/create-uImage-dtb
  107. # flat_dt target expect FIT image - which WNDR4700's uboot doesn't support
  108. -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) \
  109. -O linux -T kernel -C none \
  110. -n '$(call toupper,$(LINUX_KARCH)) LEDE Linux-$(LINUX_VERSION)' \
  111. -d $(IMAGE_KERNEL).dtb [email protected]
  112. @mv [email protected] $@
  113. endef
  114. define Build/wndr4700-specialImage
  115. rm -rf [email protected] [email protected]
  116. dd if=/dev/zero [email protected] bs=32 count=1 conv=sync
  117. # Netgear used an old uboot that doesn't have FIT support.
  118. # So we are stuck with either a full ext2/4 fs in a initrd.
  119. # ... or we try to make the "multi" image approach to work
  120. # for us.
  121. #
  122. # Sadly, the "multi" image has to consists of three
  123. # "fixed" parts in the following "fixed" order:
  124. # 1. The kernel which is in $@
  125. # 2. The (fake) initrd which is in [email protected]
  126. # 3. The device tree binary which is in [email protected]
  127. #
  128. # Now, given that we use the function for the kernel which
  129. # already has a initramfs image inside, we still have to
  130. # add a "fake" initrd (which a mkimage header) in the second
  131. # part of the legacy multi image. Since we need to put the
  132. # device tree stuff into part 3.
  133. -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) -O linux -T multi \
  134. -C $(1) -a $(KERNEL_LOADADDR) -e $(KERNEL_ENTRY) \
  135. -n '$(DEVICE_PROFILE) initramfs' -d $@:[email protected]:[email protected] [email protected]
  136. mv [email protected] $@
  137. rm -rf [email protected]
  138. endef
  139. define Device/WNDR4700
  140. DEVICE_TITLE := Netgear Centria N900 WNDR4700/WNDR4720
  141. DEVICE_PACKAGES := badblocks block-mount e2fsprogs \
  142. kmod-ath9k kmod-dm kmod-fs-ext4 kmod-fs-vfat kmod-usb-ledtrig-usbport \
  143. kmod-md-mod kmod-nls-cp437 kmod-nls-iso8859-1 kmod-nls-iso8859-15 \
  144. kmod-nls-utf8 kmod-usb3 kmod-usb-dwc2 kmod-usb-storage \
  145. partx-utils swconfig wpad-mini
  146. DEVICE_NAME := wndr4700
  147. DEVICE_PROFILE := wndr4700
  148. DEVICE_DTS := wndr4700
  149. PAGESIZE := 2048
  150. SUBPAGESIZE := 512
  151. BLOCKSIZE := 128k
  152. DTB_SIZE := 131008
  153. IMAGE_SIZE := 24960k
  154. IMAGES := factory.img sysupgrade.tar kernel.dtb
  155. KERNEL_SIZE := 1920k
  156. KERNEL := dtb | kernel-bin | lzma | uImage lzma | pad-offset $$(BLOCKSIZE) 64 | \
  157. append-uImage-fakeroot-hdr
  158. KERNEL_INITRAMFS := kernel-bin | gzip | dtb | wndr4700-specialImage gzip
  159. IMAGE/factory.img := create-uImage-dtb | append-kernel | pad-to 2M | append-ubi | \
  160. netgear-dni | check-size $$$$(IMAGE_SIZE)
  161. IMAGE/sysupgrade.tar := sysupgrade-tar
  162. IMAGE/kernel.dtb := export-dtb | uImage none
  163. NETGEAR_BOARD_ID := WNDR4700
  164. NETGEAR_HW_ID := 29763875+128+256
  165. UBINIZE_OPTS := -E 5
  166. endef
  167. TARGET_DEVICES += WNDR4700
  168. endif
  169. ifeq ($(SUBTARGET),sata)
  170. ### Image scripts for the WD My Book Live Series ###
  171. define Build/boot-script
  172. $(STAGING_DIR_HOST)/bin/mkimage -A powerpc -T script -C none -n "$(PROFILE) Boot Script" \
  173. -d mbl_boot.scr \
  174. [email protected]
  175. endef
  176. define Build/boot-img
  177. $(RM) -rf [email protected]
  178. mkdir -p [email protected]/boot
  179. $(CP) [email protected] [email protected]/boot/boot.scr
  180. $(CP) $(IMAGE_KERNEL).dtb [email protected]/boot/$(DEVICE_DTB)
  181. $(CP) $(IMAGE_KERNEL) [email protected]/boot/uImage
  182. genext2fs --block-size $(BLOCKSIZE:%k=%Ki) --size-in-blocks $$((1024 * $(BOOT_SIZE))) --root [email protected] [email protected]
  183. # convert it to revision 1 - needed for u-boot ext2load
  184. $(STAGING_DIR_HOST)/bin/tune2fs -O filetype [email protected]
  185. $(STAGING_DIR_HOST)/bin/e2fsck -pDf [email protected] > /dev/null
  186. endef
  187. define Build/hdd-img
  188. ./mbl_gen_hdd_img.sh $@ [email protected] $(IMAGE_ROOTFS)
  189. endef
  190. define Device/MyBookLiveDefault
  191. IMAGE_SIZE := 48m
  192. BLOCKSIZE := 1k
  193. DTB_SIZE := 16384
  194. KERNEL := kernel-bin | dtb | gzip | uImage gzip
  195. KERNEL_INITRAMFS := kernel-bin | dtb | gzip | uImage gzip
  196. BOOT_SIZE := 8
  197. IMAGES := rootfs.img kernel.dtb
  198. DEVICE_DTB := apollo3g.dtb
  199. FILESYSTEMS := ext4
  200. IMAGE/kernel.dtb := export-dtb
  201. IMAGE/rootfs.img := boot-script | boot-img | hdd-img
  202. endef
  203. define Device/MyBookLiveSingle
  204. $(Device/MyBookLiveDefault)
  205. DEVICE_TITLE := Western Digital My Book Live
  206. DEVICE_DTS := apollo3g
  207. DEVICE_PROFILE := apollo3g
  208. endef
  209. TARGET_DEVICES += MyBookLiveSingle
  210. define Device/MyBookLiveDuo
  211. $(Device/MyBookLiveDefault)
  212. DEVICE_TITLE := Western Digital My Book Live Duo
  213. DEVICE_PACKAGES := kmod-usb-dwc2 kmod-usb-ledtrig-usbport kmod-usb-storage kmod-fs-vfat wpad-mini
  214. DEVICE_DTS := apollo3g-duo
  215. DEVICE_PROFILE := ap2nc
  216. endef
  217. TARGET_DEVICES += MyBookLiveDuo
  218. endif
  219. $(eval $(call BuildImage))