Differences between revisions 4 and 5
Revision 4 as of 2022-05-26 16:04:45
Size: 8977
Editor: ?BaptisteJonglez
Comment: Add debootstrap and keyring installation
Revision 5 as of 2022-05-26 17:07:39
Size: 9085
Editor: ?AlanBeadle
Comment: Various minor improvements
Deletions are marked like this. Additions are marked like this.
Line 74: Line 74:
== Prepare filesystems and rootfs == == Partitions and filesystems ==
Line 180: Line 180:
# Edit /boot/extlinux/extlinux.conf to match your files: # On the host machine, find the UUID of your microSD card with blkid command.
# In the chroot, e
dit /boot/extlinux/extlinux.conf to match your files and UUID:
Line 192: Line 193:
# Edit /boot/grub.cfg to match your files: # Edit /boot/grub.cfg to match your files and UUID:
Line 210: Line 211:
# Change hostname
echo visionfive > /etc/hostname

# Install ssh server and ntp
apt install openssh-server ntp
Line 212: Line 219:

# Change hostname
echo visionfive > /etc/hostname

# Install ssh server and ntp
apt install openssh-server ntp

DebianOn is an effort to document how to install, configure and use Debian on some specific hardware. Therefore potential buyers would know if that hardware is supported and owners would know how get the best out of that hardware.

The purpose is not to duplicate the Debian Official Documentation, but to document how to install Debian on some specific hardware.

If you need help to get Debian running on your hardware, please have a look at our user support channels where you may find specific channels (mailing list, IRC channel) dedicated to certain types of hardware.

Translation(s): none

Models covered
?StarFive ?VisionFiveV1

  • ?StarFive VisionFive V1, ?StarFive JH7100 (Dual-core 64-bit ?SiFive U74) + Embedded 32-bit ?SiFive E24 Core, 8 GB 64-bit LPDDR4, Gigabit Ethernet, microSD Card.

Overall Status

Core Components

[ATTACH]

Boot Standard Kernel:

{?}

LAN network card ():

{OK}

Detect hard drives (microSD/NVMe):

{OK}

Xorg

[?]

Extra Features

CPU Frequency Scaling

[?]

Hibernation

[?]

Sleep / Suspend

[?]

Power Off / Reboot

{OK}

Legend :
{OK} = OK ; {X} Unsupported(No Driver) ; /!\ = Error (Couldn't get it working); [?] Unknown, Not Test ; [-] Not-applicable
{i} = Configuration Required; X-( = Only works with a non-free driver and or firmware

Important Note

There are no official Debian images available yet.

Installing Debian on VisionFive V1

Build the kernel

# Install prerequisites on the host machine
sudo apt install libncurses-dev libssl-dev bc flex bison make gcc gcc-riscv64-linux-gnu

# Download and extract latest StarFive JH7100 sources
wget https://github.com/starfive-tech/linux/archive/refs/heads/visionfive.zip
unzip visionfive.zip

# build the kernel
cd linux-visionfive/
cp arch/riscv/configs/starfive_jh7100_fedora_defconfig .config
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- menuconfig
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- -jX bindeb-pkg LOCALVERSION=-starfive-5.18

# While you wait for the kernel to compile, you can begin setting up the roots in the next section. The following step will not work until you do this.
# Once the kernel is built and the microSD partitions are mounted (see next section), copy the .deb files to the microSD card
sudo cp ../*.deb /mnt/jh7100/root/

# Also copy the device tree
sudo cp arch/riscv/boot/dts/starfive/jh7100-starfive-visionfive-v1.dtb /mnt/jh7100/boot/

Partitions and filesystems

# These instructions assume that your microSD card is at /dev/mmcblk0
# First, prepare the microSD card partitions
sudo cfdisk -z /dev/mmcblk0
# Pick "dos" when prompted
# Create the following four partitions:
#
# 16M: 83 Linux (will be deleted anyway)
# 16M: C W95 FAT 32
# 512M: 83 Linux BOOTABLE
# Rest of card: 83 Linux

# Then, delete the first partition (leaving 16M free space there), write the partitions, and exit
# You can double check your work with:
fdisk -l /dev/mmcblk0

# Next, prepare the filesystems
sudo mkfs.vfat /dev/mmcblk0p2
sudo mkfs.ext4 -L _/boot /dev/mmcblk0p3
sudo mkfs.ext4 -L _/ /dev/mmcblk0p4

sudo mkdir /mnt/jh7100
sudo mount /dev/mmcblk0p4 /mnt/jh7100

sudo mkdir -p /mnt/jh7100/boot
sudo mount /dev/mmcblk0p3 /mnt/jh7100/boot/

sudo mkdir -p /mnt/jh7100/boot/efi
sudo mount /dev/mmcblk0p2 /mnt/jh7100/boot/efi/

# You can check your work with lsblk

Bootstrapping

# Install prerequisites on host:
sudo apt install qemu-user-static binfmt-support debootstrap debian-ports-archive-keyring

# The command below will bootstrap debian on the SD card.
sudo debootstrap --arch=riscv64 --keyring /usr/share/keyrings/debian-ports-archive-keyring.gpg --include=debian-ports-archive-keyring unstable /mnt/jh7100 https://deb.debian.org/debian-ports/

# If you get an error "Unable to execute target architecture", try the following process instead:
sudo debootstrap --foreign --arch=riscv64 --keyring /usr/share/keyrings/debian-ports-archive-keyring.gpg --include=debian-ports-archive-keyring unstable /mnt/jh7100/ http://deb.debian.org/debian-ports
sudo mkdir -p /mnt/jh7100/usr/bin/
sudo cp "$(which qemu-riscv64-static)" /mnt/jh7100/usr/bin/
sudo chroot /mnt/jh7100/ /debootstrap/debootstrap --second-stage

# Now enter the chroot and ensure that the package db is up to date
sudo systemd-nspawn -D /mnt/jh7100/ -M debian --bind-ro=/etc/resolv.conf
apt update
apt dist-upgrade

Installing kernel and bootloader config

# Now that you are in the chroot, you will install the .deb files from the kernel compilation
apt install ./*.deb

# Next, prepare the initramfs
cd /boot
apt install initramfs-tools
update-initramfs -ck all

# You will need some files from the official StarFive Fedora image
# Open a terminal on the host machine and download the image from here:
# https://github.com/starfive-tech/Fedora_on_StarFive

# Extract the Fedora image
sudo apt install zstd
zstd -d  Fedora-riscv64-jh7100-developer-xfce-Rawhide-20211226-214100.n.0-sda.raw.zst

# Examine the partitions. Note the partition start locations and units
fdisk -u -l Fedora-riscv64-jh7100-developer-xfce-Rawhide-20211226-214100.n.0-sda.raw

# Mount the second partition of the image as follows.
# Compute the offset by multiplying (units * start)
# For example, if the start is 319488 and units is 512 bytes, then (319488 * 512) = 163577856
# Use this offset value to mount the second partition:
sudo mkdir /mnt/fedora/
sudo mount -o loop,offset=163577856 Fedora-riscv64-jh7100-developer-xfce-Rawhide-20211226-214100.n.0-sda.raw /mnt/fedora

# Now you should be able to copy some files from the Fedora image to the SD card
sudo cp -R /mnt/fedora/boot/ /mnt/jh7100/boot
sudo cp -R /mnt/fedora/extlinux/ /mnt/jh7100/boot/
sudo cp /mnt/fedora/grub.cfg /mnt/jh7100/boot/

# Unmount the second Fedora partition
sudo umount /mnt/fedora

# And mount the first Fedora partition
sudo mount -o loop,offset=35651584 Fedora-riscv64-jh7100-developer-xfce-Rawhide-20211226-214100.n.0-sda.raw /mnt/fedora
sudo cp -R /mnt/fedora/EFI /mnt/jh7100/boot/efi

# Back in the chroot, you need to edit some of the new files

# Edit /boot/boot/uEnv.txt by commenting out ipaddr and netmask, and change "fedora" to "debian"

# Rename a directory:
cd /boot/efi/EFI
mv fedora/ debian/

# On the host machine, find the UUID of your microSD card with blkid command.
# In the chroot, edit /boot/extlinux/extlinux.conf to match your files and UUID:

timeout 20
menu title Kernel Boot Options.

label kernel
        kernel /vmlinuz-5.18.0-starfive-5.18
        fdt /jh7100-starfive-visionfive-v1.dtb
        append rw root=UUID=245a4691-f80c-4d26-8c59-9c4fce3f044d rhgb console=tty0 console=ttyS0,115200 earlycon=sbi rootwait stmmaceth=chain_mode:1 selinux=0 LANG=en_US.UTF-8
        initrd /initrd.img-5.18.0-starfive-5.18


# Edit /boot/grub.cfg to match your files and UUID:

set default=0
set timeout_style=menu
set timeout=2

set debug="linux,loader,mm"
set term="vt100"

menuentry 'Debian vmlinuz-5.18.0-starfive-5.18 visionfive' {
        linux /vmlinuz-5.18.0-starfive-5.18 rw root=UUID=245a4691-f80c-4d26-8c59-9c4fce3f044d rhgb console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0 LANG=en_US.UTF-8
        devicetree /jh7100-starfive-visionfive-v1.dtb
        initrd /initrd.img-5.18.0-starfive-5.18
}

# Set root password
passwd

# Change hostname
echo visionfive > /etc/hostname

# Install ssh server and ntp
apt install openssh-server ntp

# sync disks
sync

# exit chroot
exit

# Unmount everything from the host
sudo umount /mnt/fedora
sudo umount /mnt/jh7100/boot/efi
sudo umount /mnt/jh7100/boot/
sudo umount /mnt/jh7100/

# Now the microSD card should be bootable by the VisionFive V1