68 lines
2.0 KiB
Markdown
68 lines
2.0 KiB
Markdown
# Personal NixOS RISC-V 64 flake
|
|
|
|
Goals:
|
|
|
|
* I want to flash NixOS on to the M.2 NVMe SSD of a VisionFive2
|
|
* I want a flake with a neat cross story / UX
|
|
|
|
# Nix?
|
|
|
|
* https://nixos.org/
|
|
* https://determinate.systems/posts/determinate-nix-installer
|
|
|
|
# How?
|
|
|
|
The VisionFive2 shipped with a stinky firmware, which does not support booting from the SSD.
|
|
This capability was later added in [starfive uboot v3.0.4](https://github.com/starfive-tech/u-boot/commit/2139bf20ea67250c9dc426735fb9daf14e21bb9f).
|
|
As such we have to flash an SD card, use it to flash new firmware to the VisionFive2 SPI flash, then finally boot from the NVMe, all the while [fiddling with DIP switches](dip-pics.md).
|
|
|
|
## Building an image
|
|
|
|
Pick a host, then pick your poison:
|
|
|
|
| Hostname | Description |
|
|
| -------------- | ------------------- |
|
|
| `demo-r12a` | Board rev 1.2A |
|
|
| `demo-r12a-8g` | Board rev 1.2A, 8GB |
|
|
| `demo-r13b` | Board rev 1.3B |
|
|
| `demo-r13b-8g` | Board rev 1.3B, 8GB |
|
|
| `asgaut` | Asgaut |
|
|
| `gunder` | Gunder |
|
|
|
|
```shell
|
|
nix build .#asgaut-qemu # emulation go brr
|
|
nix build .#asgaut-nvme-image
|
|
nix build .#asgaut-sd-image
|
|
nix build .#asgaut-sd-installer
|
|
```
|
|
|
|
## Building without cross compilation
|
|
|
|
Either use a `riscv64-linux` host, or run the following command with `riscv64-linux` [binfmt emulation](https://search.nixos.org/options?query=boot.binfmt.emulatedSystems) configured:
|
|
|
|
```shell
|
|
nix build .#packages.riscv64-linux.demo-nvme-image
|
|
```
|
|
|
|
## Flashing an image
|
|
|
|
```shell
|
|
nix build .#something
|
|
lsblk # locate your SD card
|
|
umount /run/media/pbsds/9C33-6BBD # example mounts
|
|
sudo dd if=result/sd-image/*.img of=/dev/sdX bs=4M conf=fsync status=progress
|
|
sync
|
|
```
|
|
|
|
## Booting
|
|
|
|
Here are some sweet [dip pics](https://doc-en.rvspace.org/VisionFive2/Boot_UG/VisionFive2_SDK_QSG/boot_mode_settings.html).
|
|
|
|
After flashing the firmware you can boot using quad SPI. Use SDIO3.0 to boot using the u-boot SPL and FIT firmware on the sd card.
|
|
|
|
## Updating SPI firmware
|
|
|
|
```shell
|
|
sudo update-firmware
|
|
```
|