This builds a complete RISC-V cross-compile toolchain for the StarFiveTechJH7110 SoC. It also builds U-boot SPL, U-boot and a flattened image tree (FIT) image with a Opensbi binary, linux kernel, device tree, ramdisk image and rootfs image for the JH7110 VisionFive2 board.
This will take some time and require around 5GB of disk space. Some modules may fail because certain dependencies don’t have the best git hosting. The only solution is to wait and try again later (or ask someone for a copy of that source repository).
For user who build the release tag version, the above command is enough. For developer, need to switch the 5 submodules buildroot, u-boot, linux, opensbi, soft_3rdpart to correct branch manually, also could refer to .gitmodule
$ cd buildroot && git checkout --track origin/JH7110_VisionFive2_devel && cd ..
$ cd u-boot && git checkout --track origin/JH7110_VisionFive2_devel && cd ..
$ cd linux && git checkout --track origin/JH7110_VisionFive2_devel && cd ..
$ cd opensbi && git checkout master && cd ..
$ cd soft_3rdpart && git checkout JH7110_VisionFive2_devel && cd ..
Quick Build Instructions
Below are the quick building for the initramfs image image.fit which could be translated to board through tftp and run on board. The completed toolchain, u-boot-spl.bin.normal.out, visionfive2_fw_payload.img, image.fit will be generated under work/ directory. The completed build tree will consume about 16G of disk space.
$ make -j$(nproc)
Then the below target files will be generated, copy files to tftp server workspace path:
Additional command to config buildroot, uboot, linux, busybox:
$ make buildroot_initramfs-menuconfig # buildroot initramfs menuconfig
$ make buildroot_rootfs-menuconfig # buildroot rootfs menuconfig
$ make uboot-menuconfig # uboot menuconfig
$ make linux-menuconfig # Kernel menuconfig
$ make -C ./work/buildroot_initramfs/ O=./work/buildroot_initramfs busybox-menuconfig # for initramfs busybox menuconfig
$ make -C ./work/buildroot_rootfs/ O=./work/buildroot_rootfs busybox-menuconfig # for rootfs busybox menuconfig
Additional command to build single package or module:
$ make vmlinux # build linux kernel
$ make -C ./work/buildroot_rootfs/ O=./work/buildroot_rootfs busybox-rebuild # build busybox package
$ make -C ./work/buildroot_rootfs/ O=./work/buildroot_rootfs ffmpeg-rebuild # build ffmpeg package
Running on JH7110 VisionFive2 Board via Network
After the JH7110 VisionFive2 Board is properly connected to the serial port cable, network cable and power cord, turn on the power from the wall power socket to power and you will see the startup information as follows:
When you see the buildroot login: message, then congratulations, the launch was successful
buildroot login:root
Password: starfive
APPENDIX I: Generate Booting SD Card
If you don’t already use a local tftp server, then you probably want to make the TF card target; the default size is 16 GBs. NOTE THIS WILL DESTROY ALL EXISTING DATA on the target TF card; The GPT Partition Table for the TF card is recommended.
Generate SD Card Image File
We could generate a sdcard image file by the below command. The sdcard image file could be burned into sd card or tf card through dd command, or rpi-imager or balenaEtcher tool
$ make -j$(nproc)
$ make buildroot_rootfs -j$(nproc)
$ make img
The output file work/sdcard.img will be generated.
Burn Image File to SD Card
The sdcard.img can be burn into a tf card. e.g. through dd command as below
The second way could be done on VisionFive2 board, use fdisk and resize2fs command:
# fdisk /dev/mmcblk1
Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.
Command (m for help): d
Partition number (1-4, default 4): 4
Partition 4 has been deleted.
Command (m for help): n
Partition number (4-128, default 4): 4
First sector (614400-62333918, default 614400):
): t sector, +/-sectors or +/-size{K,M,G,T,P} (614400-62333918, default 62333918)
Created a new partition 4 of type 'Linux filesystem' and of size 29.4 GiB.
Partition #4 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: N
Command (m for help): w
The partition table has been altered.
Syncing disks.
# resize2fs /dev/mmcblk1p4
resize2fs 1.46.4 (18-Aug-2021)
Filesystem at /d[
111.756178] EXT4-fs (mmcblk1p4): resizing filesystem from 512000
to 30859756 blocks
ev/mmcblk1p4 is [
111.765203] EXT4-fs (mmcblk1p4): resizing filesystem from 512000
to 30859265 blocks
mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 118
[ 112.141953] random: crng init done
[ 112.145369] random: 7 urandom warning(s) missed due to ratelimiting
[ 115.474184] EXT4-fs (mmcblk1p4): resized filesystem to 30859265
The filesystem on /dev/mmcblk1p4 is now 30859756 (1k) blocks long.
If you need to add a new partition, such as a swap partition (here we do set the rest of disk space to swap partition,
but normally swap partition size should be the same as DDR size or double of DDR size),
you can use the following shell script afer the image running on board:
#!bin/sh
sgdisk -e /dev/mmcblk0
disk=/dev/mmcblk0
gdisk $disk << EOF
p
n
5
8200
p
c
5
hibernation
w
y
EOF
mkswap /dev/mmcblk0p5
swapoff -a
swapon /dev/mmcblk0p5
APPENDIX II: Using DTB Overlay Dynamically
The system support loading dtb overlay dynamically when the board is running. Run below on board:
# mount -t configfs none /sys/kernel/config
# mkdir -p /sys/kernel/config/device-tree/overlays/dtoverlay
# cd <the dtoverlay.dtbo path>
# cat vf2-overlay-uart3-i2c.dtbo > /sys/kernel/config/device-tree/overlays/dtoverlay/dtbo
The SPL and U-Boot are stored inside the SPI flash on board. There may be situations where you accidentally emptied the flash or if the flash is damaged on your board. In these situations, it’s better to recover the bootloader.
StarFiveTech VisionFive2 SDK
This builds a complete RISC-V cross-compile toolchain for the
StarFiveTech
JH7110
SoC. It also builds U-boot SPL, U-boot and a flattened image tree (FIT) image with a Opensbi binary, linux kernel, device tree, ramdisk image and rootfs image for theJH7110 VisionFive2
board.Prerequisites
Recommend OS: Ubuntu 16.04/18.04/20.04/22.04 x86_64
Install required additional packages:
Additional packages for Git LFS support:
Fetch Code Instructions
Checkout this repository (e.g.: branch
JH7110_VisionFive2_devel
). Then checkout all of the linked submodules using:This will take some time and require around 5GB of disk space. Some modules may fail because certain dependencies don’t have the best git hosting. The only solution is to wait and try again later (or ask someone for a copy of that source repository).
For user who build the release tag version, the above command is enough. For developer, need to switch the 5 submodules
buildroot
,u-boot
,linux
,opensbi
,soft_3rdpart
to correct branch manually, also could refer to.gitmodule
Quick Build Instructions
Below are the quick building for the initramfs image
image.fit
which could be translated to board through tftp and run on board. The completed toolchain,u-boot-spl.bin.normal.out
,visionfive2_fw_payload.img
,image.fit
will be generated underwork/
directory. The completed build tree will consume about 16G of disk space.Then the below target files will be generated, copy files to tftp server workspace path:
Additional command to config buildroot, uboot, linux, busybox:
Additional command to build single package or module:
Running on JH7110 VisionFive2 Board via Network
After the JH7110 VisionFive2 Board is properly connected to the serial port cable, network cable and power cord, turn on the power from the wall power socket to power and you will see the startup information as follows:
Then press any key to stop and enter uboot terminal, there are two way to boot the board
1. Running image.fit with the default dtb
jh7110-visionfive-v2.dtb
transfer image.fit through TFTP:
Step1: set enviroment parameter:
Step2: upload image file to ddr:
Step3: load and excute:
When you see the
buildroot login:
message, then congratulations, the launch was successful2. Running the other dtb with the Image.gz and initramfs.cpio.gz
If we want to loading the other dtb, e.g.
jh7110-visionfive-v2-wm8960.dtb
, follow the belowStep1: set enviroment parameter:
Step2: upload files to ddr:
Step3: load and excute:
When you see the
buildroot login:
message, then congratulations, the launch was successfulAPPENDIX I: Generate Booting SD Card
If you don’t already use a local tftp server, then you probably want to make the TF card target; the default size is 16 GBs. NOTE THIS WILL DESTROY ALL EXISTING DATA on the target TF card; The
GPT
Partition Table for the TF card is recommended.Generate SD Card Image File
We could generate a sdcard image file by the below command. The sdcard image file could be burned into sd card or tf card through
dd
command, orrpi-imager
orbalenaEtcher
toolThe output file
work/sdcard.img
will be generated.Burn Image File to SD Card
The
sdcard.img
can be burn into a tf card. e.g. throughdd
command as belowThen extend the tf card rootfs partition if needed. There are two ways to implement it.
The first way could be done on Ubuntu host, need to install the below package:
Then insert the tf card to Ubuntu host, run the below, note
/dev/sdX
is the tf card device.The second way could be done on VisionFive2 board, use fdisk and resize2fs command:
If you need to add a new partition, such as a swap partition (here we do set the rest of disk space to swap partition, but normally swap partition size should be the same as DDR size or double of DDR size), you can use the following shell script afer the image running on board:
APPENDIX II: Using DTB Overlay Dynamically
The system support loading dtb overlay dynamically when the board is running. Run below on board:
Additional, you could remove the dtbo feature:
APPENDIX III: Updating SPL and U-Boot binaries Under U-boot
Prepare the tftp sever. e.g.
sudo apt install tftpd-hpa
for Ubuntu host.Power on the VisionFive2 board and wait until enters the u-boot command line
Configure the environment variables by executing:
Check the connectivity by pinging the host PC from evaluation board;
Initialize SPI flash:
Update SPL binary
Update U-Boot binary
APPENDIX IV: Recovering Bootloader
The SPL and U-Boot are stored inside the SPI flash on board. There may be situations where you accidentally emptied the flash or if the flash is damaged on your board. In these situations, it’s better to recover the bootloader.
Please jump to https://github.com/starfive-tech/Tools for more details