kumquat-buildroot/boot/opensbi/opensbi.mk
Thomas Petazzoni 24010550be boot/opensbi: add options to enable/disable image installation
Until now, whenever a BR2_TARGET_OPENSBI_PLAT value was specified,
opensbi.mk was assuming that both fw_jump and fw_dynamic would be
produced. However, this is not the case: the OpenSBI per-platform
config.mk can decide which image to build.

As an example, the config.mk for VIC7100-based BeagleV only enables
producing the fw_payload image.

This commit adds three options to enable the installation of images:
one for fw_jump, one for fw_dynamic, one for fw_payload.

The options for fw_jump and fw_dynamic are "default y" when
BR2_TARGET_OPENSBI_PLAT is not empty, to preserve existing behavior.

The option for fw_payload is forcefully selected when either Linux or
U-Boot are selected as payloads.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2021-05-07 22:29:02 +02:00

85 lines
2.5 KiB
Makefile

################################################################################
#
# opensbi
#
################################################################################
OPENSBI_VERSION = $(call qstrip,$(BR2_TARGET_OPENSBI_VERSION))
ifeq ($(OPENSBI_VERSION),custom)
# Handle custom OpenSBI tarballs as specified by the configuration
OPENSBI_TARBALL = $(call qstrip,$(BR2_TARGET_OPENSBI_CUSTOM_TARBALL_LOCATION))
OPENSBI_SITE = $(patsubst %/,%,$(dir $(OPENSBI_TARBALL)))
OPENSBI_SOURCE = $(notdir $(OPENSBI_TARBALL))
else ifeq ($(BR2_TARGET_OPENSBI_CUSTOM_GIT),y)
OPENSBI_SITE = $(call qstrip,$(BR2_TARGET_OPENSBI_CUSTOM_REPO_URL))
OPENSBI_SITE_METHOD = git
else
# Handle official OpenSBI versions
OPENSBI_SITE = $(call github,riscv,opensbi,v$(OPENSBI_VERSION))
endif
OPENSBI_LICENSE = BSD-2-Clause
OPENSBI_LICENSE_FILES = COPYING.BSD
OPENSBI_INSTALL_TARGET = NO
OPENSBI_INSTALL_STAGING = YES
ifeq ($(BR2_TARGET_OPENSBI)$(BR2_TARGET_OPENSBI_LATEST_VERSION),y)
BR_NO_CHECK_HASH_FOR += $(OPENSBI_SOURCE)
endif
OPENSBI_MAKE_ENV = \
CROSS_COMPILE=$(TARGET_CROSS)
OPENSBI_PLAT = $(call qstrip,$(BR2_TARGET_OPENSBI_PLAT))
ifneq ($(OPENSBI_PLAT),)
OPENSBI_MAKE_ENV += PLATFORM=$(OPENSBI_PLAT)
endif
ifeq ($(BR2_TARGET_OPENSBI_LINUX_PAYLOAD),y)
OPENSBI_DEPENDENCIES += linux
OPENSBI_MAKE_ENV += FW_PAYLOAD_PATH="$(BINARIES_DIR)/Image"
endif
ifeq ($(BR2_TARGET_OPENSBI_UBOOT_PAYLOAD),y)
OPENSBI_DEPENDENCIES += uboot
OPENSBI_MAKE_ENV += FW_PAYLOAD_PATH="$(BINARIES_DIR)/u-boot.bin"
endif
define OPENSBI_BUILD_CMDS
$(TARGET_MAKE_ENV) $(OPENSBI_MAKE_ENV) $(MAKE) -C $(@D)
endef
ifeq ($(BR2_TARGET_OPENSBI_INSTALL_DYNAMIC_IMG),y)
OPENSBI_INSTALL_IMAGES = YES
OPENSBI_FW_IMAGES += dynamic
endif
ifeq ($(BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG),y)
OPENSBI_INSTALL_IMAGES = YES
OPENSBI_FW_IMAGES += jump
endif
ifeq ($(BR2_TARGET_OPENSBI_INSTALL_PAYLOAD_IMG),y)
OPENSBI_INSTALL_IMAGES = YES
OPENSBI_FW_IMAGES += payload
endif
define OPENSBI_INSTALL_IMAGES_CMDS
$(foreach f,$(OPENSBI_FW_IMAGES),\
$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_$(f).bin \
$(BINARIES_DIR)/fw_$(f).bin
$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_$(f).elf \
$(BINARIES_DIR)/fw_$(f).elf
)
endef
# libsbi.a is not a library meant to be linked in user-space code, but
# with bare metal code, which is why we don't install it in
# $(STAGING_DIR)/usr/lib
define OPENSBI_INSTALL_STAGING_CMDS
$(INSTALL) -m 0644 -D $(@D)/build/lib/libsbi.a $(STAGING_DIR)/usr/share/opensbi/libsbi.a
endef
$(eval $(generic-package))