mirror of
https://github.com/NixOS/nixos-hardware
synced 2025-01-25 18:25:00 +01:00
starfive visionfive2: allow uboot and opensbi source overrides
This commit is contained in:
parent
a2861aa696
commit
7eab0aa0b7
4 changed files with 57 additions and 31 deletions
|
@ -5,6 +5,10 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
|
imports = [
|
||||||
|
./firmware.nix
|
||||||
|
];
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
consoleLogLevel = lib.mkDefault 7;
|
consoleLogLevel = lib.mkDefault 7;
|
||||||
# Switch to default as soon they reach >= 6.11
|
# Switch to default as soon they reach >= 6.11
|
||||||
|
|
|
@ -1,26 +1,50 @@
|
||||||
{ callPackage
|
{ config, pkgs, lib, ... }:
|
||||||
, writeShellApplication
|
let
|
||||||
, stdenv
|
cfg = config.hardware.visionfive2;
|
||||||
, mtdutils
|
in
|
||||||
}:
|
{
|
||||||
|
options = {
|
||||||
rec {
|
hardware.visionfive2 = {
|
||||||
opensbi = callPackage ./opensbi.nix { };
|
opensbi.src = lib.mkOption {
|
||||||
uboot = callPackage ./uboot.nix { inherit opensbi; };
|
description = "VisionFive2 OpenSBI source";
|
||||||
updater-flash = writeShellApplication {
|
type = lib.types.nullOr lib.types.package;
|
||||||
name = "visionfive2-firmware-update-flash";
|
default = null;
|
||||||
runtimeInputs = [ mtdutils ];
|
};
|
||||||
text = ''
|
uboot.src = lib.mkOption {
|
||||||
flashcp -v ${uboot}/u-boot-spl.bin.normal.out /dev/mtd0
|
description = "VisionFive2 U-boot source";
|
||||||
flashcp -v ${uboot}/u-boot.itb /dev/mtd2
|
type = lib.types.nullOr lib.types.package;
|
||||||
'';
|
default = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
updater-sd = writeShellApplication {
|
|
||||||
name = "visionfive2-firmware-update-sd";
|
config = {
|
||||||
runtimeInputs = [ ];
|
system.build = {
|
||||||
text = ''
|
opensbi = (pkgs.callPackage ./opensbi.nix {}).overrideAttrs (f: p: {
|
||||||
dd if=${uboot}/u-boot-spl.bin.normal.out of=/dev/mmcblk0p1 conv=fsync
|
src = if cfg.opensbi.src != null then cfg.opensbi.src else p.src;
|
||||||
dd if=${uboot}/u-boot.itb of=/dev/mmcblk0p2 conv=fsync
|
});
|
||||||
'';
|
|
||||||
|
uboot = (pkgs.callPackage ./uboot.nix { inherit (config.system.build) opensbi; }).overrideAttrs (f: p: {
|
||||||
|
src = if cfg.uboot.src != null then cfg.uboot.src else p.src;
|
||||||
|
});
|
||||||
|
|
||||||
|
updater-flash = pkgs.writeShellApplication {
|
||||||
|
name = "visionfive2-firmware-update-flash";
|
||||||
|
runtimeInputs = [ pkgs.mtdutils ];
|
||||||
|
text = ''
|
||||||
|
flashcp -v ${config.system.build.uboot}/u-boot-spl.bin.normal.out /dev/mtd0
|
||||||
|
flashcp -v ${config.system.build.uboot}/u-boot.itb /dev/mtd2
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
updater-sd = pkgs.writeShellApplication {
|
||||||
|
name = "visionfive2-firmware-update-sd";
|
||||||
|
runtimeInputs = [ ];
|
||||||
|
text = ''
|
||||||
|
dd if=${config.system.build.uboot}/u-boot-spl.bin.normal.out of=/dev/mmcblk0p1 conv=fsync
|
||||||
|
dd if=${config.system.build.uboot}/u-boot.itb of=/dev/mmcblk0p2 conv=fsync
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
{ config, pkgs, modulesPath, ... }:
|
{ config, pkgs, modulesPath, ... }:
|
||||||
|
{
|
||||||
let firmware = pkgs.callPackage ./firmware.nix { };
|
|
||||||
in {
|
|
||||||
imports = [
|
imports = [
|
||||||
"${modulesPath}/profiles/base.nix"
|
"${modulesPath}/profiles/base.nix"
|
||||||
"${modulesPath}/installer/sd-card/sd-image.nix"
|
"${modulesPath}/installer/sd-card/sd-image.nix"
|
||||||
|
@ -36,10 +34,10 @@ in {
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
eval $(partx $img -o START,SECTORS --nr 1 --pairs)
|
eval $(partx $img -o START,SECTORS --nr 1 --pairs)
|
||||||
dd conv=notrunc if=${firmware.uboot}/u-boot-spl.bin.normal.out of=$img seek=$START count=$SECTORS
|
dd conv=notrunc if=${config.system.build.uboot}/u-boot-spl.bin.normal.out of=$img seek=$START count=$SECTORS
|
||||||
|
|
||||||
eval $(partx $img -o START,SECTORS --nr 2 --pairs)
|
eval $(partx $img -o START,SECTORS --nr 2 --pairs)
|
||||||
dd conv=notrunc if=${firmware.uboot}/u-boot.itb of=$img seek=$START count=$SECTORS
|
dd conv=notrunc if=${config.system.build.uboot}/u-boot.itb of=$img seek=$START count=$SECTORS
|
||||||
'';
|
'';
|
||||||
|
|
||||||
populateRootCommands = ''
|
populateRootCommands = ''
|
||||||
|
@ -48,5 +46,5 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = [ firmware.updater-flash ];
|
environment.systemPackages = [ config.system.build.updater-flash ];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{ stdenv, fetchFromGitHub }:
|
{ stdenv, fetchFromGitHub }:
|
||||||
|
|
||||||
stdenv.mkDerivation rec{
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "spi_tool";
|
pname = "spi_tool";
|
||||||
version = "0x01010101";
|
version = "0x01010101";
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
|
@ -15,4 +15,4 @@ stdenv.mkDerivation rec{
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp spl_tool $out/bin
|
cp spl_tool $out/bin
|
||||||
'';
|
'';
|
||||||
}
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue