Tag Archives: risc-v linux

Getting Started with StarFive VisionFive

I’ve been excited to get my hands on a StarFive VisionFive and it finally arrived last week after being on backorder since late March of 2022. Unlike the HiFive which runs OSes suitable for a microcontroller, the VisionFive will boot into a fully functional Fedora distribution with the Xfce desktop environment.

To get started with the VisionFive you’ll need

  • a microSD Card (at least 16GB, preferably a lot more)
  • USB-C Power Supply (like one used for a Raspberry Pi 4)
  • Keyboard and Mouse
  • Monitor
  • HDMI cable

If you’ve never booted up a BeagleBone or Raspberry Pi “from scratch”, head on over to the VisionFive Quick Start Guide for a gentler introduction.

The Fedora image for the VisionFive can be found on Github. For whatever reason the download of the image kept stalling in Safari, so I resorted to using curl:

curl https://fedora.starfivetech.com/pub/downloads/VisionFive-release/Fedora-riscv64-jh7100-developer-xfce-Rawhide-20211226-214100.n.0-sda.raw.zst -O

The image is compressed with Zstandard. Compressed it is around 3.5 gigabytes. Uncompressed it is around 13G. Once you’ve downloaded the file, go ahead and verify its integrity with sha256sum:

sha256sum Fedora-riscv64-jh7100-developer-xfce-Rawhide-20211226-214100.n.0-sda.raw.zst
94c73c967e12c80192d7bf25147badd9f0ee1738dc9800d1c502f376df5d5e2f  Fedora-riscv64-jh7100-developer-xfce-Rawhide-20211226-214100.n.0-sda.raw.zst

The checksum for the 20211226 image is 94c73c967e12c80192d7bf25147badd9f0ee1738dc9800d1c502f376df5d5e2f. Now, decompress it:

zstd -d Fedora-riscv64-jh7100-developer-xfce-Rawhide-20211226-214100.n.0-sda.raw.zst

On macOS we’ll use diskutil and dd to write the image. If the microSD is mounted after inserting it, unmount it with diskutil unmountDisk. On my machine the SD card is presented as disk4. Always verify where your disk is mounted before using dd!

/dev/disk4 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *16.0 GB    disk4
   1:             Windows_FAT_32 boot                    58.7 MB    disk4s1
   2:                      Linux                         16.0 GB    disk4s2

diskutil unmountDisk /dev/disk4

Now, let’s write the image to the disk. Take note here that we’re using /dev/rdisk4, i.e., the “raw” disk.

sudo time dd if=Fedora-riscv64-jh7100-developer-xfce-Rawhide-20211226-214100.n.0-sda.raw of=/dev/rdisk4 bs=1g

Once your disk is written insert it into the VisionFive and boot it up! I found that having all of the peripherals (keyboard, mouse, monitor, and Ethernet cable) is the best way to go. Be patient, this board is not as snappy as a Pi 4. But, in a few minutes you’ll be presented with a login screen. The default user is riscv and the password is starfive.

Setting Your Timezone

After booting Fedora I noticed the date was in the future. Typing date at the command line resulted in Mon Aug 22 04:52:18 AM CST 2022. Well, I’m in America/Chicago but why is that still ahead? Big dummy. CST in this context is Asia/Shanghai.

Easily fixed with:

timedatectl set-timezone "America/Chicago"

Resize Your Root Partition

After booting your VisionFive you might notice that the root partition is smaller than the actual microSD size. In this example we’re using a 16GB microSD, but the root partition is only 11.4G. We can fix that! Using these general instructions we can resize the root partition without rebooting.

[riscv@fedora-starfive ~]$ sudo fdisk -l
Disk /dev/mmcblk0: 14.92 GiB, 16022241280 bytes, 31293440 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xae0e1c91

Device         Boot   Start      End  Sectors  Size Id Type
/dev/mmcblk0p2        69632   319487   249856  122M  c W95 FAT32 (LBA)
/dev/mmcblk0p3 *     319488  1320959  1001472  489M 83 Linux
/dev/mmcblk0p4      1320960 25319423 23998464 11.4G 83 Linux
[riscv@fedora-starfive ~]$ sudo fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/mmcblk0: 14.92 GiB, 16022241280 bytes, 31293440 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xae0e1c91

Device         Boot   Start      End  Sectors  Size Id Type
/dev/mmcblk0p2        69632   319487   249856  122M  c W95 FAT32 (LBA)
/dev/mmcblk0p3 *     319488  1320959  1001472  489M 83 Linux
/dev/mmcblk0p4      1320960 25319423 23998464 11.4G 83 Linux

Command (m for help): d
Partition number (2-4, default 4): 4

Partition 4 has been deleted.

Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1,4, default 1): 4
First sector (2048-31293439, default 2048): 1320960
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1320960-31293439, default 31293439):

Created a new partition 4 of type 'Linux' and of size 14.3 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.

Now use resize2fs on /dev/mmcblk0p4:

[riscv@fedora-starfive ~]$ sudo resize2fs /dev/mmcblk0p4
resize2fs 1.45.6 (20-Mar-2020)
Filesystem at /dev/mmcblk0p4 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 2
The filesystem on /dev/mmcblk0p4 is now 3746560 (4k) blocks long.

Impressions

The StarFive VisionFive is really cool. While not exactly usable as a daily driver and a bit sluggish compared to the Raspberry Pi, it is a fully-functional desktop computer with a dual-core RISC-V chip on it. I continue to be excited about the future of RISC-V as an open alternative to x86 or ARM. Two years ago I was tinkering with RISC-V with the equivalent of an Arduino Duo. Today there are RISC-V-based SBCs running full-featured Linux. The Fedora distribution for the VisionFive has a lot of packages installed, including the gcc and g++ compilers, Perl, Python, Ruby, Lua, and even Go. Indeed, it is only a matter of time before one begins seeing other languages like NodeJS (we know, it’s not a language), Swift, Rust, and Racket. Exciting times!