File u-boot.spec of Package u-boot

#
# spec file for package u-boot
#
# Copyright (c) 2025 SUSE LLC
# Copyright (c) 2010 Texas Instruments Inc by Nishanth Menon
# Copyright (c) 2007-2010 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define target @BUILD_FLAVOR@
%define binext .bin
%define is_armv6 0
%define is_armv7 0
%define is_armv8 0
%define is_ppc 0
%define is_riscv64 0
%define tools_only 0

%if "%target" == "rpiarm64" || "%target" == "rpiarm64-secureboot" || "%target" == "rpi5" || "%target" == "rpi5-secureboot"
%define is_rpi 1
%define is_armv8 1
%endif

# archive_version differs from version for RC version only
%define archive_version 2025.10
%if "%{target}" == ""
ExclusiveArch:  do_not_build
%else
%if "%{target}" == "tools"
%define tools_only 1
%else
%if %is_armv8
ExclusiveArch:  aarch64
%else
%if %is_armv7
ExclusiveArch:  armv7l armv7hl
%else
%if %is_armv6
ExclusiveArch:  armv6l armv6hl
%else
%if %is_ppc
ExclusiveArch:  ppc
%else
%if %is_riscv64
ExclusiveArch:  riscv64
%else
ExclusiveArch:  do_not_build
%endif
%endif
%endif
%endif
%endif
%endif
%endif

Version:        2025.10
Release:        0
Summary:        The U-Boot firmware for the %target platform
License:        GPL-2.0-only
Group:          System/Boot
URL:            http://www.denx.de/wiki/U-Boot
Source:         http://ftp.denx.de/pub/u-boot/u-boot-%{archive_version}.tar.bz2
Source1:        http://ftp.denx.de/pub/u-boot/u-boot-%{archive_version}.tar.bz2.sig
Source5:        ubootefi.var
Source99:       u-boot.keyring
Source300:      u-boot-rpmlintrc
Source900:      update_git.sh
# Patches: start
Patch0001:      0001-XXX-openSUSE-XXX-Prepend-partition-.patch
Patch0002:      0002-Revert-Revert-omap3-Use-raw-SPL-by-.patch
Patch0003:      0003-rpi-Use-firmware-provided-device-tr.patch
Patch0004:      0004-Temp-workaround-for-Chromebook-snow.patch
Patch0005:      0005-tools-zynqmpbif-Add-support-for-loa.patch
Patch0006:      0006-Kconfig-add-btrfs-to-distro-boot.patch
Patch0007:      0007-configs-Re-sync-with-CONFIG_DISTRO_.patch
Patch0008:      0008-sunxi-dts-OrangePi-Zero-Add-SPI-ali.patch
Patch0009:      0009-sunxi-dts-OrangePi-Zero-Enable-SPI-.patch
Patch0010:      0010-Disable-CONFIG_CMD_BTRFS-in-xilinx_.patch
Patch0011:      0011-smbios-Fix-table-when-no-string-is-.patch
Patch0012:      0012-riscv-enable-CMD_BTRFS.patch
Patch0013:      0013-Disable-timer-check-in-file-loading.patch
Patch0014:      0014-Enable-EFI-and-ISO-partitions-suppo.patch
Patch0015:      0015-cmd-boot-add-brom-cmd-to-reboot-to-.patch
Patch0016:      0016-Kconfig-add-btrfs-to-standard-boot.patch
Patch0017:      u-boot-rpi-silent.patch
Patch0018:      u-boot-rpi5.patch
# Patches: end
BuildRequires:  bc
BuildRequires:  bison
# Arndale board needs DTC >= 1.4
BuildRequires:  dtc >= 1.4.0
BuildRequires:  flex
BuildRequires:  pkgconfig
# gnutls/gnutls.h required for tools/mkeficapsule.c
BuildRequires:  pkgconfig(gnutls)
# u-boot-clearfog (tools/kwbimage.c) needs openssl to build
BuildRequires:  pkgconfig(openssl)
# uuid/uuid.h required for tools/mkeficapsule.c
BuildRequires:  pkgconfig(uuid)
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  swig
Conflicts:      u-boot-loader
Provides:       u-boot-loader
%if "%_project" == "hardware:boot" || "%_project" == "hardware:boot:staging" || "%_project" == "openSUSE:Factory" || "%_project" == "openSUSE:Factory:ARM" || "%_project" == "openSUSE:Factory:PowerPC" || "%_project" == "openSUSE:Factory:RISCV" || "%_project" == "openSUSE:Leap:15.2" || "%_project" == "openSUSE:Leap:15.2:ARM" || "%_project" == "openSUSE:Leap:15.2:PowerPC"
# A complete multibuild-flavoured package is only built in above projects.
# In order to build a defined subset in forked projects, add the
# following to the respective project config (without the "#|"):
#|Macros:
#|%prjconf_multibuild_selection patch
#|:Macros
#|BuildFlags: onlybuild:u-boot:my-flavor1 onlybuild:u-boot:my-flavor2
#|BuildFlags: onlybuild:u-boot:my-flavor3 onlybuild:u-boot:my-flavor4
# If you opt to use onlybuild: to select U-Boot flavours and also
# have additional packages in that project, these need to be listed, too:
#|BuildFlags: onlybuild:package onlybuild:otherpackage onlybuild:thirdpackage
# Any packages not included in that list will neither build in that project
# nor in subprojects!
# It is still possible to enable the full multiboot set plus eventual
# additional packages by adding the Macros: [...] :Macros section and
# omitting the "onlybuild:"-lines.
%else
%if "%target" == "tools" || "%target" == ""
# At least build the tools.
%else
#BuildRequires:  %prjconf_multibuild_selection
%endif
%endif
%if "%target" == "tools" || "%target" == ""
Name:           u-boot
%else
Name:           u-boot-%target
%endif

%if "%target" == "tools"
# Fixes ld: cannot find -ltinfo: No such file or directory
BuildRequires:  ncurses-devel
%endif
%if 0%{?is_rpi}
# Owns /boot/vc directory
BuildRequires:  raspberrypi-firmware
%endif
%if 0%{?is_rpi}
# For mountpoint
Requires(post): util-linux
%endif

%if "%{name}" == "u-boot-rpiarm64" || "%{name}" == "u-boot-rpiarm64-secureboot" || "%{name}" == "u-boot-rpi5" || "%{name}" == "u-boot-rpi5-secureboot"
Supplements:    modalias(of:NfirmwareT*Craspberrypi%2Cbcm2835-firmwareC*)
# Provides one u-boot image for both RPi3 and RPi4
Obsoletes:      u-boot-rpi3 < %{version}
Provides:       u-boot-rpi3 = %{version}
Obsoletes:      u-boot-rpi4 < %{version}
Provides:       u-boot-rpi4 = %{version}
%endif

%if "%{name}" == "u-boot-rpi5" || "%{name}" == "u-boot-rpi5-secureboot"
Obsoletes:      u-boot-rpiarm64 < %{version}
Provides:       u-boot-rpiarm64 = %{version}
%endif

%description
Das U-Boot (or just "U-Boot" for short) is Open Source Firmware for Embedded PowerPC, ARM, MIPS and x86 processors.
This package contains the firmware for the %target platform.

%if %tools_only
%package tools
Summary:        Tools for the U-Boot Firmware
Group:          System/Boot

%description tools
Das U-Boot (or just "U-Boot" for short) is Open Source Firmware for Embedded PowerPC, ARM, MIPS and x86 processors.
This package contains:
mkimage- a tool that creates kernel bootable images for U-Boot.

%else

%package doc
Summary:        Documentation for the U-Boot Firmware
Group:          Documentation/Other

%description doc
Das U-Boot (or just "U-Boot" for short) is Open Source Firmware for Embedded PowerPC, ARM, MIPS and x86 processors.
This package contains documentation for U-Boot firmware.

%endif

%prep
%setup -q -n u-boot-%{archive_version}
%autopatch -p1

%build

%if %tools_only
# needed for include/config/auto.conf
make sandbox_defconfig
make syncconfig
make %{?_smp_mflags} CFLAGS="%{optflags}" tools-only NO_SDL=y
%else

%if "%target" == "rpiarm64-secureboot"
confname="rpi_arm64_defconfig"
%else
%if "%target" == "rpi5-secureboot"
confname="rpi_5_defconfig"
%else
confname=$(ls configs | perl -ne '$l=lc; $l=~ s,_,,g; $l eq "%{target}defconfig\n" && print;')
%endif
%endif

make %{?_smp_mflags} CROSS_COMPILE= HOSTCFLAGS="%{optflags}" $confname

echo "CONFIG_SPI=y" >> .config
echo "CONFIG_DM_SPI=y" >> .config
echo "CONFIG_SOFT_SPI=y" >> .config
echo "CONFIG_TPM_RNG=y" >> .config
echo "CONFIG_TPM_V1=y" >> .config
echo "CONFIG_TPM_V2=y" >> .config
echo "CONFIG_TPM=y" >> .config
echo "CONFIG_SHA1=y" >> .config
echo "CONFIG_SHA256=y" >> .config
echo "CONFIG_SHA512=y" >> .config
echo "CONFIG_SHA384=y" >> .config
echo "CONFIG_SMBIOS_PARSER=y" >> .config
echo "CONFIG_EFI_TCG2_PROTOCOL=y" >> .config
echo "CONFIG_EFI_TCG2_PROTOCOL_EVENTLOG_SIZE=65536" >> .config
echo "CONFIG_CMD_HASH=y" >> .config
echo "CONFIG_HASH_VERIFY=y" >> .config
echo "CONFIG_CMD_TPM_V1=y" >> .config
echo "CONFIG_CMD_TPM_V2=y" >> .config
echo "CONFIG_CMD_TPM=y" >> .config
echo "CONFIG_TPM2_TIS_SPI=y" >> .config
echo "CONFIG_SILENT_CONSOLE=y" >> .config
echo "CONFIG_VIDEO_LOGO=n" >> .config
echo "CONFIG_BOOTDELAY=-2" >> .config
%if "%target" == "rpiarm64-secureboot" || "%target" == "rpi5-secureboot"
echo "CONFIG_BOOTM_EFI=y" >> .config
echo "CONFIG_USE_BOOTCOMMAND=y" >> .config
echo 'CONFIG_BOOTCOMMAND="load mmc 0:1 ${loadaddr} EFI/BOOT/linux.efi && bootefi ${loadaddr}"' >> .config
echo "CONFIG_ENV_IS_NOWHERE=y" >> .config
echo "CONFIG_ENV_IS_MMC=y" >> .config
echo "CONFIG_ENV_WRITEABLE_LIST=y" >> .config
echo "CONFIG_CMD_BOOTEFI=y" >> .config
echo "CONFIG_EFI_LOADER=y" >> .config
echo "CONFIG_EFI_VARIABLES_PRESEED=y" >> .config
echo "CONFIG_EFI_VAR_SEED_FILE=\"ubootefi.var\"" >> .config
echo "CONFIG_EFI_SECURE_BOOT=y" >> .config
echo "CONFIG_FIT=y" >> .config
echo "CONFIG_FIT_SIGNATURE=y" >> .config
echo "CONFIG_FIT_EXTERNAL_OFFSET=0x0" >> .config
echo "CONFIG_FIT_FULL_CHECK=y" >> .config
echo "CONFIG_FIT_SIGNATURE_MAX_SIZE=0x10000000" >> .config
echo "CONFIG_FIT_PRINT=y" >> .config
echo "CONFIG_BOOTMETH_VBE=y" >> .config
echo "CONFIG_BOOTMETH_VBE_REQUEST=y" >> .config
echo "CONFIG_BOOTMETH_VBE_SIMPLE=y" >> .config
echo "CONFIG_BOOTMETH_VBE_SIMPLE_OS=y" >> .config
echo "CONFIG_IMAGE_SIGN_INFO=y" >> .config
echo "CONFIG_MD5=y" >> .config
echo "CONFIG_CMD_NVEDIT_EFI=y" >> .config
%endif
echo "# CONFIG_MEASURED_BOOT is not set" >> .config
echo "# CONFIG_CMD_SPI is not set" >> .config
echo "# CONFIG_CMD_TPM_TEST is not set" >> .config
echo "# CONFIG_APPLE_SPI_KEYB is not set" >> .config
echo "# CONFIG_MMC_SPI is not set" >> .config
echo "# CONFIG_SPI_MEM is not set" >> .config
echo "# CONFIG_ALTERA_SPI is not set" >> .config
echo "# CONFIG_APPLE_SPI is not set" >> .config
echo "# CONFIG_ATCSPI200_SPI is not set" >> .config
echo "# CONFIG_ATMEL_SPI is not set" >> .config
echo "# CONFIG_BCMSTB_SPI is not set" >> .config
echo "# CONFIG_CADENCE_QSPI is not set" >> .config
echo "# CONFIG_CF_SPI is not set" >> .config
echo "# CONFIG_DESIGNWARE_SPI is not set" >> .config
echo "# CONFIG_EXYNOS_SPI is not set" >> .config
echo "# CONFIG_FSL_DSPI is not set" >> .config
echo "# CONFIG_FSL_QSPI is not set" >> .config
echo "# CONFIG_GXP_SPI is not set" >> .config
echo "# CONFIG_ICH_SPI is not set" >> .config
echo "# CONFIG_IPROC_QSPI is not set" >> .config
echo "# CONFIG_KIRKWOOD_SPI is not set" >> .config
echo "# CONFIG_MICROCHIP_COREQSPI is not set" >> .config
echo "# CONFIG_MPC8XXX_SPI is not set" >> .config
echo "# CONFIG_MVEBU_A3700_SPI is not set" >> .config
echo "# CONFIG_MXS_SPI is not set" >> .config
echo "# CONFIG_SPI_MXIC is not set" >> .config
echo "# CONFIG_NPCM_FIU_SPI is not set" >> .config
echo "# CONFIG_NPCM_PSPI is not set" >> .config
echo "# CONFIG_OMAP3_SPI is not set" >> .config
echo "# CONFIG_PL022_SPI is not set" >> .config
echo "# CONFIG_ROCKCHIP_SFC is not set" >> .config
echo "# CONFIG_ROCKCHIP_SPI is not set" >> .config
echo "# CONFIG_SPI_SIFIVE is not set" >> .config
echo "# CONFIG_SPI_SUNXI is not set" >> .config
echo "# CONFIG_TEGRA114_SPI is not set" >> .config
echo "# CONFIG_TEGRA20_SFLASH is not set" >> .config
echo "# CONFIG_TEGRA20_SLINK is not set" >> .config
echo "# CONFIG_TEGRA210_QSPI is not set" >> .config
echo "# CONFIG_TI_QSPI is not set" >> .config
echo "# CONFIG_XILINX_SPI is not set" >> .config
echo "# CONFIG_ZYNQ_SPI is not set" >> .config
echo "# CONFIG_ZYNQ_QSPI is not set" >> .config
echo "# CONFIG_ZYNQMP_GQSPI is not set" >> .config
echo "# CONFIG_SH_QSPI is not set" >> .config
echo "# CONFIG_MXC_SPI is not set" >> .config
echo "# CONFIG_TPM_ATMEL_TWI is not set" >> .config
echo "# CONFIG_TPM_AUTH_SESSIONS is not set" >> .config
echo "# CONFIG_TPM_ST33ZP24_SPI is not set" >> .config
echo "# CONFIG_TPM_FLUSH_RESOURCES is not set" >> .config
echo "# CONFIG_TPM_LOAD_KEY_BY_SHA1 is not set" >> .config
echo "# CONFIG_TPM_LIST_RESOURCES is not set" >> .config
echo "# CONFIG_TPM2_MMIO is not set" >> .config
echo "# CONFIG_USB_GADGET_MAX3420 is not set" >> .config
echo "# CONFIG_EFI_TCG2_PROTOCOL_MEASURE_DTB is not set" >> .config
echo "# CONFIG_SILENT_U_BOOT_ONLY is not set" >> .config
echo "# CONFIG_SILENT_CONSOLE_UPDATE_ON_SET is not set" >> .config
echo "# CONFIG_SILENT_CONSOLE_UPDATE_ON_RELOC is not set" >> .config
echo "# CONFIG_SILENT_CONSOLE_UNTIL_ENV is not set" >> .config
%if "%target" == "rpiarm64-secureboot" || "%target" == "rpi5-secureboot"
echo "# CONFIG_FIT_RSASSA_PSS is not set" >> .config
echo "# CONFIG_FIT_CIPHER is not set" >> .config
echo "# CONFIG_FIT_VERBOSE is not set" >> .config
echo "# CONFIG_FIT_BEST_MATCH is not set" >> .config
echo "# CONFIG_SPL_LOAD_FIT_FULL is not set" >> .config
echo "# CONFIG_UPDATE_TFTP is not set" >> .config
echo "# CONFIG_CMD_VBE is not set" >> .config
echo "# CONFIG_ASYMMETRIC_KEY_TYPE is not set" >> .config
%endif

echo "Attempting to enable fdt apply command (.dtbo) support."
echo "CONFIG_OF_LIBFDT_OVERLAY=y" >> .config

%if "%target" == "rpiarm64-secureboot" || "%target" == "rpi5-secureboot"
cp %{SOURCE5} .
%endif

make %{?_smp_mflags} CROSS_COMPILE= HOSTCFLAGS="%{optflags}" $extra_makeflags all

# Make sure EFI Secure Boot is enabled
%if "%target" == "rpiarm64-secureboot" || "%target" == "rpi5-secureboot"
grep 'CONFIG_EFI_SECURE_BOOT=y' .config || exit 1
%endif

%endif # tools_only

%install
%if %tools_only
install -D -m 0755 tools/mkenvimage %{buildroot}%{_bindir}/mkenvimage
install -D -m 0755 tools/gen_ethaddr_crc %{buildroot}%{_bindir}/gen_ethaddr_crc
install -D -m 0755 tools/dumpimage %{buildroot}%{_bindir}/dumpimage
install -D -m 0755 tools/fit_info %{buildroot}%{_bindir}/fit_info
install -D -m 0755 tools/fit_check_sign %{buildroot}%{_bindir}/fit_check_sign
install -D -m 0755 tools/fdtgrep %{buildroot}%{_bindir}/fdtgrep
install -D -m 0755 tools/ifwitool %{buildroot}%{_bindir}/ifwitool
install -D -m 0755 tools/mkimage %{buildroot}%{_bindir}/mkimage
install -D -m 0644 doc/mkimage.1 %{buildroot}%{_mandir}/man1/mkimage.1

%else

export NO_BRP_STRIP_DEBUG=true
export NO_DEBUGINFO_STRIP_DEBUG=true
%define uboot_dir /boot

%if 0%{?is_rpi}
%define uboot_dir /boot/vc
%endif

install -D -m 0644 u-boot%{binext} %{buildroot}%{uboot_dir}/u-boot%{binext}

%if "%{name}" == "u-boot-rpi4" || "%{name}" == "u-boot-rpiarm64" || "%{name}" == "u-boot-rpiarm64-secureboot" || "%{name}" == "u-boot-rpi5-secureboot"
echo -e "# Boot in AArch64 mode\narm_64bit=1" > %{buildroot}%{uboot_dir}/ubootconfig.txt
%endif

%if 0%{?is_rpi}
%post
# On the Raspberry Pi we chain-load u-boot.bin from bootcode.bin via config.txt.
# It needs to be on the first FAT partition, wherever we mounted it.
# a) Unmounted, then do nothing.
# b) Mounted as /boot/vc, then they're in the right place already.
# c) Mounted as /boot/efi, with /boot/vc as symlink, then nothing to be done.
# d) Mounted as /boot/efi, with /boot/vc a directory, then copy files over.
if mountpoint -q /boot/efi; then
  if ! [[ "$(readlink -f /boot/efi)" -ef "$(readlink -f %{uboot_dir})" ]]; then
    [ -f %{uboot_dir}/ubootconfig.txt ] && cp %{uboot_dir}/ubootconfig.txt /boot/efi
    cp %{uboot_dir}/u-boot%{binext} /boot/efi/
  fi
fi
%endif

%endif

%if %tools_only
%files tools
%else

%files
%endif
%defattr(-,root,root)
%license Licenses/gpl-2.0.txt

%if %tools_only
%{_bindir}/mkenvimage
%{_bindir}/gen_ethaddr_crc
%{_bindir}/dumpimage
%{_bindir}/fit_info
%{_bindir}/fit_check_sign
%{_bindir}/fdtgrep
%{_bindir}/ifwitool
%{_bindir}/mkimage
%{_mandir}/man1/mkimage.1.gz
%else
%doc README
%{uboot_dir}/*

%files doc
%defattr(-,root,root)
# Generic documents
%doc doc/develop/index.rst
%doc doc/usage/index.rst doc/usage/netconsole.rst
%doc doc/README.JFFS2_NAND
%doc doc/README.autoboot doc/README.console doc/README.dns
%doc doc/README.hwconfig doc/README.nand doc/README.serial_multi
%doc doc/README.standalone doc/README.update doc/README.usb
%doc doc/README.video doc/README.VLAN doc/README.silent doc/README.POST
%doc doc/usage/*
%doc doc/board/*
# Copy some useful kermit scripts as well
%doc tools/kermit/dot.kermrc tools/kermit/flash_param tools/kermit/send_cmd tools/kermit/send_image
# Now any h/w dependent Documentation
%endif

%changelog
openSUSE Build Service is sponsored by