Giter VIP home page Giter VIP logo

risc-v-getting-started-guide's Introduction

RISC-V Getting Started Guide

This is the repository for the RISC-V Getting Started Guide, an introductory material prepared by the RISC-V Foundation and hosted at Read The Docs to show you where to start if you're interested in developing for the free and open source ISA.

For details about RISC-V itself, see the RISC-V Website.

You can contribute to the Getting Started Guide too! We are always happy to add more platforms and examples, and make the Guide more attractive to readers. See Contributing below for details.

Compiling the Guide

The Guide is built using Sphinx, a popular documentation framework used e.g. by Python, Zephyr and Linux, based on reStructuredText.

Sphinx can be installed with pip, the Python package manager:

pip install sphinx

(for detailed instructions, see Installing Sphinx)

To compile the HTML version of the Guide, use:

make html

The output will reside in the build/ directory.

You can also generate a PDF, which requires TeX and a few other tools.

Contributing

The RISC-V ecosystem is largely based around a diversified pool of corporate and personal contributions coming from over 130 corporate members and thousands of developers around the world. We especially welcome contributions that make RISC-V more accessible to the broader public (such as improving this Guide) - and we are happy you are reading this!

Please use the GitHub issues and pull requests mechanisms to contribute to the Guide. This may include:

  • guides for new platforms (please follow the style in which existing platforms are written)
  • corrections and extensions to existing platforms
  • more advanced pieces of content showcasing additional software that can be run on RISC-V

Note that in order to keep the material universally accessible, please only contribute guides based on software that is freely available without unnecessary limitation.

New platform contributions should be complete and tested on multiple platforms (or at least explicitly marked as incomplete in some aspects), so that users can get started successfully without running into problems.

For the sake of clarity, legibility and user-friendliness, the RISC-V Foundation reserves the right to modify or refuse to include submitted pieces of content at its discretion.

risc-v-getting-started-guide's People

Contributors

alistair23 avatar andreas-schwab avatar antonkrug avatar enjoy-digital avatar jjscheel avatar kgugala avatar kodykantor avatar mateusz-holenko avatar mgielda avatar nenad avatar piotrzierhoffer avatar pkatarzynski avatar sanderjo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

risc-v-getting-started-guide's Issues

I think the RV32 compilation should be updated

The step for the Linux compilation for rv32 should be updated to use rv32_defconfig instead of defconfig. Compiling with defconfig will cause the kernel to hang when loaded in Spike/OpenSbi.

Build Linux for the RISC-V target: directory "linux" does not exist

Based on the instruction

image

the cd linux does not work

root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain/qemu# cd linux
bash: cd: linux: No such file or directory
root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain/qemu# ll | grep drw | grep linux
drwxr-xr-x 11 root root     4096 Nov 26 17:09 linux-headers/
drwxr-xr-x 25 root root     4096 Nov 26 17:09 linux-user/

Am I in the wrong directory /riscv64-linux/riscv-gnu-toolchain/qemu

Must I switch to /riscv64-linux/linux/ ? If so, what did I miss in the Guide?

LiteX blurb on Zephyr intro page is garbled/confusing

This text (bold emphasis is mine):

The LiteX soft SoC, developed in MiGen/Python that VexRiscv can be - and often is - combined with scales from simple designs with UART or SPI, I2C to complex setups with Ethernet, USB, PCIe, DDR controllers etc.

on this page of the docs:

https://risc-v-getting-started-guide.readthedocs.io/en/latest/zephyr-introduction.html

is garbled/confusing - particularly the bit in bold - but I'm not in a position to suggest a correction myself unfortunately.

kernel panic when running the qemu riscv command

The following command:

sudo qemu-system-riscv64 -nographic -machine virt  -kernel linux/arch/riscv/boot/Image -append "root=/dev/vda ro console=ttyS0" -drive file=busybox/busybox,format=raw,id=hd0 -device virtio-blk-device,drive=hd0

that is described in the getting started guide https://github.com/riscv/risc-v-getting-started-guide/blame/master/source/linux-qemu.rst#L161 gives a kernel panic

image

what is the expected behavior when that command is executed?

"./configure --target-list=riscv64-softmmu" gives "ERROR: pkg-config binary 'pkg-config' not found"

root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain/qemu# ./configure --target-list=riscv64-softmmu

ERROR: pkg-config binary 'pkg-config' not found

So ... try:

root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain/qemu# apt-get install pkg-config
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libglib2.0-0 libglib2.0-data shared-mime-info xdg-user-dirs
The following NEW packages will be installed:
  libglib2.0-0 libglib2.0-data pkg-config shared-mime-info xdg-user-dirs
0 upgraded, 5 newly installed, 0 to remove and 10 not upgraded.
Need to get 1693 kB of archives.
After this operation, 7246 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libglib2.0-0 amd64 2.56.4-0ubuntu0.18.04.4 [1169 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libglib2.0-data all 2.56.4-0ubuntu0.18.04.4 [4496 B]
Get:3 http://archive.ubuntu.com/ubuntu bionic/main amd64 shared-mime-info amd64 1.9-2 [426 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic/main amd64 xdg-user-dirs amd64 0.17-1ubuntu1 [48.0 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic/main amd64 pkg-config amd64 0.29.1-0ubuntu2 [45.0 kB]
Fetched 1693 kB in 0s (5001 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libglib2.0-0:amd64.
(Reading database ... 17720 files and directories currently installed.)
Preparing to unpack .../libglib2.0-0_2.56.4-0ubuntu0.18.04.4_amd64.deb ...
Unpacking libglib2.0-0:amd64 (2.56.4-0ubuntu0.18.04.4) ...
Selecting previously unselected package libglib2.0-data.
Preparing to unpack .../libglib2.0-data_2.56.4-0ubuntu0.18.04.4_all.deb ...
Unpacking libglib2.0-data (2.56.4-0ubuntu0.18.04.4) ...
Selecting previously unselected package shared-mime-info.
Preparing to unpack .../shared-mime-info_1.9-2_amd64.deb ...
Unpacking shared-mime-info (1.9-2) ...
Selecting previously unselected package xdg-user-dirs.
Preparing to unpack .../xdg-user-dirs_0.17-1ubuntu1_amd64.deb ...
Unpacking xdg-user-dirs (0.17-1ubuntu1) ...
Selecting previously unselected package pkg-config.
Preparing to unpack .../pkg-config_0.29.1-0ubuntu2_amd64.deb ...
Unpacking pkg-config (0.29.1-0ubuntu2) ...
Setting up libglib2.0-0:amd64 (2.56.4-0ubuntu0.18.04.4) ...
No schema files found: doing nothing.
Setting up pkg-config (0.29.1-0ubuntu2) ...
Setting up libglib2.0-data (2.56.4-0ubuntu0.18.04.4) ...
Setting up shared-mime-info (1.9-2) ...
Setting up xdg-user-dirs (0.17-1ubuntu1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...

No:

root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain/qemu# ./configure --target-list=riscv64-softmmu

ERROR: glib-2.40 gthread-2.0 is required to compile QEMU

root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain/qemu#

Solution:
apt-get install libglib2.0-dev
Then

root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain/qemu# ./configure --target-list=riscv64-softmmu

ERROR: pixman >= 0.21.8 not present.
       Please install the pixman devel package.

solution:
apt-get install libpixman-1-dev

python3 is needed by "make linux -j $(nproc)"

make linux -j $(nproc) on fresh Ubuntu 18.04 x86_64 gives problems.
First:

checking for riscv64-unknown-linux-gnu-nm... riscv64-unknown-linux-gnu-nm
checking for python3... no
checking for python... no
configure: error:
*** These critical programs are missing or too old: python

So I installed python (python2), but that results in:

checking for riscv64-unknown-linux-gnu-nm... riscv64-unknown-linux-gnu-nm
checking for python3... no
checking for python... python
checking version of python... 2.7.15, bad
configure: error:
*** These critical programs are missing or too old: python
*** Check the INSTALL file for required versions.

After installation of python3, the make linux -j $(nproc) proceeds.

Missing LICENSE file

The project is missing a LICENSE file. Per RISC-V guidelines, documentation should be licensed CC-BY-4.0.

I propose adding a plain text LICENSE file like the one in the ISA manual project. This enables GitHub to automatically find it and recognize it.

I'm happy to add this into the project directly and will do so in the coming days. If anyone has concerns, please raise them.

Thanks,
-Jeff

qemu emulation problems

I'm following the tutorial and had stumbled on this error

qemu-system-riscv64: -drive file=busybox,format=raw,id=hd0: A regular file was expected by the 'file' driver, but something else was given

when running QEMU as:

sudo qemu-system-riscv64 -nographic -machine virt \
     -kernel linux/arch/riscv/boot/Image -append "root=/dev/vda ro console=ttyS0" \
     -drive file=busybox,format=raw,id=hd0 \
     -device virtio-blk-device,drive=hd0

Next I've modified the 'file' to be busybox/busybox because in busybox folder I have built busybox as stated in the tutorial.
Then I get new warnings:

qemu-system-riscv64: warning: No -bios option specified. Not loading a firmware.
qemu-system-riscv64: warning: This default will change in a future QEMU release. Please use the -bios option to avoid breakages when this happens.
qemu-system-riscv64: warning: See QEMU's deprecation documentation for details.

And the QEMU just hangs.

I've also built the QEMU as stated in the guide.

QEMU version:

$ qemu-system-riscv64 --version
QEMU emulator version 5.0.0 (v5.0.0-dirty)
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers

Ubuntu version:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.5 LTS
Release:	18.04
Codename:	bionic

"git checkout v3.0.0" error: The following untracked working tree files would be overwritten by checkout: slirp/COPYRIGHT

root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain# cd qemu
root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain/qemu# git checkout v3.0.0
error: The following untracked working tree files would be overwritten by checkout:
        slirp/COPYRIGHT
Please move or remove them before you switch branches.
Aborting
root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain/qemu# ./configure --target-list=riscv64-softmmu^C
root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain/qemu#

So ... try:

root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain/qemu#
root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain/qemu# mv slirp/COPYRIGHT slirp/COPYRIGHT.org
root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain/qemu# git checkout v3.0.0
warning: unable to rmdir 'roms/edk2': Directory not empty
warning: unable to rmdir 'slirp': Directory not empty
warning: unable to rmdir 'tests/fp/berkeley-softfloat-3': Directory not empty
warning: unable to rmdir 'tests/fp/berkeley-testfloat-3': Directory not empty
Checking out files: 100% (5361/5361), done.
M       dtc
M       roms/QemuMacDrivers
M       roms/SLOF
M       roms/ipxe
M       roms/openbios
M       roms/qemu-palcode
M       roms/seabios
M       roms/seabios-hppa
M       roms/skiboot
M       roms/u-boot
Previous HEAD position was 57dfc2c4d5 Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20190704-1' into staging
HEAD is now at 38441756b7 Update version for v3.0.0 release
root@6f42517b2121:/riscv64-linux/riscv-gnu-toolchain/qemu#

Is that good?

Failed to run Ubuntu/Debian on QEMU RISC-V

I followed the instructions in RISC-V getting started guide with #26 and #28 to run Ubuntu/Debian on QEMU RISC-V. But failed to do that.

After building QEMU, Linux, Busybox, I ran the following command to boot QEMU RISC-V with Ubuntu.

https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html#running

$ sudo qemu-system-riscv64 -nographic -machine virt \
     -kernel linux/arch/riscv/boot/Image -append "root=/dev/vda ro console=ttyS0" \
     -drive file=busybox/busybox,format=raw,id=hd0 \
     -device virtio-blk-device,drive=hd0

But I faced the following warnings and see no other messages.

qemu-system-riscv64: warning: No -bios option specified. Not loading a firmware.
qemu-system-riscv64: warning: This default will change in a future QEMU release. Please use the -bios option to avoid breakages when this happens.
qemu-system-riscv64: warning: See QEMU's deprecation documentation for details.

I also tried -bios default option but it seems to fail to mount root fs.

$ sudo qemu-system-riscv64 -nographic -machine virt \
     -kernel linux/arch/riscv/boot/Image -append "root=/dev/vda ro console=ttyS0" \
     -drive file=busybox/busybox,format=raw,id=hd0 \
     -device virtio-blk-device,drive=hd0 -bios default

OpenSBI v0.6
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name          : QEMU Virt Machine
Platform HART Features : RV64ACDFIMSU
Platform Max HARTs     : 8
Current Hart           : 0
Firmware Base          : 0x80000000
Firmware Size          : 120 KB
Runtime SBI Version    : 0.2

MIDELEG : 0x0000000000000222
MEDELEG : 0x000000000000b109
PMP0    : 0x0000000080000000-0x000000008001ffff (A)
PMP1    : 0x0000000000000000-0xffffffffffffffff (A,R,W,X)
[    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
[    0.000000] Linux version 5.4.0 (takahiro@takahiro-VirtualBox) (gcc version 10.1.0 (GCC)) #1 SMP Tue Sep 1 10:34:30 PDT 2020
[    0.000000] initrd not found or empty - disabling initrd
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000080200000-0x0000000087ffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080200000-0x0000000087ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x0000000087ffffff]
[    0.000000] software IO TLB: mapped [mem 0x83e3a000-0x87e3a000] (64MB)
[    0.000000] elf_hwcap is 0x112d
[    0.000000] percpu: Embedded 17 pages/cpu s30680 r8192 d30760 u69632
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 31815
[    0.000000] Kernel command line: root=/dev/vda ro console=ttyS0
[    0.000000] Dentry cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.000000] Inode-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.000000] Sorting __ex_table...
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 51968K/129024K available (6166K kernel code, 387K rwdata, 1962K rodata, 213K init, 305K bss, 77056K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu: 	RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=1.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[    0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
[    0.000000] plic: mapped 53 interrupts with 1 handlers for 2 contexts.
[    0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0]
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns
[    0.000125] sched_clock: 64 bits at 10MHz, resolution 100ns, wraps every 4398046511100ns
[    0.005020] Console: colour dummy device 80x25
[    0.010186] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=40000)
[    0.010365] pid_max: default: 32768 minimum: 301
[    0.011845] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.011882] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.050872] rcu: Hierarchical SRCU implementation.
[    0.053564] smp: Bringing up secondary CPUs ...
[    0.053647] smp: Brought up 1 node, 1 CPU
[    0.066191] devtmpfs: initialized
[    0.074566] random: get_random_u32 called from bucket_table_alloc.isra.0+0x4e/0x154 with crng_init=0
[    0.077193] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.077550] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[    0.082457] NET: Registered protocol family 16
[    0.145915] vgaarb: loaded
[    0.147398] SCSI subsystem initialized
[    0.149305] usbcore: registered new interface driver usbfs
[    0.149656] usbcore: registered new interface driver hub
[    0.149818] usbcore: registered new device driver usb
[    0.162399] clocksource: Switched to clocksource riscv_clocksource
[    0.188781] NET: Registered protocol family 2
[    0.196592] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.196850] TCP established hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.197156] TCP bind hash table entries: 1024 (order: 2, 16384 bytes, linear)
[    0.197395] TCP: Hash tables configured (established 1024 bind 1024)
[    0.200620] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.201112] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.203875] NET: Registered protocol family 1
[    0.208520] RPC: Registered named UNIX socket transport module.
[    0.208629] RPC: Registered udp transport module.
[    0.208658] RPC: Registered tcp transport module.
[    0.208684] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.208925] PCI: CLS 0 bytes, default 64
[    0.220011] workingset: timestamp_bits=62 max_order=14 bucket_order=0
[    0.237291] NFS: Registering the id_resolver key type
[    0.238422] Key type id_resolver registered
[    0.238471] Key type id_legacy registered
[    0.238607] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.239371] 9p: Installing v9fs 9p2000 file system support
[    0.241016] NET: Registered protocol family 38
[    0.241576] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
[    0.241747] io scheduler mq-deadline registered
[    0.242013] io scheduler kyber registered
[    0.245290] pci-host-generic 30000000.pci: host bridge /soc/pci@30000000 ranges:
[    0.246223] pci-host-generic 30000000.pci:    IO 0x03000000..0x0300ffff -> 0x00000000
[    0.247150] pci-host-generic 30000000.pci:   MEM 0x40000000..0x7fffffff -> 0x40000000
[    0.250176] pci-host-generic 30000000.pci: ECAM at [mem 0x30000000-0x3fffffff] for [bus 00-ff]
[    0.251579] pci-host-generic 30000000.pci: PCI host bridge to bus 0000:00
[    0.251902] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.252057] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
[    0.252077] pci_bus 0000:00: root bus resource [mem 0x40000000-0x7fffffff]
[    0.253324] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000
[    0.325890] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.335978] printk: console [ttyS0] disabled
[    0.337057] 10000000.uart: ttyS0 at MMIO 0x10000000 (irq = 10, base_baud = 230400) is a 16550A
[    0.474052] printk: console [ttyS0] enabled
[    0.477304] [drm] radeon kernel modesetting enabled.
[    0.522895] loop: module loaded
[    0.553166] virtio_blk virtio0: [vda] 1869 512-byte logical blocks (957 kB/935 KiB)
[    0.628744] libphy: Fixed MDIO Bus: probed
[    0.632066] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
[    0.633691] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    0.637151] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.641902] ehci-pci: EHCI PCI platform driver
[    0.646206] ehci-platform: EHCI generic platform driver
[    0.647905] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.649146] ohci-pci: OHCI PCI platform driver
[    0.652005] ohci-platform: OHCI generic platform driver
[    0.654601] usbcore: registered new interface driver uas
[    0.659067] usbcore: registered new interface driver usb-storage
[    0.662377] mousedev: PS/2 mouse device common for all mice
[    0.667578] usbcore: registered new interface driver usbhid
[    0.669186] usbhid: USB HID core driver
[    0.680722] NET: Registered protocol family 10
[    0.695196] Segment Routing with IPv6
[    0.697284] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    0.714403] NET: Registered protocol family 17
[    0.717662] 9pnet: Installing 9P2000 support
[    0.730306] Key type dns_resolver registered
[    0.791312] List of all partitions:
[    0.792612] fe00             934 vda 
[    0.792667]  driver: virtio_blk
[    0.794799] No filesystem could mount root, tried: 
[    0.794817]  ext3
[    0.804603]  ext2
[    0.805518]  ext4
[    0.806190]  vfat
[    0.806785]  msdos
[    0.807208] 
[    0.808590] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(254,0)
[    0.814049] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.4.0 #1
[    0.815836] Call Trace:
[    0.816993] [<ffffffe000037ac4>] walk_stackframe+0x0/0xa6
[    0.818928] [<ffffffe000037c3a>] show_stack+0x2a/0x34
[    0.820095] [<ffffffe000621ab6>] dump_stack+0x6e/0x88
[    0.820438] [<ffffffe00003cb86>] panic+0xdc/0x246
[    0.824519] [<ffffffe000000ff4>] mount_block_root+0x1fe/0x218
[    0.825814] [<ffffffe00000111c>] mount_root+0x10e/0x124
[    0.826750] [<ffffffe000001244>] prepare_namespace+0x112/0x15c
[    0.828045] [<ffffffe000000c10>] kernel_init_freeable+0x188/0x1a4
[    0.832528] [<ffffffe000636392>] kernel_init+0x12/0xf0
[    0.833898] [<ffffffe000036818>] ret_from_exception+0x0/0xc
[    0.836435] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(254,0) ]---

Do I need to pass a certain bios file to QEMU? Or am I missing something? Does anyone succeeded in booting Ubuntu/Debian on QEMU RISC-V with the guideline?

Undefined references building riscv32-softmmu

I try to compile the following kernel on Ubuntu 20.04.1 LTS:

git clone https://github.com/qemu/qemu
git clone https://github.com/torvalds/linux
git clone https://git.busybox.net/busybox

git checkout v5.0.0
./configure --target-list=riscv32-softmmu
make -j $(nproc)
sudo make install

git checkout v5.4

make ARCH=riscv CROSS_COMPILE=riscv32-unknown-linux-gnu- defconfig
make ARCH=riscv CROSS_COMPILE=riscv32-unknown-linux-gnu- -j $(nproc)

CROSS_COMPILE=riscv32-unknown-linux-gnu- make defconfig
CROSS_COMPILE=riscv32-unknown-linux-gnu- make -j $(nproc)

... and end up with the following error message:

Trying libraries: crypt m rt
Failed: -Wl,--start-group -lcrypt -lm -lrt -Wl,--end-group
Output of:
riscv32-unknown-linux-gnu-gcc -Wall -Wshadow -Wwrite-strings -Wundef -Wstrict-prototypes -Wunused -Wunused-parameter -Wunused-function -Wunused-value -Wmissing-prototypes -Wmissing-declarations -Wno-format-security -Wdeclaration-after-statement -Wold-style-definition -finline-limit=0 -fno-builtin-strlen -fomit-frame-pointer -ffunction-sections -fdata-sections -fno-guess-branch-probability -funsigned-char -static-libgcc -falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-builtin-printf -Os -o busybox_unstripped -Wl,--sort-common -Wl,--sort-section,alignment -Wl,--gc-sections -Wl,--start-group applets/built-in.o archival/lib.a archival/libarchive/lib.a console-tools/lib.a coreutils/lib.a coreutils/libcoreutils/lib.a debianutils/lib.a klibc-utils/lib.a e2fsprogs/lib.a editors/lib.a findutils/lib.a init/lib.a libbb/lib.a libpwdgrp/lib.a loginutils/lib.a mailutils/lib.a miscutils/lib.a modutils/lib.a networking/lib.a networking/libiproute/lib.a networking/udhcp/lib.a printutils/lib.a procps/lib.a runit/lib.a selinux/lib.a shell/lib.a sysklogd/lib.a util-linux/lib.a util-linux/volume_id/lib.a archival/built-in.o archival/libarchive/built-in.o console-tools/built-in.o coreutils/built-in.o coreutils/libcoreutils/built-in.o debianutils/built-in.o klibc-utils/built-in.o e2fsprogs/built-in.o editors/built-in.o findutils/built-in.o init/built-in.o libbb/built-in.o libpwdgrp/built-in.o loginutils/built-in.o mailutils/built-in.o miscutils/built-in.o modutils/built-in.o networking/built-in.o networking/libiproute/built-in.o networking/udhcp/built-in.o printutils/built-in.o procps/built-in.o runit/built-in.o selinux/built-in.o shell/built-in.o sysklogd/built-in.o util-linux/built-in.o util-linux/volume_id/built-in.o -Wl,--end-group -Wl,--start-group -lcrypt -lm -lrt -Wl,--end-group

/opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: coreutils/lib.a(mktemp.o): in function .L5': mktemp.c:(.text.mktemp_main+0x86): warning: the use of mktemp' is dangerous, better use mkstemp' or mkdtemp'
/opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: networking/lib.a(nslookup.o): in function add_query': nslookup.c:(.text.add_query+0xb8): undefined reference to __res_mkquery'
/opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: networking/lib.a(nslookup.o): in function .L59': nslookup.c:(.text.send_queries+0x40e): undefined reference to ns_initparse'
/opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: networking/lib.a(nslookup.o): in function .L63': nslookup.c:(.text.send_queries+0x476): undefined reference to ns_parserr'
/opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: networking/lib.a(nslookup.o): in function .L130': nslookup.c:(.text.send_queries+0x59a): undefined reference to ns_name_uncompress'
/opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: networking/lib.a(nslookup.o): in function .L81': nslookup.c:(.text.send_queries+0x606): undefined reference to ns_get16'
/opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: nslookup.c:(.text.send_queries+0x62e): undefined reference to ns_name_uncompress' /opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: networking/lib.a(nslookup.o): in function .L70':
nslookup.c:(.text.send_queries+0x6f2): undefined reference to ns_name_uncompress' /opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: nslookup.c:(.text.send_queries+0x714): undefined reference to ns_get16'
/opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: nslookup.c:(.text.send_queries+0x722): undefined reference to ns_get16' /opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: nslookup.c:(.text.send_queries+0x730): undefined reference to ns_get16'
/opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: networking/lib.a(nslookup.o): in function .L86': nslookup.c:(.text.send_queries+0x7a2): undefined reference to ns_name_uncompress'
/opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: nslookup.c:(.text.send_queries+0x7d0): undefined reference to ns_name_uncompress' /opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: networking/lib.a(nslookup.o): in function .L74':
nslookup.c:(.text.send_queries+0x7f6): undefined reference to ns_get32' /opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: networking/lib.a(nslookup.o): in function .L87':
nslookup.c:(.text.send_queries+0x810): undefined reference to ns_get32' /opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: nslookup.c:(.text.send_queries+0x82a): undefined reference to ns_get32'
/opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: nslookup.c:(.text.send_queries+0x844): undefined reference to ns_get32' /opt/riscv/lib/gcc/riscv32-unknown-linux-gnu/10.2.0/../../../../riscv32-unknown-linux-gnu/bin/ld: nslookup.c:(.text.send_queries+0x85e): undefined reference to ns_get32'
collect2: error: ld returned 1 exit status
Note: if build needs additional libraries, put them in CONFIG_EXTRA_LDLIBS.
Example: CONFIG_EXTRA_LDLIBS="pthread dl tirpc audit pam"
make: *** [Makefile:718: busybox_unstripped] Error 1

The RISCV toolchain is installed as such:

https://github.com/riscv/riscv-gnu-toolchain
./configure --prefix=/opt/riscv --with-arch=rv32gc --with-abi=ilp32d

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.