645: starfive visionfive2: Add firmware update script. r=Mic92 a=leifhelm



Co-authored-by: Jakob Leifhelm <jakob.leifhelm@gmail.com>
This commit is contained in:
bors[bot] 2023-06-10 11:20:27 +00:00 committed by GitHub
commit 70d5f55fae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 4 deletions

View file

@ -83,3 +83,31 @@ hardware.deviceTree.overlays = [{
"${nixos-hardware}/starfive/visionfive/v2/visionfive-2-v1.2a-8GB.dts"; "${nixos-hardware}/starfive/visionfive/v2/visionfive-2-v1.2a-8GB.dts";
}]; }];
``` ```
# Updating the bootloader
## SD-Card
Install the firmware update script
``` nix
environment.systemPackages = [
(pkgs.callPackage
"${nixos-hardware}/starfive/visionfive/v2/firmware.nix"
{ }).updater-sd
];
```
Then run as root
``` sh
visionfive2-firmware-update-sd
```
## SPI Flash
Install the firmware update script
``` nix
environment.systemPackages = [
(pkgs.callPackage
"${nixos-hardware}/starfive/visionfive/v2/firmware.nix"
{ }).updater-flash
];
```
Then run as root
``` sh
visionfive2-firmware-update-flash
```

View file

@ -1,4 +1,5 @@
{ callPackage, pkgsBuildHost, runCommand, writeText, stdenv, dtc }: { callPackage, pkgsBuildHost, runCommand, writeText, writeShellApplication
, stdenv, dtc, mtdutils, coreutils }:
let let
uboot = callPackage ./uboot.nix { }; uboot = callPackage ./uboot.nix { };
opensbi = callPackage ./opensbi.nix { opensbi = callPackage ./opensbi.nix {
@ -36,7 +37,7 @@ let
}; };
}; };
''; '';
in { in rec {
inherit opensbi uboot; inherit opensbi uboot;
spl = stdenv.mkDerivation { spl = stdenv.mkDerivation {
name = "starfive-visionfive2-spl"; name = "starfive-visionfive2-spl";
@ -58,4 +59,20 @@ in {
${uboot}/mkimage -f ${its-file} -A riscv -O u-boot -T firmware $out/share/starfive-visionfive2/visionfive2_fw_payload.img ${uboot}/mkimage -f ${its-file} -A riscv -O u-boot -T firmware $out/share/starfive-visionfive2/visionfive2_fw_payload.img
''; '';
}; };
updater-flash = writeShellApplication {
name = "visionfive2-firmware-update-flash";
runtimeInputs = [ mtdutils ];
text = ''
flashcp -v ${spl}/share/starfive-visionfive2/spl.bin /dev/mtd0
flashcp -v ${uboot-fit-image}/share/starfive-visionfive2/visionfive2_fw_payload.img /dev/mtd1
'';
};
updater-sd = writeShellApplication {
name = "visionfive2-firmware-update-sd";
runtimeInputs = [ ];
text = ''
dd if=${spl}/share/starfive-visionfive2/spl.bin of=/dev/mmcblk0p1 conv=fsync
dd if=${uboot-fit-image}/share/starfive-visionfive2/visionfive2_fw_payload.img of=/dev/mmcblk0p2 conv=fsync
'';
};
} }

View file

@ -1,7 +1,6 @@
{ config, pkgs, lib, modulesPath, ... }: { config, pkgs, lib, modulesPath, ... }:
let let firmware = pkgs.callPackage ./firmware.nix { };
firmware = pkgs.callPackage ./firmware.nix { };
in { in {
imports = [ imports = [
"${modulesPath}/profiles/base.nix" "${modulesPath}/profiles/base.nix"
@ -48,4 +47,6 @@ in {
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot ${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
''; '';
}; };
environment.systemPackages = [ firmware.updater-flash ];
} }