Experimental Gentoo Image

Here is a link to my latest Image which includes the v2.10.4 Firmware on the SD Image
https://drive.google.com/file/d/10TDsk2FwZDJv3yJvDAfCam5Wf9ibS6Eg/view?usp=sharing

Install using dd or Balana Etcher after uncompressing the file EG

sudo dd if=gentoo.img of=/dev/mmcblk0 bs=1024

Modify the SD Card for expand the last partition to use the rest of the SD Card.

sudo growpart /dev/mmcblk0 4
sudo e2fsck -f /dev/mmcblk0p4
sudo resize2fs /dev/mmcblk0p4
sudo fsck.ext4 /dev/mmcblk0p4

Set the DIP Switches on the board to boot from the SD Card

Boot the device and connect using either the serial port or using ssh
Log on as root

Set a root password.

passwd root

Update /etc/portage/make.conf with CPU Info etc

Refer to https://wiki.gentoo.org/wiki/Safe_CFLAGS The section on RISC-V

Add a normal User and set the Password.

useradd -m -G users,wheel,audio -s /bin/bash user
passwd user

Do an Initial Sync of the Device and select a Profile.

emaint -a sync

eselect profile list
eselect profile set 8

Select the Kernel

eselect kernel list
eselect kernel set 1

Follow the standard Gentoo Documents.

If you want to build a custom Kernel follow the steps below

emerge --ask –verbose sys-kernel/dracut

mkdir -p /usr/src/compiled-kernel
cd /usr/src/linux
make menuconfig
time make -j4


make  INSTALL_PATH=/usr/src/compiled-kernel/ zinstall -j4

make modules_install

mkdir /boot/dtbs/new
mkdir /boot/dtbs/new/starfive
cp arch/riscv/boot/dts/starfive/jh7110-visionfive-v2*.dtb /boot/dtbs/new/starfive/
cp -r arch/riscv/boot/dts/starfive/vf2-overlay /boot/dtbs/new/starfive/
cp /usr/src/compiled-kernel/vmlinuz-5.15.0-starfive-dirty /boot/vmlinuz-5.15.0-starfive-dirty
cp /usr/src/compiled-kernel/System.map-5.15.0-starfive-dirty /boot/System.map-5.15.0-starfive-dirty
cp /usr/src/compiled-kernel/config-5.15.0-starfive-dirty /boot/config-5.15.0-starfive-dirty

dracut /boot/initrd.img-5.15.0-starfive-dirty  --force

edit /boot/extlinux/extlinux.conf so that it looks like this

## /extlinux/extlinux.conf
##
## IMPORTANT WARNING
##
## The configuration of this file is generated automatically.
## Do not edit this file manually, use: u-boot-update

default l1
menu title U-Boot menu
prompt 0
timeout 50


label l0
        menu label Debian GNU/Linux bookworm/sid 5.15.0-starfive
        linux /vmlinuz-5.15.0-starfive
        initrd /initrd.img-5.15.0-starfive


        fdtdir /dtbs
        append  root=/dev/mmcblk1p4 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0

label l0r
        menu label Debian GNU/Linux bookworm/sid 5.15.0-starfive (rescue target)
        linux /vmlinuz-5.15.0-starfive
        initrd /initrd.img-5.15.0-starfive

        fdtdir /dtbs
        append  root=/dev/mmcblk1p4 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0 single


label l1
        menu label Gentoo GNU/Linux 5.15.0-starfive-dirty
        linux /vmlinuz-5.15.0-starfive-dirty
        initrd /initrd.img-5.15.0-starfive-dirty

        fdtdir /dtbs/new
        append  root=/dev/mmcblk1p4 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0

Reboot and test

If you build your own kernel and it only shows half your ram when you reboot you need to apply the fix mentioned in this thread Device trees limit Linux to 4GB of RAM on 8GB devices · Issue #20 · starfive-tech/VisionFive2 · GitHub
by Updating the Memory settings in arch/riscv/boot/dts/starfive/jh7110-visionfive-v2.dtsi and then rebuild the kernel and install it again.

4 Likes