QEMU stuck while booting ubuntu for RISC-V

I was following the installation instructions of Ubuntu for RISC-V on QEMU from a book called “RISC-V Assembly Language Programming” by “Stephen Smith” and I faced problem while booting the image.
I ran this command:

qemu-system-riscv64 -machine virt -cpu rv64 -m 2G 
-device virtio-blk-device,drive=hd 
-drive file=ubunturv.img,if=none,id=hd 
-device virtio-net-device,netdev=net 
-netdev user,id=net,hostfwd=tcp::2222-:22 
-bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf 
-kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf 
-object rng-random,filename=/dev/urandom,id=rng 
-device virtio-rng-device,rng=rng 
-append "root=LABEL=rootfs console=ttyS0" 
-nographic

And this what was produced:

➜  Downloads qemu-system-riscv64 -machine virt -cpu rv64 -m 2G -device virtio-blk-device,drive=hd -drive file=ubunturv.img,format=raw,if=none,id=hd -device virtio-net-device,netdev=net -netdev user,id=net,hostfwd=tcp::2222-:22 -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf -object rng-random,filename=/dev/urandom,id=rng -device virtio-rng-device,rng=rng -append "root=LABEL=rootfs console=ttyS0 earlyprintk=serial,ttyS0,115200 debug" --nographic

OpenSBI v1.3
   ____                    _____ ____ _____
  / __                   / ____|  _ _   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_  / _  '_  ___ |  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  ____/| .__/ ___|_| |_|_____/|___/_____|
        | |
        |_|

Platform Name             : riscv-virtio,qemu
Platform Features         : medeleg
Platform HART Count       : 1
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 10000000Hz
Platform Console Device   : semihosting
Platform HSM Device       : ---
Platform PMU Device       : ---
Platform Reboot Device    : sifive_test
Platform Shutdown Device  : sifive_test
Platform Suspend Device   : ---
Platform CPPC Device      : ---
Firmware Base             : 0x80000000
Firmware Size             : 194 KB
Firmware RW Offset        : 0x20000
Firmware RW Size          : 66 KB
Firmware Heap Offset      : 0x28000
Firmware Heap Size        : 34 KB (total), 2 KB (reserved), 9 KB (used), 22 KB (free)
Firmware Scratch Size     : 4096 B (total), 760 B (used), 3336 B (free)
Runtime SBI Version       : 1.0

Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff M: (I,R,W) S/U: ()
Domain0 Region01          : 0x0000000080000000-0x000000008001ffff M: (R,X) S/U: ()
Domain0 Region02          : 0x0000000080020000-0x000000008003ffff M: (R,W) S/U: ()
Domain0 Region03          : 0x0000000000000000-0xffffffffffffffff M: (R,W,X) S/U: (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x0000000082200000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes
Domain0 SysSuspend        : yes

Boot HART ID              : 0
Boot HART Domain          : root
Boot HART Priv Version    : v1.10
Boot HART Base ISA        : rv64imafdc
Boot HART ISA Extensions  : time
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 0
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109


U-Boot 2022.01+dfsg-2ubuntu2.5 (Sep 18 2023 - 03:02:43 +0000)

CPU:   rv64imafdcsu
Model: riscv-virtio,qemu
DRAM:  2 GiB
Flash: 32 MiB
Loading Environment from nowhere... OK
In:    uart@10000000
Out:   uart@10000000
Err:   uart@10000000
Net:   eth0: virtio-net#1
Hit any key to stop autoboot:  0 

Device 0: QEMU VirtIO Block Device
            Type: Hard Disk
            Capacity: 25088.0 MB = 24.5 GB (51380224 x 512)
... is now current device
Scanning virtio 0:1...
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
Scanning disk virtio-blk#0...
Found 7 disks
** Unable to read file ubootefi.var **
Failed to load EFI variables
BootOrder not defined
EFI boot manager: Cannot load any image
Scanning virtio 0:f...
** Unable to read file / **
Failed to load '/'
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
BootOrder not defined
EFI boot manager: Cannot load any image
Found EFI removable media binary efi/boot/bootriscv64.efi
159744 bytes read in 1 ms (152.3 MiB/s)
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
Booting /efibootbootriscv64.efi
error: no suitable video mode found.

After this, a selection appeared and I choosed to boot with ubuntu, not with advanced options:


                                    GNU GRUB  version 2.12

 ┌──────────────────────────────────────────────────────────────────────────────────────────┐
 │*Ubuntu                                                                                   │ 
 │ Advanced options for Ubuntu                                                              │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │
 │                                                                                          │ 
 └──────────────────────────────────────────────────────────────────────────────────────────┘

      Use the ▲ and ▼ keys to select which entry is highlighted.                        
      Press enter to boot the selected OS, `e' to edit the commands before booting or   
      `c' for a command-line.                                                           

Then the boot process got stuck with these messages:

Loading Linux 6.8.0-31-generic ...
Loading initial ramdisk ...
Loading device tree blob...
EFI stub: Booting Linux Kernel...
EFI stub: EFI_RNG_PROTOCOL unavailable
EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
EFI stub: Using DTB from configuration table
EFI stub: Exiting boot services...

I kept waiting maybe I get a prompt or something but nothing happened for 10 minutes. I thought maybe I’m not supposed to get any prompt back and an ssh server is running, so I ran this command ssh ubuntu@localhost:2222 but it was unsuccessful.


How to reproduce:

The book states that you have to follow these instructions if you work a linux machine (ubuntu).

  1. Install QEMU with
    sudo apt install qemu-system-riscv64
    sudo apt install u-boot-qemu opensbi
  2. Download the Ubuntu Server preinstalled image
    from https://ubuntu.com/download/risc-v.
  3. From the downloaded Ubuntu image, extract the
    img file from the xz file with
    unxz < downloaded_file_name.img.xz > ubunturv.img
  4. Expand the image, so there is some disk space to
    play around with
    sudo qemu-img resize ubunturv.img +10G
  5. Now we are ready to run with the rather long qemu
    command:
qemu-system-riscv64 -machine virt -cpu rv64 -m 2G 
-device virtio-blk-device,drive=hd 
-drive file=ubunturv.img,if=none,id=hd 
-device virtio-net-device,netdev=net 
-netdev user,id=net,hostfwd=tcp::2222-:22 
-bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf 
-kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf 
-object rng-random,filename=/dev/urandom,id=rng 
-device virtio-rng-device,rng=rng 
-append "root=LABEL=rootfs console=ttyS0" 
-nographic

I really appreciate if you have any clue how to solve this issue.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật