https://rvspace.org/en/project/VisionFive2_Debian_User_Guide
不如官方做的,官方的带gpu
opensbi
sudo apt install gcc-riscv64-linux-gnu
git clone https://github.com/riscv-software-src/opensbi.git
cd opensbi/
make PLATFORM=generic FW_TEXT_START=0x40000000 FW_OPTIONS=0 CROSS_COMPILE=riscv64-linux-gnu- -j$(nproc)
uboot
sudo apt install swig
git clone https://github.com/u-boot/u-boot.git
cd u-boot/
configs/starfive_visionfive2_defconfig:
添加:
CONFIG_CMD_SYSBOOT=y
CONFIG_BOOTCOMMAND="sysboot mmc 1:3 any b0000000 /extlinux/extlinux.conf"
注释掉:
CONFIG_BOOTARGS # 不用这个,用 extlinux.conf 传递参数
make starfive_visionfive2_defconfig
make CROSS_COMPILE=riscv64-linux-gnu- OPENSBI=../opensbi/build/platform/generic/firmware/fw_dynamic.bin -j$(nproc)
linux
git clone https://github.com/starfive-tech/linux.git
cd linux/
git checkout JH7110_VisionFive2_upstream
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- starfive_visionfive2_defconfig
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- menuconfig
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- -j$(nproc)
给日志添加时间戳:
│ Symbol: PRINTK_TIME [=y] │
│ Type : bool │
│ Defined at lib/Kconfig.debug:6 │
│ Prompt: Show timing information on printks │
│ Depends on: PRINTK [=y] │
│ Location: │
│ -> Kernel hacking │
│ -> printk and dmesg options │
│ -> Show timing information on printks (PRINTK_TIME [=y])
rootfs
sudo apt install mmdebstrap qemu-user-static binfmt-support
mkdir rvrootfs
sudo mmdebstrap --architectures=riscv64 sid rvrootfs "deb http://mirrors.tuna.tsinghua.edu.cn/debian sid main"
# 建议在主硬盘上使用这个命令。如果 rvrootfs 文件夹在移动硬盘上使用 apt install 来预先安装软件有问题,需要在本地硬盘上操作。这和挂载属性有关,debootstrap 则直接不支持在移动硬盘上创建。这不会影响 rootfs 本身
sudo chroot rvrootfs
passwd # 给当前用户 root 设置密码,不然开发板上不能登录
apt update
apt install ca-certificates network-manager chrony
# https 需要 ca-certificates,nmcli 连 wifi 需要 network-manager,ntp 自动同步时间需要 chrony
nano /etc/apt/sources.list # 将 http 改为 https
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime # 设置时区
exit
dd if=/dev/zero of=rootfs.img bs=1G count=1
sudo mkfs.ext4 rootfs.img
mkdir rootfs_mount
sudo mount rootfs.img rootfs_mount
sudo cp -rfp rvrootfs/* rootfs_mount
sudo umount rootfs_mount
rm -r rootfs_mount
sudo fsck -f rootfs.img
sudo resize2fs -M rootfs.img # 调整镜像为实际大小
extlinux.conf
default hhh
label hhh
kernel /Image.gz
fdt /jh7110-starfive-visionfive-2-v1.3b.dtb
append root=/dev/mmcblk1p4 rw rootwait console=tty0 console=ttyS0,115200
下载到 sdcard
sudo sgdisk /dev/sdc -o \
--new=1:4096:8191 --change-name=1:spl --typecode=1:2E54B353-1271-4842-806F-E436D6AF6985 \
--new=2:8192:16383 --change-name=2:uboot --typecode=2:ea00 \
--new=3:16384:81919 --change-name=3:boot --typecode=3:ef00 \
--new=4:81920: --change-name=4:rootfs \
-p
# 分区大小分别为 2MiB、4MiB、32MiB、扩展到最后
sudo mkfs.vfat /dev/sdc3 # 分区后可能需要插拔一次才能格式化
sudo dd if=u-boot/spl/u-boot-spl.bin.normal.out of=/dev/sdc1 bs=4096
sudo dd if=u-boot/u-boot.itb of=/dev/sdc2 bs=4096
sudo dd if=rootfs.img of=/dev/sdc4 bs=4096
sync
sleep 1
sudo mount /dev/sdc3 /mnt/
sudo mkdir /mnt/extlinux
sudo cp extlinux.conf /mnt/extlinux/
sudo cp linux/arch/riscv/boot/Image.gz /mnt/
sudo cp linux/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2-v1.3b.dtb /mnt/
sync
sleep 1
sudo umount /mnt
重置分区大小:
如果 rootfs 分区被电脑自动挂载了需要先用 umount 卸载
sudo e2fsck -f /dev/sdc4
sudo resize2fs /dev/sdc4
power on…
使用root
用户登录
联网测试:
插上网线
ip addr # 查看各网卡信息。自带 iproute2,代替 ifconfig
ip link set end0 up # 启动 end0 网卡。最边上的那个网口
dhclient end0 # dhcp
date -s '2024-04-26 19:07:00' # 设置为实际时间,如果系统时间和实际时间误差过大就访问不了 apt update,apt install 可能还可以用
apt update # 测试网络是否正常
创建普通用户和 sudo:
apt install sudo
adduser hhh
...
usermod -aG sudo hhh
可选
鼠标和屏幕触摸等:
linux 里打开
│ Symbol: INPUT_EVDEV [=y] │
│ Type : tristate │
│ Defined at drivers/input/Kconfig:146 │
│ Prompt: Event interface │
│ Depends on: INPUT [=y] │
│ Location: │
│ -> Device Drivers │
│ -> Input device support │
│ -> Generic input layer (needed for keyboard, mouse, ...) (INPUT [=y]) │
│ -> Event interface (INPUT_EVDEV [=y])
ls -l /dev/input # 查看有没有 event…,若没有,i2c类可能是设备树不对或驱动没配置,usb 类打开这个还有 HID support 的 USB tran… layer
如果没有打开图形界面但连接了 usb 触摸、鼠标,会不停的刷断开重连的信息。比如可以 apt install weston (一个wayland 图形界面示例),执行 weston 就会打开一个图形界面,这样就不会一直刷了。weston 在没有输入 event 时打不开
其他工具:
lsusb:usbutils
lspci:pciutils
桌面:
我使用 hdmi,装完后重启,重启前把 hdmi 插上
xfec4
gnome:有些包含的软件 riscv 源里没有,装不了
xfce:
apt install xfce4 dbus-x11
自动登录:
nano /etc/lightdm/lightdm.conf
[Seat:*] # 找到这个
autologin-user=hhh # 修改这个为用户名,不需要密码就能登陆
禁止自动关闭屏幕:
/etc/X11/xorg.conf # 没有就创建此文件
Section "ServerFlags"
Option "BlankTime" "0"
Option "StandbyTime" "0"
Option "SuspendTime" "0"
Option "OffTime" "0"
EndSection
禁止各种自动休眠(做不到禁止自动关闭屏幕):
systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
修改之后可能要重启