Skip to content

Commit 70d5f55

Browse files
bors[bot]leifhelm
andauthored
Merge #645
645: starfive visionfive2: Add firmware update script. r=Mic92 a=leifhelm Co-authored-by: Jakob Leifhelm <[email protected]>
2 parents 3ea1758 + cc94292 commit 70d5f55

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

starfive/visionfive/v2/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,31 @@ hardware.deviceTree.overlays = [{
8383
"${nixos-hardware}/starfive/visionfive/v2/visionfive-2-v1.2a-8GB.dts";
8484
}];
8585
```
86+
# Updating the bootloader
87+
## SD-Card
88+
Install the firmware update script
89+
``` nix
90+
environment.systemPackages = [
91+
(pkgs.callPackage
92+
"${nixos-hardware}/starfive/visionfive/v2/firmware.nix"
93+
{ }).updater-sd
94+
];
95+
```
96+
Then run as root
97+
``` sh
98+
visionfive2-firmware-update-sd
99+
```
100+
## SPI Flash
101+
Install the firmware update script
102+
``` nix
103+
environment.systemPackages = [
104+
(pkgs.callPackage
105+
"${nixos-hardware}/starfive/visionfive/v2/firmware.nix"
106+
{ }).updater-flash
107+
];
108+
```
109+
Then run as root
110+
``` sh
111+
visionfive2-firmware-update-flash
112+
```
113+

starfive/visionfive/v2/firmware.nix

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{ callPackage, pkgsBuildHost, runCommand, writeText, stdenv, dtc }:
1+
{ callPackage, pkgsBuildHost, runCommand, writeText, writeShellApplication
2+
, stdenv, dtc, mtdutils, coreutils }:
23
let
34
uboot = callPackage ./uboot.nix { };
45
opensbi = callPackage ./opensbi.nix {
@@ -36,7 +37,7 @@ let
3637
};
3738
};
3839
'';
39-
in {
40+
in rec {
4041
inherit opensbi uboot;
4142
spl = stdenv.mkDerivation {
4243
name = "starfive-visionfive2-spl";
@@ -58,4 +59,20 @@ in {
5859
${uboot}/mkimage -f ${its-file} -A riscv -O u-boot -T firmware $out/share/starfive-visionfive2/visionfive2_fw_payload.img
5960
'';
6061
};
62+
updater-flash = writeShellApplication {
63+
name = "visionfive2-firmware-update-flash";
64+
runtimeInputs = [ mtdutils ];
65+
text = ''
66+
flashcp -v ${spl}/share/starfive-visionfive2/spl.bin /dev/mtd0
67+
flashcp -v ${uboot-fit-image}/share/starfive-visionfive2/visionfive2_fw_payload.img /dev/mtd1
68+
'';
69+
};
70+
updater-sd = writeShellApplication {
71+
name = "visionfive2-firmware-update-sd";
72+
runtimeInputs = [ ];
73+
text = ''
74+
dd if=${spl}/share/starfive-visionfive2/spl.bin of=/dev/mmcblk0p1 conv=fsync
75+
dd if=${uboot-fit-image}/share/starfive-visionfive2/visionfive2_fw_payload.img of=/dev/mmcblk0p2 conv=fsync
76+
'';
77+
};
6178
}

starfive/visionfive/v2/sd-image.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{ config, pkgs, lib, modulesPath, ... }:
22

3-
let
4-
firmware = pkgs.callPackage ./firmware.nix { };
3+
let firmware = pkgs.callPackage ./firmware.nix { };
54
in {
65
imports = [
76
"${modulesPath}/profiles/base.nix"
@@ -48,4 +47,6 @@ in {
4847
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
4948
'';
5049
};
50+
51+
environment.systemPackages = [ firmware.updater-flash ];
5152
}

0 commit comments

Comments
 (0)