BrunoLevy / learn-fpga

Learning FPGA, yosys, nextpnr, and RISC-V
BSD 3-Clause "New" or "Revised" License
2.53k stars 242 forks source link

LiteOS will not compile for petitbateau variant #71

Closed AEW2015 closed 1 year ago

AEW2015 commented 2 years ago

I can compile LiteOS for the quark variant just fine, but when I try petitbateau variant, I get this error:

CC       boot.elf
/home/farmer/litex/riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14/bin/../lib/gcc/riscv64-unknown-elf/8.1.0/../../../../riscv64-unknown-elf/bin/ld: /home/farmer/litex/riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14/bin/../lib/gcc/riscv64-unknown-elf/8.1.0/libgcc.a(div.o): ABI is incompatible with that of the selected emulation:
  target emulation `elf64-littleriscv' does not match `elf32-littleriscv'
/home/farmer/litex/riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14/bin/../lib/gcc/riscv64-unknown-elf/8.1.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file /home/farmer/litex/riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14/bin/../lib/gcc/riscv64-unknown-elf/8.1.0/libgcc.a(div.o)
collect2: error: ld returned 1 exit status
Makefile:21: recipe for target 'boot.elf' failed
M4rkoHR commented 1 year ago

I have the same issue, I think you need to add -march=rv32imac -mabi=ilp32 to LDFLAGS, but when I do that I get the error:

❯ make
 CC       boot.elf
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/rv32imac/ilp32/libgcc.a(_udivdi3.o): can't link soft-float modules with single-float modules
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file /opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/rv32imac/ilp32/libgcc.a(_udivdi3.o)
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/rv32imac/ilp32/libgcc.a(_umoddi3.o): can't link soft-float modules with single-float modules
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file /opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/rv32imac/ilp32/libgcc.a(_umoddi3.o)
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/rv32imac/ilp32/libgcc.a(_clz.o): can't link soft-float modules with single-float modules
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file /opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/rv32imac/ilp32/libgcc.a(_clz.o)
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: warning: boot.elf has a LOAD segment with RWX permissions
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: builtins.o: in function `catalog':
builtins.c:(.text+0x2a): undefined reference to `fatfs_set_ops_spisdcard'
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: builtins.c:(.text+0xec): undefined reference to `fatfs_set_ops_spisdcard'
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: builtins.o: in function `run':
builtins.c:(.text+0x10a): undefined reference to `elf32_load'
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: main.o: in function `main':
main.c:(.text.startup+0x142): undefined reference to `fb_base'
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: main.c:(.text.startup+0x146): undefined reference to `fb_base'
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: main.c:(.text.startup+0x14a): undefined reference to `fb_off'
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: main.c:(.text.startup+0x194): undefined reference to `fb_on'
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: /Users/marko/Documents/GitHub/LiteX/litex-boards/litex_boards/targets/build/radiona_ulx3s/software/liblitedram/liblitedram.a(sdram.o): in function `init_sequence':
/Users/marko/Documents/GitHub/LiteX/litex-boards/litex_boards/targets/build/radiona_ulx3s/software/include/generated/sdram_phy.h:90: undefined reference to `memtest'
/opt/homebrew/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: /Users/marko/Documents/GitHub/LiteX/litex-boards/litex_boards/targets/build/radiona_ulx3s/software/include/generated/sdram_phy.h:96: undefined reference to `memspeed'
collect2: error: ld returned 1 exit status
make: *** [boot.elf] Error 1

This is being built on MacOS but I get the same error when I replicate it on Linux.

BrunoLevy commented 1 year ago

Fixed (now LiteX uses extended RiscV extension names, which confuses the linker, fixed makefile.inc to remove them in the flag passed to the linker)