Makefile 2.6 KB

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