Welcome to StarFive's VisionFive 2 - Debian Wiki!
Your VisionFive 2 will need an operating system to work.
Currently, StarFive provides a pre-built Debian image for users to flash into SD/eMMC cards.
Debian is an open-source GNU/Linux distribution created by the Debian community.
Debian Official WebPage: Debian
Linux Kernel: 5.15.0 (StarFive kernel tag v2.6.0)
U-boot: StarFive uboot tag v2.10.4
Debian Snapshot date: 20221225T084846Z (sid)
Link for Image Download: VisionFive v2 Debian
As of February 2023, the latest release is the 202302 Release, which can be found in
Engineering Release/202302 in the link above.
There are 2 different images available for VisionFive v2 to support different boot modes, which include:
VisionFive v2 provides pins to determine the boot mode before it is powered up. The following are the available boot modes and details.
Current method of flashing is to flash the image through Linux
Boot to Debian using SD image and download the eMMC image.
Using dd method to flash to the eMMC partition
dd if=starfive-jh7110-202302-eMMC-minimal-desktop.img of=/dev/mmcblk0 bs=4096 status=progress
To copy existing files from sd card partition, we can use dd method as well, once flashed, we would need to change the fstab to point to emmc partition.
dd if=/dev/mmcblk1p4 of=/dev/mmcblk0p4 bs=4096 status=progress
edit fstab file
Change to below
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # systemd generates mount units based on this file, see systemd.mount(5). # Please run 'systemctl daemon-reload' after making changes here. # # <file system> <mount point> <type> <options> <dump> <pass> /dev/mmcblk0p3 /boot vfat defaults 0 2 /dev/mmcblk0p4 / ext4 errors=remount-ro 0 1
The minimal image is a clean image with minimal package installation for having a small image size. Hence, you will need to download the packages with
Some packages particular are not available to download via apt/apt-get, and is provided by StarFive, which includes:
Debian Repo for StarFive Packages: Github Link
There is a script prepared so that you can install the packages (and its runtime dependencies) with the run of a script. You will just need to run:
wget https://github.com/starfive-tech/Debian/releases/download/v0.7.0-engineering-release/install_package_and_dependencies.sh chmod +x install_package_and_dependencies.sh ./install_package_and_dependencies.sh
This script will help to install the packages provided by StarFive. Feel free to customize the script to suit your needs.
When you initially boot into the image, the rootfs partition will not be fully utilized. Hence, you will need to extend the partition size.
You can use terminal tools such as ‘fdisk’ and ‘resize2fs’ commands to resize the rootfs partition.
Please refer to this document: Extending Partition
Refer to Quick start Guide for updating u-boot
Install dependencies to build kernel
apt-get install build-essential linux-source bc kmod cpio flex libncurses5-dev libelf-dev libssl-dev dwarves bison git
Clone the kernel from StarFive Github
git clone https://github.com/starfive-tech/linux
Checkout the desired kernel version
git checkout <tag version>
Before building, we need to add in a patch that fixes build with newer binutils, save the below patch to patchfile and apply the patch.
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index 0eb4568fbd29..c18d87212177 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -52,6 +52,12 @@ riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima riscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c + +# Newer binutils versions default to ISA spec version 20191213 which moves some +# instructions from the I extension to the Zicsr and Zifencei extensions. +toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(riscv-march-y)_zicsr_zifencei) +riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei + KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y)) KBUILD_AFLAGS += -march=$(riscv-march-y)
once applied the above patch, we can continue to proceed building the kernel
Build the kernel with bindeb-pkg
cd linux/ cp arch/riscv/configs/starfive_visionfive2_defconfig .config make ARCH=riscv olddefconfig make ARCH=riscv -j$(nproc) bindeb-pkg
Once the compile is finished, install the .deb kernel packages
dpkg -i *.deb
Note: currently the dtbs are not synced once you installed a different version of kernel, you'll need to copy over the dtbs from /usr/lib/linux-image-<custom version>/ to /boot/dtbs/
Please refer the above section for how to compile the kernel
To enable the trng module in visionfive2, apply this below patch when building the kernel
diff --git a/arch/riscv/configs/starfive_visionfive2_defconfig b/arch/riscv/configs/starfive_visionfive2_defconfig index c545421012d4..0cf0c483ac0b 100755 --- a/arch/riscv/configs/starfive_visionfive2_defconfig +++ b/arch/riscv/configs/starfive_visionfive2_defconfig @@ -172,7 +172,7 @@ CONFIG_HVC_RISCV_SBI=y CONFIG_TTY_PRINTK=y CONFIG_VIRTIO_CONSOLE=y CONFIG_HW_RANDOM=y -CONFIG_HW_RANDOM_VIRTIO=y +CONFIG_HW_RANDOM_STARFIVE=y CONFIG_I2C_CHARDEV=y CONFIG_I2C_DESIGNWARE_PLATFORM=y CONFIG_SPI=y
Note: this would be turn on by default on the next release
Please refer to JH7110 Technical Documents for your reference
To be updated