diff --git a/improve-riscv64-configs.patch b/improve-riscv64-configs.patch new file mode 100644 index 0000000..5244872 --- /dev/null +++ b/improve-riscv64-configs.patch @@ -0,0 +1,81 @@ +diff --git a/configs/qemu-riscv64_defconfig b/configs/qemu-riscv64_defconfig +index b8ccf8f4..c4463115 100644 +--- a/configs/qemu-riscv64_defconfig ++++ b/configs/qemu-riscv64_defconfig +@@ -20,3 +20,12 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y + CONFIG_DM_MTD=y + CONFIG_FLASH_SHOW_PROGRESS=0 + CONFIG_SYS_MAX_FLASH_BANKS=2 ++CONFIG_NR_CPUS=32 ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="cp.l ${fdtcontroladdr} ${fdt_addr_r} 0x20000;" ++CONFIG_CMD_SBI=y ++CONFIG_SYSRESET=y ++CONFIG_SYSRESET_SBI=y ++CONFIG_CMD_POWEROFF=y ++CONFIG_SYSRESET_CMD_POWEROFF=y ++CONFIG_FS_BTRFS=y +diff --git a/configs/qemu-riscv64_smode_defconfig b/configs/qemu-riscv64_smode_defconfig +index 6baad1de..71c443d2 100644 +--- a/configs/qemu-riscv64_smode_defconfig ++++ b/configs/qemu-riscv64_smode_defconfig +@@ -23,3 +23,8 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y + CONFIG_DM_MTD=y + CONFIG_FLASH_SHOW_PROGRESS=0 + CONFIG_SYS_MAX_FLASH_BANKS=2 ++CONFIG_CMD_SBI=y ++CONFIG_SYSRESET=y ++CONFIG_SYSRESET_SBI=y ++CONFIG_CMD_POWEROFF=y ++CONFIG_SYSRESET_CMD_POWEROFF=y +diff --git a/configs/qemu-riscv64_spl_defconfig b/configs/qemu-riscv64_spl_defconfig +index f663a137..5365b874 100644 +--- a/configs/qemu-riscv64_spl_defconfig ++++ b/configs/qemu-riscv64_spl_defconfig +@@ -25,3 +25,6 @@ CONFIG_DM_MTD=y + CONFIG_FLASH_SHOW_PROGRESS=0 + CONFIG_SYS_MAX_FLASH_BANKS=2 + # CONFIG_BINMAN_FDT is not set ++CONFIG_NR_CPUS=32 ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="cp.l ${fdtcontroladdr} ${fdt_addr_r} 0x20000;" +diff --git a/configs/sifive_unleashed_defconfig b/configs/sifive_unleashed_defconfig +index f68171c9..9ff2666c 100644 +--- a/configs/sifive_unleashed_defconfig ++++ b/configs/sifive_unleashed_defconfig +@@ -40,3 +40,8 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y + CONFIG_SPL_DM_SEQ_ALIAS=y + CONFIG_SPL_CLK=y + CONFIG_DM_MTD=y ++CONFIG_CMD_SBI=y ++CONFIG_SYSRESET=y ++CONFIG_SYSRESET_SBI=y ++CONFIG_CMD_POWEROFF=y ++CONFIG_SYSRESET_CMD_POWEROFF=y +diff --git a/configs/sifive_unmatched_defconfig b/configs/sifive_unmatched_defconfig +index 7c6c5b4d..c822f9d5 100644 +--- a/configs/sifive_unmatched_defconfig ++++ b/configs/sifive_unmatched_defconfig +@@ -63,3 +63,9 @@ CONFIG_SCSI=y + CONFIG_USB=y + CONFIG_USB_XHCI_HCD=y + CONFIG_USB_XHCI_PCI=y ++CONFIG_CMD_SBI=y ++CONFIG_SYSRESET=y ++CONFIG_SYSRESET_SBI=y ++CONFIG_CMD_POWEROFF=y ++CONFIG_SYSRESET_CMD_POWEROFF=y ++CONFIG_FS_BTRFS=y +diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h +index 2f594bfc..c3ce49ba 100644 +--- a/include/configs/qemu-riscv.h ++++ b/include/configs/qemu-riscv.h +@@ -31,8 +31,6 @@ + + #define CFG_EXTRA_ENV_SETTINGS \ + CFG_STD_DEVICES_SETTINGS \ +- "fdt_high=0xffffffffffffffff\0" \ +- "initrd_high=0xffffffffffffffff\0" \ + "kernel_addr_r=0x84000000\0" \ + "kernel_comp_addr_r=0x88000000\0" \ + "kernel_comp_size=0x4000000\0" \ diff --git a/riscv64-boards b/riscv64-boards new file mode 100644 index 0000000..0e0d939 --- /dev/null +++ b/riscv64-boards @@ -0,0 +1,6 @@ +qemu-riscv64 +qemu-riscv64_smode +qemu-riscv64_spl +sifive_unleashed +sifive_unmatched +starfive_visionfive2 diff --git a/uboot-tools.spec b/uboot-tools.spec index d726634..53f2e98 100644 --- a/uboot-tools.spec +++ b/uboot-tools.spec @@ -5,9 +5,12 @@ %bcond_without toolsonly %endif +# Set it to "opensbi" (stable) or opensbi-unstable (unstable, git) +%global opensbi opensbi-unstable + Name: uboot-tools Version: 2024.04 -Release: 0.7%{?candidate:.%{candidate}}%{?dist} +Release: 0.7%{?candidate:.%{candidate}}.0.riscv64%{?dist} Epoch: 1 Summary: U-Boot utilities License: GPLv2+ BSD LGPL-2.1+ LGPL-2.0+ @@ -16,6 +19,7 @@ URL: http://www.denx.de/wiki/U-Boot ExcludeArch: s390x Source0: https://ftp.denx.de/pub/u-boot/u-boot-%{version}%{?candidate:-%{candidate}}.tar.bz2 Source1: aarch64-boards +Source2: riscv64-boards # This is now legacy, most devices use bootflow, we keep this for the laggards Patch1: uefi-distro-load-FDT-from-any-partition-on-boot-device.patch @@ -36,6 +40,9 @@ Patch10: rpi-Switch-to-OF_HAS_PRIOR_STAGE-by-default.patch Patch11: rockchip-Add-initial-support-for-the-PinePhone-Pro.patch Patch12: rockchip-Enable-preboot-start-for-pci-usb.patch +# RISCV (riscv64): +Patch20: improve-riscv64-configs.patch + BuildRequires: bc BuildRequires: bison BuildRequires: dtc @@ -59,6 +66,9 @@ BuildRequires: python3-pyelftools %endif %endif Requires: dtc +%ifarch riscv64 +BuildRequires: %{opensbi} +%endif %description This package contains a few U-Boot utilities - mkimage for creating boot images @@ -73,12 +83,21 @@ BuildArch: noarch %description -n uboot-images-armv8 U-Boot firmware binaries for aarch64 boards %endif + +%ifarch riscv64 +%package -n uboot-images-riscv64 +Summary: U-Boot firmware images for riscv64 boards +BuildArch: noarch + +%description -n uboot-images-riscv64 +U-Boot firmware binaries for riscv64 boards +%endif %endif %prep %autosetup -p1 -n u-boot-%{version}%{?candidate:-%{candidate}} -cp %SOURCE1 . +cp %SOURCE1 %SOURCE2 . %build mkdir builds @@ -87,7 +106,12 @@ mkdir builds %make_build HOSTCC="gcc $RPM_OPT_FLAGS" CROSS_COMPILE="" tools-all O=builds/ %if %{with toolsonly} -%ifarch aarch64 +# OpenSBI firmware is distributed in U-Boot SPL images +%ifarch riscv64 +export OPENSBI=%{_datadir}/%{opensbi}/generic/firmware/fw_dynamic.bin +%endif + +%ifarch aarch64 riscv64 for board in $(cat %{_arch}-boards) do echo "Building board: $board" @@ -136,10 +160,10 @@ mkdir -p %{buildroot}%{_mandir}/man1 mkdir -p %{buildroot}%{_datadir}/uboot/ %if %{with toolsonly} -%ifarch aarch64 +%ifarch aarch64 riscv64 for board in $(ls builds) do - for file in u-boot.bin u-boot.img u-boot-dtb.img u-boot.itb u-boot-sunxi-with-spl.bin u-boot-rockchip-spi.bin u-boot-rockchip.bin idbloader.img idbloader-spi.img spl/boot.bin + for file in u-boot.bin u-boot.img u-boot-dtb.img u-boot.itb u-boot-sunxi-with-spl.bin u-boot-rockchip-spi.bin u-boot-rockchip.bin idbloader.img idbloader-spi.img spl/boot.bin spl/u-boot-spl.bin do if [ -f builds/$(echo $board)/$(echo $file) ]; then install -pD -m 0644 builds/$(echo $board)/$(echo $file) %{buildroot}%{_datadir}/uboot/$(echo $board)/$(echo $file) @@ -187,9 +211,18 @@ install -p -m 0755 builds/tools/env/fw_printenv %{buildroot}%{_bindir} %dir %{_datadir}/uboot/ %{_datadir}/uboot/* %endif + +%ifarch riscv64 +%files -n uboot-images-riscv64 +%dir %{_datadir}/uboot/ +%{_datadir}/uboot/* +%endif %endif %changelog +* Fri Mar 22 2024 David Abdurachmanov - 1:2024.04-0.7.rc4.0.riscv64 +- Add support for riscv64 + * Thu Mar 21 2024 Peter Robinson - 1:2024.04-0.7.rc4 - Updated patch for DTB loading