2 # Copyright (C) 2015 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
7 include $(TOPDIR
)/rules.mk
8 include $(INCLUDE_DIR
)/image.mk
11 FAT32_BLOCKS
=$(shell echo
$$(($(CONFIG_SOCFPGA_SD_BOOT_PARTSIZE
)*1024*1024/$(FAT32_BLOCK_SIZE
))))
13 KDIR_TMP_EXT4
:=$(KDIR
)/tmp-ext4
15 # Terasic SoCkit: QSPI NOR, N25Q00A
16 SOCFPGA_SOCKIT_UBIFS_OPTS
="-m 1 -e 65408 -c 2040"
17 SOCFPGA_SOCKIT_UBI_OPTS
="-m 1 -p 64KiB -s 1"
19 define sanitize_profile_name
20 $(shell echo
$(PROFILE
) | tr
'[:upper:]' '[:lower:]' | sed
's/_/-/g')
23 define Image
/BuildKernel
/Template
26 $(CP
) $(DTS_DIR
)/$(1).dtb
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).dtb
28 $(call Image
/BuildKernel
/MkFIT
,$(1),$(KDIR
)/zImage
,$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).dtb
,none
,0x00008000,0x00008000)
29 $(CP
) $(KDIR
)/fit-
$(1).itb
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1)-fit-uImage.itb
31 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),)
32 $(call Image
/BuildKernel
/MkFIT
,$(1),$(KDIR
)/zImage-initramfs
,$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).dtb
,none
,0x00008000,0x00008000,-initramfs
)
33 $(CP
) $(KDIR
)/fit-
$(1)-initramfs.itb
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1)-fit-uImage-initramfs.itb
37 $(CP
) $(KDIR
)/zImage
$(BIN_DIR
)/$(IMG_PREFIX
)-zImage
38 $(call Image
/BuildKernel
/MkuImage
, \
39 none
, 0x00008000, 0x00008000, \
40 $(BIN_DIR
)/$(IMG_PREFIX
)-zImage
, \
41 $(BIN_DIR
)/$(IMG_PREFIX
)-uImage \
44 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),)
45 $(CP
) $(KDIR
)/zImage-initramfs
$(BIN_DIR
)/$(IMG_PREFIX
)-zImage-initramfs
46 $(call Image
/BuildKernel
/MkuImage
, \
47 none
, 0x00008000, 0x00008000, \
48 $(BIN_DIR
)/$(IMG_PREFIX
)-zImage-initramfs
, \
49 $(BIN_DIR
)/$(IMG_PREFIX
)-uImage-initramfs \
54 define Image
/InstallKernel
/Template
56 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_KERNEL
)$(CONFIG_TARGET_socfpga_SOCFPGA_SOCKIT
),)
57 $(INSTALL_DIR
) $(TARGET_DIR
)/boot
58 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_UIMAGE
)$(CONFIG_TARGET_socfpga_SOCFPGA_SOCKIT
),)
59 $(CP
) $(BIN_DIR
)/$(IMG_PREFIX
)-uImage
$(TARGET_DIR
)/boot
/
60 ln
-sf
$(IMG_PREFIX
)-uImage
$(TARGET_DIR
)/boot
/uImage
62 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_ZIMAGE
),)
63 $(CP
) $(BIN_DIR
)/$(IMG_PREFIX
)-zImage
$(TARGET_DIR
)/boot
/
64 ln
-sf
$(IMG_PREFIX
)-zImage
$(TARGET_DIR
)/boot
/zImage
66 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_FIT
),)
67 $(foreach dts
,$(shell echo
$(1)),
68 $(CP
) $(BIN_DIR
)/$(IMG_PREFIX
)-$(dts
)-fit-uImage.itb
$(TARGET_DIR
)/boot
/
73 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_DTB
)$(CONFIG_TARGET_socfpga_SOCFPGA_SOCKIT
),)
74 $(INSTALL_DIR
) $(TARGET_DIR
)/boot
75 $(foreach dts
,$(shell echo
$(1)),
76 $(CP
) $(BIN_DIR
)/$(IMG_PREFIX
)-$(dts
).dtb
$(TARGET_DIR
)/boot
/,
77 ln
-sf
$(IMG_PREFIX
)-$(dts
).dtb
$(TARGET_DIR
)/boot
/$(dts
).dtb
82 define Image
/Build
/SDCard
85 .
/gen_socfpga_sdcard_img.sh \
86 $(BIN_DIR
)/$(IMG_PREFIX
)-$(call sanitize_profile_name
)-sdcard-vfat-
$(1).img \
88 $(CONFIG_TARGET_ROOTFS_PARTSIZE
) \
89 $(BIN_DIR
)/uboot-socfpga-
$(2)/$(IMG_PREFIX
)-$(2)-u-boot-with-spl.sfp \
94 define Image
/mkfs
/targz
95 $(TAR
) -czpf
$(BIN_DIR
)/$(IMG_PREFIX
)-$(call sanitize_profile_name
)-rootfs.
tar.gz
--numeric-owner
--owner
=0 --group
=0 -C
$(TARGET_DIR
)/ .
98 Image
/BuildKernel
/Template
/Generic
=$(call Image
/BuildKernel
/Template
)
99 Image
/InstallKernel
/Template
/Generic
=$(call Image
/InstallKernel
/Template
)
101 Image
/BuildKernel
/Template
/SOCFPGA_SOCKIT
=$(foreach dts
,$(shell echo
$(SOCFPGA_SOCKIT_DTS
)),$(call Image
/BuildKernel
/Template
,$(dts
)))
102 Image
/InstallKernel
/Template
/SOCFPGA_SOCKIT
=$(call Image
/InstallKernel
/Template
,$(SOCFPGA_SOCKIT_DTS
))
104 define Image
/BuildKernel
105 $(call Image
/BuildKernel
/Template
/$(PROFILE
))
108 define Image
/InstallKernel
109 $(call Image
/InstallKernel
/Template
/$(PROFILE
))
112 define Image
/Build
/Profile
/SOCFPGA_SOCKIT
115 $(call Image
/Build
/SDCard
,$(1),socfpga_cyclone5_sockit
)
116 $(call Image
/Build
/SysupgradeNAND
,$(call sanitize_profile_name
),ext4
,)
119 $(call Image
/Build
/SysupgradeNAND
,$(call sanitize_profile_name
),ubifs
,)
124 $(if
$(Image
/Build
/$(1)), \
125 $(call Image
/Build
/$(1),$(1)), \
126 $(CP
) $(KDIR
)/root.
$(1) $(BIN_DIR
)/$(IMG_PREFIX
)-$(call sanitize_profile_name
)-$(1).img \
129 $(if
$(Image
/Build
/Profile
/$(PROFILE
)), \
130 $(call Image
/Build
/Profile
/$(PROFILE
),$(1)), \
131 $(CP
) $(KDIR
)/root.
$(1) $(BIN_DIR
)/$(IMG_PREFIX
)-$(call sanitize_profile_name
)-$(1).img \
135 $(eval
$(call BuildImage
))