Makefile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #
  2. # Copyright (C) 2016 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. # On ARC initramfs is put before entry point and so entry point moves
  10. # in memory from build to built. Thus we need to extract EP from vmlinux
  11. # every time before generation of uImage.
  12. kernel_ep = `$(KERNEL_CROSS)readelf -h $(1) | grep "Entry point address" | grep -o 0x.*`
  13. define Build/patch-dtb
  14. $(STAGING_DIR_HOST)/bin/patch-dtb $@ $(DTS_DIR)/$(DEVICE_DTS).dtb
  15. endef
  16. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  17. # Root FS built-in
  18. define Device/vmlinux
  19. KERNEL_SUFFIX := .elf
  20. KERNEL := kernel-bin | patch-dtb
  21. KERNEL_INITRAMFS_NAME = vmlinux-initramfs.elf
  22. endef
  23. define Device/nsim_hs
  24. $(call Device/vmlinux)
  25. DEVICE_PROFILE := nsim_hs
  26. DEVICE_DTS := nsim_hs_idu
  27. endef
  28. TARGET_DEVICES += nsim_hs
  29. endif
  30. # Root FS on SD-card
  31. KERNEL_LOADADDR := 0x80000000
  32. DEVICE_DTS_LIST:= axs103_idu nsim_hs_idu
  33. FAT32_BLOCK_SIZE=1024
  34. FAT32_BLOCKS=$(shell echo $$(($(CONFIG_AXS10X_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
  35. define Image/Prepare
  36. # Build .dtb for all boards we may run on
  37. $(foreach dts,$(DEVICE_DTS_LIST),
  38. $(call Image/BuildDTB,$(DTS_DIR)/$(dts).dts,$(DTS_DIR)/$(dts).dtb)
  39. )
  40. endef
  41. define Image/Build/SDCard
  42. rm -f $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img
  43. mkfs.fat $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img -C $(FAT32_BLOCKS)
  44. mkimage -C none -A arc -T script -d uEnv.txt $(BIN_DIR)/uEnv.scr
  45. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(BIN_DIR)/uEnv.scr ::boot.scr
  46. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(DTS_DIR)/*.dtb ::
  47. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(BIN_DIR)/$(IMG_PREFIX)-uImage ::uImage
  48. ./gen_axs10x_sdcard_img.sh \
  49. $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img \
  50. $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img \
  51. $(KDIR)/root.$(1) \
  52. $(CONFIG_AXS10X_SD_BOOT_PARTSIZE) \
  53. $(CONFIG_TARGET_ROOTFS_PARTSIZE)
  54. ifneq ($(CONFIG_TARGET_IMAGES_GZIP),)
  55. gzip -f9n $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img
  56. endif
  57. endef
  58. define Image/BuildKernel
  59. # Build unified uImage
  60. $(call Image/BuildKernel/MkuImage, \
  61. none, $(KERNEL_LOADADDR),$(call kernel_ep,$(KDIR)/vmlinux.elf) , \
  62. $(KDIR)/vmlinux, \
  63. $(BIN_DIR)/$(IMG_PREFIX)-uImage \
  64. )
  65. endef
  66. define Image/Build
  67. $(call Image/Build/$(1),$(1))
  68. $(call Image/Build/SDCard,$(1))
  69. dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
  70. $(call Image/Gzip,$(BIN_DIR)/$(IMG_PREFIX)-root.$(1))
  71. endef
  72. $(eval $(call BuildImage))