Makefile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. #
  3. # Copyright (C) 2016 OpenWrt.org
  4. include $(TOPDIR)/rules.mk
  5. include $(INCLUDE_DIR)/image.mk
  6. # On ARC initramfs is put before entry point and so entry point moves
  7. # in memory from build to built. Thus we need to extract EP from vmlinux
  8. # every time before generation of uImage.
  9. kernel_ep = `$(KERNEL_CROSS)readelf -h $(1) | grep "Entry point address" | grep -o 0x.*`
  10. define Build/patch-dtb
  11. $(STAGING_DIR_HOST)/bin/patch-dtb $@ $(DTS_DIR)/$(DEVICE_DTS).dtb
  12. endef
  13. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  14. # Root FS built-in
  15. define Device/vmlinux
  16. KERNEL_SUFFIX := .elf
  17. KERNEL := kernel-bin | patch-dtb
  18. KERNEL_INITRAMFS_NAME = vmlinux-initramfs.elf
  19. endef
  20. define Device/nsim_hs
  21. $(call Device/vmlinux)
  22. DEVICE_PROFILE := nsim_hs
  23. DEVICE_DTS := nsim_hs_idu
  24. endef
  25. TARGET_DEVICES += nsim_hs
  26. endif
  27. # Root FS on SD-card
  28. KERNEL_LOADADDR := 0x90000000
  29. DEVICE_DTS_LIST:= axs103_idu nsim_hs_idu hsdk
  30. FAT32_BLOCK_SIZE=1024
  31. FAT32_BLOCKS=$(shell echo $$(($(CONFIG_AXS10X_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
  32. define Image/Prepare
  33. # Build .dtb for all boards we may run on
  34. $(foreach dts,$(DEVICE_DTS_LIST),
  35. $(call Image/BuildDTB,$(DTS_DIR)/$(dts).dts,$(DTS_DIR)/$(dts).dtb)
  36. )
  37. endef
  38. define Image/Build/SDCard
  39. rm -f $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img
  40. mkfs.fat $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img -C $(FAT32_BLOCKS)
  41. mkimage -C none -A arc -T script -d uEnv.txt $(BIN_DIR)/uEnv.scr
  42. mkenvimage -s 0x4000 -o $(BIN_DIR)/uboot.env ./uboot.env.txt
  43. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(BIN_DIR)/uEnv.scr ::boot.scr
  44. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(DTS_DIR)/*.dtb ::
  45. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(BIN_DIR)/$(IMG_PREFIX)-uImage ::uImage
  46. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(BIN_DIR)/uboot.env ::uboot.env
  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 Image/BuildKernel/MkuImage, \
  60. none, $(KERNEL_LOADADDR),$(call kernel_ep,$(KDIR)/vmlinux.elf) , \
  61. $(KDIR)/vmlinux, \
  62. $(BIN_DIR)/$(IMG_PREFIX)-uImage \
  63. )
  64. endef
  65. define Image/Build
  66. $(call Image/Build/$(1),$(1))
  67. $(call Image/Build/SDCard,$(1))
  68. dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
  69. $(call Image/Gzip,$(BIN_DIR)/$(IMG_PREFIX)-root.$(1))
  70. endef
  71. $(eval $(call BuildImage))