mirror of
https://github.com/nix-community/raspberry-pi-nix.git
synced 2025-11-09 12:06:02 +01:00
remove all DT imports
This commit is contained in:
parent
3027e45b9c
commit
9ba390ca28
10 changed files with 14 additions and 217 deletions
|
|
@ -25,6 +25,8 @@ in {
|
||||||
# disable firmware compression so that brcm firmware can be found at
|
# disable firmware compression so that brcm firmware can be found at
|
||||||
# the path expected by raspberry pi firmware/device tree
|
# the path expected by raspberry pi firmware/device tree
|
||||||
compressFirmwareXz = x: x;
|
compressFirmwareXz = x: x;
|
||||||
|
|
||||||
|
# A recent known working version of libcamera-apps
|
||||||
libcamera-apps = final.callPackage ./libcamera-apps.nix { };
|
libcamera-apps = final.callPackage ./libcamera-apps.nix { };
|
||||||
|
|
||||||
# provide generic rpi arm64 u-boot
|
# provide generic rpi arm64 u-boot
|
||||||
|
|
@ -37,14 +39,16 @@ in {
|
||||||
url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${version}.tar.bz2";
|
url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${version}.tar.bz2";
|
||||||
sha256 = "03wm651ix783s4idj223b0nm3r6jrdnrxs1ncs8s128g72nknhk9";
|
sha256 = "03wm651ix783s4idj223b0nm3r6jrdnrxs1ncs8s128g72nknhk9";
|
||||||
};
|
};
|
||||||
# In raspberry pi products the firmware manipulates the device
|
# In raspberry pi sbcs the firmware manipulates the device tree in
|
||||||
# tree in a variety of ways before handing it off to the linux
|
# a variety of ways before handing it off to the linux kernel. [1]
|
||||||
# kernel. Since we have installed u-boot in place of a linux
|
# Since we have installed u-boot in place of a linux kernel we may
|
||||||
# kernel we have the option of passing this device tree passed by
|
# pass the device tree passed by the firmware onto the kernel, or
|
||||||
# the firmware to the kernel, or providing our own. This
|
# we may provide the kernel with a device tree of our own. This
|
||||||
# configuration uses the device tree provided by firmware so that
|
# configuration uses the device tree provided by firmware so that
|
||||||
# we don't have to be aware of all manipulation done by the
|
# we don't have to be aware of all manipulation done by the
|
||||||
# firmware and attempt to mimic it.
|
# firmware and attempt to mimic it.
|
||||||
|
#
|
||||||
|
# 1. https://forums.raspberrypi.com/viewtopic.php?t=329799#p1974233
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
CONFIG_OF_HAS_PRIOR_STAGE=y
|
CONFIG_OF_HAS_PRIOR_STAGE=y
|
||||||
CONFIG_OF_BOARD=y
|
CONFIG_OF_BOARD=y
|
||||||
|
|
@ -54,6 +58,10 @@ in {
|
||||||
raspberrypifw = final.rpi-kernels.v5_15_87.firmware;
|
raspberrypifw = final.rpi-kernels.v5_15_87.firmware;
|
||||||
|
|
||||||
} // {
|
} // {
|
||||||
|
# rpi kernels and firmware are available at
|
||||||
|
# `pkgs.rpi-kernels.<VERSION>.{kernel,firmware,wireless-firmware}'.
|
||||||
|
#
|
||||||
|
# For example: `pkgs.rpi-kernels.v5_15_87.kernel'
|
||||||
rpi-kernels = rpi-kernels [
|
rpi-kernels = rpi-kernels [
|
||||||
{
|
{
|
||||||
version = "5.15.36";
|
version = "5.15.36";
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
rpi:
|
|
||||||
{ lib, pkgs, config, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [ rpi ];
|
|
||||||
hardware.raspberry-pi.deviceTree = {
|
|
||||||
base-dtb = "bcm2710-rpi-3-b-plus.dtb";
|
|
||||||
# u-boot expects bcm2837-rpi-3-b-plus.dtb for the 3b+ Rename the
|
|
||||||
# raspberry pi dtb to match mainline linux and satisfy u-boot.
|
|
||||||
postInstall = ''
|
|
||||||
mv $out/broadcom/bcm2710-rpi-3-b-plus.dtb $out/broadcom/bcm2837-rpi-3-b-plus.dtb
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
rpi:
|
|
||||||
{ lib, pkgs, config, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [ rpi ];
|
|
||||||
hardware.raspberry-pi.deviceTree.base-dtb = "bcm2711-rpi-4-b.dtb";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
rpi:
|
|
||||||
{ lib, pkgs, config, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [ rpi ];
|
|
||||||
hardware.raspberry-pi.deviceTree.base-dtb = "bcm2710-rpi-zero-2.dtb";
|
|
||||||
# u-boot expects bcm2837-rpi-zero-2.dtb for the zero 2 w (this is
|
|
||||||
# the device tree name in the upstream kernel), Rename the raspberry
|
|
||||||
# pi dtb to the expected name to satisfy u-boot.
|
|
||||||
hardware.raspberry-pi.deviceTree.postInstall = ''
|
|
||||||
mv $out/broadcom/bcm2710-rpi-zero-2.dtb $out/broadcom/bcm2837-rpi-zero-2.dtb
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
{ config, lib, pkgs, ... }:
|
|
||||||
|
|
||||||
let cfg = config.hardware.raspberry-pi.audio;
|
|
||||||
in {
|
|
||||||
options.hardware.raspberry-pi.audio = {
|
|
||||||
enable = lib.mkEnableOption "configuration for audio";
|
|
||||||
};
|
|
||||||
config = lib.mkIf cfg.enable {
|
|
||||||
hardware = {
|
|
||||||
raspberry-pi.deviceTree.base-dtb-params = [ "audio=on" ];
|
|
||||||
pulseaudio.configFile = lib.mkOverride 990
|
|
||||||
(pkgs.runCommand "default.pa" { } ''
|
|
||||||
sed 's/module-udev-detect$/module-udev-detect tsched=0/' ${config.hardware.pulseaudio.package}/etc/pulse/default.pa > $out
|
|
||||||
'');
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -2,14 +2,7 @@
|
||||||
{ lib, pkgs, config, ... }:
|
{ lib, pkgs, config, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [ ../sd-image ];
|
||||||
../sd-image
|
|
||||||
./device-tree.nix
|
|
||||||
./audio.nix
|
|
||||||
./i2c.nix
|
|
||||||
./i2s.nix
|
|
||||||
./modesetting.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
nixpkgs = { overlays = [ overlay ]; };
|
nixpkgs = { overlays = [ overlay ]; };
|
||||||
boot = {
|
boot = {
|
||||||
|
|
|
||||||
|
|
@ -1,102 +0,0 @@
|
||||||
{ config, lib, pkgs, ... }:
|
|
||||||
|
|
||||||
let cfg = config.hardware.raspberry-pi.deviceTree;
|
|
||||||
in {
|
|
||||||
options.hardware.raspberry-pi.deviceTree = {
|
|
||||||
base-dtb = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
example = "bcm2711-rpi-4-b.dtb";
|
|
||||||
description = "base dtb to apply";
|
|
||||||
};
|
|
||||||
base-dtb-params = lib.mkOption {
|
|
||||||
type = lib.types.listOf lib.types.string;
|
|
||||||
default = [ ];
|
|
||||||
example = [ "i2c1=on" "audio=on" ];
|
|
||||||
description = "parameters to pass to the base dtb";
|
|
||||||
};
|
|
||||||
dt-overlays = lib.mkOption {
|
|
||||||
type = with lib.types;
|
|
||||||
listOf (submodule {
|
|
||||||
options = {
|
|
||||||
overlay = lib.mkOption { type = oneOf [ str path ]; };
|
|
||||||
args = lib.mkOption {
|
|
||||||
type = listOf str;
|
|
||||||
default = [ ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
default = [ ];
|
|
||||||
example = [{
|
|
||||||
overlay = "vc4-fkms-v3d";
|
|
||||||
args = [ "cma-512" ];
|
|
||||||
}];
|
|
||||||
description = "dtb overlays to apply";
|
|
||||||
};
|
|
||||||
postInstall = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "";
|
|
||||||
description = "bash command to run after building dtb";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
config = {
|
|
||||||
hardware = {
|
|
||||||
deviceTree = {
|
|
||||||
enable = true;
|
|
||||||
filter = cfg.base-dtb;
|
|
||||||
package = let
|
|
||||||
dtbsWithSymbols = pkgs.stdenv.mkDerivation {
|
|
||||||
name = "dtbs-with-symbols";
|
|
||||||
inherit (config.boot.kernelPackages.kernel)
|
|
||||||
src nativeBuildInputs depsBuildBuild;
|
|
||||||
patches = map (patch: patch.patch)
|
|
||||||
config.boot.kernelPackages.kernel.kernelPatches;
|
|
||||||
buildPhase = ''
|
|
||||||
patchShebangs scripts/*
|
|
||||||
substituteInPlace scripts/Makefile.lib \
|
|
||||||
--replace 'DTC_FLAGS += $(DTC_FLAGS_$(basetarget))' 'DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) -@'
|
|
||||||
make ${pkgs.stdenv.hostPlatform.linux-kernel.baseConfig} ARCH="${pkgs.stdenv.hostPlatform.linuxArch}"
|
|
||||||
make dtbs ARCH="${pkgs.stdenv.hostPlatform.linuxArch}"
|
|
||||||
'';
|
|
||||||
installPhase = ''
|
|
||||||
make dtbs_install INSTALL_DTBS_PATH=$out/dtbs ARCH="${pkgs.stdenv.hostPlatform.linuxArch}"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
compiled-overlays = map (x:
|
|
||||||
let
|
|
||||||
overlay-file = if builtins.isPath x.overlay then
|
|
||||||
pkgs.runCommand "overlay.dtbo" {
|
|
||||||
buildInputs = with pkgs; [ dtc ];
|
|
||||||
} "dtc -I dts -O dtb -o $out ${x.overlay}"
|
|
||||||
else
|
|
||||||
"${config.boot.kernelPackages.kernel}/dtbs/overlays/${x.overlay}.dtbo";
|
|
||||||
in x // { overlay = overlay-file; }) cfg.dt-overlays;
|
|
||||||
in lib.mkForce (pkgs.runCommand "device-tree-overlays" {
|
|
||||||
buildInputs = with pkgs; [ findutils libraspberrypi ];
|
|
||||||
} ''
|
|
||||||
cd ${dtbsWithSymbols}/dtbs
|
|
||||||
for dtb in $(find . -type f -name "${config.hardware.deviceTree.filter}")
|
|
||||||
do
|
|
||||||
install -D $dtb $out/$dtb
|
|
||||||
|
|
||||||
${
|
|
||||||
lib.concatMapStrings (param: ''
|
|
||||||
dtmerge -d $out/$dtb{,-merged} - ${param}
|
|
||||||
mv $out/$dtb{-merged,}
|
|
||||||
'') cfg.base-dtb-params
|
|
||||||
}
|
|
||||||
|
|
||||||
${
|
|
||||||
lib.concatMapStrings (x: ''
|
|
||||||
dtmerge -d $out/$dtb{,-merged} ${x.overlay} ${
|
|
||||||
builtins.concatStringsSep " " x.args
|
|
||||||
}
|
|
||||||
mv $out/$dtb{-merged,}
|
|
||||||
'') compiled-overlays
|
|
||||||
}
|
|
||||||
done
|
|
||||||
${cfg.postInstall}
|
|
||||||
'');
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
14
rpi/i2c.nix
14
rpi/i2c.nix
|
|
@ -1,14 +0,0 @@
|
||||||
{ config, lib, pkgs, ... }:
|
|
||||||
|
|
||||||
let cfg = config.hardware.raspberry-pi.i2c;
|
|
||||||
in {
|
|
||||||
options.hardware.raspberry-pi.i2c = {
|
|
||||||
enable = lib.mkEnableOption "configuration for i2c";
|
|
||||||
};
|
|
||||||
config = lib.mkIf cfg.enable {
|
|
||||||
hardware = {
|
|
||||||
raspberry-pi.deviceTree.base-dtb-params = [ "i2c1=on" ];
|
|
||||||
i2c.enable = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
13
rpi/i2s.nix
13
rpi/i2s.nix
|
|
@ -1,13 +0,0 @@
|
||||||
{ config, lib, pkgs, ... }:
|
|
||||||
|
|
||||||
let cfg = config.hardware.raspberry-pi.i2s;
|
|
||||||
in {
|
|
||||||
options.hardware.raspberry-pi.i2s = {
|
|
||||||
enable = lib.mkEnableOption "configuration for i2s";
|
|
||||||
};
|
|
||||||
config = lib.mkIf cfg.enable {
|
|
||||||
hardware = {
|
|
||||||
raspberry-pi.deviceTree.base-dtb-params = [ "i2s=on" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
{ config, lib, pkgs, ... }:
|
|
||||||
|
|
||||||
let cfg = config.hardware.raspberry-pi.fkms-3d;
|
|
||||||
in {
|
|
||||||
options.hardware.raspberry-pi.fkms-3d = {
|
|
||||||
enable = lib.mkEnableOption "Enable modesetting through fkms-3d";
|
|
||||||
};
|
|
||||||
config = lib.mkIf cfg.enable {
|
|
||||||
hardware = {
|
|
||||||
raspberry-pi.deviceTree.dt-overlays = [
|
|
||||||
{
|
|
||||||
overlay = "cma";
|
|
||||||
args = [ ];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
overlay = "vc4-fkms-v3d";
|
|
||||||
args = [ ];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
services.xserver.videoDrivers = lib.mkBefore [ "modesetting" "fbdev" ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue