uboot-airoha: move FIP generation to target and enable autoselection

Move FIP handling to target now that we compile ATF. This is to have always
in sync new ATF and new U-Boot if one of the 2 is already compiled.

Also add HIDDEN ops to enable autoselection of the U-Boot for the required
target. This is needed to prevent user to deselect the U-Boot package
causing failure on ARTIFACTS generation.

Drop precompiled BL2 and BL31 as they can be now compiled from source.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/24257
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
Christian Marangi 2026-07-16 20:38:44 +02:00 committed by Robert Marko
parent c249552ea5
commit 94a21b3fe9
7 changed files with 26 additions and 40 deletions

View file

@ -14,6 +14,7 @@ include $(INCLUDE_DIR)/host-build.mk
define U-Boot/Default
BUILD_TARGET:=airoha
LZMA_COMPRESS:=1
HIDDEN:=1
endef
define U-Boot/an7581_gemtek_w1700k
@ -21,7 +22,6 @@ define U-Boot/an7581_gemtek_w1700k
UBOOT_CONFIG:=an7581_w1700k
BUILD_DEVICES:=gemtek_w1700k-ubi
BUILD_SUBTARGET:=an7581
UBOOT_IMAGE:=u-boot.bin
endef
define U-Boot/an7581_nokia_valyrian
@ -29,7 +29,6 @@ define U-Boot/an7581_nokia_valyrian
UBOOT_CONFIG:=an7581_nokia_valyrian
BUILD_DEVICES:=nokia_valyrian
BUILD_SUBTARGET:=an7581
UBOOT_IMAGE:=u-boot.fip
BL2_IMAGE:=an7581-bl2.bin
BL31_IMAGE:=an7581-bl31.bin
endef
@ -39,7 +38,6 @@ define U-Boot/an7581_nokia_xg-040g-md
UBOOT_CONFIG:=an7581_nokia_xg-040g-md
BUILD_DEVICES:=nokia_xg-040g-md-ubi
BUILD_SUBTARGET:=an7581
UBOOT_IMAGE:=u-boot.fip
BL2_IMAGE:=an7581-bl2.bin
BL31_IMAGE:=an7581-bl31.bin
endef
@ -47,21 +45,21 @@ endef
define U-Boot/an7581_rfb
NAME:=AN7581 Reference Board
UBOOT_CONFIG:=an7581_evb
BUILD_DEVICES:=airoha_an7581-evb
BUILD_DEVICES:=airoha_an7581-evb airoha_an7581-evb-emmc-eagle airoha_an7581-evb-emmc-kite
BUILD_SUBTARGET:=an7581
UBOOT_IMAGE:=u-boot.fip
BL2_IMAGE:=an7581-bl2.bin
BL31_IMAGE:=an7581-bl31.bin
DEPENDS:=+trusted-firmware-a-an7581-bl31
endef
define U-Boot/an7583_rfb
NAME:=AN7583 Reference Board
UBOOT_CONFIG:=an7583_evb
BUILD_DEVICES:=airoha_an7583-evb
BUILD_DEVICES:=airoha_an7583-evb airoha_an7583-evb-emmc
BUILD_SUBTARGET:=an7583
UBOOT_IMAGE:=u-boot.fip
BL2_IMAGE:=an7583-bl2.bin
BL31_IMAGE:=an7583-bl31.bin
DEPENDS:=+trusted-firmware-a-an7583-bl31
endef
define U-Boot/en7523_rfb
@ -69,7 +67,6 @@ define U-Boot/en7523_rfb
UBOOT_CONFIG:=en7523_evb
BUILD_DEVICES:=airoha_en7523-evb
BUILD_SUBTARGET:=en7523
UBOOT_IMAGE:=u-boot.fip
BL2_IMAGE:=en7523-bl2.bin
BL31_IMAGE:=en7523-bl31.bin
endef
@ -89,22 +86,6 @@ UBOOT_CUSTOMIZE_CONFIG := \
--enable SERIAL_RX_BUFFER \
--set-val SERIAL_RX_BUFFER_SIZE 256
define Build/fip-image-bl2
$(STAGING_DIR_HOST)/bin/fiptool create \
--tb-fw files/$(BL2_IMAGE) \
$(PKG_BUILD_DIR)/bl2.fip
endef
define Build/fip-image
$(if $(LZMA_COMPRESS), $(STAGING_DIR_HOST)/bin/lzma e \
files/$(BL31_IMAGE) \
$(PKG_BUILD_DIR)/bl31.bin.lzma)
$(STAGING_DIR_HOST)/bin/fiptool create \
--soc-fw $(PKG_BUILD_DIR)/bl31.bin$(if $(LZMA_COMPRESS),.lzma) \
--nt-fw $(PKG_BUILD_DIR)/u-boot.bin$(if $(LZMA_COMPRESS),.lzma) \
$(PKG_BUILD_DIR)/u-boot.fip
endef
define Build/Configure
$(call Build/Configure/U-Boot)
sed -i 's/CONFIG_TOOLS_LIBCRYPTO=y/# CONFIG_TOOLS_LIBCRYPTO is not set/' $(PKG_BUILD_DIR)/.config
@ -114,11 +95,7 @@ define Build/Compile
$(call Build/Compile/U-Boot)
$(if $(LZMA_COMPRESS), $(STAGING_DIR_HOST)/bin/lzma e \
$(PKG_BUILD_DIR)/u-boot.bin \
$(PKG_BUILD_DIR)/u-boot.bin.lzma)
ifeq ($(UBOOT_IMAGE),u-boot.fip)
$(call Build/fip-image-bl2)
$(call Build/fip-image)
endif
$(PKG_BUILD_DIR)/u-boot.lzma)
endef
# don't stage files to bindir, let target/linux/airoha/image/*.mk do that
@ -127,15 +104,10 @@ endef
define Build/InstallDev
$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
ifeq ($(UBOOT_IMAGE),u-boot.fip)
$(INSTALL_DATA) $(PKG_BUILD_DIR)/bl2.fip $(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-bl2.fip
$(INSTALL_DATA) $(PKG_BUILD_DIR)/u-boot.fip $(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-bl31-u-boot.fip
else
$(INSTALL_DATA) $(PKG_BUILD_DIR)/u-boot.bin$(if $(LZMA_COMPRESS),.lzma) \
$(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-u-boot.bin$(if $(LZMA_COMPRESS),.lzma)
$(INSTALL_DATA) $(PKG_BUILD_DIR)/u-boot.$(if $(LZMA_COMPRESS),lzma,bin) \
$(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-u-boot.$(if $(LZMA_COMPRESS),lzma,bin)
$(INSTALL_DATA) $(PKG_BUILD_DIR)/u-boot.dtb \
$(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-u-boot.dtb
endif
endef
$(eval $(call BuildPackage/U-Boot))

View file

@ -5,10 +5,17 @@ define Build/an7581-emmc-bl2-bl31-uboot
endef
define Build/an7581-preloader
$(STAGING_DIR_HOST)/bin/fiptool create \
--tb-fw $(STAGING_DIR_IMAGE)/an7581-bl2.bin \
$(STAGING_DIR_IMAGE)/an7581_$1-bl2.fip
cat $(STAGING_DIR_IMAGE)/an7581_$1-bl2.fip >> $@
endef
define Build/an7581-bl31-uboot
$(STAGING_DIR_HOST)/bin/fiptool create \
--soc-fw $(STAGING_DIR_IMAGE)/an7581-bl31.lzma \
--nt-fw $(STAGING_DIR_IMAGE)/an7581_$1-u-boot.lzma \
$(STAGING_DIR_IMAGE)/an7581_$1-bl31-u-boot.fip
cat $(STAGING_DIR_IMAGE)/an7581_$1-bl31-u-boot.fip >> $@
endef
@ -65,8 +72,8 @@ define Device/airoha_an7581-evb-emmc-eagle
DEVICE_DTS := an7581-evb-emmc-eagle
DEVICE_PACKAGES := airoha-en7581-mt7996-npu-firmware \
kmod-mt7996-firmware wpad-basic-mbedtls
ARTIFACT/preloader.bin := an7581-preloader rfb
ARTIFACT/bl31-uboot.fip := an7581-bl31-uboot rfb
ARTIFACT/preloader.bin := an7581-preloader rfb-emmc-eagle
ARTIFACT/bl31-uboot.fip := an7581-bl31-uboot rfb-emmc-eagle
ARTIFACTS := preloader.bin bl31-uboot.fip
endef
TARGET_DEVICES += airoha_an7581-evb-emmc-eagle
@ -77,8 +84,8 @@ define Device/airoha_an7581-evb-emmc-kite
DEVICE_DTS := an7581-evb-emmc-kite
DEVICE_PACKAGES := airoha-en7581-npu-firmware \
kmod-mt7992-firmware wpad-basic-mbedtls
ARTIFACT/preloader.bin := an7581-preloader rfb
ARTIFACT/bl31-uboot.fip := an7581-bl31-uboot rfb
ARTIFACT/preloader.bin := an7581-preloader rfb-emmc-kite
ARTIFACT/bl31-uboot.fip := an7581-bl31-uboot rfb-emmc-kite
ARTIFACTS := preloader.bin bl31-uboot.fip
endef
TARGET_DEVICES += airoha_an7581-evb-emmc-kite

View file

@ -1,8 +1,15 @@
define Build/an7583-preloader
$(STAGING_DIR_HOST)/bin/fiptool create \
--tb-fw $(STAGING_DIR_IMAGE)/an7583-bl2.bin \
$(STAGING_DIR_IMAGE)/an7583_$1-bl2.fip
cat $(STAGING_DIR_IMAGE)/an7583_$1-bl2.fip >> $@
endef
define Build/an7583-bl31-uboot
$(STAGING_DIR_HOST)/bin/fiptool create \
--soc-fw $(STAGING_DIR_IMAGE)/an7583-bl31.lzma \
--nt-fw $(STAGING_DIR_IMAGE)/an7583_$1-u-boot.lzma \
$(STAGING_DIR_IMAGE)/an7583_$1-bl31-u-boot.fip
cat $(STAGING_DIR_IMAGE)/an7583_$1-bl31-u-boot.fip >> $@
endef