diff options
author | Khem Raj <raj.khem@gmail.com> | 2022-02-14 15:37:39 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-02-16 09:46:29 +0000 |
commit | 3656dd75c273ca5d7b240a0b7fbf77d5726e5654 (patch) | |
tree | 73f965d8f1f70ba5244bb093b631115407007b72 /meta/recipes-bsp/u-boot | |
parent | f23738b9fbf69c8e06fa4fb0d3e7dd80a89fe841 (diff) | |
download | poky-3656dd75c273ca5d7b240a0b7fbf77d5726e5654.tar.gz |
u-boot: Fix RISCV build with binutils 2.38
Ensure right ABI and march is used which matches OE core settings
(From OE-Core rev: 17cd727f333580c6fd7ff20c90ede9ccce9ef60b)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-bsp/u-boot')
3 files changed, 52 insertions, 8 deletions
diff --git a/meta/recipes-bsp/u-boot/files/0001-riscv-fix-build-with-binutils-2.38.patch b/meta/recipes-bsp/u-boot/files/0001-riscv-fix-build-with-binutils-2.38.patch new file mode 100644 index 0000000000..3598329b99 --- /dev/null +++ b/meta/recipes-bsp/u-boot/files/0001-riscv-fix-build-with-binutils-2.38.patch | |||
@@ -0,0 +1,40 @@ | |||
1 | From 26a7f6b1e4c5f715c03e59a623f0d620498b92cf Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sun, 13 Feb 2022 21:11:31 -0800 | ||
4 | Subject: [PATCH] riscv: fix build with binutils 2.38 | ||
5 | |||
6 | From version 2.38, binutils default to ISA spec version 20191213. This | ||
7 | means that the csr read/write (csrr*/csrw*) instructions and fence.i | ||
8 | instruction has separated from the `I` extension, become two standalone | ||
9 | extensions: Zicsr and Zifencei. | ||
10 | |||
11 | The fix is to specify those extensions explicitely in -march. However as | ||
12 | older binutils version do not support this, we first need to detect | ||
13 | that. | ||
14 | |||
15 | Fixes | ||
16 | arch/riscv/lib/cache.c: Assembler messages: | ||
17 | arch/riscv/lib/cache.c:12: Error: unrecognized opcode `fence.i' | ||
18 | |||
19 | Upstream-Status: Submitted [] | ||
20 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
21 | --- | ||
22 | arch/riscv/Makefile | 7 ++++++- | ||
23 | 1 file changed, 6 insertions(+), 1 deletion(-) | ||
24 | |||
25 | --- a/arch/riscv/Makefile | ||
26 | +++ b/arch/riscv/Makefile | ||
27 | @@ -28,7 +28,12 @@ ifeq ($(CONFIG_CMODEL_MEDANY),y) | ||
28 | CMODEL = medany | ||
29 | endif | ||
30 | |||
31 | -ARCH_FLAGS = -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_F)$(ARCH_D)$(ARCH_C) -mabi=$(ABI) \ | ||
32 | +# Newer binutils versions default to ISA spec version 20191213 which moves some | ||
33 | +# instructions from the I extension to the Zicsr and Zifencei extensions. | ||
34 | +toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_F)$(ARCH_D)$(ARCH_C)_zicsr_zifencei) | ||
35 | +zicsr_zifencei-$(toolchain-need-zicsr-zifencei) := _zicsr_zifencei | ||
36 | + | ||
37 | +ARCH_FLAGS = -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_F)$(ARCH_D)$(ARCH_C)$(zicsr_zifencei-y) -mabi=$(ABI) \ | ||
38 | -mcmodel=$(CMODEL) | ||
39 | |||
40 | PLATFORM_CPPFLAGS += $(ARCH_FLAGS) | ||
diff --git a/meta/recipes-bsp/u-boot/files/0001-riscv32-Use-double-float-ABI-for-rv32.patch b/meta/recipes-bsp/u-boot/files/0001-riscv32-Use-double-float-ABI-for-rv32.patch index 0ed3de4914..0bf1bef2c9 100644 --- a/meta/recipes-bsp/u-boot/files/0001-riscv32-Use-double-float-ABI-for-rv32.patch +++ b/meta/recipes-bsp/u-boot/files/0001-riscv32-Use-double-float-ABI-for-rv32.patch | |||
@@ -13,11 +13,16 @@ Upstream-Status: Inappropriate [embedded specific] | |||
13 | arch/riscv/Makefile | 6 ++++-- | 13 | arch/riscv/Makefile | 6 ++++-- |
14 | 1 file changed, 4 insertions(+), 2 deletions(-) | 14 | 1 file changed, 4 insertions(+), 2 deletions(-) |
15 | 15 | ||
16 | diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile | ||
17 | index 0b80eb8d86..7324946f48 100644 | ||
18 | --- a/arch/riscv/Makefile | 16 | --- a/arch/riscv/Makefile |
19 | +++ b/arch/riscv/Makefile | 17 | +++ b/arch/riscv/Makefile |
20 | @@ -9,7 +9,9 @@ ifeq ($(CONFIG_ARCH_RV64I),y) | 18 | @@ -5,11 +5,15 @@ |
19 | |||
20 | ifeq ($(CONFIG_ARCH_RV64I),y) | ||
21 | ARCH_BASE = rv64im | ||
22 | - ABI = lp64 | ||
23 | + ABI = lp64d | ||
24 | + ARCH_D = d | ||
25 | + ARCH_F = f | ||
21 | endif | 26 | endif |
22 | ifeq ($(CONFIG_ARCH_RV32I),y) | 27 | ifeq ($(CONFIG_ARCH_RV32I),y) |
23 | ARCH_BASE = rv32im | 28 | ARCH_BASE = rv32im |
@@ -28,7 +33,7 @@ index 0b80eb8d86..7324946f48 100644 | |||
28 | endif | 33 | endif |
29 | ifeq ($(CONFIG_RISCV_ISA_A),y) | 34 | ifeq ($(CONFIG_RISCV_ISA_A),y) |
30 | ARCH_A = a | 35 | ARCH_A = a |
31 | @@ -24,7 +26,7 @@ ifeq ($(CONFIG_CMODEL_MEDANY),y) | 36 | @@ -24,7 +28,7 @@ ifeq ($(CONFIG_CMODEL_MEDANY),y) |
32 | CMODEL = medany | 37 | CMODEL = medany |
33 | endif | 38 | endif |
34 | 39 | ||
@@ -37,6 +42,3 @@ index 0b80eb8d86..7324946f48 100644 | |||
37 | -mcmodel=$(CMODEL) | 42 | -mcmodel=$(CMODEL) |
38 | 43 | ||
39 | PLATFORM_CPPFLAGS += $(ARCH_FLAGS) | 44 | PLATFORM_CPPFLAGS += $(ARCH_FLAGS) |
40 | -- | ||
41 | 2.30.0 | ||
42 | |||
diff --git a/meta/recipes-bsp/u-boot/u-boot_2022.01.bb b/meta/recipes-bsp/u-boot/u-boot_2022.01.bb index 617827ff08..0d2464d74b 100644 --- a/meta/recipes-bsp/u-boot/u-boot_2022.01.bb +++ b/meta/recipes-bsp/u-boot/u-boot_2022.01.bb | |||
@@ -1,7 +1,9 @@ | |||
1 | require u-boot-common.inc | 1 | require u-boot-common.inc |
2 | require u-boot.inc | 2 | require u-boot.inc |
3 | 3 | ||
4 | SRC_URI:append = " file://0001-riscv32-Use-double-float-ABI-for-rv32.patch" | 4 | SRC_URI:append = " file://0001-riscv32-Use-double-float-ABI-for-rv32.patch \ |
5 | file://0001-riscv-fix-build-with-binutils-2.38.patch \ | ||
6 | " | ||
5 | 7 | ||
6 | DEPENDS += "bc-native dtc-native python3-setuptools-native" | 8 | DEPENDS += "bc-native dtc-native python3-setuptools-native" |
7 | 9 | ||