Arch Linux Image for VisionFive 2

Starfive is porting SDK to 6.1kernel with downstream driver. I think we could replace them with upstream stuff?
Besides, upstream u-boot is completely usable now (CMA might not be handled since upstream kernel doesn’t have that)

1 Like

I’m running the kernel from the StarFive 6.1 branch on one of my VF2, but it has one major problem: it often fails or is very slow to reboot, which makes the board go offline for too long if I try to reboot it remotely. This refrains me from publishing the new kernel package.

Edit: I just see that there is a new tag for 6.1: VF2_6.1_v3.7.5. I’m building it and will test this one.

3 Likes

Hmm… not sure that it gonna help the reboot problem, but at least they ported the Eswin USB WiFi driver to 6.1 and also fix compatibility problem with WD NVMe SSD.

https://github.com/starfive-tech/linux/compare/VF2_6.1_v3.7.1...VF2_6.1_v3.7.5.diff

$ cat VF2_6.1_v3.7.1...VF2_6.1_v3.7.5.patch |grep "^Subject:"
Subject: [PATCH 1/8] driver: pci: Update reset timing as the requirement in
Subject: [PATCH 2/8] riscv: drm: panel: update radxa panel startup process and
Subject: [PATCH 3/8] net: wireless: eswin: proting esiwn wifi driver
Subject: [PATCH 4/8] net: wireless: eswin: update eswin wifi driver for kernel
Subject: [PATCH 5/8] display : hdmi: fix hotplug hang
Subject: [PATCH 6/8] uart: 8250: add reset operation in runtime PM
Subject: [PATCH 7/8] Mosaic cursor: Revert commit
Subject: [PATCH 8/8] Enlarge flush cache size to avoid flick on
2 Likes

thanks, boots from usb
with my new u-boot changes
and that is OpenBSD installed on the nvme :wink:

ArchVF2 login: root
Password:
[root@ArchVF2 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 1 28.7G 0 disk
├─sda1 8:1 1 2M 0 part
├─sda2 8:2 1 4M 0 part
├─sda3 8:3 1 100M 0 part /boot
└─sda4 8:4 1 2.1G 0 part /var/cache/pacman/pkg
/var/log
/home
/.snapshots
/
mtdblock0 31:0 0 512K 0 disk
mtdblock1 31:1 0 4M 0 disk
mtdblock2 31:2 0 64K 0 disk
mtdblock3 31:3 0 10M 0 disk
zram0 254:0 0 1.9G 0 disk [SWAP]
nvme0n1 259:0 0 238.5G 0 disk
├─nvme0n1p1 259:1 0 16M 0 part
└─nvme0n1p4 259:2 0 238.4G 0 part

Could you share the config file you used to build your kernel?

Read it from the system ?

Or else https://github.com/cwt/pkgbuild-linux-cwt-starfive-visionfive2/blob/5.15/config

And a third option might be to use the extract-ikconfig script on a kernel image:
https://github.com/torvalds/linux/blob/master/scripts/extract-ikconfig

I do know where I can get the original config file. I asking, because the standard config file does not include the amdgpu driver, and I’m not sure if it’s just “enable the amdgpu driver”, or if other config settings need to be changed aswell.

Sorry. I just saw this.

config (187.7 KB)

I primarily used this as reference.

You will need to change it to use the compressed firmware in the firmware folder. I was using the uncompressed firmware. You can use the below link to figure out what firmware you need.

https://wiki.gentoo.org/wiki/AMDGPU#Known_firmware_blobs

I have a strange bootloop. I wrote the latest image from github Release cwt17 · cwt/Arch-VF2-Image · GitHub to the TF card and the DIP switch is set to SDIO mode with rgpio_1 low and rgpio_0 high. I get this message on the UART:

U-Boot SPL 2021.10 (Sep 26 2023 - 22:53:52 +0800)
LPDDR4: 8G version: g8ad50857.
Trying to boot from MMC2

OpenSBI v1.2
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|___/_____|
        | |
        |_|

Platform Name             : StarFive VisionFive V2
Platform Features         : medeleg
Platform HART Count       : 5
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 4000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform PMU Device       : ---
Platform Reboot Device    : pm-reset
Platform Shutdown Device  : pm-reset
Platform Suspend Device   : ---
Firmware Base             : 0x40000000
Firmware Size             : 392 KB
Firmware RW Offset        : 0x40000
Runtime SBI Version       : 1.0

Domain0 Name              : root
Domain0 Boot HART         : 1
Domain0 HARTs             : 0*,1*,2*,3*,4*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff M: (I,R,W) S/U: ()
Domain0 Region01          : 0x0000000040000000-0x000000004003ffff M: (R,X) S/U: ()
Domain0 Region02          : 0x0000000040040000-0x000000004007ffff M: (R,W) S/U: ()
Domain0 Region03          : 0x0000000000000000-0xffffffffffffffff M: (R,W,X) S/U: (R,W,X)
Domain0 Next Address      : 0x0000000040200000
Domain0 Next Arg1         : 0x0000000042200000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes
Domain0 SysSuspend        : yes

Boot HART ID              : 1
Boot HART Domain          : root
Boot HART Priv Version    : v1.11
Boot HART Base ISA        : rv64imafdcbx
Boot HART ISA Extensions  : none
Boot HART PMP Count       : 8
Boot HART PMP Granularity : 4096
Boot HART PMP Address Bits: 34
Boot HART MHPM Count      : 2
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109


U-Boot 2021.10 (Sep 26 2023 - 22:53:52 +0800), Build: jenkins-github_visionfive2-18

CPU:   rv64imacu_zba_zbb
Model: StarFive VisionFive V2
DRAM:  8 GiB
MMC:   sdio0@16010000: 0, sdio1@16020000: 1
Loading Environment from SPIFlash... SF: Detected gd25lq128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
*** Warning - bad CRC, using default environment

StarFive EEPROM format v2

--------EEPROM INFO--------
Vendor : StarFive Technology Co., Ltd.
Product full SN: VF7110B1-2253-D008E000-00006943
data version: 0x2
PCB revision: 0xb2
BOM revision: A
Ethernet MAC0 address: 6c:cf:39:00:69:3a
Ethernet MAC1 address: 6c:cf:39:00:69:3d
--------EEPROM INFO--------

In:    serial
Out:   serial
Err:   serial
Model: StarFive VisionFive V2
Net:   eth0: ethernet@16030000, eth1: ethernet@16040000
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc1 is current device
Try booting from MMC1 ...
Failed to load 'vf2_uEnv.txt'
## Info: input data size = 482 = 0x1E2
## Error: "boot2" not defined
Tring booting distro ...
switch to partitions #0, OK
mmc1 is current device
Try booting from MMC1 ...
406 bytes read in 6 ms (65.4 KiB/s)
## Warning: defaulting to text format
52402 bytes read in 11 ms (4.5 MiB/s)
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
52402 bytes written in 11 ms (4.5 MiB/s)
Retrieving file: /extlinux/extlinux.conf
520 bytes read in 8 ms (63.5 KiB/s)
1:	Arch Linux
Retrieving file: /initramfs-linux.img
7804480 bytes read in 343 ms (21.7 MiB/s)
Retrieving file: /vmlinuz
10765880 bytes read in 471 ms (21.8 MiB/s)
append: root="LABEL=VF2" rw console=tty1 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0 rootflags=defaults,discard=async,compress=lzo,user_subvol_rm_allowed,subvol=@
Retrieving file: /dtbs/starfive/jh7110-visionfive-v2.dtb
52402 bytes read in 11 ms (4.5 MiB/s)
   Uncompressing Kernel Image
Moving Image from 0x44000000 to 0x40200000, end=41efd000
## Flattened Device Tree blob at 48000000
   Booting using the fdt blob at 0x48000000
   Using Device Tree in place at 0000000048000000, end 000000004800fcb1

Starting kernel ...

clk u2_dw_i2c_clk_core already disabled
clk u2_dw_i2c_clk_apb already disabled
clk u5_dw_i2c_clk_core already disabled
clk u5_dw_i2c_clk_apb already disabled
[    0.591609] L2CACHE: DataError @ 0x00000000.08040270
[    0.597099] L2CACHE: DataFail @ 0x00000000.08040140
[    1.431411] jh7110-sec 16000000.crypto: Unable to request sec_m dma channel in DMA channel
[    1.440576] jh7110-sec 16000000.crypto: Cannot initial dma chan
[    1.561345] debugfs: Directory '16008000.sec_dma' with parent 'dmaengine' already present!
[    1.573982] seeed_panel 2-0045: Unknown Atmel firmware revision: 0x00
[    1.613623] imx219 6-0010: failed to read chip id 219
[    1.621005] ov4689 6-0036: ov4689_read_reg: error: reg=300a
[    1.627216] ov4689 6-0036: ov4689_check_chip_id: failed to read chip identifier
[    2.034227] usb usb2-port1: over-current condition
[    2.177129] mailbox_test mailbox_client: invalid resource
[    2.182598] mailbox_test mailbox_client: invalid resource
[    2.188692] starfive-i2s 120b0000.i2stx_4ch0: designware: i2s master mode supported
[    2.197027] cdns-dsi 295d0000.mipi: starfive dsi bind end
:: running early hook [udev]
Starting systemd-udevd version 254.4-1-arch
:: running hook [udev]
:: Triggering uevents...

And at this point it seems to crash and loops back to the start with OpenSBI.

Anything I can try?

Turns out it was a power quality issue. My USB-to-serial adapter couldn’t supply enough power for that stage in the boot process. Switching to USB-C power fixed the issue.

2 Likes

For anyone that has weird color with the built-in HDMI output, I have appeared to fix it with this Xorg configuration file. Here it is running xfce4 with the correct blue mouse color.
gist

3 Likes

I just uploaded the new cwt18 image to GitHub.

You should upgrade the onboard firmware (SPL and U-boot) to the latest version first.
Make sure you are going to write the firmware to the right MTD partition.

$ cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00001000 "spl"
mtd1: 00400000 00001000 "uboot"
mtd2: 00010000 00001000 "uboot-env"
mtd3: 00a00000 00001000 "reserved-data"

In this case, spl is mtd0, and uboot is mtd1. Please note that in the latest StarFive kernel, the MTD partitions have been rearranged so that uboot is now on mtd2. Therefore, it’s important to always check with cat /proc/mtd.

$ mkdir fw && cd fw
$ wget https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v3.8.2/u-boot-spl.bin.normal.out
$ wget https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v3.8.2/visionfive2_fw_payload.img
$ sudo flashcp -v u-boot-spl.bin.normal.out /dev/mtd0
$ sudo flashcp -v visionfive2_fw_payload.img /dev/mtd1

You can download the Kernel and GPU packages and then update the previous cwt image efortlessly.

$ mkdir cwt18 && cd cwt18
$ wget https://github.com/cwt/pkgbuild-linux-cwt-starfive-visionfive2/releases/download/cwt18-3.8.2-1/linux-cwt-515-starfive-visionfive2-18.3.8.2-1-riscv64.pkg.tar.zst
$ wget https://github.com/cwt/pkgbuild-linux-cwt-starfive-visionfive2/releases/download/cwt18-3.8.2-1/linux-cwt-515-starfive-visionfive2-headers-18.3.8.2-1-riscv64.pkg.tar.zst
$ wget https://github.com/cwt/pkgbuild-linux-cwt-starfive-visionfive2/releases/download/cwt18-3.8.2-1/linux-cwt-515-starfive-visionfive2-soft_3rdpart-18.3.8.2-1-riscv64.pkg.tar.zst
$ wget https://github.com/cwt/aur-visionfive2-img-gpu/releases/download/cwt18-1.19.6345021-4/visionfive2-img-gpu-1.19.6345021-4-riscv64.pkg.tar.zst
$ sudo pacman -U *.tar.zst
$ sudo reboot
3 Likes

Great, thank you!

What if one has a dual boot setup, having Arch and Debian on two different NVME-Partitions, sharing the same Partitions for Booting (nvme0n1p{1-3})?
What is the path to update debian and arch with the same partition order then?
I have not seen a possible package upgrade for the debian part at all!?

The debian image is really a “developer” image and not suitable for any long term desktop or server use. Its based on a debian snapshot release and the custom packaging conflicts with base packages, specifically mesa. Upgrading between releases isn’t really “supported” either.

2 Likes

Well…so I’ll download the image, copy the new debian kernel to boot partition, apply extlinux.conf changes, boot back to arch, update firmware an install cwt’s new Archlinux kernel packages and off I go.

When I do the steps in the PKGBUILD for the kernel manually, patching the kernel source fails when patching linux-6-fix_qspi_partitions_according_to_datasheet.patch
(doing this line: https://github.com/cwt-vf2/aur-linux-cwt-starfive-vf2/blob/c340d37938147a2a9c87d4f955e4c589db6fcb84/PKGBUILD#L67). How do I prevent this error? And if that error is irrelevant, why is the patch still being applied?

1 Like

The linux-6 patch is no longer needed, it was removed from PKGBUILD.

Unfortunately I forgot to removed it from git, makepkg will not use any file that wasn’t specified in the source variable.

Ah ok thanks for clearing this up.

1 Like

cwt19 is released :sunglasses: Release cwt19 · cwt-vf2/archlinux-image-vf2 · GitHub

3 Likes

I forgot to add udev rules for Mutter to the img-gpu package. Please update it to release 6 if you intend to run the GNOME desktop.

$ wget https://github.com/cwt-vf2/img-gpu-vf2/releases/download/cwt19-1.19.6345021-6/img-gpu-vf2-1.19.6345021-6-riscv64.pkg.tar.zst
$ sudo pacman -U img-gpu-vf2-1.19.6345021-6-riscv64.pkg.tar.zst