Makefile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. #################################################
  10. # Images
  11. #################################################
  12. # build a ubi for a specific flash geometry/layout which can contain
  13. # volumes with the following data from ubinize-$(DEVICE_NAME).cfg:
  14. # - 'boot.ubifs' volume: kernel+dtbs+bootscript
  15. # - 'root.squashfs' volume: rootfs
  16. # $(1): name (used for suffix)
  17. # $(2): PAGESIZE (-m param to mkfs.ubifs/ubinize)
  18. # $(3): ERASESIZE (logical eraseblock size: -e param to mkfs.ubifs)
  19. # $(4): BLOCKSIZE (-p param to ubinize)
  20. # $(5): MAXSIZE (maximum file-system size in LEB's -c param to mkfs.ubifs)
  21. #
  22. define Build/ubi-boot-overlay
  23. # ubi-boot-overlay $(DEVICE_NAME) $(word 1, $(1))
  24. # boot filesystem
  25. rm -rf $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))
  26. mkdir -p $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))
  27. $(CP) $< $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))/$(IMG_PREFIX)-uImage
  28. ln -sf $(IMG_PREFIX)-uImage \
  29. $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))/uImage
  30. $(foreach dts,$(shell echo $(DEVICE_DTS)), \
  31. $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/$(dts).dtb \
  32. $(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb; \
  33. $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/$(dts).dtb \
  34. $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))/$(IMG_PREFIX)-$(dts).dtb; \
  35. ln -sf $(IMG_PREFIX)-$(dts).dtb \
  36. $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))/$(dts).dtb; \
  37. )
  38. mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
  39. -n '$(DEVICE_ID) OpenWrt bootscript' \
  40. -d ./bootscript-$(DEVICE_NAME) \
  41. $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))/6x_bootscript-$(DEVICE_NAME)
  42. $(STAGING_DIR_HOST)/bin/mkfs.ubifs \
  43. --space-fixup --force-compr=zlib --squash-uids \
  44. -m $(word 2, $(1)) -e $(word 3, $(1)) -c $(word 5, $(1)) \
  45. -o $(KDIR)/boot-$(DEVICE_NAME)-bootfs_$(word 1, $(1)).ubifs \
  46. -d $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))
  47. $(CP) $(KDIR)/boot-$(DEVICE_NAME)-bootfs_$(word 1, $(1)).ubifs \
  48. $(BIN_DIR)/$(IMG_PREFIX)-$(DEVICE_NAME)-bootfs_$(word 1, $(1)).ubifs
  49. # ubi
  50. rm -rf p $(KDIR)/$(DEVICE_NAME)_$(word 1, $(1))
  51. mkdir -p $(KDIR)/$(DEVICE_NAME)_$(word 1, $(1))
  52. $(CP) $(word 2, $^) \
  53. $(KDIR)/$(DEVICE_NAME)_$(word 1, $(1))/
  54. $(CP) $(KDIR)/boot-$(DEVICE_NAME)-bootfs_$(word 1, $(1)).ubifs \
  55. $(KDIR)/$(DEVICE_NAME)_$(word 1, $(1))/boot.ubifs
  56. $(CP) ./ubinize-$(DEVICE_NAME).cfg \
  57. $(KDIR)/$(DEVICE_NAME)_$(word 1, $(1))/ubinize.cfg
  58. ( cd $(KDIR)/$(DEVICE_NAME)_$(word 1, $(1)); \
  59. $(STAGING_DIR_HOST)/bin/ubinize \
  60. -m $(word 2, $(1)) -p $(word 4, $(1)) -s $(word 2, $(1)) \
  61. -o $@ \
  62. ubinize.cfg \
  63. )
  64. endef
  65. define Build/bootfs.tar.gz
  66. # boot filesystem
  67. rm -rf $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)
  68. mkdir -p $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)
  69. $(CP) $< $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/$(IMG_PREFIX)-uImage
  70. ln -sf $(IMG_PREFIX)-uImage \
  71. $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/uImage
  72. $(foreach dts,$(shell echo $(DEVICE_DTS)), \
  73. $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/$(dts).dtb \
  74. $(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb; \
  75. $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/$(dts).dtb \
  76. $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/$(IMG_PREFIX)-$(dts).dtb; \
  77. ln -sf $(IMG_PREFIX)-$(dts).dtb \
  78. $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/$(dts).dtb; \
  79. )
  80. mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
  81. -n '$(DEVICE_ID) OpenWrt bootscript' \
  82. -d ./bootscript-$(DEVICE_NAME) \
  83. $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/6x_bootscript-$(DEVICE_NAME)
  84. # tar and zip
  85. ( \
  86. cd $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME); \
  87. $(TAR) --numeric-owner --owner=0 --group=0 --transform "s,./,./boot/," \
  88. -czvf $(BIN_DIR)/$(IMG_PREFIX)-$(DEVICE_NAME)-bootfs.tar.gz . ; \
  89. )
  90. endef
  91. #################################################
  92. # Devices
  93. #################################################
  94. KERNEL_LOADADDR=0x10008000
  95. define Device/Default
  96. DEVICE_DTS :=
  97. FILESYSTEMS := squashfs ext4
  98. KERNEL_INSTALL := 1
  99. KERNEL_SUFFIX := -uImage
  100. KERNEL_NAME := zImage
  101. KERNEL_PREFIX := $$(IMAGE_PREFIX)
  102. KERNEL := kernel-bin | uImage none
  103. IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
  104. IMAGES :=
  105. endef
  106. DEVICE_VARS += DEVICE_DTS
  107. define Device/ventana
  108. PROFILES = Generic VENTANA
  109. DEVICE_DTS:= \
  110. imx6dl-gw51xx \
  111. imx6dl-gw52xx \
  112. imx6dl-gw53xx \
  113. imx6dl-gw54xx \
  114. imx6dl-gw551x \
  115. imx6dl-gw552x \
  116. imx6q-gw51xx \
  117. imx6q-gw52xx \
  118. imx6q-gw53xx \
  119. imx6q-gw54xx \
  120. imx6q-gw5400-a \
  121. imx6q-gw551x \
  122. imx6q-gw552x
  123. IMAGES := nand_normal.ubi nand_large.ubi bootfs.tar.gz
  124. IMAGE/nand_normal.ubi := ubi-boot-overlay normal 2048 124KiB 128KiB 8124
  125. IMAGE/nand_large.ubi := ubi-boot-overlay large 4096 248KiB 256KiB 8124
  126. IMAGE/bootfs.tar.gz := bootfs.tar.gz
  127. IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1)-$$(2)
  128. endef
  129. define Device/wandboard
  130. PROFILES = Generic IMX6DL_WANDBOARD
  131. DEVICE_DTS := imx6dl-wandboard
  132. endef
  133. TARGET_DEVICES += \
  134. ventana \
  135. wandboard
  136. $(eval $(call BuildImage))