Build for RISC-V with LLVM
Nathaniel
I at nathaniel.land
Sun Apr 27 01:25:50 CEST 2025
On Apr 26 2025, at 1:30 am, Yao Zi <ziyao at disroot.org> wrote:
> On Fri, Apr 25, 2025 at 12:43:08PM -0500, Nathaniel Hourt wrote:
> > Hi, all
> >
> > I am trying to build u-boot and SPL for my Mars board (riscv, variant of the
> > starfive visionfive2) following the board-specific docs [1], using
> > LLVM/clang as my toolchain with the HOSTCC and CC make options mentioned in
> > [2]. I'm building from a RISC-V native chroot using qemu-binfmt so I am not
> > using the cross-compile options; thus my make invocation looks like `make
> > HOSTCC=clang CC=clang` (for OpenSBI, I just pass 'LLVM=1'). Note that the
> > chroot I'm building from does not contain gcc/binutils at all; LLVM is the
> > only toolchain present.
> >
> > The build usually succeeds, so I try to pass the SPL to the MaskROM over
> > UART (using the u-boot-spl.bin.normal.out image) and it just hangs. No
> > output, no response, and I have to reset the board. If I pass a working SPL
>
> Have you tried to apply this patch[1]? U-Boot support for JH7110 is
> broken at least in v2025.04 release afaik.
>
> Best regards,
> Yao Zi
>
> [1]: https://lore.kernel.org/all/20250330162421.238483-1-heinrich.schuchardt@canonical.com/
> > I downloaded, it logs some output then accepts a main u-boot payload over
> > UART, so if I send the main u-boot payload I built (u-boot.itb), I get a
> > "Load address misaligned" error as in [3].
> >
> > I attempted to configure my SPL to log to UART by turning on various logging
> > options in `menuconfig`, including the options recently mentioned by
> > Heinrich Schuchardt in [4], but I have been unsuccessful in getting any
> > output from the SPL I built.
> >
> > So I am looking for guidance. Is building with LLVM/clang (for riscv)
> > supported? I don't know what to try next.
> >
> > Thanks
> > —
> > Nathaniel
> >
> >
> > [1]
> > https://docs.u-boot.org/en/latest/board/starfive/milk-v_mars.html#milk-v-mars
> > [2] https://docs.u-boot.org/en/latest/build/clang.html
> > [3] https://pastebin.com/xwEcqEpz
> > [4] https://lists.denx.de/pipermail/u-boot/2025-April/586264.html
>
I just tried the patch, and also pulled latest master, which has that patch by now, but it didn't change the SPL's behavior.
I have heard that I need to be using v2025.01; however, that fails to build for me:
LD lib/efi_loader/boothart_efi.so
ld: error: section type mismatch for .dynamic
>>> <internal>:(.dynamic): SHT_DYNAMIC
>>> output section .text: SHT_PROGBITS
make[2]: *** [scripts/Makefile.lib:539: lib/efi_loader/boothart_efi.so] Error 1
make[1]: *** [scripts/Makefile.build:398: lib/efi_loader] Error 2
make: *** [Makefile:1915: lib] Error 2
I don't understand that error; I'm guessing it's ELF wizardry thus far beyond my ken.
So master builds but doesn't run (at all? there's no output) and going off of [1], wouldn't we expect there to be some output from the SPL when it doesn't work for the known reasons?
v2025.01 doesn't build with my LLVM toolchain, and I'm wondering whether I'm getting actually sane images even when master builds successfully. I have no idea how to verify that... Does anyone know how to analyze the SPL image output, or even what format it's in? Or alternatively, is there a hello world SPL I can build just to test whether I can produce working binaries at all?
Or am I barking up the wrong tree altogether? Ideas welcome. =)
—
Nathaniel
[1] https://lore.kernel.org/all/20250330162421.238483-1-heinrich.schuchardt@canonical.com/
More information about the U-Boot
mailing list