Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@
fileSystems."/boot/EFI" = {
device = "/dev/disk/by-label/ESP";
};
firmwareci.base = {
sshAccess = {
user = "root";
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKcSD9iHnCrJXkSt7aGSnfL0tVHUm+x6/EDr/FchmBfu";
firmwareci = {
base = {
sshAccess = {
user = "root";
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKcSD9iHnCrJXkSt7aGSnfL0tVHUm+x6/EDr/FchmBfu";
};
};
amdDebug.enable = true;
};
};

Expand All @@ -49,6 +52,7 @@
version = "6.12.36";
sha256 = "sha256-ShaK7S3lqBqt2QuisVOGCpjZm/w0ZRk24X8Y5U8Buow==";
};
amdDebug.enable = true;
};
};

Expand Down
48 changes: 36 additions & 12 deletions modules/base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ with lib;

let
cfg = config.firmwareci.base;
amdDebugCfg = config.firmwareci.amdDebug;

chipsecKernelVersion = "6.12.36";
kernelPackages = pkgs.linuxPackagesFor (pkgs.linux_6_12.override {
Expand All @@ -23,6 +24,12 @@ let
withDriver = true;
};

amd-debug-tools = pkgs.python3Packages.callPackage ../pkgs/amd-debug-tools/default.nix { };

s0ix-selftest-tool = pkgs.callPackage ../pkgs/s0ix-selftest-tool/default.nix {
linuxPackages = config.boot.kernelPackages;
};

in
{
options.firmwareci.base = {
Expand Down Expand Up @@ -68,7 +75,14 @@ in
default = true;
description = "Include the default tools package in the image.";
};
};

options.firmwareci.amdDebug = {
enable = mkOption {
type = types.bool;
default = false;
description = "Enable AMD debug tools (amd-s2idle, amd-bios, amd-pstate, amd-ttm) with ethtool and edid-decode.";
};
};

config = {
Expand All @@ -92,32 +106,42 @@ in
dmidecode
fwts
sbctl
s0ix-selftest-tool
config.boot.kernelPackages.turbostat
stress-ng
sysbench
bc
powertop
]
++ [ s0ix-selftest-tool ]
++ lib.optional cfg.includeChipSec chipsec
++ lib.optional cfg.includeDefaultTools (pkgs.callPackage ../pkgs/default-tools/default.nix { });
++ lib.optional cfg.includeDefaultTools (pkgs.callPackage ../pkgs/default-tools/default.nix { })
++ lib.optionals amdDebugCfg.enable [
amd-debug-tools
ethtool
edid-decode
];

hardware.enableAllFirmware = cfg.enableAllFirmware;

services.openssh = mkIf (cfg.sshAccess.user != "" && cfg.sshAccess.key != "") {
enable = true;
settings.PermitRootLogin = if cfg.sshAccess.user == "root" then "yes" else "no";
services = {
openssh = mkIf (cfg.sshAccess.user != "" && cfg.sshAccess.key != "") {
enable = true;
settings.PermitRootLogin = if cfg.sshAccess.user == "root" then "yes" else "no";
};

fwupd = mkIf cfg.enableFwupd {
enable = true;
daemonSettings = lib.mkForce {
EspLocation = "/boot/EFI";
};
};

# Enable D-Bus system daemon for AMD debug tools
dbus.enable = mkIf amdDebugCfg.enable true;
};

users.users.${cfg.sshAccess.user} = mkIf (cfg.sshAccess.user != "" && cfg.sshAccess.key != "") {
openssh.authorizedKeys.keys = [ cfg.sshAccess.key ];
};

services.fwupd = mkIf cfg.enableFwupd {
enable = true;
daemonSettings = lib.mkForce {
EspLocation = "/boot/EFI";
};
};
};
}
66 changes: 66 additions & 0 deletions pkgs/amd-debug-tools/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, setuptools
, dbus-fast
, dbus-python
, pyudev
, packaging
, pandas
, jinja2
, tabulate
, seaborn
, matplotlib
,
}:

buildPythonPackage rec {
pname = "amd-debug-tools";
version = "0.2.9";
format = "pyproject";

src = fetchFromGitHub {
owner = "superm1";
repo = "amd-debug-tools";
rev = version;
sha256 = "sha256-RrXo1045M+2D/xycO74ExeFhqBJL9mE6OPy0MSLmEFc=";
};

build-system = [
setuptools
];

postPatch = ''
# Replace dynamic versioning with static version
substituteInPlace pyproject.toml \
--replace-fail 'dynamic = ["version"]' 'version = "${version}"' \
--replace-fail ', "setuptools-git-versioning>=2.0,<3"' ""

# Remove the git-versioning configuration section
sed -i '/\[tool\.setuptools-git-versioning\]/,/^$/d' pyproject.toml
'';

dependencies = [
dbus-fast
dbus-python
pyudev
packaging
pandas
jinja2
tabulate
seaborn
matplotlib
];

# Tests require additional setup
doCheck = false;

# Skip runtime dependency check (cysystemd is optional)
dontCheckRuntimeDeps = true;

meta = with lib; {
description = "AMD debug tools for firmware development";
homepage = "https://github.com/superm1/amd-debug-tools";
license = licenses.mit;
Comment thread
RiSKeD marked this conversation as resolved.
Comment thread
RiSKeD marked this conversation as resolved.
};
}
73 changes: 73 additions & 0 deletions pkgs/s0ix-selftest-tool/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{ acpica-tools
, bc
, coreutils
, fetchFromGitHub
, gawk
, gnugrep
, gnused
, linuxPackages
, lib
, pciutils
, powertop
, makeWrapper
, stdenv
, unstableGitUpdater
, util-linux
, xorg
, xxd
,
}:

let
deps = lib.makeBinPath [
acpica-tools
bc
coreutils
gawk
gnugrep
gnused
linuxPackages.turbostat
pciutils
powertop
util-linux
xorg.xset
xxd
];
in
stdenv.mkDerivation {
pname = "s0ix-selftest-tool";
version = "0-unstable-2024-09-22";

src = fetchFromGitHub {
owner = "intel";
repo = "S0ixSelftestTool";
rev = "2707d34bf8130feb21e5902efbdecbd2dc915148";
sha256 = "sha256-2quAiVYt6elULJTqMFhnciNWork6ViTWcPTRJQfvu+I=";
};

postPatch = ''
substituteInPlace s0ix-selftest-tool.sh --replace-fail '"$DIR"/turbostat' 'turbostat'
'';

nativeBuildInputs = [ makeWrapper ];
dontConfigure = true;
dontBuild = true;

installPhase = ''
runHook preInstall
install -Dm555 s0ix-selftest-tool.sh "$out/bin/s0ix-selftest-tool"
wrapProgram "$out/bin/s0ix-selftest-tool" --prefix PATH : ${deps}
runHook postInstall
'';

passthru.updateScript = unstableGitUpdater { };

meta = with lib; {
homepage = "https://github.com/intel/S0ixSelftestTool";
description = "Tool for testing the S2idle path CPU Package C-state and S0ix failures";
license = licenses.gpl2Only;
platforms = platforms.linux;
maintainers = with maintainers; [ adamcstephens ];
mainProgram = "s0ix-selftest-tool";
};
}
Loading