Compile error for custom0 custom instruction - riscv

I'm trying to design simple accelerator to be familiar with RoCC and its interface in spike, and access it through RoCC command(such as custom0, custom1, ...)
In fact, I follow some guides described in cs250 lab4 from Berkeley by using master branch of riscv tools.(Actually, guides are different from this, but I could understand basic ideas, so I go through it.)
However, it seems that it does not work well.
First of all, I just build riscv tools in repository, and then I tried to compile dummy_rocc_test.c which resides in riscv-isa-sim/dumy_rocc
but it produces following outputs when using command:
riscv64-unknown-elf-gcc -o d ./dummy_rocc_test.c
./dummy_rocc_test.c: Assembler messages:
./dummy_rocc_test.c:13: Error: unrecognized opcode `custom0 x0,a5,2,0'
./dummy_rocc_test.c:15: Error: unrecognized opcode `custom0 a5,x0,2,1'
./dummy_rocc_test.c:18: Error: unrecognized opcode `custom0 x0,a5,2,3'
./dummy_rocc_test.c:20: Error: unrecognized opcode `custom0 a5,x0,2,1'
./dummy_rocc_test.c:23: Error: unrecognized opcode `custom0 x0,a5,2,2'
./dummy_rocc_test.c:24: Error: unrecognized opcode `custom0 x0,a5,2,3'
./dummy_rocc_test.c:25: Error: unrecognized opcode `custom0 a5,x0,2,1'
Did I miss something before compiling this? or Should I have to modify some build option even though I want to use dummy extension?

By default recognition of custom0/custom1 is off.
Try to use -march option with custom suffix:
riscv64-unknown-elf-gcc -march=rv64imafdxcustom -o d ./dummy_rocc_test.c
Note: old toolchain use upper case ISA extensions symbols, i.e:
-march=RV64IMAFDXcustom

Related

Unrecognized opcode in creating custom RISC-V instruction

I've downloaded the rocket-chip repo and the corresponding rocket-tools repo. Everything works just fine when I initially build everything.
I've created my own tightly coupled accelerator for the AES algorithm and want to test it using the custom-0 and custom-1 instructions. I've followed the instructions in the riscv-isa-sim repo (https://github.com/riscv/riscv-isa-sim) to simulate a new instruction and successfully rebuilt rocket-tools.
I want to make a really simple assembly test in rocket-tools/riscv-tests/isa/rv64ui/ to test my new instructions but when I run make in the isa folder, I get the Error: unrecognized opcode for all my instructions:
rv32ui/../rv64ui/aes.S: Assembler messages:
rv32ui/../rv64ui/aes.S:20: Error: unrecognized opcode `wkeyl x14,x1,x2'
rv32ui/../rv64ui/aes.S:21: Error: unrecognized opcode `wkeyh x14,x1,x2'
rv32ui/../rv64ui/aes.S:22: Error: unrecognized opcode `wstatel x14,x1,x2'
rv32ui/../rv64ui/aes.S:23: Error: unrecognized opcode `wstateh x14,x1,x2'
Makefile:74: recipe for target 'rv32ui-p-aes' failed
make: *** [rv32ui-p-aes] Error 1
make: *** Waiting for unfinished jobs....
What is the correct way to implement custom instructions in RISC-V? I tried to follow this tutorial but get a segmentation fault when I run spike: https://nitish2112.github.io/post/adding-instruction-riscv/

newlib: Compiler gets confused when building 32-bit compatibility

I am compiling newlib so I can continue the building of my cross-compiler, but newlib is getting confused with the 32-bit support I also included in my cross-compiler.
I already have my cross-compiler compiled and installed, but it's missing a standard library along with libgcc, so most programs will not compile, but programs not using standard functions will compile as long as the -nostdlib argument is used
If you're asking to me: "You should use glibc instead!", I'll answer: It requires source files from Linux, but the Linux source code does not play well on Windows, because Windows thinks that some files are the same due to the case-insensitive file system.
The errors are:
x86_64-linux-gnu-gcc -m32 -DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\" -DPACKAGE_VERSION=\"4.0.0\" -DPACKAGE_STRING=\"newlib\ 4.0.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -I. -I../../../../../../../newlib/newlib/libc/machine/x86_64 -fno-builtin -DMISSING_SYSCALL_NAMES -DHAVE_INIT_FINI -fno-builtin -DMISSING_SYSCALL_NAMES -DHAVE_INIT_FINI -nostdlib -m32 -c -o lib_a-setjmp.o `test -f 'setjmp.S' || echo '../../../../../../../newlib/newlib/libc/machine/x86_64/'`setjmp.S
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S: Assembler messages:
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:25: Error: bad register name `%rbx'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:26: Error: bad register name `%rbp'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:27: Error: bad register name `%r12'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:28: Error: bad register name `%r13'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:29: Error: bad register name `%r14'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:30: Error: bad register name `%r15'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:31: Error: bad register name `%rsp)'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:32: Error: bad register name `%rax'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:33: Error: bad register name `%rsp)'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:34: Error: bad register name `%rax'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:35: Error: bad register name `%rax'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:39: Error: bad register name `%rsi'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:41: Error: bad register name `%rdi)'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:44: Error: bad register name `%rdi)'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:45: Error: bad register name `%rdi)'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:46: Error: bad register name `%rdi)'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:47: Error: bad register name `%rdi)'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:48: Error: bad register name `%rdi)'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:49: Error: bad register name `%rdi)'
../../../../../../../newlib/newlib/libc/machine/x86_64/setjmp.S:50: Error: bad register name `%rdi)'
Here's the entire log:
Original (some parts are in Spanish)
English translation
My compiler is: MinGW-w64 x86-64 (from MSYS2)
The cross-compiler I am trying to build is: Linux x86-64
I fixed it. I simply disabled multilib, because I can just simply build another compiler for 32-bit.

IP multimedia subsystem cross compilation

I am using OpenIMSCore on x86 architecture. I need to cross compile OpenIMS for power-pc. In /ser_ims/Makefile.defs file there is a option for ppc. But I am not able to figure out how to cross compile it for ppc. There is no configure file through which I can configure IMS and compile it for ppc. Has anyone cross compiled IMS? I tried compiling through command
make CFLAGS="arch=Power Macintosh"
make CFLAGS="arch=ppc"
But both the commands are not working. It is giving following error:
Makefile.defs:598: You are using an old and unsupported gcc version (G++), compile at your own risk!
powerpc-linux-gnu-gcc -g -O9 -funroll-loops -Wcast-align -Wall -DNAME='"ser"' -DVERSION='"2.1.0-dev1 OpenIMSCore"' -DARCH='"i386"' -DOS='linux_' -DOS_QUOTED='"linux"' -DCOMPILER='"powerpc-linux-gnu-gcc G++"' -D__CPU_i386 -D__OS_linux -DSER_VER=2001000 -DCFG_DIR='"/usr/local/etc/ser/"' -DPKG_MALLOC -DSHM_MEM -DSHM_MMAP -DDNS_IP_HACK -DUSE_IPV6 -DUSE_MCAST -DUSE_TCP -DDISABLE_NAGLE -DHAVE_RESOLV_RES -DDBG_QM_MALLOC -DUSE_DNS_CACHE -DUSE_DNS_FAILOVER -DUSE_DST_BLACKLIST -ggdb -DUSE_TLS -DTLS_HOOKS -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DCC_GCC_LIKE_ASM -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_EPOLL -DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND -DHAVE_SELECT -c core_cmd.c -o core_cmd.o
core_cmd.c: In function 'core_shmmem':
mem/../fastlock.h:181: error: can't find a register in class 'MQ_REGS' while reloading 'asm'
mem/../fastlock.h:358: error: can't find a register in class 'MQ_REGS' while reloading 'asm'
mem/../fastlock.h:181: error: can't find a register in class 'MQ_REGS' while reloading 'asm'
mem/../fastlock.h:181: error: 'asm' operand has impossible constraints
Probably, the error you are getting is due to the separate header file definition and most importantly different shared library files for x86 architecture and different header files for PowerPC architecture. You can change the header file definitions with the new ones using "-I" flag and the shared library file path which is for PowerPC architecture, which can be changed by using -L option. But these all changes might be implemented in Makefile, so u just need to change the location in different flags, like LDFLAG, CFLAGS etc.

using mupdf ndk-build error

I am trying to use mupdf in android application.I am using windows 7 and cygwin terminal.I used make but it gave error and
make NOX11=yes
execute successfully.
then i used ndk-build and it gives this error.
SharedLibrary : libmupdf.so
c:/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/libmupdfcore.a(pdf_fontfile.o)(.text.pdf_lookup_builtin_font+0x18): unresolvable R_ARM_THM_CALL relocation against symbol `strcmp'
c:/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/../../../../arm-linux-androideabi/bin/ld.exe: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
/cygdrive/c/android-ndk-r8b/build/core/build-binary.mk:378: recipe for target `obj/local/armeabi/libmupdf.so' failed
make: *** [obj/local/armeabi/libmupdf.so] Error 1
please help me.I am new to android ndk.
Thank you.
This seems like a known issue. Try adding the line:
NDK_TOOLCHAIN_VERSION=4.4.3
to the file ..\android\jin\Application.mk. That will at least get rid of this particular error.
EDIT: Look here http://code.google.com/p/android/issues/detail?id=35393 for more information
UPDATE:
mupdf world is a murky one. Even the version of NDK vis-a-vis the version of mupdf (http://mupdf.com/download/archive/) you use will determine what sort of errors or warnings you get. From my experience, mupdf-0.9 (+mupdf-thirdparty-2011-02-24.zip) behaves well with android-ndk-r6b, while mupdf-1.1 (+mupdf-thirdparty-2012-08-14.zip) will behave just fine with android-ndk-r8b.

Problem in Cross-Compiling libSDL for MIPS Platform

I was trying to compile libSDL-1.2.14 for my mips platform.
But it was not successful.
These were the steps that I tried out :
export PATH=/opt/mips-4.3/bin:$PATH
Went inside the libSDL-1.2.14 source folder.
Gave a "./configure --prefix=/usr/local/SDL_Lib --host=mips-linux-gnu"
Executed the "make" command
This was the error received :
cc1: warning: include location
"/usr/include" is unsafe for
cross-compilation
./src/audio/dma/SDL_dmaaudio.c: In
function 'DMA_WaitAudio':
./src/audio/dma/SDL_dmaaudio.c:167:
error: can't find a register in class
'COP3_REGS' while reloading 'asm'
./src/audio/dma/SDL_dmaaudio.c:167:
error: 'asm' operand has impossible
constraints make: *
[build/SDL_dmaaudio.lo] Error 1
But then i reconfigured the make file by giving the following commands :
make clean
./configure --prefix=/usr/local/SDL_Lib --host=mips-linux-gnu CPPFLAGS=-I/opt/mips-4.3/mips-linux-gnu/libc/usr/include/
make
NOTE : /opt/mips-4.3/mips-linux-gnu/libc/usr/include/ - This is the path where you can locate the select.h file for the mips Platform.
It contains the definitions of the macros FD_ZERO and FD_SET.
Still I am getting the same error.
cc1: warning: include location
"/usr/include" is unsafe for
cross-compilation
./src/audio/dma/SDL_dmaaudio.c: In
function 'DMA_WaitAudio':
./src/audio/dma/SDL_dmaaudio.c:167:
error: can't find a register in class
'COP3_REGS' while reloading 'asm'
./src/audio/dma/SDL_dmaaudio.c:167:
error: 'asm' operand has impossible
constraints make: *
[build/SDL_dmaaudio.lo] Error 1
Please help me with some valuable pointers.
Thanks,
Sen
First, don't set the path to the cross-compiler as the first part of your PATH, set it as last:
export PATH=$PATH:<path to cross-compiler>
It's safer this way. Second, run ./configure --help to get all the options. What that error message would say if it was smarter is the following:
You're trying to cross-compile since you're setting the --host flag
But you're not changing any of the other options for where to find includes and libs for the target environment
I'm going to use /usr/include by default
But that's for the host system which will not work when cross-compiling
Check what other configure options you need to set to tell the configure script where to find the .h files (includes) and the libraries for your target. These usually come with the cross-compiler that you download. Also, you should probably set the CROSS_COMPILE environment variable to the cross-compiler prefix before running configure. The prefix is the part before gcc in a cross-compiler, assuming you're using GCC as your cross-compiler.

Resources