reformat code
This commit is contained in:
parent
9670876842
commit
f0748371bf
@ -3,6 +3,7 @@ paramsPerOverlayMap: {
|
||||
stdenvNoCC,
|
||||
dtc,
|
||||
libraspberrypi,
|
||||
pkgs,
|
||||
}:
|
||||
with lib; (base: overlays':
|
||||
stdenvNoCC.mkDerivation {
|
||||
@ -10,21 +11,28 @@ with lib; (base: overlays':
|
||||
nativeBuildInputs = [dtc libraspberrypi];
|
||||
buildCommand = let
|
||||
overlays = toList overlays';
|
||||
baseDTBs =
|
||||
map (x: (builtins.unsafeDiscardStringContext (lib.removeSuffix ".dtb" (builtins.baseNameOf x))))
|
||||
(lib.filesystem.listFilesRecursive "${base}");
|
||||
in ''
|
||||
mkdir -p $out
|
||||
cd "${base}"
|
||||
find . -type f -name '*.dtb' -print0 \
|
||||
| xargs -0 cp -v --no-preserve=mode --target-directory "$out" --parents
|
||||
|
||||
for dtb in $(find "$out" -type f -name '*.dtb'); do
|
||||
|
||||
echo -n "Applying params to $(basename "$dtb")... "
|
||||
echo ${concatStringsSep " " (mapAttrsToList (name: value: "${name}=${value}") (paramsPerOverlayMap.bcm2711-rpi-cm4 or {}))}
|
||||
echo baseDTBs: ${toString baseDTBs}
|
||||
|
||||
${flip (concatMapStringsSep "\n") baseDTBs (o: ''
|
||||
dtb=$(find "$out" -type f -name '${o}.dtb')
|
||||
echo -n "Applying params to ${o}.dtb... "
|
||||
echo -n ${concatStringsSep " " (mapAttrsToList (name: value: "${name}=${value}") (paramsPerOverlayMap.${o} or {}))} " "
|
||||
mv "$dtb"{,.in}
|
||||
dtmerge "$dtb.in" "$dtb" - ${concatStringsSep " " (mapAttrsToList (name: value: "${name}=${value}") (paramsPerOverlayMap.bcm2711-rpi-cm4 or {}))}
|
||||
dtmerge "$dtb.in" "$dtb" - ${concatStringsSep " " (mapAttrsToList (name: value: "${name}=${value}") (paramsPerOverlayMap.${o} or {}))}
|
||||
rm "$dtb.in"
|
||||
echo "ok"
|
||||
'')}
|
||||
|
||||
for dtb in $(find "$out" -type f -name '*.dtb'); do
|
||||
dtbCompat=$(fdtget -t s "$dtb" / compatible 2>/dev/null || true)
|
||||
# skip files without `compatible` string
|
||||
test -z "$dtbCompat" && continue
|
||||
@ -59,6 +67,6 @@ with lib; (base: overlays':
|
||||
rm "$dtb.in" "$dtboWithExt"
|
||||
fi
|
||||
'')}
|
||||
|
||||
done'';
|
||||
done
|
||||
'';
|
||||
})
|
@ -10,5 +10,6 @@
|
||||
./dtb-cpi-bluetooth.nix
|
||||
./dtb-vc4-kms-v3d.nix
|
||||
./dtb-cpi-spi4.nix
|
||||
./dtb-rpi4-disable-pwrled.nix
|
||||
];
|
||||
}
|
30
raspberry-pi/overlays/dtb-rpi4-disable-pwrled.nix
Normal file
30
raspberry-pi/overlays/dtb-rpi4-disable-pwrled.nix
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkIf mkMerge mkOption types;
|
||||
cfg = config.hardware.raspberry-pi."4".overlays.rpi4-disable-pwrled;
|
||||
in {
|
||||
options.hardware.raspberry-pi."4".overlays.rpi4-disable-pwrled = {
|
||||
enable = mkEnableOption ''overlay enable'';
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
default = "rpi4-disable-pwrled";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkMerge [
|
||||
(mkIf cfg.enable {
|
||||
hardware.deviceTree = {
|
||||
overlays = [
|
||||
{
|
||||
name = "${cfg.name}";
|
||||
filter = "bcm2711-rpi-4-b.dtb";
|
||||
dtsFile = ./source/rpi4-disable-pwrled.dts;
|
||||
}
|
||||
];
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
12
raspberry-pi/overlays/source/rpi4-disable-pwrled.dts
Normal file
12
raspberry-pi/overlays/source/rpi4-disable-pwrled.dts
Normal file
@ -0,0 +1,12 @@
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
/{
|
||||
compatible = "raspberrypi,4-model-b";
|
||||
fragment@0 {
|
||||
target = <&led_pwr>;
|
||||
__overlay__ {
|
||||
gpios = <&expgpio 2 0>; /* first two values copied from bcm2711-rpi-4-b.dts */
|
||||
linux,default-trigger = "default-on";
|
||||
};
|
||||
};
|
||||
};
|
@ -1,5 +1,5 @@
|
||||
{pkgs, ...}: let
|
||||
rpi-utils = pkgs.callPackage ./packages/rpi-utils {};
|
||||
rpi-utils = pkgs.callPackage ../raspberry-pi/packages/rpi-utils {};
|
||||
audio-patch = pkgs.writeText "audio_3.5_patch.py" ''
|
||||
import os
|
||||
import time
|
@ -1,35 +1,37 @@
|
||||
{
|
||||
pkgs,
|
||||
nixos-hardware,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
rpi-utils = pkgs.callPackage ./packages/rpi-utils {};
|
||||
inherit (lib) mkDefault;
|
||||
rpi-utils = pkgs.callPackage ../raspberry-pi/packages/rpi-utils {};
|
||||
in {
|
||||
imports =
|
||||
[nixos-hardware.nixosModules.raspberry-pi-4]
|
||||
++ [./kernel]
|
||||
++ [./overlays]
|
||||
++ [./packages/overlays]
|
||||
++ [./audio-patch.nix];
|
||||
++ [../raspberry-pi/overlays]
|
||||
++ [../raspberry-pi/apply-overlays]
|
||||
++ [./audio.nix];
|
||||
|
||||
config = {
|
||||
environment.systemPackages = [rpi-utils];
|
||||
|
||||
hardware.raspberry-pi."4" = {
|
||||
xhci.enable = false;
|
||||
dwc2.enable = true;
|
||||
dwc2.dr_mode = "host";
|
||||
xhci.enable = mkDefault false;
|
||||
dwc2.enable = mkDefault true;
|
||||
dwc2.dr_mode = mkDefault "host";
|
||||
overlays = {
|
||||
cpu-revision.enable = true;
|
||||
audremap.enable = true;
|
||||
vc4-kms-v3d.enable = true;
|
||||
disable-pcie.enable = true;
|
||||
disable-genet.enable = true;
|
||||
panel-uc.enable = true;
|
||||
cpi-pmu.enable = true;
|
||||
cpi-i2c1.enable = false;
|
||||
cpi-spi4.enable = false;
|
||||
cpi-bluetooth.enable = true;
|
||||
cpu-revision.enable = mkDefault true;
|
||||
audremap.enable = mkDefault true;
|
||||
vc4-kms-v3d.enable = mkDefault true;
|
||||
disable-pcie.enable = mkDefault true;
|
||||
disable-genet.enable = mkDefault true;
|
||||
panel-uc.enable = mkDefault true;
|
||||
cpi-pmu.enable = mkDefault true;
|
||||
cpi-i2c1.enable = mkDefault false;
|
||||
cpi-spi4.enable = mkDefault false;
|
||||
cpi-bluetooth.enable = mkDefault true;
|
||||
};
|
||||
};
|
||||
|
||||
@ -40,25 +42,25 @@ in {
|
||||
{
|
||||
name = "bcm2711-rpi-cm4";
|
||||
params = {
|
||||
# ant2 = "on";
|
||||
audio = "on";
|
||||
spi = "off";
|
||||
i2c_arm = "on";
|
||||
ant2 = mkDefault "off";
|
||||
audio = mkDefault "on";
|
||||
spi = mkDefault "off";
|
||||
i2c_arm = mkDefault "on";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "cpu-revision";
|
||||
params = {cm4-8 = "on";};
|
||||
params = {cm4-8 = mkDefault "on";};
|
||||
}
|
||||
{
|
||||
name = "audremap";
|
||||
params = {pins_12_13 = "on";};
|
||||
params = {pins_12_13 = mkDefault "on";};
|
||||
}
|
||||
{
|
||||
name = "vc4-kms-v3d";
|
||||
params = {
|
||||
cma-384 = "on";
|
||||
nohdmi1 = "on";
|
||||
cma-384 = mkDefault "on";
|
||||
nohdmi1 = mkDefault "on";
|
||||
};
|
||||
}
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user