xref: /OK3568_Linux_fs/buildroot/boot/opensbi/opensbi.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun################################################################################
2*4882a593Smuzhiyun#
3*4882a593Smuzhiyun# opensbi
4*4882a593Smuzhiyun#
5*4882a593Smuzhiyun################################################################################
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunOPENSBI_VERSION = $(call qstrip,$(BR2_TARGET_OPENSBI_VERSION))
8*4882a593Smuzhiyun
9*4882a593Smuzhiyunifeq ($(OPENSBI_VERSION),custom)
10*4882a593Smuzhiyun# Handle custom OpenSBI tarballs as specified by the configuration
11*4882a593SmuzhiyunOPENSBI_TARBALL = $(call qstrip,$(BR2_TARGET_OPENSBI_CUSTOM_TARBALL_LOCATION))
12*4882a593SmuzhiyunOPENSBI_SITE = $(patsubst %/,%,$(dir $(OPENSBI_TARBALL)))
13*4882a593SmuzhiyunOPENSBI_SOURCE = $(notdir $(OPENSBI_TARBALL))
14*4882a593Smuzhiyunelse ifeq ($(BR2_TARGET_OPENSBI_CUSTOM_GIT),y)
15*4882a593SmuzhiyunOPENSBI_SITE = $(call qstrip,$(BR2_TARGET_OPENSBI_CUSTOM_REPO_URL))
16*4882a593SmuzhiyunOPENSBI_SITE_METHOD = git
17*4882a593Smuzhiyunelse
18*4882a593Smuzhiyun# Handle official OpenSBI versions
19*4882a593SmuzhiyunOPENSBI_SITE = $(call github,riscv,opensbi,v$(OPENSBI_VERSION))
20*4882a593Smuzhiyunendif
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunOPENSBI_LICENSE = BSD-2-Clause
23*4882a593Smuzhiyunifeq ($(BR2_TARGET_OPENSBI_LATEST_VERSION),y)
24*4882a593SmuzhiyunOPENSBI_LICENSE_FILES = COPYING.BSD
25*4882a593Smuzhiyunendif
26*4882a593SmuzhiyunOPENSBI_INSTALL_TARGET = NO
27*4882a593SmuzhiyunOPENSBI_INSTALL_STAGING = YES
28*4882a593Smuzhiyun
29*4882a593Smuzhiyunifeq ($(BR2_TARGET_OPENSBI)$(BR2_TARGET_OPENSBI_LATEST_VERSION),y)
30*4882a593SmuzhiyunBR_NO_CHECK_HASH_FOR += $(OPENSBI_SOURCE)
31*4882a593Smuzhiyunendif
32*4882a593Smuzhiyun
33*4882a593SmuzhiyunOPENSBI_MAKE_ENV = \
34*4882a593Smuzhiyun	CROSS_COMPILE=$(TARGET_CROSS)
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunOPENSBI_PLAT = $(call qstrip,$(BR2_TARGET_OPENSBI_PLAT))
37*4882a593Smuzhiyunifneq ($(OPENSBI_PLAT),)
38*4882a593SmuzhiyunOPENSBI_MAKE_ENV += PLATFORM=$(OPENSBI_PLAT)
39*4882a593Smuzhiyunendif
40*4882a593Smuzhiyun
41*4882a593Smuzhiyunifeq ($(BR2_TARGET_OPENSBI_LINUX_PAYLOAD),y)
42*4882a593SmuzhiyunOPENSBI_DEPENDENCIES += linux
43*4882a593SmuzhiyunOPENSBI_MAKE_ENV += FW_PAYLOAD_PATH="$(BINARIES_DIR)/Image"
44*4882a593Smuzhiyunendif
45*4882a593Smuzhiyun
46*4882a593Smuzhiyunifeq ($(BR2_TARGET_OPENSBI_UBOOT_PAYLOAD),y)
47*4882a593SmuzhiyunOPENSBI_DEPENDENCIES += uboot
48*4882a593SmuzhiyunOPENSBI_MAKE_ENV += FW_PAYLOAD_PATH="$(BINARIES_DIR)/u-boot.bin"
49*4882a593Smuzhiyunifeq ($(BR2_TARGET_OPENSBI_FW_FDT_PATH),y)
50*4882a593SmuzhiyunOPENSBI_MAKE_ENV += FW_FDT_PATH="$(BINARIES_DIR)/u-boot.dtb"
51*4882a593Smuzhiyunendif
52*4882a593Smuzhiyunendif
53*4882a593Smuzhiyun
54*4882a593Smuzhiyundefine OPENSBI_BUILD_CMDS
55*4882a593Smuzhiyun	$(TARGET_MAKE_ENV) $(OPENSBI_MAKE_ENV) $(MAKE) -C $(@D)
56*4882a593Smuzhiyunendef
57*4882a593Smuzhiyun
58*4882a593Smuzhiyunifeq ($(BR2_TARGET_OPENSBI_INSTALL_DYNAMIC_IMG),y)
59*4882a593SmuzhiyunOPENSBI_INSTALL_IMAGES = YES
60*4882a593SmuzhiyunOPENSBI_FW_IMAGES += dynamic
61*4882a593Smuzhiyunendif
62*4882a593Smuzhiyun
63*4882a593Smuzhiyunifeq ($(BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG),y)
64*4882a593SmuzhiyunOPENSBI_INSTALL_IMAGES = YES
65*4882a593SmuzhiyunOPENSBI_FW_IMAGES += jump
66*4882a593Smuzhiyunendif
67*4882a593Smuzhiyun
68*4882a593Smuzhiyunifeq ($(BR2_TARGET_OPENSBI_INSTALL_PAYLOAD_IMG),y)
69*4882a593SmuzhiyunOPENSBI_INSTALL_IMAGES = YES
70*4882a593SmuzhiyunOPENSBI_FW_IMAGES += payload
71*4882a593Smuzhiyunendif
72*4882a593Smuzhiyun
73*4882a593Smuzhiyundefine OPENSBI_INSTALL_IMAGES_CMDS
74*4882a593Smuzhiyun	$(foreach f,$(OPENSBI_FW_IMAGES),\
75*4882a593Smuzhiyun		$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_$(f).bin \
76*4882a593Smuzhiyun			$(BINARIES_DIR)/fw_$(f).bin
77*4882a593Smuzhiyun		$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_$(f).elf \
78*4882a593Smuzhiyun			$(BINARIES_DIR)/fw_$(f).elf
79*4882a593Smuzhiyun	)
80*4882a593Smuzhiyunendef
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun# libsbi.a is not a library meant to be linked in user-space code, but
83*4882a593Smuzhiyun# with bare metal code, which is why we don't install it in
84*4882a593Smuzhiyun# $(STAGING_DIR)/usr/lib
85*4882a593Smuzhiyundefine OPENSBI_INSTALL_STAGING_CMDS
86*4882a593Smuzhiyun	$(INSTALL) -m 0644 -D $(@D)/build/lib/libsbi.a $(STAGING_DIR)/usr/share/opensbi/libsbi.a
87*4882a593Smuzhiyunendef
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun$(eval $(generic-package))
90