2024-09-19 14:19:46 +00:00
|
|
|
{ lib, stdenv, stdenvNoCC, dtc, writers, python3 }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
{
|
2023-10-09 19:29:22 +00:00
|
|
|
# Compile single Device Tree overlay source
|
|
|
|
# file (.dts) into its compiled variant (.dtb)
|
|
|
|
compileDTS = ({
|
|
|
|
name,
|
|
|
|
dtsFile,
|
|
|
|
includePaths ? [],
|
|
|
|
extraPreprocessorFlags ? []
|
|
|
|
}: stdenv.mkDerivation {
|
|
|
|
inherit name;
|
|
|
|
|
|
|
|
nativeBuildInputs = [ dtc ];
|
|
|
|
|
|
|
|
buildCommand =
|
|
|
|
let
|
|
|
|
includeFlagsStr = lib.concatMapStringsSep " " (includePath: "-I${includePath}") includePaths;
|
|
|
|
extraPreprocessorFlagsStr = lib.concatStringsSep " " extraPreprocessorFlags;
|
|
|
|
in
|
|
|
|
''
|
|
|
|
$CC -E -nostdinc ${includeFlagsStr} -undef -D__DTS__ -x assembler-with-cpp ${extraPreprocessorFlagsStr} ${dtsFile} | \
|
|
|
|
dtc -I dts -O dtb -@ -o $out
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
applyOverlays = (base: overlays': stdenvNoCC.mkDerivation {
|
2020-04-24 23:36:52 +00:00
|
|
|
name = "device-tree-overlays";
|
2024-09-19 14:19:46 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
(python3.pythonOnBuildForHost.withPackages(ps: [ps.libfdt]))
|
|
|
|
];
|
|
|
|
buildCommand = ''
|
|
|
|
python ${./apply_overlays.py} --source ${base} --destination $out --overlays ${writers.writeJSON "overlays.json" overlays'}
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
});
|
|
|
|
}
|