[Buildroot] [PATCH v4 0/9] Add RV64 NOMMU and Canaan K210 SoC support

Damien Le Moal Damien.LeMoal at wdc.com
Thu Sep 2 05:13:18 UTC 2021


On Mon, 2021-08-30 at 23:55 +0200, Thomas Petazzoni wrote:
> Hello Damien,
> 
> On Mon, 30 Aug 2021 21:42:02 +0000
> Damien Le Moal <Damien.LeMoal at wdc.com> wrote:
> 
> > On 2021/08/31 6:32, Thomas Petazzoni wrote:
> > > Hello Damien,
> > > 
> > > On Mon, 30 Aug 2021 13:40:51 +0900
> > > Damien Le Moal <damien.lemoal at wdc.com> wrote:
> > >   
> > > > Christoph Hellwig (2):
> > > >   package/elf2flt: add RISC-V 64-bits support
> > > >   package/Makefile.in: Fix NOMMU RISC-V 64-bits toolchain base name
> > > > 
> > > > Damien Le Moal (7):
> > > >   arch/config: Make RISC-V 64-bits MMU optional  
> > > 
> > > Just tested with the first 3 patches applied the following defconfig:
> > > 
> > > BR2_riscv=y
> > > # BR2_USE_MMU is not set
> > > 
> > > It fails to build with:
> > > 
> > > /home/thomas/buildroot/buildroot/output/host/riscv64-buildroot-linux-uclibc/bin/elf2flt: Loading to RAM ('-r' option) 
> > > is required  
> > 
> > Yes, this option is mandatory for rv64. The elf2flt patch checks for it, but
> > only for rv64. Other architectures should not be affected.
> > The following patch that adds the Sipeed MAIX bit board support adds that option
> > to busybox build. So I guess that build option should be moved to this patch ?
> 
> I see:
> 
> +CONFIG_EXTRA_LDFLAGS="-Os -static -Wl,-elf2flt=-r"
> 
> in your Busybox configuration file indeed. But what about other
> packages ?
> 
> If this is needed for all packages built for RISC-V 64-bit noMMU, then
> we need to have it set as part of the toolchain wrapper. Actually, the
> toolchain wrapper already passes -Wl,-elf2flt, so it would only have to
> be tweaked to pass -Wl,-elf2flt=-r instead.
> 
> See:
> 
> #ifdef BR_BINFMT_FLAT
>         "-Wl,-elf2flt",
> #endif
> 
> in toolchain/toolchain-wrapper.c

I tried this approach, doing this:

diff --git a/toolchain/toolchain-wrapper.c b/toolchain/toolchain-wrapper.c
index 0fb6064b1c..730f46d60e 100644
--- a/toolchain/toolchain-wrapper.c
+++ b/toolchain/toolchain-wrapper.c
@@ -92,6 +92,9 @@ static char *predef_args[] = {
 #ifdef BR_BINFMT_FLAT
        "-Wl,-elf2flt",
 #endif
+#ifdef BR_BINFMT_FLAT_ONE_STATIC
+       "-static -Wl,-elf2flt=-r",
+#endif
 #ifdef BR_MIPS_TARGET_LITTLE_ENDIAN
        "-EL",
 #endif
diff --git a/toolchain/toolchain-wrapper.mk b/toolchain/toolchain-wrapper.mk
index 8b551e3a18..5573002755 100644
--- a/toolchain/toolchain-wrapper.mk
+++ b/toolchain/toolchain-wrapper.mk
@@ -54,6 +54,12 @@ ifeq ($(BR2_x86_x1000),y)
 TOOLCHAIN_WRAPPER_ARGS += -DBR_OMIT_LOCK_PREFIX
 endif
 
+# NOMMU RISCV_64 does not support flat shared libraries and
+# requires loading to RAM in one big lump.
+ifeq ($(BR2_BINFMT_FLAT):$(BR2_RISCV_64),y:y)
+TOOLCHAIN_WRAPPER_ARGS += -DBR_BINFMT_FLAT_ONE_STATIC
+endif
+
 # Avoid FPU bug on XBurst CPUs
 ifeq ($(BR2_mips_xburst),y)
 # Before gcc 4.6, -mno-fused-madd was needed, after -ffp-contract is

But this result in uclibc build to fail. That is expected since this option
should be used only for packages, not for the toolchain itself.
Anything I am overlooking here ?

Of note is that I do not see anywhere BR_BINFMT_FLAT being defined for
compiling the toolchain wrapper for an internal toolchain. I.e., something like

ifeq ($(BR2_BINFMT_FLAT),y)
TOOLCHAIN_WRAPPER_ARGS += -DBR_BINFMT_FLAT
endif

seems to be absent (git grep BR_BINFMT_FLAT). It is being enabled in pkg-
toolchain-external.mk though, but that is for external toolchain only...

Best regards.

-- 
Damien Le Moal
Western Digital Research



More information about the buildroot mailing list