How to print strings in a bare metal program in spike?

641 views
Skip to first unread message

Junyi Yang

unread,
Oct 27, 2018, 10:29:46 AM10/27/18
to RISC-V SW Dev
Hello!
I want to write a bare metal program to print someting in qemu-system-riscv32 -machine spike_v1.10.
But I don't know how to do that.
I also find anything about that.
How can I do that?
Thanks.

Jim Wilson

unread,
Oct 29, 2018, 2:25:58 PM10/29/18
to yangre...@gmail.com, sw-...@groups.riscv.org
The github.com/sifive/freedom-e-sdk has some examples of how to do
bare metal programming. bsp/libwrap/sys/write.c has code to send
bytes to a uart, which will print them on the serial console. This
should work work the sifive_e machine, but may or may not work with
the spike machine depending on what UART it supports.

Jim

jimmy li

unread,
Nov 22, 2018, 5:19:31 AM11/22/18
to RISC-V SW Dev

you could call a "write syscall", and the riscv-fesvr will help you print it on the console.

ref  https://github.com/riscv/riscv-tests/blob/master/benchmarks/common/syscalls.c 

在 2018年10月27日星期六 UTC+8下午10:29:46,Junyi Yang写道:
Reply all
Reply to author
Forward
0 new messages