-
Notifications
You must be signed in to change notification settings - Fork 1
/
boot-bin.nix
96 lines (91 loc) · 3.67 KB
/
boot-bin.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{ config, pkgs, lib, ... }:
{
options.hardware.zynq = {
platform = lib.mkOption {
type = lib.types.enum [ "zynq" "zynqmp" ];
description = lib.mdDoc ''
Whether you use Zynq 7000 or Zynq UltraScale+ MPSoC.
'';
};
dtb = lib.mkOption {
type = lib.types.path;
example = lib.literalExpression "./firmware/system.dtb";
description = lib.mdDoc ''
Generation for device tree from XSA file in Nix is not implemented yet.
You need to provide the path to system.dtb generated by Vitis.
Can be semi-automated using {command}`./vitisgenfw.tcl`
Nixos-xlnx uses this for {option}`hardware.deviceTree.dtbSource`.
Note you can still use {option}`hardware.deviceTree.overlays` to
update your device tree configurations.
'';
};
bitstream = lib.mkOption {
type = lib.types.path;
example = lib.literalExpression "./firmware/system.bit";
description = lib.mdDoc ''
Generation for bitstream from XSA file in Nix is not implemented yet.
You need to provide the path to system.bit generated by Vitis.
Can be semi-automated using {command}`./vitisgenfw.tcl`
'';
};
fsbl = lib.mkOption {
type = lib.types.path;
example = lib.literalExpression "./firmware/fsbl_a53.elf";
description = lib.mdDoc ''
Generation for First Stage Boot Loader from XSA file in Nix is not implemented yet.
You need to provide the path to fsbl_a53.elf generated by Vitis.
Can be semi-automated using {command}`./vitisgenfw.tcl`
'';
};
pmufw = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
example = lib.literalExpression "./firmware/pmufw.elf";
description = lib.mdDoc ''
Generation for Zynq MPSoC Platform Management Unit Firmware from XSA file in Nix is not implemented yet.
You need to provide the path to pmufw.elf generated by Vitis.
Can be semi-automated using {command}`./vitisgenfw.tcl`
'';
};
boot-bin = lib.mkOption {
type = lib.types.path;
default = let
dtb = "${config.hardware.deviceTree.package}/system.dtb";
bif = {
zynqmp = ''
the_ROM_image: {
[bootloader, destination_cpu=a53-0] ${config.hardware.zynq.fsbl}
[pmufw_image] ${config.hardware.zynq.pmufw}
[destination_device=pl] ${config.hardware.zynq.bitstream}
[destination_cpu=a53-0, exception_level=el-3, trustzone] ${pkgs.armTrustedFirmwareZynqMP}/bl31.elf
[destination_cpu=a53-0, load=0x00100000] ${dtb}
[destination_cpu=a53-0, exception_level=el-2] ${pkgs.ubootZynqMP}/u-boot.elf
}
'';
zynq = ''
the_ROM_image: {
[bootloader] ${config.hardware.zynq.fsbl}
${config.hardware.zynq.bitstream}
${pkgs.ubootZynq}/u-boot.elf
[load=0x00100000] ${dtb}
}
'';
}.${config.hardware.zynq.platform};
in pkgs.runCommand "BOOT.BIN" { nativeBuildInputs = [ pkgs.xilinx-bootgen_2022_2 ]; } ''
bootgen -image ${pkgs.writeText "bootgen.bif" bif} -arch ${config.hardware.zynq.platform} -w -o $out
'';
description = lib.mdDoc ''
You can build BOOT.BIN without building the whole system using
{command}`nix build .#nixosConfigurations.<hostname>.config.hardware.zynq.boot-bin`
'';
};
};
config = {
assertions = [
{
assertion = config.hardware.zynq.platform == "zynqmp" -> config.hardware.zynq.pmufw != null;
message = "hardware.zynq.pmufw is not optional on ZynqMP.";
}
];
};
}