Open anon63github opened 6 years ago
Here's a simple baremetal program for all riscv-qemu machines: spike
, sifive_e
, sifive_u
and virt
Please try it out and if it is satisfactory, then you can close this issue. It should work for both rv32 and rv64.
Dear all,
I post this here in riscv-qemu and in riscv-gnu-toolchain.
Can someone explain me simply how to make the user-space hello-world init working in qemu-system-riscv64 :
compiled statically as we do when we test with busybox
riscv-linux is compiled with allnoconfig + printk + tty + 8250_serial port + 8250/16550 console + elf + script beginning with #! + proc / sysfs pseudofilesystem , initramfs with the initramfs source name provided directly
It's trivial with x86_64 :
gcc -static hello.c -o root-x8664/init mkdir dev/ sudo mknod dev/console c 5 1 find . | cpio --quiet -o -H newc > initramfs.cpio
It's trivial with arm64 with the compiler command replaced by
aarch64-linux-gnu-gcc -static hello.c -o init
and the ARM AMBA PL011 + support console serial port instead of 8250 serial portI just cannot make it work with riscv... :(
I read carefully
https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt https://www.cnx-software.com/2018/03/16/how-to-run-linux-on-risc-v-with-qemu-emulator/ https://github.com/riscv/riscv-tools/issues/70 https://mgalgs.github.io/2015/05/16/how-to-build-a-custom-linux-kernel-for-qemu-2015-edition.html
these made the hello-world userspace init really easy for the x8664 and arm64 cases.... but impossible for me with riscv... (and I have not been able to do the busybox or busybear stuff either)
What did I miss ?? Is it supposed to work with the following riscv-gnu-toolchain ?
$ git submodule status 8db5daf9efe8a6174d3b10ac7bba8c178836e9ce riscv-binutils (remotes/origin/riscv-binutils-2.30) 2e99dc08d8e5e16f07627bd52a192906abfa9a5c riscv-dejagnu (2e99dc0) af8bbdf198a7cd619efd7c9a7aef2f86d5590aae riscv-gcc (remotes/origin/riscv-gcc-8.1.0) 635c14ec58512380f28fc80447a427de9341293d riscv-gdb (heads/riscv-binutils-2.29) 2f626de717a86be3a1fe39e779f0b179e13ccfbb riscv-glibc (2f626de717) 320b28ea27c71df7afe62b21a220f77aef9eb88a riscv-newlib (newlib-3.0.0-12-g320b28ea2) ff36f2f77ec3e6a6211c63bfe1707ec057b12f7d riscv-qemu (pull-tcg-20160920-410-gff36f2f77e)
and current riscv-all branch of riscv-qemu ? (I wasnt able to do it, even before the recent bump risc-gcc-8.1.0, binutils 2.30)
Did I miss some config options in the kernel ?(Virtual driver, ...) Is it not working with the -machine virt of qemu-riscv ? Did I miss some mknod dev/ttyS0 ? dev/null ? as in the busybear repository ?
My logs in x86_64
My logs in arm64
My deceptive logs in riscv64 (with vmlinux as bbl payload) :
Sometimes I have no messages at all after the linux logs. It seems that sometimes I get in the function because If I don't do the infinite while loop, linux tells me that init was killed (init returned) so I may have forgotten something really simple with tty or the serial driver....
Thanks for your help (if it's not a bug) !