Open
Description
RISC-V from scratch 1: Introduction, toolchain setup, and hello world!
A post that discusses what RISC-V is and why it's important, teaches readers how to install the GNU RISC-V toolchain, and walks through building and running a simple C program on emulated RISC-V hardware.
https://twilco.github.io/riscv-from-scratch/2019/03/10/riscv-from-scratch-1.html
Metadata
Metadata
Assignees
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
DyslexicAtheist commentedon May 25, 2019
in the code snipped change:
to
thanks for this awesome guide! I especially love part deux =)
twilco commentedon May 26, 2019
@DyslexicAtheist, thanks for the kind words! Glad you enjoyed it.
Fixed with 2f9ed76.
alicelyy commentedon May 26, 2019
Ran into the following error when running the helloword executable:
Any suggestion?
alicelyy commentedon May 26, 2019
One little issue, according to their README.md
by default compiles only the hello program, not all the example programs
twilco commentedon May 26, 2019
@limslarmo, turns out the issue you encountered is due to a bug introduced into QEMU. Someone has created a patch to fix the problem, but it hasn't yet been merged. See this comment for more information.
Getting this example running is unnecessary to progress in future posts, so don't worry too much about it. In the meantime, I've updated the post to note that the freedom-e-sdk "hello world" program won't work for now: dae59ca
Thanks for the correction on
make software
- I've fixed it here: f43b895alicelyy commentedon May 26, 2019
Thanks!!
yashomer1994 commentedon Jul 27, 2019
Hey, I am having issue while using for sifive-hifive1 , the error comes like error finding bsp for sifive-hifive1 I havee also tried using the bsp directory, and simply make or make software.
nothing is working
twilco commentedon Jul 27, 2019
Hey @yashomer1994 - sorry you're having troubles. Could you post the exact error you're getting? What OS are you running?
The freedom-e-sdk appears to change very quickly, making it hard to keep the instructions up to date. It might be worth opening an issue in their repository, as the instructions provided in my guide appear to mirror those they suggest.
Also, running this example is unnecessary to continue on in the series, so don't let it hold you back unless you're really keen on getting it working :)
yashomer1994 commentedon Jul 30, 2019
Hey, Ya I solved the problem redoing everything on fresh terminal, now its working perfectly emulated easily on Qemu. Thanks
oliverbm67 commentedon Aug 12, 2019
Hi, I have installed Qemu (on Linux Mint) and I have a bunch of system installed, but no risc-v ones. Is that normal ? Where should I get the qemu-system-riscv32 machine ?
Thank you for this nice tutorial !
twilco commentedon Aug 12, 2019
Hey @oliverbm67. What happens when you run
qemu-system-riscv32 --version
? Here is what I get:The RISC-V port of QEMU was upstreamed to QEMU proper, so installing QEMU via the means specified on their website should give you this command.
If this isn't the case, or if my instructions are generally unclear, let me know so I can fix them up 🙂
oliverbm67 commentedon Aug 12, 2019
Hey @twilco !
qemu-system-riscv32 --version
return command not found. Other system works such asqemu-system-i386 --version
return :QEMU emulator version 2.11.1(Debian 1:2.11+dfsg-1ubuntu7.15) Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
I installed qemu with
apt-get install qemu
, maybe it is a version issue ?EDIT : I uninstalled qemu and reinstalled by compiling the latest version from source and solved the problem. The issue is on the qemu website, not in your tutorial. The version in the repo is outdated.
twilco commentedon Aug 12, 2019
Yep, according to this blog post, QEMU 2.12.0 is the first official release to contain RISC-V. Glad you got it figured out!
balaji-ch commentedon Oct 5, 2020
I tried using file IO and I am unable to succeed.
This is what I did, in the hello world program
printf("Hello, World!\n");
FILE *fp;
fp = fopen("test_rv.txt", "w+");
if(fp==NULL)
{
printf("Unable to open the file \n");
}
printf("Testing ---- After ! \n");
The output is
Hello, World!
Unable to open the file
Testing ---- After !
How can I make to open a file and do some read/write operations ?
5 remaining items