XUANTIE-RV / wujian100_open

IC design and development should be faster,simpler and more reliable
MIT License
1.85k stars 569 forks source link

编译case异常。 #34

Closed xxxwm closed 2 years ago

xxxwm commented 4 years ago

您好,

我按照这个路径: https://www.t-head.cn/product/mcu-platform?spm=a2ouz.12987052.0.0.167548abiiSAQs下载了riscv的工具包

我使用的工具包是:riscv64-elf-x86_64-20190731.tar.gz。

但在运行'../tools/run_case -sim_tool vcs ../case/timer/timer_test.c'室,它报出了异常: Fatal error:invalid -march= option:`rv32emcxcki'

我应该如何处理呢?

谢谢。

xxxwm commented 4 years ago

我使用RISC-V官网提供的gcc,在不使用-march=rv32emcxcki这些选项(参考rocket-chip的编译环境)时,能编译通过,但利用生成的hex进行仿真时,mcause会报非法指令异常,所以最后下载了相应的工具链,按照指示运行,但还是异常。

birdshanshan commented 4 years ago

-march选项是说明程序的指令集架构,即使您从RISC-V的官网获取gcc,依然需要在编译时,说明对应的指令集架构,否则就是默认的通用CPU。这样即使编译通过了,也会因为与设计的处理器不匹配,导致程序执行失败。你需要做的是确认自己的确使用的是软件工具包里的斌一起编译的,即${TOOL_PATH}/bin/riscv64-unknown-elf-gcc。如果可以确认这一点,再把错误信息报告出来。可以考虑加入相关钉钉群。

jie-debug commented 4 years ago

您好, 我只用来仿真器编译仿真,下载了riscv64-linux-x86_64-*.tar.gz,然后使用解压后的bin/riscv64-unknown-linux-gnu-gcc做编译器,运行../tools/run_case -sim_tool vcs ../case/dma/dma_test.c的时候报如下错误: riscv_toolchain/sysroot/usr/include/gnu/stubs.h:8:11: fatal error: gnu/stubs-ilp32.h: No such file or directory 请问该如何解决? 钉钉群是哪个?

jie-debug commented 4 years ago

如果用riscv64-elf-x86_64-20190731.tar.gz编译的话,又会报如下error:

../riscv_toolchain_elf/bin/riscv64-unknown-elf-gcc -Tlinker.lcf -nostartfiles -march=rv32emc -mabi=ilp32e -lc -lgcc crt0.o dtostr.o fprintf.o fputc.o getc.o getchar.o isinf.o isnan.o lltostr.o __ltostr.o printf.o putc.o putchar.o puts.o snprintf.o sprintf.o timer_test.o vfprintf.o __v_printf.o vprintf.o vsnprintf.o vsprintf.o -o timer_test.elf -lm ../riscv_toolchain_elf/bin/riscv64-unknown-elf-objcopy -O srec timer_test.elf timer_test.hex rm -f *.pat

../tools/Srec2vmem.py timer_test.hex test.pat

../tools/Srec2vmem.py -i timer_test.hex -o test.pat Traceback (most recent call last): File "../tools/Srec2vmem.py", line 182, in main(sys.argv[1:]) File "../tools/Srec2vmem.py", line 179, in main hex2vmem(o_argv_info) File "../tools/Srec2vmem.py", line 133, in hex2vmem line_addr = cur_line[line_addr_idx:line_addr_end] TypeError: slice indices must be integers or None or have an index method

xxxwm commented 4 years ago

-march选项是说明程序的指令集架构,即使您从RISC-V的官网获取gcc,依然需要在编译时,说明对应的指令集架构,否则就是通用的CPU。这样即使编译通过了,也会因为与设计的处理器不匹配,导致程序执行失败。你需要做的是确认自己的确使用的是软件工具包里的斌一起编译的,即$ {TOOL_PATH} / bin / riscv64-unknown-elf-gcc 。如果可以确认这一点,再把错误信息报告出来。可以考虑加入相关钉钉群。

您好,我现在的情况是这样的: 1.我可以确定我用的就是${TOOL_PATH}/bin/riscv64-unknown-elf-gcc,而且这个gcc就是从平头哥官网下载的riscv64-elf-x86_64-20190731.tar.gz。 2.在workdir目录中运行 ../tools/run_case -sim_tool vcs ../case/timer/timer_test.c 指令后,它报出了异常:Fatal error:invalid -march= option:`rv32emcxcki'。

其他信息,这些信息是我自己试验的: 我利用RISC-V官网下载的gcc(非平头哥官网下载),使用-march = rv32imac选项,编译通过,修改tb.v中readmemh()的路径,仿真能运行起来,编译的case是我根据总线范围自己编写的简单case,并非project自带的case。为什么用-march = rv32imac?因为我试过-march = rv32emac也编译不通过。至于程序与mcu不匹配的问题,我也很好奇,因为我的实验中,wujian没有报异常(我看的是mcause),而且能正常运行下去(通过看总线ahb接口的数据输出确认运行正常),关于这种采用了-march = rv32imac编译选项生成的程序,但设计原来只有16个通用寄存器的处理器,我也想知道你们是如何处理的?当然也有可能是我编译的case本来就用了很少的寄存器,刚好用到的这部门寄存器和处理器设计没有冲突,这个我需要核实一下。

strongwong commented 4 years ago

如果用riscv64-elf-x86_64-20190731.tar.gz编译的话,又会报如下error:

../riscv_toolchain_elf/bin/riscv64-unknown-elf-gcc -Tlinker.lcf -nostartfiles -march=rv32emc -mabi=ilp32e -lc -lgcc crt0.o dtostr.o fprintf.o fputc.o getc.o getchar.o isinf.o isnan.o lltostr.o __ltostr.o printf.o putc.o putchar.o puts.o snprintf.o sprintf.o timer_test.o vfprintf.o __v_printf.o vprintf.o vsnprintf.o vsprintf.o -o timer_test.elf -lm ../riscv_toolchain_elf/bin/riscv64-unknown-elf-objcopy -O srec timer_test.elf timer_test.hex rm -f *.pat

../tools/Srec2vmem.py timer_test.hex test.pat

../tools/Srec2vmem.py -i timer_test.hex -o test.pat Traceback (most recent call last): File "../tools/Srec2vmem.py", line 182, in main(sys.argv[1:]) File "../tools/Srec2vmem.py", line 179, in main hex2vmem(o_argv_info) File "../tools/Srec2vmem.py", line 133, in hex2vmem line_addr = cur_line[line_addr_idx:line_addr_end] TypeError: slice indices must be integers or None or have an index method

您好,这个错误是由于 python2 和 python3 执行除法得到的结果不同而导致的错误,最新 PR 的版本应该已经修复了这个问题了,你重新 clone 一下这个仓库就行了。

jie-debug commented 4 years ago

如果用riscv64-elf-x86_64-20190731.tar.gz编译的话,又会报如下error: ../riscv_toolchain_elf/bin/riscv64-unknown-elf-gcc -Tlinker.lcf -nostartfiles -march=rv32emc -mabi=ilp32e -lc -lgcc crt0.o dtostr.o fprintf.o fputc.o getc.o getchar.o isinf.o isnan.o lltostr.o __ltostr.o printf.o putc.o putchar.o puts.o snprintf.o sprintf.o timer_test.o vfprintf.o __v_printf.o vprintf.o vsnprintf.o vsprintf.o -o timer_test.elf -lm ../riscv_toolchain_elf/bin/riscv64-unknown-elf-objcopy -O srec timer_test.elf timer_test.hex rm -f *.pat

../tools/Srec2vmem.py timer_test.hex test.pat

../tools/Srec2vmem.py -i timer_test.hex -o test.pat Traceback (most recent call last): File "../tools/Srec2vmem.py", line 182, in main(sys.argv[1:]) File "../tools/Srec2vmem.py", line 179, in main hex2vmem(o_argv_info) File "../tools/Srec2vmem.py", line 133, in hex2vmem line_addr = cur_line[line_addr_idx:line_addr_end] TypeError: slice indices must be integers or None or have an index method

您好,这个错误是由于 python2 和 python3 执行除法得到的结果不同而导致的错误,最新 PR 的版本应该已经修复了这个问题了,你重新 clone 一下这个仓库就行了。

多谢。我再试试,请教下,钉钉群是哪个?

jie-debug commented 4 years ago

如果用riscv64-elf-x86_64-20190731.tar.gz编译的话,又会报如下error: ../riscv_toolchain_elf/bin/riscv64-unknown-elf-gcc -Tlinker.lcf -nostartfiles -march=rv32emc -mabi=ilp32e -lc -lgcc crt0.o dtostr.o fprintf.o fputc.o getc.o getchar.o isinf.o isnan.o lltostr.o __ltostr.o printf.o putc.o putchar.o puts.o snprintf.o sprintf.o timer_test.o vfprintf.o __v_printf.o vprintf.o vsnprintf.o vsprintf.o -o timer_test.elf -lm ../riscv_toolchain_elf/bin/riscv64-unknown-elf-objcopy -O srec timer_test.elf timer_test.hex rm -f *.pat

../tools/Srec2vmem.py timer_test.hex test.pat

../tools/Srec2vmem.py -i timer_test.hex -o test.pat Traceback (most recent call last): File "../tools/Srec2vmem.py", line 182, in main(sys.argv[1:]) File "../tools/Srec2vmem.py", line 179, in main hex2vmem(o_argv_info) File "../tools/Srec2vmem.py", line 133, in hex2vmem line_addr = cur_line[line_addr_idx:line_addr_end] TypeError: slice indices must be integers or None or have an index method

您好,这个错误是由于 python2 和 python3 执行除法得到的结果不同而导致的错误,最新 PR 的版本应该已经修复了这个问题了,你重新 clone 一下这个仓库就行了。

您知道钉钉群是哪个吗

mballackh13 commented 2 years ago

已更新代码