天天看点

在Ubuntu下跑通wujian100_open仿真测试

本机系统Ubuntu 19.04,内核5.0.0-36-generic

获取T-Head Tools

浏览器进入 https://www.t-head.cn/product/mcu-platform?spm=a2ouz.12987052.0.0.167548abiiSAQs 下载相关工具:“T-Head Tools package.zip”

从压缩包中获取工具链

vircoys@ubuntu:~/Downloads$ unzip ‘T-Head Tools package.zip’ -d ~/Documents/
Archive:  T-Head Tools package.zip
 extracting: /home/vircoys/Documents/T-Head CDK-windows-V1.18.10-20191018-1527.zip  
   creating: /home/vircoys/Documents/T-Head DebugServer-V5.8.6/
  inflating: /home/vircoys/Documents/T-Head DebugServer-V5.8.6/changelog.txt  
  inflating: /home/vircoys/Documents/T-Head DebugServer-V5.8.6/CSKY-DebugServer-linux-i686-V5.8.6-20191010.sh  
 extracting: /home/vircoys/Documents/T-Head DebugServer-V5.8.6/CSKY-DebugServer-linux-i686-V5.8.6-20191010.sh.tar.gz  
  inflating: /home/vircoys/Documents/T-Head DebugServer-V5.8.6/CSKY-DebugServer-linux-x86_64-V5.8.6-20191010.sh  
 extracting: /home/vircoys/Documents/T-Head DebugServer-V5.8.6/CSKY-DebugServer-linux-x86_64-V5.8.6-20191010.sh.tar.gz  
 extracting: /home/vircoys/Documents/T-Head DebugServer-V5.8.6/CSKY-DebugServer-windows-V5.8.6-20191010-1638.zip  
  inflating: /home/vircoys/Documents/T-Head DebugServer-V5.8.6/Readme.txt  
   creating: /home/vircoys/Documents/T-Head RISC-V Toolchain-V1.2.2/
  inflating: /home/vircoys/Documents/T-Head RISC-V Toolchain-V1.2.2/changelog.txt  
  inflating: /home/vircoys/Documents/T-Head RISC-V Toolchain-V1.2.2/Readme.txt  
  inflating: /home/vircoys/Documents/T-Head RISC-V Toolchain-V1.2.2/riscv64-elf-i386-20190801.tar.gz  
  inflating: /home/vircoys/Documents/T-Head RISC-V Toolchain-V1.2.2/riscv64-elf-mingw-20190731.tar.gz  
  inflating: /home/vircoys/Documents/T-Head RISC-V Toolchain-V1.2.2/riscv64-elf-x86_64-20190731.tar.gz  
  inflating: /home/vircoys/Documents/T-Head RISC-V Toolchain-V1.2.2/riscv64-linux-x86_64-20190731.tar.gz            

vircoys@ubuntu:~/Downloads$ cd Documents

vircoys@ubuntu:~/Documents$ mkdir riscv_toolchain/

将riscv64-elf-x86_64-20190731.tar.gz解压到riscv_toolchain

vircoys@ubuntu:~/Documents$ tar -zxf “T-Head RISC-V Toolchain-V1.2.2”/riscv64-elf-x86_64-20190731.tar.gz -C riscv_toolchain/

安装开源EDA工具

vircoys@ubuntu:~/Documents$ sudo apt install iverilog verilator gtkwave

获取平台代码(forked from T-head-Semi/wujian100_open)

vircoys@ubuntu:~/Documents$ git clone [email protected]:T-head-Semi/wujian100_open.git
Cloning into 'wujian100_open'...
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 911 (delta 0), reused 0 (delta 0), pack-reused 906
Receiving objects: 100% (911/911), 1.26 MiB | 193.00 KiB/s, done.
Resolving deltas: 100% (313/313), done.           

vircoys@ubuntu:~/Documents$ cd wujian100_open/

vircoys@ubuntu:~/Documents$ cd wujian100_open/tools/

安装csh

vircoys@ubuntu:~/Documents/wujian100_open/tools$ sudo apt install csh

使用csh脚本设置环境变量

vircoys@ubuntu:~/Documents/wujian100_open/tools$ csh setup.csh

vircoys@ubuntu:~/Documents/wujian100_open/tools$ csh

% source setup.csh
% exit           
vircoys@ubuntu:~/Documents/wujian100_open/tools$ cd …/workdir/

第一次仿真测试不通过,make: /bin/riscv64-unknown-elf-gcc: Command not found

vircoys@ubuntu:~/Documents/wujian100_open/workdir$ …/tools/run_case -sim_tool iverilog …/case/timer/timer_test.c
Useless use of not in void context at ../tools/run_case line 204.

Step1 (Remove all things in current 'workdir') is finished!
../case/timer//timer_test.c

Step2 (Process the command line arguments) is finished!
mkdir: cannot create directory ‘../regress/regress_result’: File exists
rm -rf *.o *.pat *.elf *.obj *.hex
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o crt0.o crt0.s
make: /bin/riscv64-unknown-elf-gcc: Command not found
make: *** [Makefile:58: crt0.o] Error 127
can't make at ../tools/run_case line 208.           

vircoys@ubuntu:~/Documents/wujian100_open/tools$ cd …/…/riscv_toolchain/bin/

vircoys@ubuntu:~/Documents/riscv_toolchain/bin$ pwd

/home/vircoys/Documents/riscv_toolchain/bin           

建立工具链的软连接

vircoys@ubuntu:~/Documents/riscv_toolchain/bin$ sudo ln -s /home/vircoys/Documents/riscv_toolchain/bin/riscv64-unknown-elf-gcc /bin/riscv64-unknown-elf-gcc

vircoys@ubuntu:~/Documents/riscv_toolchain/bin$ sudo ln -s /home/vircoys/Documents/riscv_toolchain/bin/riscv64-unknown-elf-objcopy /bin/riscv64-unknown-elf-objcopy

vircoys@ubuntu:~/Documents/riscv_toolchain/bin$ sudo ln -s /home/vircoys/Documents/riscv_toolchain/bin/riscv64-unknown-elf-objdump /bin/riscv64-unknown-elf-objdump

仿真测试通过

vircoys@ubuntu:~/Documents/riscv_toolchain/bin$ cd …/…/wujian100_open/workdir/
Useless use of not in void context at ../tools/run_case line 204.

Step1 (Remove all things in current 'workdir') is finished!
../case/timer//timer_test.c

Step2 (Process the command line arguments) is finished!
mkdir: cannot create directory ‘../regress/regress_result’: File exists
rm -rf *.o *.pat *.elf *.obj *.hex
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o crt0.o crt0.s
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o __dtostr.o __dtostr.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o __isnan.o __isnan.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o printf.o printf.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o vprintf.o vprintf.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o sprintf.o sprintf.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o snprintf.o snprintf.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o vfprintf.o vfprintf.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o fprintf.o fprintf.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o getchar.o getchar.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o timer_test.o timer_test.c
In file included from timer_test.c:12:
vtimer.h: In function 'get_vtimer':
vtimer.h:14:14: warning: assignment to 'int *' from 'unsigned int' makes pointer from integer without a cast [-Wint-conversion]
   TIMER_ADDR = 0xE0013000;
              ^
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o putc.o putc.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o puts.o puts.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o fputc.o fputc.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o getc.o getc.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o __isinf.o __isinf.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o putchar.o putchar.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o vsprintf.o vsprintf.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o __v_printf.o __v_printf.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o vsnprintf.o vsnprintf.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o __ltostr.o __ltostr.c
/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o __lltostr.o __lltostr.c
/bin/riscv64-unknown-elf-gcc -Tlinker.lcf -nostartfiles -march=rv32emc -mabi=ilp32e -lc -lgcc  crt0.o vprintf.o sprintf.o snprintf.o fprintf.o puts.o getchar.o __isnan.o timer_test.o getc.o printf.o vsprintf.o __v_printf.o vsnprintf.o __dtostr.o vfprintf.o putc.o fputc.o __isinf.o putchar.o __lltostr.o __ltostr.o -o timer_test.elf -lm 
/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
/bin/riscv64-unknown-elf-objdump -S -Mnumeric timer_test.elf > timer_test.obj
make clean; make all CPU=e902m ENDIAN_MODE=little-endian FILE=timer_test HGPR=

Step3 (Make) is finished!
Use of uninitialized value $had_v in concatenation (.) or string at ../tools/run_case line 241.
warning: Found both default and `timescale based delays. Use
         -Wtimescale to find the module(s) with no `timescale.
######time:                   0, Dump start######
VCD info: dumpfile test.vcd opened for output.
    ******START TO LOAD PROGRAM******


Hello Friend!

timer test successfully
***************************************

*              Test Pass              *

***************************************


Step4 (Run simulation) is finished           

原文作者:Vircoys

点击查看原文

继续阅读