我是靠谱客的博主 成就小蜜蜂,最近开发中收集的这篇文章主要介绍risc-v-debian-qemu一、通过下载镜像实现引导二、自定义镜像实现引导,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Linux debian 5.17.0-3 64-bit RISC-V released for QEMU
使用两种方法来测试
一、通过下载镜像实现引导
二、自定义镜像实现引导

一、通过下载镜像实现引导

doc

https://colatkinson.site/linux/riscv/2021/01/27/riscv-qemu
https://wiki.ubuntu.com/RISC-V

download

https://gitlab.com/api/v4/projects/giomasce%2Fdqib/jobs/artifacts/master/download?job=convert_riscv64-virt
#unzip img file

install software

sudo apt install qemu-system-misc opensbi u-boot-qemu qemu-utils

booting with qemu run1

qemu-system-riscv64 
-machine virt 
-cpu rv64 
-m 1G 
-device virtio-blk-device,drive=hd 
-drive file=image.qcow2,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_dynamic.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

booting with qemu run2

qemu-system-riscv64 
-machine virt 
-cpu rv64 
-m 1G 
-device virtio-blk-device,drive=hd 
-drive file=image.qcow2,if=none,id=hd 
-device virtio-net-device,netdev=net 
-netdev user,id=net,hostfwd=tcp::2222-:22 
-initrd initrd 
-kernel kernel 
-object rng-random,filename=/dev/urandom,id=rng 
-device virtio-rng-device,rng=rng 
-append "root=LABEL=rootfs  console=ttyS0" 
-nographic

login

username:root
password:root
OpenSBI v1.0
   ____                    _____ ____ _____
  / __                   / ____|  _ _   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_  / _  '_  ___ |  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  ____/| .__/ ___|_| |_|_____/|____/_____|
        | |
        |_|

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   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base             : 0x80000000
Firmware Size             : 252 KB
Runtime SBI Version       : 0.3
[  OK  ] Finished Permit User Sessions.
[  OK  ] Started Getty on tty1.
[  OK  ] Started Getty on tty2.
[  OK  ] Started Getty on tty3.
[  OK  ] Started Getty on tty4.
[  OK  ] Started Getty on tty5.
[  OK  ] Started Getty on tty6.
[  OK  ] Started Serial Getty on ttyS0.
[  OK  ] Reached target Login Prompts.
[  OK  ] Started OpenBSD Secure Shell server.
[  OK  ] Finished Remove Stale Onli…ext4 Metadata Check Snapshots.
[  OK  ] Reached target Multi-User System.
[  OK  ] Reached target Graphical Interface.
         Starting Record Runlevel Change in UTMP...
[  OK  ] Finished Record Runlevel Change in UTMP.

Debian GNU/Linux bookworm/sid debian ttyS0

debian login: root
Password: 
Linux debian 5.17.0-3-riscv64 #1 SMP Debian 5.17.11-1 (2022-05-26) riscv64

二、自定义镜像实现引导

文档

https://wiki.debian.org/InstallingDebianOn/SiFive/HiFiveUnleashed
https://wiki.debian.org/RISC-V#Creating_a_riscv64_chroot
https://www.ports.debian.org/archive

安装组件

sudo apt install mmdebstrap qemu-user-static binfmt-support debian-ports-archive-keyring

添加key

wget -O - https://www.ports.debian.org/archive_2022.key | sudo apt-key add -

开始制作

sudo mkdir /mnt/debian
#下面任选一个
#这个速度有点慢
sudo mmdebstrap --architectures=riscv64 --include="debian-ports-archive-keyring" sid /mnt/temp/debian "deb http://deb.debian.org/debian-ports sid main" "deb http://deb.debian.org/debian-ports unreleased main"
#这两个速度快
sudo mmdebstrap --arch riscv64 jammy /mnt/debian https://mirrors.ustc.edu.cn/ubuntu-ports
sudo mmdebstrap --arch riscv64 kinetic /mnt/debian https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports

更新组件

sudo cp /usr/bin/qemu-arm-static /mnt/debian/usr/bin/
sudo chroot /mnt/debian
echo "debian-riscv64" >/etc/hostname
echo "127.0.0.1 localhost" >/etc/hosts
echo "127.0.0.1 debian-riscv64" >/etc/hosts
echo "nameserver 8.8.8.8" >/etc/resolv.conf
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
apt update
passwd root
useradd test
exit

制作镜像

sudo mkdir /mnt/temp
sudo dd if=/dev/zero of=~/debian.img bs=1 count=0 seek=4096M
sudo mkfs.ext4  ~/debian.img
sudo mount ~/debian.img /mnt/temp
sudo cp -ar /mnt/debian/* /mnt/temp/
sudo umount /mnt/temp

引导启动

#Image为手动编译的kernel
sudo qemu-system-riscv64 
-machine virt 
-cpu rv64 
-m 1G 
-device virtio-blk-device,drive=hd -drive file=~/debian.img,if=none,id=hd 
-netdev bridge,id=net0,br=virbr0 
-device virtio-net-device,netdev=net0,mac=12:22:33:44:55:66 
-kernel Image 
-display sdl,gl=on 
-device virtio-gpu-pci 
-device qemu-xhci,id=xhci 
-device usb-kbd 
-device usb-tablet 
-object rng-random,filename=/dev/urandom,id=rng 
-device virtio-rng-device,rng=rng 
-append "root=/dev/vda  console=ttyS0 rw ip=dhcp " -nographic

引导界面

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



Welcome to Debian GNU/Linux bookworm/sid!

Debian GNU/Linux bookworm/sid debian-arm ttyS0

debian-arm login: 

root@debian-arm:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.110  netmask 255.255.255.0  broadcast 192.168.122.255
        inet6 fe80::1022:33ff:fe44:5566  prefixlen 64  scopeid 0x2## 0<link>
        ether 12:22:33:44:55:66  txqueuelen 1000  (Ethernet)

图形测试

#安装桌面
apt install vim wget net-tools gnome-shell gdm3
systemctl enable gdm.service
systemctl set-default graphical.target
#测试weston
apt install weston
mkdir ~/weston
export XDG_RUNTIME_DIR=~/weston 
weston --tty=2 --backend=drm-backend.so --config=/root/weston/weston.ini --use-pixman

最后

以上就是成就小蜜蜂为你收集整理的risc-v-debian-qemu一、通过下载镜像实现引导二、自定义镜像实现引导的全部内容,希望文章能够帮你解决risc-v-debian-qemu一、通过下载镜像实现引导二、自定义镜像实现引导所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部