YosysHQ / picorv32

PicoRV32 - A Size-Optimized RISC-V CPU
ISC License
3.08k stars 748 forks source link

Bug: TRAP after >8000 clock cycles #223

Closed kaminto-1999 closed 6 months ago

kaminto-1999 commented 1 year ago

I have tried to run all the "make test" in the root folder. But seem like the "make test" command returns an Error after the run for about 8000 cycles. Does anyone know how to fix it? Thank you. image

filamoon commented 1 year ago

Same here. No error messages at all.

ogris commented 1 year ago

I got a little bit more information after chainging the picorv32.v file: ` Built with Verilator 4.038 2020-07-11.

Recommended: Verilator 4.0 or later.

MISALIGNED WORD: 0x00000152

MISALIGNED WORD: 0x00000152

TRAP after 8223 clock cycles

ERROR!

%Error: testbench.v:271: Verilog $stop `

TurBoss commented 1 year ago

hello, i managed to get it build by using this command

make TOOLCHAIN_PREFIX=riscv32-unknown-elf-

:)

Edit: doesn't work after a make clean ..., so not the solution

Edit2: found that need to set path to opt

export PATH=/opt/riscv32im/bin:$PATH

here for im

rigoorozco commented 11 months ago

I'm getting the same thing. I was able to get around it using version 10.2.0 here: https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/

Not sure what the problem is but it seems to not work with newer versions of gcc

rigoorozco commented 11 months ago

Got around this issue on GCC 13.2.0 doing the following to the Makefile:

diff --git a/Makefile b/Makefile
index d7027e3..feda8a7 100644
--- a/Makefile
+++ b/Makefile
@@ -15,8 +15,8 @@ TEST_OBJS = $(addsuffix .o,$(basename $(wildcard tests/*.S)))
 FIRMWARE_OBJS = firmware/start.o firmware/irq.o firmware/print.o firmware/hello.o firmware/sieve.o firmware/multest.o firmware/stats.o
 GCC_WARNS  = -Werror -Wall -Wextra -Wshadow -Wundef -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings
 GCC_WARNS += -Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes -pedantic # -Wconversion
-TOOLCHAIN_PREFIX = $(RISCV_GNU_TOOLCHAIN_INSTALL_PREFIX)i/bin/riscv32-unknown-elf-
-COMPRESSED_ISA = C
+TOOLCHAIN_PREFIX ?= $(RISCV_GNU_TOOLCHAIN_INSTALL_PREFIX)i/bin/riscv32-unknown-elf-
+COMPRESSED_ISA = 

 # Add things like "export http_proxy=... https_proxy=..." here
 GIT_ENV = true
@@ -116,7 +116,7 @@ firmware/start.o: firmware/start.S
        $(TOOLCHAIN_PREFIX)gcc -c -mabi=ilp32 -march=rv32im$(subst C,c,$(COMPRESSED_ISA)) -o $@ $<

 firmware/%.o: firmware/%.c
-       $(TOOLCHAIN_PREFIX)gcc -c -mabi=ilp32 -march=rv32i$(subst C,c,$(COMPRESSED_ISA)) -Os --std=c99 $(GCC_WARNS) -ffreestanding -nostdlib -o $@ $<
+       $(TOOLCHAIN_PREFIX)gcc -c -mabi=ilp32 -march=rv32im$(subst C,c,$(COMPRESSED_ISA)) -Os --std=c99 $(GCC_WARNS) -ffreestanding -nostdlib -o $@ $<

 tests/%.o: tests/%.S tests/riscv_test.h tests/test_macros.h
        $(TOOLCHAIN_PREFIX)gcc -c -mabi=ilp32 -march=rv32im -o $@ -DTEST_FUNC_NAME=$(notdir $(basename $<)) \
zavs commented 7 months ago

It was solved by modifying the start.S to fix the alignment in issue #210 . rethhelo also opened a PR to fix the problem #218 . "This PR forces irq_regs to always be aligned with .balign 0x200, by doing this solves the problem." in start.S

KrystalDelusion commented 6 months ago

Closed by #218