Makefile 2.7 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. 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 := 0x90000000
  32. DEVICE_DTS_LIST:= axs103_idu nsim_hs_idu hsdk
  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. mkenvimage -s 0x4000 -o $(BIN_DIR)/uboot.env ./uboot.env.txt
  46. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(BIN_DIR)/uEnv.scr ::boot.scr
  47. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(DTS_DIR)/*.dtb ::
  48. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(BIN_DIR)/$(IMG_PREFIX)-uImage ::uImage
  49. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(BIN_DIR)/uboot.env ::uboot.env
  50. ./gen_axs10x_sdcard_img.sh \
  51. $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img \
  52. $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img \
  53. $(KDIR)/root.$(1) \
  54. $(CONFIG_AXS10X_SD_BOOT_PARTSIZE) \
  55. $(CONFIG_TARGET_ROOTFS_PARTSIZE)
  56. ifneq ($(CONFIG_TARGET_IMAGES_GZIP),)
  57. gzip -f9n $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img
  58. endif
  59. endef
  60. define Image/BuildKernel
  61. # Build unified uImage
  62. $(call Image/BuildKernel/MkuImage, \
  63. none, $(KERNEL_LOADADDR),$(call kernel_ep,$(KDIR)/vmlinux.elf) , \
  64. $(KDIR)/vmlinux, \
  65. $(BIN_DIR)/$(IMG_PREFIX)-uImage \
  66. )
  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. $(call Image/Gzip,$(BIN_DIR)/$(IMG_PREFIX)-root.$(1))
  73. endef
  74. $(eval $(call BuildImage))