#language en #pragma description How to install Debian/Linux on a generic computer ## ## Read http://wiki.debian.org/InstallingDebianOn/HowToContribute before modifying this page ## ## You will find some comments like this one below to help you write a report. ## ------------------------------------------------------------------------------------------ ## ## Location Bar + DebianOn compatibility rating ||<>||<>|| ~-Translation(s): none-~ <> ## In this block, we describe the similar, compatible models that are also covered by this guide. ~-''Models covered''-~<
>'''SiFive HiFive Unmatched''' ## ~- Sub-models ('''LIST OF MODEL REFERENCE NUMBER''') options :<
> - Video card (Intel or ATI radeon or ATI FireGL) '''(adapt this list to actually match __options__ available. Common features are listed below)''' <
> - Screen size (14", 15", or 15" ''wide'')<
> - Wireless card<
> - Disk and Ram size, optical device <
> - Other options, like fingerprint reader, bluetooth... -~ * '''SiFive !HiFive Unmatched''', SiFive FU740-C000 (Quad-core 64-bit SiFive U74) + Embedded 64-bit SiFive S7 Core, 16 GB 64-bit DDR4, 1x PCI Express Gen3 x8 via PCI Express x16 Connector, Ethernet – 10/100/1000 Mbps, NVMe SSD M.2 , microSD Card. = Overall Status = ## If you installed Debian from scratch on this computer, please rate it! ## see InstallingDebianOn/Ratings (change the "included" file above). ||||'''Core Components'''||<|10 style="text-align:right;border-style:none;vertical-align:top;"> {{attachment:photo.png}}|| ||Boot Standard Kernel: || {OK} || || 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 = ### Any Important note, before the user starts installing Debian ### Like Bios, Disk, MBR Configuration. (default : ''none'') Debian on the HiFive Unmatched is very new. There are no official images available yet. You could find some experimental images in (signed with [[Deiv]]'s key): * https://people.debian.org/~deiv/riscv/debian-sid-risc-v-sifive-unmatched.tar.xz (490M) * https://people.debian.org/~deiv/riscv/debian-sid-risc-v-sifive-unmatched.tar.xz.asc This images are built with the same instructions in the next section. You just need to decompress them and burn to sd-card. = Installing Debian on HiFive = The easiest way at present to run Debian binaries on a HiFive is to generate an sdcard image with all the Debian stock parts. To boot from the SD card, ensure the MSEL[3:0] DIP switches on the board are configured as 1011: {{{ +----------> CHIPIDSEL | +--------> MSEL3 | | +------> MSEL2 | | | +----> MSEL1 | | | | +--> MSEL0 | | | | | +-+-+-+-+-+ | |X| |X|X| ON(1) | | | | | | |X| |X| | | OFF(0) +-+-+-+-+-+ BOOT MODE SEL }}} If you never touched these switches, this should be the default state. == Preparing disk image == {{{ # create image file dd if=/dev/zero of=debian-sid-risc-v-sifive-unmatched.img bs=1M count=4096 # Partition image with correct disk IDs sudo sgdisk -g --clear --set-alignment=1 \ --new=1:34:+1M: --change-name=1:'u-boot-spl' --typecode=1:5b193300-fc78-40cd-8002-e86c45580b47 \ --new=2:2082:+4M: --change-name=2:'opensbi-uboot' --typecode=2:2e54b353-1271-4842-806f-e436d6af6985 \ --new=3:16384:+400M: --change-name=3:'boot' --typecode=3:0x0700 --attributes=3:set:2 \ --new=4:835584:-0 --change-name=4:'rootfs' --typecode=4:0x8300 \ debian-sid-risc-v-sifive-unmatched.img # Mount image in loop device sudo losetup --partscan --find --show debian-sid-risc-v-sifive-unmatched.img # format partitions sudo mkfs.vfat /dev/loop0p3 sudo mkfs.ext4 /dev/loop0p4 sudo e2label /dev/loop0p3 boot sudo e2label /dev/loop0p4 rootfs }}} == Installing debian sid+riscv-port on image == {{{ # mount root partition sudo mount /dev/loop0p4 /mnt # install base files sudo apt-get install debootstrap qemu-user-static binfmt-support debian-ports-archive-keyring sudo debootstrap --arch=riscv64 --keyring /usr/share/keyrings/debian-ports-archive-keyring.gpg --include=debian-ports-archive-keyring unstable /mnt http://deb.debian.org/debian-ports # mount boot partition sudo mount /dev/loop0p3 /mnt/boot # chroot into base filesystem and made basic configuration sudo chroot /mnt }}} Inside created chroot: {{{ # Update package information apt-get update # Set up basic networking cat >>/etc/network/interfaces < /etc/hostname # Set up fstab cat > /etc/fstab < /dev/mmcblk0p4 / ext4 errors=remount-ro 0 1 /dev/mmcblk0p3 /boot vfat nodev,noexec,rw 0 2 EOF # Install kernel and bootloader infrastructure apt-get install linux-image-riscv64 u-boot-menu u-boot-sifive apt-get clean # add needed modules in initrd echo mmc_spi >>/etc/initramfs-tools/modules #update-initramfs -u (TODO: add more space in boot) rm /boot/initrd* update-initramfs -c -k all # Set up u-boot (TODO: better integration for kernel updates) # Should cp your latest dtb file,e.g, cp /usr/lib/linux-image-xx-riscv64 cp /usr/lib/linux-image-5.14.0-3-riscv64/sifive/hifive-unmatched-a00.dtb /boot/ echo U_BOOT_FDT=\"hifive-unmatched-a00.dtb\" >> /etc/default/u-boot echo U_BOOT_PARAMETERS=\"rw rootwait console=ttySIF0,115200 earlycon\" >> /etc/default/u-boot u-boot-update # Install ssh server and ntp apt-get install openssh-server openntpd ntpdate apt-get clean # set the time immediately at startup sed -i 's/^DAEMON_OPTS="/DAEMON_OPTS="-s /' /etc/default/openntpd # exit chroot exit }}} Once out of chroot: {{{ sudo rm /mnt/root/.bash_history }}} == Setup bootloaders == {{{ sudo dd if=/mnt/usr/lib/u-boot/sifive_unmatched/u-boot-spl.bin of=/dev/loop0p1 bs=4k iflag=fullblock oflag=direct conv=fsync status=progress sudo dd if=/mnt/usr/lib/u-boot/sifive_unmatched/u-boot.itb of=/dev/loop0p2 bs=4k iflag=fullblock oflag=direct conv=fsync status=progress }}} == Finish and write image to sdcard == {{{ sudo umount /mnt/boot sudo umount /mnt sudo losetup -d /dev/loop0 # take care of writing to the correct sdcard-device sudo dd if=debian-sid-risc-v-sifive-unmatched.img of=/dev/sdcard-device bs=64k iflag=fullblock oflag=direct conv=fsync status=progress }}} = Boot from onboard SPI Flash + NVMe drive = Suppose you now have a working system that boots from the SD card and have installed the ''u-boot-sifive'' package: == Make SPI Flash visible == Load the MTD block driver: {{{ sudo modprobe mtdblock }}} == Partition onboard flash == Partition onboard flash (/dev/mtdblock0): {{{ sudo sgdisk -g --clear -a 1 \ --new=1:40:2087 --change-name=1:'u-boot-spl' --typecode=1:5B193300-FC78-40CD-8002-E86C45580B47 \ --new=2:2088:10279 --change-name=2:'opensbi-uboot' --typecode=2:2E54B353-1271-4842-806F-E436D6AF6985 \ --new=3:10280:10535 --change-name=3:'uboot-env' --typecode=3:0FC63DAF-8483-4772-8E79-3D69D8477DE4 \ /dev/mtdblock0 }}} These partition offsets and types must be exact. Notice that they differ slightly from what is required for an SD card. == Setup bootloaders == {{{ sudo dd if=/usr/lib/u-boot/sifive_unmatched/u-boot-spl.bin of=/dev/mtdblock0 bs=4096 seek=5 conv=sync status=progress sudo dd if=/usr/lib/u-boot/sifive_unmatched/u-boot.itb of=/dev/mtdblock0 bs=4096 seek=261 conv=sync status=progress }}} == Installing debian sid+riscv-port on nvme drive == Similar to [[https://wiki.debian.org/InstallingDebianOn/SiFive/HiFiveUnmatched#Installing_debian_sid.2B-riscv-port_on_image|Installing debian sid+riscv-port on image]], partitioning the nvme drive, install debian into it and install kernel & other packages using chroot. You may also dd your sd card to nvme drive. == Switch to boot from onboard SPI flash == To boot from the onboard SPI flash (QSPI0 in SiFive's documentation), set MSEL[3:0] to 0110: {{{ +----------> CHIPIDSEL | +--------> MSEL3 | | +------> MSEL2 | | | +----> MSEL1 | | | | +--> MSEL0 | | | | | +-+-+-+-+-+ | | |X|X| | ON(1) | | | | | | |X|X| | |X| OFF(0) +-+-+-+-+-+ BOOT MODE SEL }}}