nixos-hardware/starfive/visionfive/v2
Nick Cao 7b49d39676 starfive visionfive2: drop dtb overlay for 8GB version
u-boot is able to automatically set the correct memory size in fdt
on VisionFive 2 boards by reading their EEPROM since v2023.10.

This allows our image to work with either variant of the boards.

Reference: 38d900b409
Reference: 43177705ab
2024-06-01 13:21:35 +00:00
..
default.nix starfive visionfive2: let u-boot set device tree name 2024-06-01 13:21:35 +00:00
firmware.nix starfive visionfive2: write u-boot.itb to mtd2 2024-01-03 07:27:55 +00:00
linux-6.6.nix Revert "starfive visionfive2: use mainline kernel" 2024-05-28 18:18:58 -04:00
opensbi.nix starfive visionfive2: adjust opensbi build params to match u-boot doc 2024-01-03 07:27:55 +00:00
README.md starfive visionfive2: drop dtb overlay for 8GB version 2024-06-01 13:21:35 +00:00
sd-image-installer.nix Init starfive visionfive 2 2023-04-16 23:18:18 +02:00
sd-image.nix starfive visionfive2: rework firmware build/update scripts 2024-01-03 07:27:55 +00:00
spl-tool.nix starfive visionfive2: Update spl_tool 2023-04-18 09:19:48 +02:00
uboot.nix starfive visionfive2: use nixpkgs default u-boot version 2024-04-27 06:47:52 +00:00

Creating a SD-Image

Create and configure the flake.nix file:

{
  inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  inputs.nixos-hardware.url = "github:nixos/nixos-hardware";

  # Some dependencies of this flake are not yet available on non linux systems
  inputs.systems.url = "github:nix-systems/x86_64-linux";
  inputs.flake-utils.url = "github:numtide/flake-utils";
  inputs.flake-utils.inputs.systems.follows = "systems";

  outputs = { self, nixpkgs, nixos-hardware, flake-utils, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      rec {
        packages.default = packages.sd-image;
        packages.sd-image = (import "${nixpkgs}/nixos" {
          configuration =
            { config, ... }: {
              imports = [
                "${nixos-hardware}/starfive/visionfive/v2/sd-image-installer.nix"
              ];

              # If you want to use ssh set a password
              # users.users.nixos.password = "super secure password";
              # OR add your public ssh key
              # users.users.nixos.openssh.authorizedKeys.keys = [ "ssh-rsa ..." ];

              # AND configure networking
              # networking.interfaces.end0.useDHCP = true;
              # networking.interfaces.end1.useDHCP = true;

              # Additional configuration goes here

              sdImage.compressImage = false;

              nixpkgs.crossSystem = {
                config = "riscv64-unknown-linux-gnu";
                system = "riscv64-linux";
              };

              system.stateVersion = "23.05";
            };
          inherit system;
        }).config.system.build.sdImage;
      });
}

Build the sd image.

nix build .#

Updating the bootloader

SD-Card

Install the firmware update script

environment.systemPackages = [
  (pkgs.callPackage
    "${nixos-hardware}/starfive/visionfive/v2/firmware.nix"
    { }).updater-sd
];

Then run as root

visionfive2-firmware-update-sd

SPI Flash

Install the firmware update script

environment.systemPackages = [
  (pkgs.callPackage
    "${nixos-hardware}/starfive/visionfive/v2/firmware.nix"
    { }).updater-flash
];

Then run as root

visionfive2-firmware-update-flash