An error when running spike

(Bin Wu) #1

I’m a rookie of RISC-V. When I finished the installation of riscv-tools and I wanted to test it, but an error occurred. My os is ubuntu 16.04 and commands are shown below:

$ git clone
$ cd riscv-tools
$ git submodule update --init --recursive
$ export RISCV=~/RISCV/riscv-tools-install
$ export PATH=$PATH:$RISCV/bin
$ ./
$ cd …
$ echo -e ‘#include <stdio.h>\n int main(void) { printf(“Hello world!\n”); return 0; }’ > hello.c
$ riscv64-unknown-elf-gcc -o hello hello.c
$ spike pk hello

However, the final command can’t work correctly. The error message is:
terminate called after throwing an instance of 'std::runtime_error’
what(): could not open pk (did you misspell it? If VCS, did you forget +permissive/+permissive-off?)

How can I solve this problem?

(Jim Wilson) #2

The error message seems pretty clear, it is telling you that spike can’t find the pk program. The readme says spike will find it automatically, but this is apparently wrong or out-of-date. You can specify the path to the pk file, or put a copy in your current dir. Or maybe put $RISCV/riscv64-unknown-elf/bin on your path.

(Bin Wu) #3

OK. It works.

(saran) #4

bro how to add it to my path i cant understand
i am beginner
pls tell me

(Jim Wilson) #5

FIrst you need the name of the directory where you installed your riscv cross compilers. Let’s call this installdir. To set your path, you want to do something like
export PATH=$PATH:installdir/bin
where you replace installdir with the actual directory name where the programs are installed. This assumes that your shell is bash or a compatible POSIX shell. If you are using csh then the command will be different. Or if you are on a Windows machine, and not using a shell like cygwin, then you need a different command.

You can always specify absolute pathnames, e.g instead of running riscv64-unknown-elf-gcc you can run /installdir/bin/riscv64-unknown-elf-gcc where again you must replace installdir with the name of the directory where the program is installed.