C Firmware code compiler for RISC-V

Is there a compiler to convert C Firmware code to .dat format to be deployed on with any SiFive based processors? If yes, kindly mention the name too. (Looking for something similar to RVDS Compiler for ARM)
Thank you!

2 Likes

We would need to know the format of this .dat file.

We have support for converting ELF files into binary files (for embedded targets) and hex files (for verilog simulators). objdump can convert an ELF file to a binary file. elf2hex can convert an ELF file to a hex file. objdump is part of FSF binutils. elf2hex is found at
https://github.com/sifive/elf2hex

1 Like

Do u have a compiler which converts C FW code to hex files instead of elf to hex format

You compile to an ELF file, and then convert the ELF file to a hex file via elf2hex.
https://github.com/sifive/elf2hex

Yeah. For generating ELF, is normal gcc compile command in Linux fine or shall we use the GNU MCU Eclipse RISC-V Embedded GCC only?

You can use any RISC-V embedded elf compiler. We have toolchain releases on our web site.

Hey Jim, I installed the riscv-gnu-toolchain from github 
Earlier I got some errors while building 
So as u suggested,I added bin to my path(I specified /opt/riscv/bin while configuring ) and I built the compiler without any errors
But even now it’s using the default built-in gcc(/user/bin/gcc) not the riscv64-unknown-elf-gcc
How do I solve this?

You have to use riscv64-unknown-elf-gcc instead of gcc. Exactly how you do that depends on your software. If you are using make for instance, then something like
make CC=riscv64-unknown-elf-gcc
might work.

Hey Jim,it’s showing this when I gave the command:

harshavardhan@dell-Vostro-5568:~/Desktop/test_riscv/riscv-gnu-toolchain$ make CC=riscv64-unknown-elf-gcc
make: Nothing to be done for ‘all’.

Also when I tried the command “update-alternatives --query gcc” to check whether the riscv gcc was built properly,I got this:

harshavardhan@dell-Vostro-5568:~/Desktop/test_riscv/riscv-gnu-toolchain$ update-alternatives --query gcc
update-alternatives: error: no alternatives for gcc

Help me fix this issue ASAP.

This is getting very confused.

The steps here are that you first get a cross compiler to RISC-V (download it or build it), then you set your path to point at it, then you use riscv64-unknown-elf-gcc to compile your firmware code, then you use elf2hex to convert the RISC-V ELF executable file to a hex file.

harshavardhan@dell-Vostro-5568:~/Desktop/test_riscv/riscv-gnu-toolchain$ make CC=riscv64->unknown-elf-gcc
make: Nothing to be done for ‘all’.

This looks like you are trying to use the cross compiler to build the cross compiler which is wrong. You use /usr/bin/gcc to build the cross compiler. Then you use the cross compiler to build your firmware code.

Apparently you already built it, so there is nothing for make to do here.

Since you already built the cross compiler, you should be using it to try to compile your firmware code.

Also when I tried the command “update-alternatives --query gcc” to check whether the riscv gcc was >built properly,I got this:

update-alternatives only knows about OS packages installed via apt, or whatever your OS package installer is. Since you didn’t use apt (or whatever) to install the cross compiler, it isn’t going to know about it.