PYNQ: PYTHON PRODUCTIVITY

Wrong return velue when executing C programs in RISC-V-On-PYNQ

Hi,

I’ve successfully have RISC-V-On-PYNQ On my Board. But when I try to run some C programs, Probelems occurs.

The bitstream I use is generated followed the tutorial.

For the sample, promgrom shon below,

%%riscvc test2 overlay.tutorialProcessor

int f(int n)
{
    if(n==1) return 1;
    else return n*f(n-1);
}

int main()
{
    int ans = f(5);
    return ans;
}

The following codes show how to read the return value,

retval = overlay.tutorialProcessor.run(test2,)
print(retval)

And the return value is 1, which is surely incorrect.


Another issue is that I cannot run the Dhrystone test as well.

Here is the commands I used to complied the Dhrystone test,

riscv32-unknown-elf-gcc -c -Qn -DSTKPTR=32768 -march=rv32im -o init.o -Os --std=c99 init.S
riscv32-unknown-elf-gcc -c -Qn -march=rv32im -o dhry_1.o -Os --std=c99 dhry_1.c
riscv32-unknown-elf-gcc -c -Qn -march=rv32im -o dhry_2.o -Os --std=c99 dhry_2.c
riscv32-unknown-elf-gcc -Os -ffreestanding -nostdlib -o dhry.elf -Wl,-Bstatic,-T,picorv32.ld init. o dhry_1.o dhry_2.o -Wl,--start-group -lc -lgloss -Wl,--end-group -march=rv32im 
riscv32-unknown-elf-objcopy -O binary dhry.elf dhry.bin

The return value is always incorrect.


Any help will be appreciated