meta-zephyr-sdk
meta-zephyr-sdk copied to clipboard
RISC-V RV32I __divdi3 contains mul instructions
There is a sample :
command : riscv32-zephyr-elf/riscv32-zephyr-elf-gcc -march=RV32I -fno-inline -fno-common -DTIME -DCORE_HZ=12000000ll -I/home/spinalvm/hdl/tools/zephyr-sdk/sysroots/riscv32-zephyr-elf/usr/include -O3 -o build/dhrystone.elf build/src/dhrystone_main.o build/src/dhrystone.o build/src/stdlib.o build/src/start.o -lc -L/home/spinalvm/hdl/tools/zephyr-sdk/sysroots/riscv32-zephyr-elf/usr/lib/riscv32-zephyr-elf/6.1.0 -L/home/spinalvm/hdl/tools/zephyr-sdk/sysroots/riscv32-zephyr-elf/usr/lib -nostdlib -lgcc -nostartfiles -ffreestanding -Wl,-Bstatic,-T,mapping.ld,-Map,build/dhrystone.map,--print-memory-usage
Then, somewere in the generated binary :
00001510 <__divdi3>:
...
15d4: 02a60633 mul a2,a2,a0
Just tested again with SDK 0.9.5, and Zephyr master branch. The issue is now a bit worst, as the machine timer driver is using __udivdi3, which contains mul and divu remu instructions.
Tested with the hello world sample and a custom SoC which had :
zephyr_compile_options(-march=RV32I)
zephyr_ld_options(-march=RV32I)
There are the compilation logs and the assembly output.
I have the same problem with nios2, found out that cmake needs to change to the lib files(libgcc.a) in the nomul dir:

In your case:

Im not very experienced with cmake so i hope someone picks this up.