[packages/uboot] add support for odroid n2(+)
atler
atler at pld-linux.org
Sun Nov 28 15:26:19 CET 2021
commit b481b637f0d575f36e3701d93437020f6aebb667
Author: Jan Palus <atler at pld-linux.org>
Date: Sun Nov 28 13:04:59 2021 +0100
add support for odroid n2(+)
unfortunately ARM trusted firmware has no support for g12b platform yet
so instead hardkernel repo is used for images other than BL33 (u-boot
payload itself). that in turn makes the experience pretty nightmarish ie
hardkernel uboot requires x86_64 host (x86_64 binaries are literally
part of the process) and an ancient toolchain (gcc4). summary of patches
to make build fully working on aarch64 with modern toolchain:
hardkernel-uboot-gcc5.patch: don't fail on gcc newer than 4 and instead
use same include file as for gcc4 with newer gcc versions
hardkernel-uboot-werror.patch: disable -Werror preventing successful
compilation with modern toolchain
hardkernel-uboot-arm_cross.patch: boot image requires toolchains for
both aarch64 and arm. hardkernel hardcoded the values without a
possibility to override them independently so add such support
hardkernel-uboot-no_stdint.patch: don't include unused stdint.h which
likely requires glibc
hardkernel-uboot-x86_64_bin.patch: build process requires use of x86_64
binaries so add support for emulation wrappers -- separately for static
binaries (qemu) and dynamic binaries (box64)
hardkernel-uboot-acs.patch: acs.bin is a simple binary with
configuration data organized around acs_setting struct loaded into fixed
address in memory. first value in this binary points to beginning of
acs_setting struct. now likely due to toolchain differences first value
with address is either followed by 2 words of zeros (original gcc4 based
toolchain) or 1 word of zeros (up-to-date toolchain) which is enough of a
difference to create broken image. ensure acs_setting address is
followed by at least two words of zeros
hardkernel-uboot-uboot_payload.patch: make BL33 image location
customizable so final image assembly can refer to uboot payload we
target. note that this way process is much simpler than following:
https://u-boot.readthedocs.io/en/latest/board/amlogic/odroid-n2.html
and it also produces smaller image than docs from u-boot which is pretty
significant difference as the bigger image is big enough to prevent
creation of first partition at 2048 sector boundary
hardkernel-uboot-acs.patch | 11 +++++++
hardkernel-uboot-arm_cross.patch | 12 +++++++
hardkernel-uboot-gcc5.patch | 14 ++++++++
hardkernel-uboot-no_stdint.patch | 10 ++++++
hardkernel-uboot-uboot_payload.patch | 28 ++++++++++++++++
hardkernel-uboot-werror.patch | 21 ++++++++++++
hardkernel-uboot-x86_64_bin.patch | 24 ++++++++++++++
uboot.spec | 64 +++++++++++++++++++++++++++++++++---
8 files changed, 180 insertions(+), 4 deletions(-)
---
diff --git a/uboot.spec b/uboot.spec
index 8fb9524..35e4027 100644
--- a/uboot.spec
+++ b/uboot.spec
@@ -7,18 +7,31 @@ License: GPL v2
Group: Applications/System
Source0: https://ftp.denx.de/pub/u-boot/u-boot-%{version}.tar.bz2
# Source0-md5: f1392080facf59dd2c34096a5fd95d4c
+Source1: https://github.com/hardkernel/u-boot/archive/travis/odroidc4-189/odroid-189.tar.gz
+# Source1-md5: dd117b6180ad5c9abb3303b31e57e7b4
Patch0: rpi-Enable-using-the-DT-provided-by-the-Raspberry-Pi.patch
Patch1: %{name}-pbp_usb_hang.patch
Patch2: rk3399-emmc.patch
+Patch3: hardkernel-uboot-gcc5.patch
+Patch4: hardkernel-uboot-werror.patch
+Patch5: hardkernel-uboot-arm_cross.patch
+Patch6: hardkernel-uboot-no_stdint.patch
+Patch7: hardkernel-uboot-x86_64_bin.patch
+Patch8: hardkernel-uboot-acs.patch
+Patch9: hardkernel-uboot-uboot_payload.patch
URL: https://www.denx.de/wiki/U-Boot
-%ifarch aarch64
-BuildRequires: arm-trusted-firmware-armv8
-%endif
BuildRequires: bison
BuildRequires: dtc
BuildRequires: flex
BuildRequires: openssl-devel
BuildRequires: rpmbuild(macros) >= 2.007
+%ifarch aarch64
+BuildRequires: arm-trusted-firmware-armv8
+BuildRequires: box64
+BuildRequires: crossarm-gcc
+BuildRequires: qemu-user
+BuildConflicts: libfdt-devel
+%endif
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%define common_configs tools-only
@@ -30,7 +43,7 @@ BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%define arch_configs rpi_2
%endif
%ifarch aarch64
-%define arch_configs pinebook-pro-rk3399
+%define arch_configs odroid-n2 pinebook-pro-rk3399
%endif
%define configs %{common_configs} %{?arch_configs}
@@ -49,6 +62,17 @@ Das U-Boot (Universal Bootloader lub "łódź podwodna" po niemiecku) to
bootloader dla wielu różnych architektur komputerów, w tym PPC, ARM,
AVR32, MIPS, x86, 68k, Nios i MicroBlaze.
+%package image-odroid-n2
+Summary: U-Boot firmware images for Odroid N2/N2+
+Summary(pl.UTF-8): Obrazy firmware'u U-Boot dla urządzeń Odroid N2/N2+
+Group: Applications/System
+
+%description image-odroid-n2
+U-Boot firmware images for Odroid N2/N2+.
+
+%description image-odroid-n2 -l pl.UTF-8
+Obrazy firmware'u U-Boot dla urządzeń Odroid N2/N2+.
+
%package image-pinebook-pro
Summary: U-Boot firmware images for Pinebook Pro
Summary(pl.UTF-8): Obrazy firmware'u U-Boot dla urządzeń Pinebook Pro
@@ -118,6 +142,18 @@ czasie utworzenia, sumach kontrolnych CRC32 itp.
%ifarch aarch64
%patch1 -p1
%patch2 -p1
+install -d build/hardkernel-uboot-odroid
+tar xf %{SOURCE1} -C build/hardkernel-uboot-odroid
+mv build/hardkernel-uboot-odroid/u-boot*/* build/hardkernel-uboot-odroid
+cd build/hardkernel-uboot-odroid
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
+%patch8 -p1
+%patch9 -p1
+cd ../..
%endif
%build
@@ -144,6 +180,19 @@ for config in %configs; do
V=1 \
O=build/$config
done
+%ifarch aarch64
+cd build/hardkernel-uboot-odroid
+%{__make} odroidn2_defconfig \
+ V=1
+%{__make} \
+ CROSS_COMPILE= \
+ ARM_CROSS_COMPILE=arm-linux-gnueabi- \
+ UBOOT_PAYLOAD=$(pwd)/../odroid-n2/u-boot.bin \
+ X86_64_DYNAMIC_WRAPPER=/usr/bin/box64 \
+ X86_64_STATIC_WRAPPER=/usr/bin/qemu-x86_64 \
+ V=1
+cd ../..
+%endif
%install
rm -rf $RPM_BUILD_ROOT
@@ -155,6 +204,9 @@ for config in %configs; do
elif echo ' %rk3399_configs ' | grep -q " $config "; then
install -d $RPM_BUILD_ROOT%{imagedir}/$config
cp -p build/$config/{idbloader.img,u-boot.itb} $RPM_BUILD_ROOT%{imagedir}/$config
+ elif [ $config = "odroid-n2" ]; then
+ install -d $RPM_BUILD_ROOT%{imagedir}/$config
+ cp -p build/hardkernel-uboot-odroid/sd_fuse/u-boot.bin $RPM_BUILD_ROOT%{imagedir}/$config
else
install -d $RPM_BUILD_ROOT%{imagedir}/$config
cp -p build/$config/u-boot.bin $RPM_BUILD_ROOT%{imagedir}/$config
@@ -170,6 +222,10 @@ rm -rf $RPM_BUILD_ROOT
%dir %{imagedir}
%ifarch aarch64
+%files image-odroid-n2
+%defattr(644,root,root,755)
+%{imagedir}/odroid-n2
+
%files image-pinebook-pro
%defattr(644,root,root,755)
%{imagedir}/pinebook-pro-rk3399
diff --git a/hardkernel-uboot-acs.patch b/hardkernel-uboot-acs.patch
new file mode 100644
index 0000000..c0d3292
--- /dev/null
+++ b/hardkernel-uboot-acs.patch
@@ -0,0 +1,11 @@
+--- hardkernel-uboot-odroid/arch/arm/cpu/armv8/g12b/firmware/acs/acs_entry.S.orig 2021-03-29 03:39:35.000000000 +0200
++++ hardkernel-uboot-odroid/arch/arm/cpu/armv8/g12b/firmware/acs/acs_entry.S 2021-11-28 02:02:25.014983869 +0100
+@@ -7,5 +7,5 @@
+ #ifdef CONFIG_MDUMP_COMPRESS
+ .word __ramdump_data
+ #else
+- .word 0x0
+-#endif
+\ No newline at end of file
++ .quad 0x0
++#endif
diff --git a/hardkernel-uboot-arm_cross.patch b/hardkernel-uboot-arm_cross.patch
new file mode 100644
index 0000000..cc3f91c
--- /dev/null
+++ b/hardkernel-uboot-arm_cross.patch
@@ -0,0 +1,12 @@
+--- hardkernel-uboot-odroid/arch/arm/cpu/armv8/g12b/firmware/scp_task/Makefile.orig 2021-11-21 15:35:31.551670174 +0100
++++ hardkernel-uboot-odroid/arch/arm/cpu/armv8/g12b/firmware/scp_task/Makefile 2021-11-21 15:38:26.863510869 +0100
+@@ -6,7 +6,8 @@
+ include $(buildtree)/.config
+
+ # Select ARMv7-m bare-metal toolchain
+-CROSS_COMPILE=arm-none-eabi-
++ARM_CROSS_COMPILE=arm-none-eabi-
++override CROSS_COMPILE=$(ARM_CROSS_COMPILE)
+ ASM=$(CROSS_COMPILE)as
+ CC=$(CROSS_COMPILE)gcc
+ CPP=$(CROSS_COMPILE)cpp
diff --git a/hardkernel-uboot-gcc5.patch b/hardkernel-uboot-gcc5.patch
new file mode 100644
index 0000000..6235fb3
--- /dev/null
+++ b/hardkernel-uboot-gcc5.patch
@@ -0,0 +1,14 @@
+--- hardkernel-uboot-odroid/include/linux/compiler-gcc.h.orig 2021-03-29 03:39:35.000000000 +0200
++++ hardkernel-uboot-odroid/include/linux/compiler-gcc.h 2021-11-21 15:25:04.044889807 +0100
+@@ -111,7 +111,11 @@
+ #define __gcc_header(x) #x
+ #define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
+ #define gcc_header(x) _gcc_header(x)
++#if __GNUC__ >= 4
++#include gcc_header(4)
++#else
+ #include gcc_header(__GNUC__)
++#endif
+
+ #if !defined(__noclone)
+ #define __noclone /* not needed */
diff --git a/hardkernel-uboot-no_stdint.patch b/hardkernel-uboot-no_stdint.patch
new file mode 100644
index 0000000..3803c16
--- /dev/null
+++ b/hardkernel-uboot-no_stdint.patch
@@ -0,0 +1,10 @@
+--- hardkernel-uboot-odroid/arch/arm/cpu/armv8/g12b/firmware/scp_task/uart.c.orig 2021-11-21 15:42:14.755011547 +0100
++++ hardkernel-uboot-odroid/arch/arm/cpu/armv8/g12b/firmware/scp_task/uart.c 2021-11-21 15:42:26.868250049 +0100
+@@ -20,7 +20,6 @@
+ */
+
+ #include "registers.h"
+-#include <stdint.h>
+ #include "task_apis.h"
+
+ /* #define P_AO_UART_WFIFO (0xc81004c0) */
diff --git a/hardkernel-uboot-uboot_payload.patch b/hardkernel-uboot-uboot_payload.patch
new file mode 100644
index 0000000..b79ec5c
--- /dev/null
+++ b/hardkernel-uboot-uboot_payload.patch
@@ -0,0 +1,28 @@
+--- hardkernel-uboot-odroid/fip/Makefile.orig 2021-03-29 03:39:35.000000000 +0200
++++ hardkernel-uboot-odroid/fip/Makefile 2021-11-21 17:32:49.696089392 +0100
+@@ -13,6 +13,7 @@
+ AML_USER_KEY := $(srctree)/$(BOARDDIR)/aml-user-key.sig
+ FIP_BL32_PROCESS =
+ DDR_FW_NAME := aml_ddr.fw
++UBOOT_PAYLOAD := $(buildtree)/u-boot.bin
+
+ ifeq ($(CONFIG_AML_BL33_COMPRESS_ENABLE),y)
+ BL33_COMPRESS_FLAG := --compress lz4
+@@ -71,7 +72,7 @@
+
+ FIP_ARGS := --bl30 $(buildtree)/fip/bl30_new.bin \
+ --bl31 $(buildsrc)/fip/$(SOC)/bl31.$(BL3X_SUFFIX) \
+- --bl33 $(buildtree)/u-boot.bin
++ --bl33 $(UBOOT_PAYLOAD)
+
+ $(buildtree)/fip/fip.bin: FORCE
+ $(Q)echo Building $@...
+@@ -122,7 +123,7 @@
+ --input $(buildsrc)/fip/$(SOC)/bl32.$(BL3X_SUFFIX) \
+ --output $(buildtree)/fip/bl32.$(BL3X_SUFFIX).enc))
+ $(call encrypt_step, --bl3sig --type bl33 $(V3_PROCESS_FLAG) $(BL33_COMPRESS_FLAG) \
+- --input $(buildtree)/u-boot.bin \
++ --input $(UBOOT_PAYLOAD) \
+ --output $(buildtree)/fip/bl33.bin.enc)
+ endif
+ $(call encrypt_step, --bl2sig \
diff --git a/hardkernel-uboot-werror.patch b/hardkernel-uboot-werror.patch
new file mode 100644
index 0000000..a3af07e
--- /dev/null
+++ b/hardkernel-uboot-werror.patch
@@ -0,0 +1,21 @@
+--- hardkernel-uboot-odroid/Makefile.orig 2021-03-29 03:39:35.000000000 +0200
++++ hardkernel-uboot-odroid/Makefile 2021-11-21 15:31:27.980593091 +0100
+@@ -589,7 +589,6 @@
+ KBUILD_CPPFLAGS += $(KCPPFLAGS)
+ KBUILD_AFLAGS += $(KAFLAGS)
+ KBUILD_CFLAGS += $(KCFLAGS)
+-KBUILD_CFLAGS += -Werror
+
+ # Use UBOOTINCLUDE when you must reference the include/ directory.
+ # Needed to be compatible with the O= option
+--- hardkernel-uboot-odroid/arch/arm/cpu/armv8/g12b/firmware/acs/Makefile.orig 2021-11-21 15:33:42.835979314 +0100
++++ hardkernel-uboot-odroid/arch/arm/cpu/armv8/g12b/firmware/acs/Makefile 2021-11-21 15:33:54.685870737 +0100
+@@ -180,7 +180,7 @@
+ -mgeneral-regs-only -D__ASSEMBLY__ \
+ ${DEFINES} ${INCLUDES}
+ CFLAGS += -nostdinc -pedantic -ffreestanding -Wall \
+- -Werror -mgeneral-regs-only -std=c99 -c -Os \
++ -mgeneral-regs-only -std=c99 -c -Os \
+ ${DEFINES} ${INCLUDES} $(VPATH_LIST:%=-I%)
+ CFLAGS += -ffunction-sections -fdata-sections
+ ASFLAGS += ${FIRMWARE_CPPFLAGS}
diff --git a/hardkernel-uboot-x86_64_bin.patch b/hardkernel-uboot-x86_64_bin.patch
new file mode 100644
index 0000000..877bcce
--- /dev/null
+++ b/hardkernel-uboot-x86_64_bin.patch
@@ -0,0 +1,24 @@
+--- hardkernel-uboot-odroid/fip/Makefile.orig 2021-11-21 17:41:53.590511510 +0100
++++ hardkernel-uboot-odroid/fip/Makefile 2021-11-22 11:19:57.287486043 +0100
+@@ -67,7 +67,7 @@
+ endef
+
+ define encrypt_step
+- $(Q)$(buildsrc)/fip/$(SOC)/aml_encrypt_$(SOC) $1
++ $(Q)$(X86_64_STATIC_WRAPPER) $(buildsrc)/fip/$(SOC)/aml_encrypt_$(SOC) $1
+ endef
+
+ FIP_ARGS := --bl30 $(buildtree)/fip/bl30_new.bin \
+--- hardkernel-uboot-odroid/fip/Makefile.orig 2021-03-29 03:39:35.000000000 +0200
++++ hardkernel-uboot-odroid/fip/Makefile 2021-11-21 17:27:36.244548072 +0100
+@@ -97,8 +97,8 @@
+ $(eval FIP_BL32_PROCESS := --bl32 $(buildsrc)/fip/$(SOC)/bl32.$(BL3X_SUFFIX).enc)
+ endif
+ endif
+- $(Q)$(buildsrc)/fip/fip_create $(FIP_ARGS) $@
+- $(Q)$(buildsrc)/fip/fip_create --dump $@
++ $(Q)$(X86_64_DYNAMIC_WRAPPER) $(buildsrc)/fip/fip_create $(FIP_ARGS) $@
++ $(Q)$(X86_64_DYNAMIC_WRAPPER) $(buildsrc)/fip/fip_create --dump $@
+
+ # build final bootloader
+ $(Q)cat $(buildtree)/fip/bl2_new.bin $(buildtree)/fip/fip.bin > $(buildtree)/fip/boot_new.bin
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/uboot.git/commitdiff/b481b637f0d575f36e3701d93437020f6aebb667
More information about the pld-cvs-commit
mailing list