Arch Linux Image for VisionFive 2

I have rebuilt the kernel from release v3.0.4 for cwt13 to include Btrfs and various other USB, network, and WiFi drivers. Additionally, it includes almost everything in the “Networking” section as I intend to use this board as a home server in the future. As such, I did not focus much on the GUI and GPU. However, I also built the JPU, VENC, and VDEC modules for this kernel.

I used the rootfs from https://riscv.mirror.pkgbuild.com/ to create my own initial image and subsequently updated all packages and installed NetworkManager, OpenSSH and other necessary components to make it ready for use.

Changelog for the cwt13 image:

  • The default hostname has been changed to ArchVF2 to distinguish it from the official image.
  • The kernel is built from the VF2_v3.0.4 tag, which includes the latest benefits and fixes from StarFive, and then update the kernel to version 5.15.2 plus some additional patches (The patches are in /home/user/VisionFive2/patches/).
  • The SPL and U-Boot were written (dd) into the first and second partitions on the SD image. Make sure to set the DIP switch to boot in SD mode.
  • The visionfive2-img-gpu driver from @trissylegs has been rebuilt with the new blob from StarFive, the clinfo and vulkaninfo commands has been installed too.

Here the links to download:

  • Google Drive: VisionFive2 - Google 云端硬盘

  • Naver MyBox: 네이버 MYBOX

  • Make sure you got the corrected sha256sum:

    • The xz compressed file: ArchLinux-VF2_5.15.2_v3.0.4-cwt13.img.xz
      c86bfc4b44fa294c741977c6fff83807e586e6036fd59c961e84311782625487
    • The raw image file: ArchLinux-VF2_5.15.2_v3.0.4-cwt13.img
      bf282027ae095f2053adcd1a23026bbb22d543980dc87d19554cf5071d0eafe0

Login and password:

root is locked
user password is user
user is sudoer, and it can run sudo without password.

Maximize the partition:
After flashing the image to an SD card of at least 4 GB, please edit partition 4 and expand it to the rest of the available space. Then use the following command to maximize the partition.

btrfs filesystem resize max /

The kernel source and other necessary components such as GPU drivers are already included in the /home/user/VisionFive2/ directory.

How to boot directly from NVMe:

  1. Make sure you understand everything I write here before running the commands on your board.
  2. Flash the new firmware:
    pacman -S mtd-utils
    flashcp -A -v /home/user/VisionFive2/firmware/u-boot-spl.bin.normal.out /dev/mtd0
    flashcp -A -v /home/user/VisionFive2/firmware/visionfive2_fw_payload.img /dev/mtd2
    
  3. Create the partitions layout the same as on the SD Image. However, I’m not certain about the need of first and second partitions, but I just set them accordingly and my board just booted successfully.
  • fdisk /dev/nvme0n1 and then set the NVMe partitions layout as below:
    • Disklabel type: gpt
    • Partitions:
      1. start: 4096 end: 8191 type: 2E54B353-1271-4842-806F-E436D6AF6985
      2. start: 8192 end: 16383 type: 5B193300-FC78-40CD-8002-E86C45580B47
      3. start: 16384 end: 221183 type: C12A7328-F81F-11D2-BA4B-00A0C93EC93B
      4. start: 221184 end: [the rest of it] type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
  1. Format the third and fourth partitions:
    • pacman -S dosfstools
    • mkfs.vfat -n EFI /dev/nvme0n1p3
    • mkfs.btrfs --checksum xxhash -L VF2_v3.0.4 /dev/nvme0n1p4
  2. Copy data and files to NVMe
    • dd if=/dev/mmcblk1p1 of=/dev/nvme0n1p1
    • dd if=/dev/mmcblk1p2 of=/dev/nvme0n1p2
    • mkdir /tmp/boot
      mount /dev/nvme0n1p3 /tmp/boot
      rsync -av /boot/ /tmp/boot/
      sed -i -e 's/mmcblk1/nvme0n1/g' -e 's/.minimal//gI' /tmp/boot/extlinux/extlinux.conf
      umount /tmp/boot
      
      mkdir /tmp/nvme
      mount -o compress=zstd /dev/nvme0n1p4 /tmp/nvme
      btrfs subvolume create /tmp/nvme/arch
      btrfs subvolume create /tmp/nvme/home
      
      mount /mnt
      rsync -av /mnt/arch-minimal/ /tmp/nvme/arch/
      rsync -av --exclude user/VisionFive2 /mnt/home/ /tmp/nvme/home/
      sed -i -e 's/mmcblk1/nvme0n1/g' -e 's/-minimal//g' /tmp/nvme/arch/etc/fstab
      umount /tmp/nvme
      
  3. Shutdown, set DIP switch to flash mode (0-0), remove the SD card, and then power on.
20 Likes

You’re a ROCK STAR!!!

2 Likes

That’s what I was waiting for ! Thanks. I will test it soon !

One comment:

It’s the sum for ArchLinux-VF2_515_v2.6.0-cwt4.img.bz2 and not for ArchLinux-VF2_515_v2.6.0-cwt4.img !

2 Likes

I was able to boot on it and log in via SSH but the output is blank (maybe because my device is a 2K one).
I ran some bench with crypsetup and openssl (thanks for 3.0.7 version) and I can say that it’s roughly half the figures I can find on my rpi4:

  • openssl
# openssl speed --multi $(nproc) rsa4096 2>&1 | tail -n 2 |  awk 'BEGIN {"openssl version"|  getline opensslversion; close("openssl version"); print opensslversion} { printf ("%s\t%s\n",$(NF-1),$NF) }'
OpenSSL 3.0.7 1 Nov 2022 (Library: OpenSSL 3.0.7 1 Nov 2022)
sign/s  verify/s
40.6    3004.4
  • cryptsetup
# cryptsetup benchmark
# Tests are approximate using memory only (no storage IO).
PBKDF2-sha1       133068 iterations per second for 256-bit key
PBKDF2-sha256     172010 iterations per second for 256-bit key
PBKDF2-sha512     146449 iterations per second for 256-bit key
PBKDF2-ripemd160  114774 iterations per second for 256-bit key
PBKDF2-whirlpool   44582 iterations per second for 256-bit key
argon2i       4 iterations, 235741 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)
argon2id      4 iterations, 237449 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)
#     Algorithm |       Key |      Encryption |      Decryption
        aes-cbc        128b        32.2 MiB/s        32.1 MiB/s
    serpent-cbc        128b        18.9 MiB/s        20.1 MiB/s
    twofish-cbc        128b        30.1 MiB/s        32.1 MiB/s
        aes-cbc        256b        32.1 MiB/s        32.1 MiB/s
    serpent-cbc        256b        19.7 MiB/s        20.1 MiB/s
    twofish-cbc        256b        30.4 MiB/s        32.1 MiB/s
        aes-xts        256b        28.2 MiB/s        29.0 MiB/s
    serpent-xts        256b        19.5 MiB/s        20.1 MiB/s
    twofish-xts        256b        31.0 MiB/s        32.0 MiB/s
        aes-xts        512b        29.0 MiB/s        29.0 MiB/s
    serpent-xts        512b        20.1 MiB/s        20.1 MiB/s
    twofish-xts        512b        31.9 MiB/s        32.1 MiB/s
  • And finally, the entropy is quite good:
#  cat /proc/sys/kernel/random/entropy_avail
3781
1 Like

One error:

# sudo pacman -Syyu
:: Synchronizing package databases...
 core.db failed to download
error: failed retrieving file 'core.db' from riscv.mirror.pkgbuild.com : SSL certificate problem: certificate is not yet valid
error: failed to synchronize all databases (download library error)

SSL certificate problem: certificate is not yet valid

The mirrorlist file was unchanged:

# grep -B 1 ^Server /etc/pacman.d/mirrorlist | head -n 2
## Worldwide
Server = https://riscv.mirror.pkgbuild.com/repo/$repo

Edit: solved by setting time

Its because time is not in sync. You need to set the right system time.

1 Like

Yes, thanks !

1 Like

Cool! Could you share your kernel config ?

To be fair none of those tests are using hardware acceleration from the Encrypt Engines, because openssl does not (yet).
And even once support is added, and patches pushed up stream, the Encrypt Engines will probably not help at all with ripemd160, whirlpool, serpent, twofish.

The kernel config is already in /boot/boot

Yes probably but I have a CPU comparaison now and I think that starfive RISC-V can really improve.

And also, I have an OS where I can install almost everything that I want and which is almost up-to-date (besides the kernel for now).

Are not the ones, that I need/wanted. I would be more focused on AES,chacha and blake2.
I know that when NEON instructions were included in the kernel crypto layer, we saw improvements on ARMv8. I hope it will be the same for RISC-V with hardware acceleration integration.

1 Like

Ah… the output is blank because I didn’t start the X or any DM. I didn’t do anything about it, from what I see on Debian image 69, they patched and build a lot of things in /usr/local my image is roughly an Arch origin.

I don’t even see any console/login prompt.

Because the GPU driver doesn’t support framebuffer yet.

yet

1 Like

2 changed files with 9 additions and 0 deletions .

small changes to see “things”…

I’m sure that there was lots of time spent gaining all the knowledge to know exactly what needed to be added and where. And head scratching and going “Why is this not working, this should be working”.

1 Like

May be I will try patching the kernel and rebuild it once I get back to office after my long weekend.

2 Likes

Indeed !
Sometimes, small changes make some great things: HUGE Improvements made to Linux Kernel Functions!! 8450% Increase - Open Source is Great. - YouTube

1 Like

It would be great ! But don’t worry we all can wait after your long week-end I think.
Do you plan to cross-compiling it ? (I think that manjaro-arm guys use cross compilation to save time)
If not it should take a looooooooooot of time, shouldn’t it ?