Makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. include $(INCLUDE_DIR)/host.mk
  10. FAT32_BLOCK_SIZE=1024
  11. FAT32_BLOCKS=$(shell echo $$(($(CONFIG_ZYNQ_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
  12. #################################################
  13. # Images
  14. #################################################
  15. define Image/boot-imgs
  16. # Copy zImage to BIN_DIR
  17. $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
  18. $(call Image/BuildKernel/MkuImage, none, $(KERNEL_LOADADDR), \
  19. $(KERNEL_ENTRY_POINT), $(KDIR)/zImage, \
  20. $(BIN_DIR)/$(IMG_PREFIX)-uImage)
  21. $(call Image/BuildDTB,$(DTS_DIR)/$(DEVICE_DTS).dts,\
  22. $(BIN_DIR)/$(IMG_PREFIX)-system.dtb)
  23. $(call Image/mkfs/cpiogz)
  24. $(call Image/mkfs/targz)
  25. # Create uboot cpio.gz
  26. mkimage -A arm -T ramdisk -C gzip -n "$(PROFILE) OpenWRT rootfs" \
  27. -d $(BIN_DIR)/$(IMG_PREFIX)-rootfs.cpio.gz \
  28. $(BIN_DIR)/$(IMG_PREFIX)-uramdisk.image.gz
  29. # create FIT image with rootfs
  30. ./mkits.sh \
  31. -D $(DEVICE_LC) -o $(KDIR)/fit-$(DEVICE_LC).its -k $(KDIR)/zImage \
  32. -d $(BIN_DIR)/$(IMG_PREFIX)-system.dtb \
  33. -C none -a $(KERNEL_LOADADDR) -e $(KERNEL_ENTRY_POINT) \
  34. -A $(ARCH) -v $(LINUX_VERSION) \
  35. -r $(BIN_DIR)/$(IMG_PREFIX)-rootfs.cpio.gz -z gzip
  36. PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/fit-$(DEVICE_LC).its $(KDIR)/fit-$(DEVICE_LC).itb
  37. $(CP) $(KDIR)/fit-$(DEVICE_LC).itb $(BIN_DIR)/$(IMG_PREFIX)-fit.itb
  38. ln -fs $(IMG_PREFIX)-fit.itb $(BIN_DIR)/fit.itb
  39. endef
  40. define Image/Build/Zynq
  41. # Create SD card image
  42. rm -f $(KDIR_TMP)/$(IMG_PREFIX)-boot.img
  43. mkfs.fat $(KDIR_TMP)/$(IMG_PREFIX)-boot.img -C $(FAT32_BLOCKS)
  44. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-boot.img $(KDIR)/uboot-$(IMG_PREFIX)-u-boot.bin ::boot.bin
  45. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-boot.img $(BIN_DIR)/$(DEVICE_DTS)-system.dtb ::devicetree.dtb
  46. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-boot.img $(KDIR)/uboot-$(IMG_PREFIX)-u-boot-dtb.img ::u-boot.img
  47. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-boot.img $(KDIR)/uboot-$(IMG_PREFIX)-uEnv.txt ::uEnv.txt
  48. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-boot.img $(BIN_DIR)/$(IMG_PREFIX)-uImage ::uImage
  49. ./gen_zynq_sdcard_img.sh \
  50. $(BIN_DIR)/$(IMG_PREFIX)-sdcard-vfat-$(1).img \
  51. $(KDIR_TMP)/$(IMG_PREFIX)-boot.img \
  52. $(KDIR)/root.$(1) \
  53. $(CONFIG_ZYNQ_SD_BOOT_PARTSIZE) \
  54. $(CONFIG_TARGET_ROOTFS_PARTSIZE)
  55. $(if $(CONFIG_TARGET_IMAGES_GZIP),gzip -9n -c $(BIN_DIR)/$(IMG_PREFIX)-sdcard-vfat-$(1).img > $(BIN_DIR)/$(IMG_PREFIX)-sdcard-vfat-$(1).img.gz)
  56. endef
  57. #################################################
  58. # Devices
  59. #################################################
  60. # default kernel load address
  61. KERNEL_LOADADDR=0x8000
  62. KERNEL_ENTRY_POINT=0x8000
  63. ### Device macros ###
  64. define Device/Default
  65. IMG_PREFIX := zynq
  66. DEVICE_DTS :=
  67. PROFILE_SANITIZED :=
  68. endef
  69. DEVICE_VARS += DEVICE_DTS
  70. define Device/DefaultConfig
  71. DEVICE_LC = $(1)
  72. IMG_PREFIX = zynq-$(1)
  73. DEVICE_DTS = zynq-$(1)
  74. endef
  75. ### ZC702 ###
  76. define Device/ZC702
  77. $(call Device/DefaultConfig,zc702)
  78. endef
  79. define Device/ZED
  80. $(call Device/DefaultConfig,zed)
  81. endef
  82. define Device/ZYBO
  83. $(call Device/DefaultConfig,zybo)
  84. endef
  85. define Image/BuildKernel
  86. $(eval $(call Device/$(PROFILE)))
  87. $(call Image/boot-imgs)
  88. endef
  89. define Image/Build
  90. $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).img
  91. $(call Image/Build/Zynq,$(1))
  92. endef
  93. $(eval $(call BuildImage))