meta-zephyr-sdk icon indicating copy to clipboard operation
meta-zephyr-sdk copied to clipboard

RISC-V RV32I __divdi3 contains mul instructions

Open Dolu1990 opened this issue 7 years ago • 2 comments

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

Dolu1990 avatar Nov 09 '18 02:11 Dolu1990

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.

compilationLogs.txt

assembly.txt

Dolu1990 avatar Dec 11 '18 00:12 Dolu1990

I have the same problem with nios2, found out that cmake needs to change to the lib files(libgcc.a) in the nomul dir: afbeelding

In your case: afbeelding

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

NelsonAtema avatar Nov 26 '20 06:11 NelsonAtema