1

I wrote an application that uses several trigonometric functions (sin, tan, cos, ...). My objective is to study the different implementations of these functions in the GNU C library, MUSL, and Newlib.

To do that for glibc and musl I just built a Linux GCC toolchain using Buildroot, then I compiled my app using the appropriate compiler then run it using QEMU (user mode). This is straightforward.

Now I would like to compare the application results with the Newlib version.

In my specific case, I'm compiling for RISC-V RV64GC architecture and the lp64d ABI. From my understanding, using the Newlib library means compiling with the riscvv64-unknown-elf-gcc compiler. Traditionally, the Spike ISS simulator can be used to run the application using the proxy-kernel lightweight OS. Is there a way to use that in QEMU? Or should I just build a completely baremetal application?

noureddine-as
  • 453
  • 4
  • 12

1 Answers1

0

Disclaimer: I am not a RISC-V expert.

I have been trying to use qemu-system-aarch64 4.1.0 with semihosting to no avail until I found someone had figured-out a fix. Since semihosting support for RISC-V in qemu-system may not currently be on par with the one provided for aarch64, I would suggest you to build a 100% baremetal application while relying on the emulated serial port for minimal input/output operations.

For example, when using the sifive-u54 as a target, there is a ns16550a UART available at address 0x10000000:

dd if=/dev/zero of=dummy.bin bs=512 count=1
qemu-system-riscv64 -nographic -serial mon:stdio -machine virt,dumpdtb=qemu-virt-riscv64.dtb -cpu sifive-u54 -bios dummy.bin
dtc -I dtb -O dts qemu-virt-riscv64.dtb > qemu-virt-riscv64.dts
more qemu-virt-riscv64.dts

/dts-v1/;

/ {
        #address-cells = <0x02>;
        #size-cells = <0x02>;
        compatible = "riscv-virtio";
        model = "riscv-virtio,qemu";

        chosen {
                bootargs = [00];
                stdout-path = "/uart@10000000";
        };

        uart@10000000 {
                interrupts = <0x0a>;
                interrupt-parent = <0x03>;
                clock-frequency = <0x384000>;
                reg = <0x00 0x10000000 0x00 0x100>;
                compatible = "ns16550a";
        };
Frant
  • 5,382
  • 1
  • 16
  • 22