NixOS on RISCV/VisionFive 2: Difference between revisions
Add note about prebuild images |
m Typo |
||
(12 intermediate revisions by 4 users not shown) | |||
Line 34: | Line 34: | ||
Please note that HDMI display patches haven't been merged yet. | Please note that HDMI display patches haven't been merged yet. | ||
= Setup = | = Setup = | ||
Precompiled SD-card images can be found [https://hydra.nichi.co/job/nixos/riscv/visionfive2 on the Hydra instance] | Precompiled SD-card images can be found [https://hydra.nichi.co/job/nixos/riscv/visionfive2 on the Hydra instance] by NickCao. Before flashing the image, use <code>unzstd</code> to unpack the downloaded archive. | ||
=== Manually build a SD-card image === | === Manually build a SD-card image === | ||
First create this [[Flake]] file | |||
{{file|flake.nix|nix|<nowiki> | {{file|flake.nix|nix|<nowiki> | ||
{ | { | ||
inputs.nixpkgs.url = " | inputs.nixpkgs.url = "nixpkgs/nixos-24.11"; | ||
inputs.nixos-hardware.url = "github:nixos/nixos-hardware"; | inputs.nixos-hardware.url = "github:nixos/nixos-hardware"; | ||
Line 74: | Line 72: | ||
# Additional configuration goes here | # Additional configuration goes here | ||
sdImage.compressImage = false; | sdImage.compressImage = false; | ||
Line 87: | Line 80: | ||
}; | }; | ||
system.stateVersion = " | system.stateVersion = "24.11"; | ||
}; | }; | ||
inherit system; | inherit system; | ||
Line 94: | Line 87: | ||
} | } | ||
</nowiki>}} | </nowiki>}} | ||
It might be helpful to add [[RISC-V#Binary cache|third-party binary cache configuration]] to this system configuration. | |||
Run following command to build the SD-card image | Run following command to build the SD-card image | ||
Line 101: | Line 96: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Flashing the | === Flashing the image === | ||
After successfull build or unpack, flash the resulting file (build file is in the directory <code>results/sd-image</code>) to the target device | After successfull build or unpack, flash the resulting file (build file is in the directory <code>results/sd-image</code>) to the target device such as a NVME SSD or in this example the SD-card (<code>/dev/mmcblk*</code>). Note that everything on the target device gets erased. | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 114: | Line 109: | ||
See official documentation https://doc-en.rvspace.org/VisionFive2/Quick_Start_Guide/VisionFive2_SDK_QSG/boot_mode_settings.html . | See official documentation https://doc-en.rvspace.org/VisionFive2/Quick_Start_Guide/VisionFive2_SDK_QSG/boot_mode_settings.html . | ||
First enable booting from SD-card by setting jumper 1 and 2 to "FLASH/QSPI mode" (both QSPI and SDIO mode support booting from an SD card): | First enable booting from SD-card or NVME SSD by setting jumper 1 and 2 to "FLASH/QSPI mode" (both QSPI and SDIO mode support booting from an SD card): | ||
[[File:Visionfive_2_jumper_config_sdcard_boot.jpg|border|frameless|803x803px]] | [[File:Visionfive_2_jumper_config_sdcard_boot.jpg|border|frameless|803x803px]] | ||
Line 124: | Line 119: | ||
</syntaxhighlight>Bootstrap NixOS system configuration at <code>/etc/nixos/configuration.nix</code><syntaxhighlight lang="bash"> | </syntaxhighlight>Bootstrap NixOS system configuration at <code>/etc/nixos/configuration.nix</code><syntaxhighlight lang="bash"> | ||
nixos-generate-config | nixos-generate-config | ||
</syntaxhighlight> | </syntaxhighlight>It is recommended to [[RISC-V#Binary cache|configure third-party binary caches]] to speed up build times. | ||
== Tips and tricks == | == Tips and tricks == | ||
Line 153: | Line 148: | ||
See [https://nixcademy.com/2023/08/10/nixos-rebuild-remote-deployment/ this guide] for a good explanation of this terminal call. | See [https://nixcademy.com/2023/08/10/nixos-rebuild-remote-deployment/ this guide] for a good explanation of this terminal call. | ||
== See also == | |||
* There's also a port of the UEFI reference implementation EDK2 available at https://github.com/starfive-tech/edk2 to support a future generic RISCV Linux image that can be booted from any RISCV device. |