From 5d5caaf6d232b0222c341c3192079e48a7bdcfee Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Mon, 4 Nov 2024 18:38:44 +0900 Subject: [PATCH 1/6] pinebookpro: Fix dead link to TF-A tarball --- build-pinebookpro.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build-pinebookpro.sh b/build-pinebookpro.sh index 377a9fdd..085e5270 100755 --- a/build-pinebookpro.sh +++ b/build-pinebookpro.sh @@ -30,7 +30,9 @@ export DEBIAN_FRONTEND="noninteractive" apt-get update apt-get install -y --no-install-recommends python3 bzip2 wget gcc-arm-none-eabi crossbuild-essential-arm64 make bison flex bc device-tree-compiler ca-certificates sed build-essential debootstrap qemu-user-static qemu-utils qemu-system-arm binfmt-support parted kpartx rsync git libssl-dev xz-utils coreutils util-linux -wget "https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/snapshot/trusted-firmware-a-$tfaver.tar.gz" +# Tarballs available on official Gitiles repo have different timestamps on every download, so we can't validate them using sha256sum +# Use GitHub mirror instead +wget -O "trusted-firmware-a-${tfaver}.tar.gz" "https://github.com/TrustedFirmware-A/trusted-firmware-a/archive/refs/tags/v${tfaver}.tar.gz" wget "ftp://ftp.denx.de/pub/u-boot/u-boot-${ubootver}.tar.bz2" echo "37f917922bcef181164908c470a2f941006791c0113d738c498d39d95d543b21 trusted-firmware-a-${tfaver}.tar.gz" | sha256sum --check From d382eec818db609613d3b6d5dafbeefadb41a772 Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Mon, 4 Nov 2024 18:57:44 +0900 Subject: [PATCH 2/6] pinebookpro: Fix gcc build error Imported from https://github.com/TrustedFirmware-A/trusted-firmware-a/commit/f943b7c8e292e3aad2fcbdd0a37505f62b3b4c87 --- build-pinebookpro.sh | 1 + ...ip-rk3399-fix-dram-section-placement.patch | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 pinebookpro/patches/uboot/0001-fix-rockchip-rk3399-fix-dram-section-placement.patch diff --git a/build-pinebookpro.sh b/build-pinebookpro.sh index 085e5270..ed1fc530 100755 --- a/build-pinebookpro.sh +++ b/build-pinebookpro.sh @@ -46,6 +46,7 @@ rm "trusted-firmware-a-${tfaver}.tar.gz" rm "u-boot-${ubootver}.tar.bz2" cd "trusted-firmware-a-${tfaver}" +patch -Np1 -i "${rootdir}/pinebookpro/patches/uboot/0001-fix-rockchip-rk3399-fix-dram-section-placement.patch" unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS CROSS_COMPILE=aarch64-linux-gnu- make PLAT=rk3399 cp build/rk3399/release/bl31/bl31.elf ../u-boot-${ubootver}/ diff --git a/pinebookpro/patches/uboot/0001-fix-rockchip-rk3399-fix-dram-section-placement.patch b/pinebookpro/patches/uboot/0001-fix-rockchip-rk3399-fix-dram-section-placement.patch new file mode 100644 index 00000000..15dc8653 --- /dev/null +++ b/pinebookpro/patches/uboot/0001-fix-rockchip-rk3399-fix-dram-section-placement.patch @@ -0,0 +1,39 @@ +From f943b7c8e292e3aad2fcbdd0a37505f62b3b4c87 Mon Sep 17 00:00:00 2001 +From: Patrick Georgi +Date: Wed, 23 Jun 2021 21:34:38 +0200 +Subject: [PATCH] fix(rockchip/rk3399): fix dram section placement + +To quote jwerner in T925: +"The __sramdata in the declaration is a mistake, the correct target +section for that global needs to be .pmusram.data. This used to be +in .sram.data once upon a time but then the suspend.c stuff got added +and required it to be moved to PMUSRAM. I guess they forgot to update +that part in the declaration and since the old GCC seemed to silently +prefer the attribute in the definition, nobody noticed." + +This fixes building with gcc 11. + +fix #T925 + +Change-Id: I2b91542277c95cf487eaa1344927294d5d1b8f2b +Signed-off-by: Patrick Georgi +--- + plat/rockchip/rk3399/drivers/dram/dram.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/plat/rockchip/rk3399/drivers/dram/dram.h b/plat/rockchip/rk3399/drivers/dram/dram.h +index 0eb12cf29..5572b1612 100644 +--- a/plat/rockchip/rk3399/drivers/dram/dram.h ++++ b/plat/rockchip/rk3399/drivers/dram/dram.h +@@ -149,7 +149,7 @@ struct rk3399_sdram_params { + uint32_t rx_cal_dqs[2][4]; + }; + +-extern __sramdata struct rk3399_sdram_params sdram_config; ++extern struct rk3399_sdram_params sdram_config; + + void dram_init(void); + +-- +2.47.0 + From b176e5f8291e89f1f05254568193585b80af9771 Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Mon, 4 Nov 2024 19:25:58 +0900 Subject: [PATCH 3/6] Fix another build error --- build-pinebookpro.sh | 3 +- ...ip-rk3399-fix-dram-section-placement.patch | 0 ...dd-support-for-new-binutils-versions.patch | 38 +++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) rename pinebookpro/patches/{uboot => trusted-firmware-a}/0001-fix-rockchip-rk3399-fix-dram-section-placement.patch (100%) create mode 100644 pinebookpro/patches/trusted-firmware-a/0002-feat-build-add-support-for-new-binutils-versions.patch diff --git a/build-pinebookpro.sh b/build-pinebookpro.sh index ed1fc530..45576998 100755 --- a/build-pinebookpro.sh +++ b/build-pinebookpro.sh @@ -46,7 +46,8 @@ rm "trusted-firmware-a-${tfaver}.tar.gz" rm "u-boot-${ubootver}.tar.bz2" cd "trusted-firmware-a-${tfaver}" -patch -Np1 -i "${rootdir}/pinebookpro/patches/uboot/0001-fix-rockchip-rk3399-fix-dram-section-placement.patch" +patch -Np1 -i "${rootdir}/pinebookpro/patches/trusted-firmware-a/0001-fix-rockchip-rk3399-fix-dram-section-placement.patch" +patch -Np1 -i "${rootdir}/pinebookpro/patches/trusted-firmware-a/0002-feat-build-add-support-for-new-binutils-versions.patch" unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS CROSS_COMPILE=aarch64-linux-gnu- make PLAT=rk3399 cp build/rk3399/release/bl31/bl31.elf ../u-boot-${ubootver}/ diff --git a/pinebookpro/patches/uboot/0001-fix-rockchip-rk3399-fix-dram-section-placement.patch b/pinebookpro/patches/trusted-firmware-a/0001-fix-rockchip-rk3399-fix-dram-section-placement.patch similarity index 100% rename from pinebookpro/patches/uboot/0001-fix-rockchip-rk3399-fix-dram-section-placement.patch rename to pinebookpro/patches/trusted-firmware-a/0001-fix-rockchip-rk3399-fix-dram-section-placement.patch diff --git a/pinebookpro/patches/trusted-firmware-a/0002-feat-build-add-support-for-new-binutils-versions.patch b/pinebookpro/patches/trusted-firmware-a/0002-feat-build-add-support-for-new-binutils-versions.patch new file mode 100644 index 00000000..5ef911a6 --- /dev/null +++ b/pinebookpro/patches/trusted-firmware-a/0002-feat-build-add-support-for-new-binutils-versions.patch @@ -0,0 +1,38 @@ +From b96d80fadd201c018a3477fd2c715d6fe9d1ad19 Mon Sep 17 00:00:00 2001 +From: Ryo Nakano +Date: Mon, 4 Nov 2024 19:22:18 +0900 +Subject: [PATCH] feat(build): add support for new binutils versions + +Backport the following commit to v2.3 + +https://github.com/TrustedFirmware-A/trusted-firmware-a/commit/1f49db5f25cdd4e43825c9bcc0575070b80f628c +--- + Makefile | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/Makefile b/Makefile +index f01a9ae3e..4621dc527 100644 +--- a/Makefile ++++ b/Makefile +@@ -366,6 +366,8 @@ endif + + GCC_V_OUTPUT := $(shell $(CC) -v 2>&1) + ++TF_LDFLAGS += -z noexecstack ++ + # LD = armlink + ifneq ($(findstring armlink,$(notdir $(LD))),) + TF_LDFLAGS += --diag_error=warning --lto_level=O1 +@@ -392,6 +394,9 @@ TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) + + # LD = gcc-ld (ld) or llvm-ld (ld.lld) or other + else ++# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we ++# are not loaded by a elf loader. ++TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments) + TF_LDFLAGS += --fatal-warnings -O1 + TF_LDFLAGS += --gc-sections + # ld.lld doesn't recognize the errata flags, +-- +2.47.0 + From 02be24c86dbfbbc26087d386edc2971debdf8cc3 Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Mon, 4 Nov 2024 19:50:26 +0900 Subject: [PATCH 4/6] pinebookpro: Fix bad patch --- build-pinebookpro.sh | 2 +- ...dd-support-for-new-binutils-versions.patch | 54 +++++++++++++++++++ ...dd-support-for-new-binutils-versions.patch | 38 ------------- 3 files changed, 55 insertions(+), 39 deletions(-) create mode 100644 pinebookpro/patches/trusted-firmware-a/0002-Add-support-for-new-binutils-versions.patch delete mode 100644 pinebookpro/patches/trusted-firmware-a/0002-feat-build-add-support-for-new-binutils-versions.patch diff --git a/build-pinebookpro.sh b/build-pinebookpro.sh index 45576998..3cf0ac0f 100755 --- a/build-pinebookpro.sh +++ b/build-pinebookpro.sh @@ -47,7 +47,7 @@ rm "u-boot-${ubootver}.tar.bz2" cd "trusted-firmware-a-${tfaver}" patch -Np1 -i "${rootdir}/pinebookpro/patches/trusted-firmware-a/0001-fix-rockchip-rk3399-fix-dram-section-placement.patch" -patch -Np1 -i "${rootdir}/pinebookpro/patches/trusted-firmware-a/0002-feat-build-add-support-for-new-binutils-versions.patch" +patch -Np1 -i "${rootdir}/pinebookpro/patches/trusted-firmware-a/0002-Add-support-for-new-binutils-versions.patch" unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS CROSS_COMPILE=aarch64-linux-gnu- make PLAT=rk3399 cp build/rk3399/release/bl31/bl31.elf ../u-boot-${ubootver}/ diff --git a/pinebookpro/patches/trusted-firmware-a/0002-Add-support-for-new-binutils-versions.patch b/pinebookpro/patches/trusted-firmware-a/0002-Add-support-for-new-binutils-versions.patch new file mode 100644 index 00000000..1a17bf48 --- /dev/null +++ b/pinebookpro/patches/trusted-firmware-a/0002-Add-support-for-new-binutils-versions.patch @@ -0,0 +1,54 @@ +From 701907b4c0e61fe35189ab8a9acf132887651932 Mon Sep 17 00:00:00 2001 +From: Ryo Nakano +Date: Mon, 4 Nov 2024 19:45:08 +0900 +Subject: [PATCH] Add support for new binutils versions + +Backport of the following upstream commits: + +- https://github.com/TrustedFirmware-A/trusted-firmware-a/commit/1f49db5f25cdd4e43825c9bcc0575070b80f628c +- https://github.com/TrustedFirmware-A/trusted-firmware-a/commit/86e489c1903c72b76c6ff3b3ff6b75774c132e59 +--- + Makefile | 4 ++++ + make_helpers/build_macros.mk | 4 ++++ + 2 files changed, 8 insertions(+) + +diff --git a/Makefile b/Makefile +index f01a9ae3e..65a30b6f7 100644 +--- a/Makefile ++++ b/Makefile +@@ -375,6 +375,7 @@ TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) + # LD = gcc (used when GCC LTO is enabled) + else ifneq ($(findstring gcc,$(notdir $(LD))),) + # Pass ld options with Wl or Xlinker switches ++TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments) + TF_LDFLAGS += -Wl,--fatal-warnings -O1 + TF_LDFLAGS += -Wl,--gc-sections + ifeq ($(ENABLE_LTO),1) +@@ -392,6 +393,9 @@ TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) + + # LD = gcc-ld (ld) or llvm-ld (ld.lld) or other + else ++# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we ++# are not loaded by a elf loader. ++TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments) + TF_LDFLAGS += --fatal-warnings -O1 + TF_LDFLAGS += --gc-sections + # ld.lld doesn't recognize the errata flags, +diff --git a/make_helpers/build_macros.mk b/make_helpers/build_macros.mk +index 1c3d14d05..cc40a30ac 100644 +--- a/make_helpers/build_macros.mk ++++ b/make_helpers/build_macros.mk +@@ -67,6 +67,10 @@ $(foreach d,$(0-9),$(eval __numeric := $(subst $(d),,$(__numeric)))) + $(if $(__numeric),$(error $(1) must be numeric)) + endef + ++# Convenience function to check for a given linker option. An call to ++# $(call ld_option, --no-XYZ) will return --no-XYZ if supported by the linker ++ld_option = $(shell $(LD) $(1) -Wl,--version >/dev/null 2>&1 || $(LD) $(1) -v >/dev/null 2>&1 && echo $(1)) ++ + # CREATE_SEQ is a recursive function to create sequence of numbers from 1 to + # $(2) and assign the sequence to $(1) + define CREATE_SEQ +-- +2.47.0 + diff --git a/pinebookpro/patches/trusted-firmware-a/0002-feat-build-add-support-for-new-binutils-versions.patch b/pinebookpro/patches/trusted-firmware-a/0002-feat-build-add-support-for-new-binutils-versions.patch deleted file mode 100644 index 5ef911a6..00000000 --- a/pinebookpro/patches/trusted-firmware-a/0002-feat-build-add-support-for-new-binutils-versions.patch +++ /dev/null @@ -1,38 +0,0 @@ -From b96d80fadd201c018a3477fd2c715d6fe9d1ad19 Mon Sep 17 00:00:00 2001 -From: Ryo Nakano -Date: Mon, 4 Nov 2024 19:22:18 +0900 -Subject: [PATCH] feat(build): add support for new binutils versions - -Backport the following commit to v2.3 - -https://github.com/TrustedFirmware-A/trusted-firmware-a/commit/1f49db5f25cdd4e43825c9bcc0575070b80f628c ---- - Makefile | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/Makefile b/Makefile -index f01a9ae3e..4621dc527 100644 ---- a/Makefile -+++ b/Makefile -@@ -366,6 +366,8 @@ endif - - GCC_V_OUTPUT := $(shell $(CC) -v 2>&1) - -+TF_LDFLAGS += -z noexecstack -+ - # LD = armlink - ifneq ($(findstring armlink,$(notdir $(LD))),) - TF_LDFLAGS += --diag_error=warning --lto_level=O1 -@@ -392,6 +394,9 @@ TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) - - # LD = gcc-ld (ld) or llvm-ld (ld.lld) or other - else -+# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we -+# are not loaded by a elf loader. -+TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments) - TF_LDFLAGS += --fatal-warnings -O1 - TF_LDFLAGS += --gc-sections - # ld.lld doesn't recognize the errata flags, --- -2.47.0 - From e777236b0f221fc5dec1383304156a6b13e24eb3 Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Mon, 4 Nov 2024 21:34:57 +0900 Subject: [PATCH 5/6] pinebookpro: Update kernel config Used the following command: make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- olddefconfig --- pinebookpro/config/kernel/pinebook-pro-5.8.config | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pinebookpro/config/kernel/pinebook-pro-5.8.config b/pinebookpro/config/kernel/pinebook-pro-5.8.config index 0a109f6e..b15d72d8 100644 --- a/pinebookpro/config/kernel/pinebook-pro-5.8.config +++ b/pinebookpro/config/kernel/pinebook-pro-5.8.config @@ -2,14 +2,15 @@ # Automatically generated file; DO NOT EDIT. # Linux/arm64 5.8.1 Kernel Configuration # -CONFIG_CC_VERSION_TEXT="gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0" +CONFIG_CC_VERSION_TEXT="aarch64-linux-gnu-gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0" CONFIG_CC_IS_GCC=y -CONFIG_GCC_VERSION=90300 -CONFIG_LD_VERSION=234000000 +CONFIG_GCC_VERSION=130200 +CONFIG_LD_VERSION=242000000 CONFIG_CLANG_VERSION=0 CONFIG_CC_CAN_LINK=y CONFIG_CC_CAN_LINK_STATIC=y CONFIG_CC_HAS_ASM_GOTO=y +CONFIG_CC_HAS_ASM_GOTO_OUTPUT=y CONFIG_CC_HAS_ASM_INLINE=y CONFIG_IRQ_WORK=y CONFIG_BUILDTIME_TABLE_SORT=y @@ -383,6 +384,7 @@ CONFIG_SYS_SUPPORTS_HUGETLBFS=y CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK=y +CONFIG_CC_HAVE_SHADOW_CALL_STACK=y CONFIG_SECCOMP=y CONFIG_PARAVIRT=y CONFIG_PARAVIRT_TIME_ACCOUNTING=y @@ -442,6 +444,7 @@ CONFIG_ARM64_AMU_EXTN=y # ARMv8.5 architectural features # CONFIG_ARM64_BTI=y +CONFIG_ARM64_BTI_KERNEL=y CONFIG_CC_HAS_BRANCH_PROT_PAC_RET_BTI=y CONFIG_ARM64_E0PD=y CONFIG_ARCH_RANDOM=y @@ -720,6 +723,7 @@ CONFIG_HAVE_STACKPROTECTOR=y CONFIG_CC_HAS_STACKPROTECTOR_NONE=y CONFIG_STACKPROTECTOR=y CONFIG_STACKPROTECTOR_STRONG=y +CONFIG_ARCH_SUPPORTS_SHADOW_CALL_STACK=y CONFIG_HAVE_CONTEXT_TRACKING=y CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y @@ -8363,7 +8367,9 @@ CONFIG_LSM="yama,loadpin,safesetid,integrity,selinux,smack,tomoyo,apparmor" # # Memory initialization # +CONFIG_CC_HAS_AUTO_VAR_INIT=y CONFIG_INIT_STACK_NONE=y +# CONFIG_INIT_STACK_ALL is not set # CONFIG_INIT_ON_ALLOC_DEFAULT_ON is not set # CONFIG_INIT_ON_FREE_DEFAULT_ON is not set # end of Memory initialization @@ -8815,6 +8821,7 @@ CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y CONFIG_HAVE_ARCH_KASAN=y CONFIG_HAVE_ARCH_KASAN_SW_TAGS=y CONFIG_CC_HAS_KASAN_GENERIC=y +CONFIG_CC_HAS_KASAN_SW_TAGS=y CONFIG_CC_HAS_WORKING_NOSANITIZE_ADDRESS=y # CONFIG_KASAN is not set CONFIG_KASAN_STACK=1 From 8086a8edc21b3c7fc1705b937c498e5a80e5fe44 Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Mon, 4 Nov 2024 21:46:31 +0900 Subject: [PATCH 6/6] pinebookpro: Use gitignored artifacts dir --- build-pinebookpro.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-pinebookpro.sh b/build-pinebookpro.sh index 3cf0ac0f..6f24151f 100755 --- a/build-pinebookpro.sh +++ b/build-pinebookpro.sh @@ -20,7 +20,7 @@ kernsha256="f8d2a4fe938ff7faa565765a52e347e518a0712ca6ddd41b198bd9cc1626a724 li free_space="500" rootdir=$(pwd) -basedir=$(pwd)/pinebook-pro +basedir=$(pwd)/artifacts/pinebook-pro mkdir -p "${basedir}" cd "${basedir}"