Makefile 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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_VENDOR := Synopsys
  23. DEVICE_MODEL := nSIM HS
  24. DEVICE_PROFILE := nsim_hs
  25. DEVICE_DTS := haps_hs
  26. endef
  27. TARGET_DEVICES += nsim_hs
  28. endif
  29. # Root FS on SD-card
  30. KERNEL_LOADADDR := 0x90000000
  31. DEVICE_DTS_LIST:= axs103_idu haps_hs hsdk
  32. FAT32_BLOCK_SIZE=1024
  33. FAT32_BLOCKS=$(shell echo $$(($(CONFIG_AXS10X_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
  34. define Image/Prepare
  35. # Build .dtb for all boards we may run on
  36. $(foreach dts,$(DEVICE_DTS_LIST),
  37. $(call Image/BuildDTB,$(DTS_DIR)/$(dts).dts,$(DTS_DIR)/$(dts).dtb)
  38. )
  39. endef
  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. mkenvimage -s 0x4000 -o $(BIN_DIR)/uboot.env ./uboot.env.txt
  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. mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(BIN_DIR)/uboot.env ::uboot.env
  49. ./gen_axs10x_sdcard_img.sh \
  50. $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img \
  51. $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img \
  52. $(KDIR)/root.$(1) \
  53. $(CONFIG_AXS10X_SD_BOOT_PARTSIZE) \
  54. $(CONFIG_TARGET_ROOTFS_PARTSIZE)
  55. ifneq ($(CONFIG_TARGET_IMAGES_GZIP),)
  56. gzip -f9n $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img
  57. endif
  58. endef
  59. define Image/BuildKernel
  60. # Build unified uImage
  61. $(call Image/BuildKernel/MkuImage, \
  62. none, $(KERNEL_LOADADDR),$(call kernel_ep,$(KDIR)/vmlinux.elf) , \
  63. $(KDIR)/vmlinux, \
  64. $(BIN_DIR)/$(IMG_PREFIX)-uImage \
  65. )
  66. endef
  67. define Image/Build
  68. $(call Image/Build/$(1),$(1))
  69. $(call Image/Build/SDCard,$(1))
  70. dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
  71. $(call Image/Gzip,$(BIN_DIR)/$(IMG_PREFIX)-root.$(1))
  72. endef
  73. $(eval $(call BuildImage))