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