Makefile 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #
  2. # Copyright (C) 2015 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. FAT32_BLOCK_SIZE=1024
  10. FAT32_BLOCKS=$(shell echo $$(($(CONFIG_SOCFPGA_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
  11. KDIR_TMP:=$(KDIR)/tmp
  12. KDIR_TMP_EXT4:=$(KDIR)/tmp-ext4
  13. # Terasic SoCkit: QSPI NOR, N25Q00A
  14. SOCFPGA_SOCKIT_UBIFS_OPTS="-m 1 -e 65408 -c 2040"
  15. SOCFPGA_SOCKIT_UBI_OPTS="-m 1 -p 64KiB -s 1"
  16. define sanitize_profile_name
  17. $(shell echo $(PROFILE) | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g')
  18. endef
  19. define Image/BuildKernel/Template
  20. ifneq ($(1),)
  21. $(CP) $(DTS_DIR)/$(1).dtb $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb
  22. $(call Image/BuildKernel/MkFIT,$(1),$(KDIR)/zImage,$(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb,none,0x00008000,0x00008000)
  23. $(CP) $(KDIR)/fit-$(1).itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage.itb
  24. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  25. $(call Image/BuildKernel/MkFIT,$(1),$(KDIR)/zImage-initramfs,$(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb,none,0x00008000,0x00008000,-initramfs)
  26. $(CP) $(KDIR)/fit-$(1)-initramfs.itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage-initramfs.itb
  27. endif
  28. endif
  29. $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
  30. $(call Image/BuildKernel/MkuImage, \
  31. none, 0x00008000, 0x00008000, \
  32. $(BIN_DIR)/$(IMG_PREFIX)-zImage, \
  33. $(BIN_DIR)/$(IMG_PREFIX)-uImage \
  34. )
  35. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  36. $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
  37. $(call Image/BuildKernel/MkuImage, \
  38. none, 0x00008000, 0x00008000, \
  39. $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs, \
  40. $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs \
  41. )
  42. endif
  43. endef
  44. define Image/InstallKernel/Template
  45. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_KERNEL)$(CONFIG_TARGET_socfpga_SOCFPGA_SOCKIT),)
  46. $(INSTALL_DIR) $(TARGET_DIR)/boot
  47. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_UIMAGE)$(CONFIG_TARGET_socfpga_SOCFPGA_SOCKIT),)
  48. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/
  49. ln -sf $(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/uImage
  50. endif
  51. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_ZIMAGE),)
  52. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/
  53. ln -sf $(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/zImage
  54. endif
  55. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_FIT),)
  56. $(foreach dts,$(shell echo $(1)),
  57. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(dts)-fit-uImage.itb $(TARGET_DIR)/boot/
  58. )
  59. endif
  60. endif
  61. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_DTB)$(CONFIG_TARGET_socfpga_SOCFPGA_SOCKIT),)
  62. $(INSTALL_DIR) $(TARGET_DIR)/boot
  63. $(foreach dts,$(shell echo $(1)),
  64. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb $(TARGET_DIR)/boot/,
  65. ln -sf $(IMG_PREFIX)-$(dts).dtb $(TARGET_DIR)/boot/$(dts).dtb
  66. )
  67. endif
  68. endef
  69. define Image/Build/SDCard
  70. ifeq ($(1),ext4)
  71. ./gen_socfpga_sdcard_img.sh \
  72. $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-sdcard-vfat-$(1).img \
  73. $(KDIR)/root.$(1) \
  74. $(CONFIG_TARGET_ROOTFS_PARTSIZE) \
  75. $(BIN_DIR)/uboot-socfpga-$(2)/$(IMG_PREFIX)-$(2)-u-boot-with-spl.sfp \
  76. $(KDIR)/cfg.img
  77. endif
  78. endef
  79. define Image/mkfs/targz
  80. $(TAR) -czpf $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
  81. endef
  82. Image/BuildKernel/Template/Generic=$(call Image/BuildKernel/Template)
  83. Image/InstallKernel/Template/Generic=$(call Image/InstallKernel/Template)
  84. Image/BuildKernel/Template/SOCFPGA_SOCKIT=$(foreach dts,$(shell echo $(SOCFPGA_SOCKIT_DTS)),$(call Image/BuildKernel/Template,$(dts)))
  85. Image/InstallKernel/Template/SOCFPGA_SOCKIT=$(call Image/InstallKernel/Template,$(SOCFPGA_SOCKIT_DTS))
  86. define Image/BuildKernel
  87. $(call Image/BuildKernel/Template/$(PROFILE))
  88. endef
  89. define Image/InstallKernel
  90. $(call Image/InstallKernel/Template/$(PROFILE))
  91. endef
  92. define Image/Build/Profile/SOCFPGA_SOCKIT
  93. ifeq ($(1),ext4)
  94. $(call Image/Build/SDCard,$(1),socfpga_cyclone5_sockit)
  95. $(call Image/Build/SysupgradeNAND,$(call sanitize_profile_name),ext4,)
  96. endif
  97. ifeq ($(1),ubifs)
  98. $(call Image/Build/SysupgradeNAND,$(call sanitize_profile_name),ubifs,)
  99. endif
  100. endef
  101. define Image/Build
  102. $(if $(Image/Build/$(1)), \
  103. $(call Image/Build/$(1),$(1)), \
  104. $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-$(1).img \
  105. )
  106. $(if $(Image/Build/Profile/$(PROFILE)), \
  107. $(call Image/Build/Profile/$(PROFILE),$(1)), \
  108. $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-$(1).img \
  109. )
  110. endef
  111. $(eval $(call BuildImage))