NixOS on RISCV/VisionFive 2: Difference between revisions

Onny (talk | contribs)
Update mainline kernel information
m Update to 24.05
 
(2 intermediate revisions by one other user not shown)
Line 37: Line 37:
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.
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.


= Building a SD-card image =
= Setup =
Precompiled SD-card images can be found [https://hydra.nichi.co/job/nixos/riscv/visionfive2 on the Hydra instance] my NickCao. Before flashing the image, use <code>unzstd</code> to unpack the downloaded archive.


=== Manually build a SD-card image ===
This example assumes you have the latest revision of the board (v1.3) with 8GB memory. For other configurations please consult the [https://github.com/NixOS/nixos-hardware/blob/master/starfive/visionfive/v2/README.md nixos-hardware documentation on this board]. First create this [[Flake]] file
This example assumes you have the latest revision of the board (v1.3) with 8GB memory. For other configurations please consult the [https://github.com/NixOS/nixos-hardware/blob/master/starfive/visionfive/v2/README.md nixos-hardware documentation on this board]. First create this [[Flake]] file


{{file|flake.nix|nix|<nowiki>
{{file|flake.nix|nix|<nowiki>
{
{
   inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
   inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
   inputs.nixos-hardware.url = "github:nixos/nixos-hardware";
   inputs.nixos-hardware.url = "github:nixos/nixos-hardware";


Line 85: Line 87:
               };
               };


               system.stateVersion = "23.11";
               system.stateVersion = "24.05";
             };
             };
           inherit system;
           inherit system;
Line 99: Line 101:
</syntaxhighlight>
</syntaxhighlight>


After successfull build, flash the resulting file in the directory <code>results/sd-image</code> to the target device, in this example the SD-card (<code>/dev/mmcblk*</code>). Note that everything on the target device gets erased.
=== Flashing the SD-card 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, 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 123: Line 126:
</syntaxhighlight>
</syntaxhighlight>


== Using the Visionfive 2 as a remote builder to build native RISCV packages for e.g. the Visionfive 2 ==
== Tips and tricks ==
 
=== Using the Visionfive 2 as a remote builder to build native RISCV packages for e.g. the Visionfive 2 ===
Building an NixOS system image that can be flashed to an SD card or NVMe SSD requires to '''build RISCV binaries''', more specifically for the <code>"riscv64-linux"</code>platform. From a typical Intel/AMD computer we can either
Building an NixOS system image that can be flashed to an SD card or NVMe SSD requires to '''build RISCV binaries''', more specifically for the <code>"riscv64-linux"</code>platform. From a typical Intel/AMD computer we can either


Line 138: Line 143:
# '''flash that resulting image onto an SD card''' or NVMe SSD using a call similar to <code>zstdcat result/sd-image/nixos-sd-image-23.11.20230703.ea4c80b-riscv64-linux.img.zst | sudo dd of=/dev/mmcblk0 bs=100M status=progress</code> and place that card into the Visionfive 2.
# '''flash that resulting image onto an SD card''' or NVMe SSD using a call similar to <code>zstdcat result/sd-image/nixos-sd-image-23.11.20230703.ea4c80b-riscv64-linux.img.zst | sudo dd of=/dev/mmcblk0 bs=100M status=progress</code> and place that card into the Visionfive 2.


== Deploy and Update the Visionfive 2 NixOS system once it's running NixOS ==
=== Deploy and Update the Visionfive 2 NixOS system once it's running NixOS ===
Once the Pi 5 is running NixOS, you can update it with newer NixOS system configurations using e.g. the usual  <code>nix-rebuild</code>
Once the Pi 5 is running NixOS, you can update it with newer NixOS system configurations using e.g. the usual  <code>nix-rebuild</code>