-
-
Save jmontleon/ae5457e1d289719046f915a9cb83a32b to your computer and use it in GitHub Desktop.
################################################################################################ | |
There is some long text that needs to be copied into grub in order to boot. | |
You should be able to copy and paste it using minicom if you add a 1 or 2 ms delay to text input | |
Ctrl-A Z Minicom Menu | |
T Terminal Settings | |
F Character tx delay (ms) | |
2 | |
################################################################################################ | |
### Choose your SD Card | |
### You need to edit this | |
export SDCARD=/dev/sdX | |
### Set the Fedora Image | |
# It should be fine to replace this with a newer version from | |
# http://riscv.rocks/koji/tasks?state=all&view=tree&method=all&order=-id | |
# but the UUID for /boot and /root will on lines ~65 and ~100 will need to be updated by | |
# by downloading, decompressing, mapping with kpartx, and running blkid, e.g. | |
# wget http://fedora.riscv.rocks/kojifiles/packages/uboot-tools/2024.04/1.1.riscv64.fc40/noarch/uboot-images-riscv64-2024.04-1.1.riscv64.fc40.noarch.rpm | |
# unxz Fedora-Minimal-40-20240426.n.0-sda.raw.xz | |
# sudo kpartx -av Fedora-Minimal-40-20240426.n.0-sda.raw | |
# blkid /dev/mapper/loop0p2 | |
# blkid /dev/mapper/loop0p3 | |
export FEDORAR5IMAGE=Fedora-Minimal-40-20240426.n.0-sda.raw | |
### Get stuff | |
wget http://fedora.riscv.rocks/kojifiles/packages/uboot-tools/2024.04/1.1.riscv64.fc40/noarch/uboot-images-riscv64-2024.04-1.1.riscv64.fc40.noarch.rpm | |
wget http://fedora.riscv.rocks/kojifiles/work/tasks/1108/1691108/${FEDORAR5IMAGE}.xz | |
wget https://github.com/jmontleon/grub2-dist-git/raw/f40-2.12-riscv-f40-binaries/grubriscv64.efi | |
### Extract stuff | |
rpm2cpio uboot-images-riscv64-2024.04-1.1.riscv64.fc40.noarch.rpm | cpio -ivd | |
unxz ${FEDORAR5IMAGE}.xz | |
### Create a new gpt label on your SD Card | |
### Double check your sd card device is correct | |
sudo parted ${SDCARD} mklabel gpt | |
### Partition your SD Card | |
sudo sgdisk -g --clear --set-alignment=1 \ | |
--new=1:4096:+2M: --change-name=1:'spl' --typecode=1:2e54b353-1271-4842-806f-e436d6af6985 \ | |
--new=2:8192:+16M: --change-name=2:'opensbi-uboot' --typecode=2:5b193300-fc78-40cd-8002-e86c45580b47 \ | |
--new=3:40960:235519 --typecode=3:C12A7328-F81F-11D2-BA4B-00A0C93EC93B \ | |
--new=4:235520:2189311 --typecode=4:0FC63DAF-8483-4772-8E79-3D69D8477DE4 \ | |
--new=5:2189312:17813503 --typecode=5:0FC63DAF-8483-4772-8E79-3D69D8477DE4 \ | |
${SDCARD} | |
### Write your SD Card | |
sudo dd if=./usr/share/uboot/starfive_visionfive2/spl/u-boot-spl.bin.normal.out of=${SDCARD}1 bs=4096 oflag=direct | |
sudo dd if=./usr/share/uboot/starfive_visionfive2/u-boot.itb of=${SDCARD}2 bs=4096 oflag=direct | |
sudo kpartx -av ${FEDORAR5IMAGE} | |
export F40R5LODEV=$(losetup -a | grep ${FEDORAR5IMAGE} | head -n 1 | awk -F ':' '{ print $1 }' | awk -F '/' '{ print $3}') | |
sudo dd if=/dev/mapper/${F40R5LODEV}p1 of=${SDCARD}3 bs=64M status=progress | |
sudo dd if=/dev/mapper/${F40R5LODEV}p2 of=${SDCARD}4 bs=64M status=progress | |
sudo dd if=/dev/mapper/${F40R5LODEV}p3 of=${SDCARD}5 bs=64M status=progress | |
sudo kpartx -dv ${FEDORAR5IMAGE} | |
### Replace grub with a working version | |
mkdir riscv-fedora-boot riscv-fedora-efi | |
sudo mount ${SDCARD}3 riscv-fedora-efi | |
sudo mount ${SDCARD}4 riscv-fedora-boot | |
sudo cp grubriscv64.efi riscv-fedora-efi/EFI/fedora/grubriscv64.efi | |
sudo bash -c 'cat << EOF > riscv-fedora-efi/EFI/fedora/grub.cfg | |
search --no-floppy --fs-uuid --set=dev 601e15e4-c750-4e41-99eb-01f7a7ee2364 | |
set prefix=(\$dev)/grub2 | |
export \$prefix | |
configfile \$prefix/grub.cfg | |
EOF' | |
sudo umount riscv-fedora-boot | |
sudo umount riscv-fedora-efi | |
rmdir riscv-fedora-boot riscv-fedora-efi | |
# Eject SD Card | |
sudo eject ${SDCARD} | |
# Boot configuratio on VisionFive 2 | |
Hit space once you reach the `Hit any key to stop autoboot` prompt. | |
env default -f -a | |
env save | |
eficonfig | |
Select Add Boot Option | |
Set the description to Fedora | |
File | |
Select File | |
mmc 1:3 | |
EFI\fedora\grubriscv64.efi | |
Save | |
Change Boot Order | |
Highlight Fedora and press the + key (Shift+=) to bring it to the top | |
Save | |
Quit | |
bootmenu | |
boot fedora | |
You should boot to a grub prompt. | |
linux (hd1,gpt4)/vmlinuz-6.8.7-300.4.riscv64.fc40.riscv64 ro root=UUID=ffa41c6d-e304-460e-9190-91456e86f7d0 rootflags=subvol=root | |
initrd (hd1,gpt4)/initramfs-6.8.7-300.4.riscv64.fc40.riscv64.img | |
boot | |
#Finish fixing boot | |
Login as root | |
grub2-mkconfig -o /boot/grub2/grub.cfg | |
dnf config-manager --disable fedora updates fedora-cisco-openh264 | |
dnf -y update https://github.com/jmontleon/grub2-dist-git/raw/f40-2.12-riscv-f40-binaries/grub2-common-2.12-0.1.1.riscv64.fc40.noarch.rpm https://github.com/jmontleon/grub2-dist-git/raw/f40-2.12-riscv-f40-binaries/grub2-efi-riscv64-2.12-0.1.1.riscv64.fc40.riscv64.rpm https://github.com/jmontleon/grub2-dist-git/raw/f40-2.12-riscv-f40-binaries/grub2-efi-riscv64-modules-2.12-0.1.1.riscv64.fc40.noarch.rpm https://github.com/jmontleon/grub2-dist-git/raw/f40-2.12-riscv-f40-binaries/grub2-tools-2.12-0.1.1.riscv64.fc40.riscv64.rpm https://github.com/jmontleon/grub2-dist-git/raw/f40-2.12-riscv-f40-binaries/grub2-tools-minimal-2.12-0.1.1.riscv64.fc40.riscv64.rpm | |
# Reboot and test. You should be booting without manual intervention now. |
@NeilHanlon glad it (mostly) worked. I updated the instructions to make it a 2 ms delay.
I can probably add something along the lines of losetup -a | grep Fedora-Minimal-40-20240426.n.0-sda.raw | awk -F ':' '{ print $1 }'
to set an env var for the loop device after running kpartx so it gets the right device and doesn't assume things.
And hopefully the wall of instructions just gets a lot shorty in the coming days.
I have been eagerly awaiting F40 for VisionFive2 and happy to see there's some progress! I tried to follow these instructions but noticed that you reference a grubriscv64.efi
file that doesn't seem to exist (at least publicly) -- I attempted to cross compile the riscv64 branch you have for grub on my amd64 workstation (running Fedora 40 KDE Plasma) by doing:
ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- ./bootstrap
ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- ./autogen.sh
ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- ./configure --target=riscv64-linux-gnu --with-platform=efi
ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- make -j$(nproc)
but assume I did something wrong; after ignoring a few -Wmaybe-uninitialized and -Wunused-variable errors, I got:
riscv64-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I.. -Wall -W -DGRUB_MACHINE_EFI=1 -DGRUB_MACHINE=RISCV64_EFI -nostdinc -isystem /usr/lib/gcc/riscv64-linux-gnu/13/include -I../include -I../include -DGRUB_FILE=\"lib/setjmp.S\" -I. -I. -I.. -I.. -I../include -I../include -I../grub-core/lib/libgcrypt-grub/src/ -g -march=rv64imac_zicsr_zifencei -mabi=lp64 -DGRUB_FILE=\"lib/setjmp.S\" -I. -I. -I.. -I.. -I../include -I../include -I../grub-core/lib/libgcrypt-grub/src/ -DASM_FILE=1 -MT lib/setjmp_module-setjmp.o -MD -MP -MF lib/.deps-core/setjmp_module-setjmp.Tpo -c -o lib/setjmp_module-setjmp.o `test -f 'lib/setjmp.S' || echo './'`lib/setjmp.S
setjmp.S: Assembler messages:
setjmp.S:143: Error: missing name
setjmp.S:24: Info: macro invoked from here
setjmp.S:144: Error: unknown pseudo-op: `.module_license'
setjmp.S:24: Info: macro invoked from here
setjmp.S:145: Error: unrecognized opcode `a"'
setjmp.S:24: Info: macro invoked from here
make[3]: *** [Makefile:36902: lib/setjmp_module-setjmp.o] Error 1
Found the missing file -- https://github.com/jmontleon/grub2-dist-git/raw/f40-2.12-riscv-f40-binaries/grubriscv64.efi
in your grub2-dist-git repo
Thanks @DaveWK for catching this. I renamed the repo when I was cloning rhboot/grub2 to work with an in progress 2.12 rebase of the official package. I've updated the instructions to download it from the correct repo.
cool -- I just ran through the instructions, and had some trouble getting u-boot to load off the image. I suspect I messed something up with changing the UUID's.
To simplify my process, I first booted the arch riscv distro, then I flashed the fedora u-boot images to the SPI by doing:
flashcp -v usr/share/uboot/starfive_visionfive2/spl/u-boot-spl.bin.normal.out /dev/mtd/by-name/spl
flashcp -v usr/share/uboot/starfive_visionfive2/spl/u-boot.itb
after which, I was able to dd Fedora-Minimal-40-20240502.n.0-sda.raw
to the root device of my emmc (this also works with sd cards)
and then followed the instructions for the eficonfig
menu and setting up grub. this way I didn't have to mess with the partitions.
happy to report that I was able to boot and use the Fedora image on both an EMMC and SD card at this point. Thanks for the info!
I used a newer image I noticed was available at: http://fedora.riscv.rocks/kojifiles/work/tasks/1193/1691193/Fedora-Minimal-40-20240502.n.0-sda.raw.xz
I noticed there's also a link to the other repo at: https://gist.github.com/jmontleon/ae5457e1d289719046f915a9cb83a32b#file-gistfile1-txt-L108 which needs to be changed as well to the other grub2-dist-git
repo -- https://github.com/jmontleon/grub2-dist-git/raw/f40-2.12-riscv-f40-binaries/grub2-2.12-0.1.1.riscv64.fc40.src.rpm
I got as far as L99, but it didn't boot the grub initramfs/vmlinuz...
I did succeed in flashcp'ing the fedora spl image out/u-boot.itb after booting into the latest starfive eng release image/flashing their latest spl image out/fw image payload.
https://gist.github.com/jmontleon/ae5457e1d289719046f915a9cb83a32b#file-gistfile1-txt-L99
Any suggestions? LOL. I did notice within the uboot, I can run eficonfig, and I can view mmc 3 files...the boot partition, but I couldn't view read the mmc 4 files...the root partition. Does that hint my dd of everything fedora root needs to be repeated?
@omac777 did you use Fedora-Minimal-40-20240426.n.0-sda.raw.xz or a different image? If different, can you please tell me which.
I don't think being unable to read the boot partition from eficonfig is anything to be concerned about. Trying just now I also see that it can only read the fat partition.
Do you see the boot menu item you created in the boot menu? If not perhaps it wasn't saved properly. I have found the menu misbehaves sometimes and jumps back a page when I hit arrow keys, losing settings in the process. If you do see it what happens when you select it?
One thing I have noticed is it appears either the m.2 NVMe is disabled or not detected in Fedora; I am not sure if this is due to an issue with u-boot or an issue with the kernel driver/config. Thanks for all the docs+work on this
@DaveWK there is no support in upstream yet, although as I understand it the patches have been accepted for 6.11.
The kernel I put in https://github.com/jmontleon/fedora-40-lpi4a should also have the pci-e stuff for the VF2.
If you are a little inventive moving partitions over you can actually boot using spi with /boot /boot/efi and / on nvme once you have nvme support.
I have a 6.9.3 SRPM as well; I tested it, but I don't think I still have the binary RPMS around, not that it would be difficult to rebuild; more just need somewhere less silly than a github repo to host rpms
@jmontleon I have been using the spi for boot, which was how I tested out booting from the emmc as well as sd card, but couldn't get it to boot off the nvme with the Fedora-Minimal-40-20240502.n.0-sda.raw
image; I also noticed when I booted off the sd or emmc that I could not see the nvme drive in Fedora, so I assume this is because I am missing a kernel driver?
Yes, with 6.11 it should all be available in upstream. They didn't make it in time for 6.10 so unfortunately we'll have to wait a bit longer.
unfortunately, I used the older Fedora-Minimal-40-20240426.n.0-sda.raw image.
I'm not on nvme. I used an sdcard as I can just push it in and pop it out of the board. The constant screwing and unscrewing of the nvme's was driving me crazy. The nvme design should have been more convenient to push in/push out in carriages and all. This really encouraged me to consider using NAS with convenient cartridges to insert and eject.
Ope -- Wayland's terrible copy/paste strikes again.. looks like I clipped the end of my second flashcp
command..
But it should be
flashcp -v usr/share/uboot/starfive_visionfive2/spl/u-boot.itb /dev/mtd/by-name/u-boot
also verify your mtd numbers by doing cat /proc/mtd
to be sure there isn't some nondeterministic ordering.
Thank you for all your help from above. I succeeded in booting up on the Starfive Visionfive 2 using the following raw image:
wget http://fedora.riscv.rocks/kojifiles/work/tasks/1193/1691193/Fedora-Minimal-40-20240502.n.0-sda.raw.xz
The recipe above for the grub entries didn't point to the same hd1. for me it was hd0.
Found DTB: starfive/jh7110-starfive-visionfive-2-v1.3b.dtb GNU GRUB version 2.12
Booting: Fedora
Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists possible device or file completions. To enable less(1)-like paging, "set pager=1".
grub> linux (hd0,gpt4)/vmlinuz-6.8.7-300.4.riscv64.fc40.riscv64 ro root=UUID=ae525e47-51d5-4c98-8442-351d530612c3 rootflags=subvol=root
grub> initrd (hd0,gpt4)/initramfs-6.8.7-300.4.riscv64.fc40.riscv64.img
grub> boot
EFI stub: Decompressing Linux Kernel...
EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
EFI stub: Using DTB from configuration table
EFI stub: Exiting boot services...
[ 0.000000] Linux version 6.8.7-300.4.riscv64.fc40.riscv64 (mockbuild@04f1060c14404e2b85a3a21c28c7a74d) (gcc (GCC) 14.0.1 20240411 (Red Hat 14.0.1-0), GNU ld version 2.42-2.rvre0.fc40) #1 SMP PREEMPT_DYNAMIC Fri Apr 26 02:00:46 EDT 2024
[ 0.000000] Machine model: StarFive VisionFive 2 v1.3B
[ 0.000000] SBI specification v2.0 detected
Thanks for this! A couple notes from my usage: