Linux RISC-V 学习笔记

StartFive VisionFive V1开发版

OpenSBI 成为启动器的固件

linux 串口工具:minicom or cu

doas minicome -D /dev/ttyUSB0


debian/ubuntu/archlinux

base system

ubuntu:
sudo apt install debootstrap
sudo apt install debian-archive-keyring 
(下载debina上面的这些公钥,是用来验证要下载的base system里面的这些deb包是被签名过的,保证deb包的安全性不会被别人篡改)
sudo mkdir -p /mnt/base_system
sudo debootstrap bullseye /mnt/base_system/ https://mirror.sjtu.edu.cn/debian/

archlinux:
sudo yay -S debootstrap
sudo yay -S ubuntu-keyring debian-archive-keyring
sudo mkdir -p /mnt/base
sudo debootstrap bullseye /mnt/base/ https://mirror.sjtu.edu.cn/debian/

openSUSE:
sudo zypper in debootstrap
sudo mkdir -p /mnt/base
sudo debootstrap --arch=amd64 bullseye /mnt/base/ https://mirror.sjtu.edu.cn/debian/

利用容器,创建RISC-V Debian Base System Native Build环境,编译内核

kvm(可以将Linux内核转换成虚拟机的监控器)
和qemu(本质是一个托管的虚拟机镜像,通过二进制的转换模拟CPU提供一组设备的模型,能够运行多种未修改的客户机操作系统)
一般情况下qemu和kvm在Linux中是相互配合使用的
qemu的两个模式
  第一个是:system mode ,qemu它会模拟一个完整的计算机系统,包括外围的设备
  另一个是:kvm的hosting模式,这个模式下,qemu只是出来kvm镜像的设置和迁移,并且参与到了硬件的仿真,但是虚拟机的执行就由kvm来完成了。
  
  qemu/kvm下的虚拟机的运行的效率它接近于裸机的性能
  
  效率高 是用qemu的用户模式为我们构建RISC-V系统
  容器和
  native build (利用到了qemu的用户模式,binfmt-qemu-static和Shebang)
  
Debian:
sudo apt install debootstrap qemu-user-static binfmt-support debian-ports-archive-keyring systemd-contrainer -y
sudo debootstrap --arch=riscv64 --keyring /user/share/keyrings/debian-ports-archive-keyring.gpg --include=debian-ports-archive-keyring unstable /mnt/riscv http://deb.debian.org/debian-ports
//容器化 (在容器里面利用到了navtive build,qemu相当于一个中间环节,binfmt还有qemu的user静态)
sudo systemd-nspawn -D /mnt/riscv -M debian-riscv --bind-ro=/etc/resolve.conf

apt install neofetch htop

ArchLinux:
yay -S debootstrap gnupg debian-archive-keyring ubuntu-keyring binfmt-qemu-static qemu-user-static

ls -l /proc/sys/fs/binfmt_misc

wget http://ftp.cn.debian.org/debian/pool/main/d/debian-ports-archive-keyring/debian-ports-archive-keyring_2022.02.15_all.deb
ar -X debian-ports-archive-keyring_2022.02.15_all.deb
tar xpvf data.tar.xz
cp /usr/share/keyrings/debian-ports-archive-keyring.gpg /usr/share/keyrings/
lsblk
debootstrap --arch=riscv64 --keyring /usr/share/keyrings/debian-ports-archive-keyring.gpg --include=debian-ports-archive-keyring unstable /mnt/riscv http://deb.debian.org/debian-ports
sudo systemd-nspawn -D /mnt/riscv -M debian-riscv --bind-ro=/etc/resolve.conf

x86_64交叉编译RISC-V:
安装依赖:
apt install libncurses-dev libssl-dev bc flex bison gcc-riscv64-linux-gnu build-essential ccache cpio fakeroot flex git kmod libelf-dev libncurses5-dev libssl-dev lz4 qtbase5-dev rsync schedtool wget zstd pahole dwarves -y

RISC-V Native Build:
apt install libncurses-dev libssl-dev bc flex bison build-essential ccache cpio fakeroot flex git kmod libelf-dev libncurses5-dev libssl-dev lz4 qtbase5-dev rsync schedtool wget zstd dwarves neofetch -y

5.17的内核支持了

mkdir build
wget https://github.com/startfive-tech/linux/archive/xxx.tar.gz
tar -xpvf xxx.tar.gz
cd linux-5.17
cp arch/riscv/configs/startfive_jh7100_fedora_defconfig .config
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- menuconfig
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- -j40 bindeb-pkg LOCALVERSION=-starfive
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- -j40 bindeb-pkg LOCALVERSION=-starfive

cutefish 打包
apt install build-essential equivs devscripts --no-install-recommends

下载libcuefish from github

运行debuild 去查看依赖
安装依赖
debuild -j48

第六部分 搭建deb软件源服务器

dpkg安装

ubuntu的包仓库管理工具reprepro 现在已经支持zstd这个压缩模式了

sudo apt install reprepro apache2 -y

用符号连接链接我们的上海时区到我们的本地时间
sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
通过这个命令将我们的系统时间同步到我们的硬件时间上
sudo hwclock --systohc

安装ntpdate这个软件
sudo apt install ntpdate

同步为标准时间
sudo ntpdate -s time.nist.gov

生成公钥和私钥
gpg --gen-key

gpg: /root/.gnupg/trustdb.gpg:建立了信任度数据库
gpg: 密钥 7EAB5BD897284186 被标记为绝对信任
gpg: 目录‘/root/.gnupg/openpgp-revocs.d’已创建
gpg: 吊销证书已被存储为‘/root/.gnupg/openpgp-revocs.d/9022C3F44505E94C7675C4FA7EAB5BD897284186.rev’
公钥和私钥已经生成并被签名。

pub   rsa3072 2023-11-09 [SC] [有效至:2025-11-08]
      9022C3F44505E94C7675C4FA7EAB5BD897284186
uid                      alongyww <4149256@qq.com>
sub   rsa3072 2023-11-09 [E] [有效至:2025-11-08]

gpg --export --armor 97284186 > /var/www/html/riscv/gpg-public.key

利用reprepro来发布到我们的web服务器riscv目录下边
reprepro -b /var/www/html/riscv/ -C main includedeb unstable /home/weiy/*.deb

列出有哪些包
reprepro -b /var/www/html/riscv/ -C main list unstable

删除
reprepro -b /var/www/html/riscv/ -C main remove unstable xxx


能够买到的RISC-V的开发板有:
平头哥的哪吒的D1  (1000元) 性能等同于树莓派2
StartFive VisionFIve V1这两款 (1100元) 性能等同于树莓派2
Fedora,Ubuntu和Debian都可以在StartFive VisionFIve V1开发板上运行
ArchLinux和Gentoo更没有问题了
可以运行的桌面环境有lxqt和xfce ,但KDE和Gnome无法在Ubuntu和Debian上运行
还有SiFive以前发布的高端的板子
国内的像香山的板子 网上买不到

用ncnn做测试 人工智能运算的性能
ncnn是腾讯为收集端极致优化的高性能神经网络前向计算框架,是基于BSD协议进行开源的
它主力的开发者和维护者就是我们著名的@nihui大佬
StartFive VisionFIve V1里面没有矢量指令集

平头哥的哪吒D1的SoC也就是玄铁C906中加入了两个StartFive没有的扩展指令集
“V” 向量指令集 和 “U” 指令集
猜测应该是user mode的扩展了

D1也支持zfh指令集,从而能够实现arm中fp16的计算,这也是ncnn神经网络性能提升的直接原因
哪吒D1的定位是AIoT,即人工智能物联网
而目前的StarFive的探索的路线是通用计算

phoronix提供的两个跑分工具
openBenchmarking.org

Sudokut
perf-bench (linux里面的性能分析工具,是基于内核的一个子系统,提供性能分析的框架功能和软件,
             可以分析整个子系统,从应用程序到内核系统几乎所有的性能瓶颈

Epoll Wait
Futex在Linux中的调用是对进程竞争情况下的同步处理提供支持
Memset 1MB (吞吐量测试)
Sched Pipe 它主要测试不同的调度器的性能和公平性 (管道性能和公平性)
SysCall Basic:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值