Skip to content

Commit 5d7721c

Browse files
authored
Update README.md
Instructions for sifive_e machines.
1 parent cba0de8 commit 5d7721c

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

README.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is a bare metal 64-bit RISC-V assembly program outputing `Hello.`. It is
44
compiled with the riscv-gnu-toolchain and can be run with the QEMU `sifive_u`
5-
machine.
5+
and `sifive_e` machines.
66

77
I searched for such a program on the Internet but the only examples I found
88
were either bare metal C, or assembly but relying on an OS. Eventually I took
@@ -29,11 +29,12 @@ Assuming the toolchain is in the `$PATH`, running the following produces our
2929
`hello` program.
3030

3131
```
32-
$ riscv64-unknown-elf-gcc -march=rv64g -mabi=lp64 -static -mcmodel=medany \
33-
-fvisibility=hidden -nostdlib -nostartfiles -Thello.ld hello.s -o hello
32+
$ riscv64-unknown-elf-gcc -march=rv64g -mabi=lp64 -static -mcmodel=medany \
33+
-fvisibility=hidden -nostdlib -nostartfiles -Tsifive_u/hello.ld -Isifive_u \
34+
hello.s -o hello
3435
```
3536

36-
The result is a 64-bit RISC-V binary.
37+
The result is a 64-bit RISC-V binary compatible with QEMU `sifive_u` machine.
3738

3839
```
3940
$ file hello
@@ -55,6 +56,33 @@ Note: the program enters an infinite loop after producing the `Hello.` text.
5556
Type `ctrl-a x` to stop QEMU.
5657

5758

59+
## Sifive_e machine
60+
61+
This program can be compiled for more resticted machines like `sifive_e`
62+
that support 32-bit RISC-V, have small amount of RAM and requires executable
63+
code to be placed in ROM with different start address.
64+
65+
Assuming the toolchain is in the `$PATH`, running the following produces our
66+
`hello` program, but now ready for `sifive_e`.
67+
68+
```
69+
$ riscv64-unknown-elf-gcc -march=rv32g -mabi=ilp32 -static -mcmodel=medany \
70+
-fvisibility=hidden -nostdlib -nostartfiles -Tsifive_e/hello.ld -Isifive_e \
71+
hello.s -o hello
72+
```
73+
74+
Run it with:
75+
76+
```
77+
$ qemu-system-riscv32 -nographic -machine sifive_e -bios none -kernel hello
78+
Hello.
79+
QEMU: Terminated
80+
```
81+
82+
Note: the program enters an infinite loop after producing the `Hello.` text.
83+
Type `ctrl-a x` to stop QEMU.
84+
85+
5886
## Assembly
5987

6088
To disassemble the program:

0 commit comments

Comments
 (0)