diff --git a/raspberry-pi/2/README.org b/raspberry-pi/2/README.org deleted file mode 100644 index 56384537..00000000 --- a/raspberry-pi/2/README.org +++ /dev/null @@ -1,10 +0,0 @@ -** Status - -The code in master as of June 2015 should be able to prepare a bootable NixOS -for Raspberry PI 2. - -There are still some drawbacks: - -NixOS does not provide a /boot/config.txt (the FAT32 partition). Making NixOS -work in the Raspberry PI 2 is mainly the result of the recent work of ambro718, -Dezgeg and viric (#nixos@irc.freenode.net). diff --git a/raspberry-pi/4/digi-amp-plus.nix b/raspberry-pi/4/digi-amp-plus.nix index f9a3a5b3..d2d37f23 100644 --- a/raspberry-pi/4/digi-amp-plus.nix +++ b/raspberry-pi/4/digi-amp-plus.nix @@ -1,91 +1,42 @@ -{ config, lib, ... }: +{ lib, ... }: -let - cfg = config.hardware.raspberry-pi."4".digi-amp-plus; -in { - options.hardware = { - raspberry-pi."4".digi-amp-plus = { - enable = lib.mkEnableOption "support for the IQaudIO DigiAMP+ Hat"; + imports = [ + (lib.mkRemovedOptionModule + [ + "hardware" + "raspberry-pi" + "4" + "digi-amp-plus" + ] + '' + Use the stock iqaudio-dacplus firmware overlay instead: - unmuteAmp = lib.mkOption { - type = lib.types.bool; - default = false; - description = '' - Whether to "one-shot" unmute when kernel module first loads. - ''; - }; + { + boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = + false; - autoMuteAmp = lib.mkOption { - type = lib.types.bool; - default = true; - description = '' - Unmute the amp when an ALSA device is opened by a client. Mute, with a five-second delay when the ALSA device is closed. - (Reopening the device within the five-second close window will cancel mute.) - ''; - }; - }; - }; - - config = lib.mkIf cfg.enable { - hardware.raspberry-pi."4".apply-overlays-dtmerge.enable = lib.mkDefault true; - - hardware.deviceTree = { - overlays = [ - # Adapted from to: https://github.com/raspberrypi/linux/blob/3ed6d34d53e94ecbebc64c8fa3d1b6d3c41db8fb/arch/arm/boot/dts/overlays/iqaudio-dacplus-overlay.dts - # changes: - # - modified top-level "compatible" field from bcm2835 to bcm2711 - # - s/i2s_clk_producer/i2s/ (name on bcm2711 platform) - { - name = "iqaudio-digiampplus-overlay"; - dtsText = '' - /dts-v1/; - /plugin/; - - / { - compatible = "brcm,bcm2711"; - - fragment@0 { - target = <&i2s>; - __overlay__ { - status = "okay"; + hardware.raspberry-pi.configtxt.deviceTreeOverlays.pi4 = [ + { + iqaudio-dacplus = { + auto_mute_amp = true; + unmute_amp = false; }; - }; + } + ]; + } - fragment@1 { - target = <&i2c1>; - __overlay__ { - #address-cells = <1>; - #size-cells = <0>; - status = "okay"; + Keep the old boolean values. Map autoMuteAmp to auto_mute_amp and + unmuteAmp to unmute_amp. - pcm5122@4c { - #sound-dai-cells = <0>; - compatible = "ti,pcm5122"; - reg = <0x4c>; - AVDD-supply = <&vdd_3v3_reg>; - DVDD-supply = <&vdd_3v3_reg>; - CPVDD-supply = <&vdd_3v3_reg>; - status = "okay"; - }; - }; - }; + On a running system, set hardware.raspberry-pi.firmware.enable to true. - fragment@2 { - target = <&sound>; - iqaudio_dac: __overlay__ { - compatible = "iqaudio,iqaudio-dac"; - i2s-controller = <&i2s>; - mute-gpios = <&gpio 22 0>; - status = "okay"; - ${lib.optionalString cfg.unmuteAmp "iqaudio-dac,unmute-amp;"} - ${lib.optionalString cfg.autoMuteAmp "iqaudio-dac,auto-mute-amp;"} - }; - }; - }; - ''; - } - ]; - }; - }; + For NixOS-Hardware specific firmware setup, read: + raspberry-pi/README.md. + + For digiamp specific details, see: + https://www.raspberrypi.com/documentation/accessories/audio.html#raspberry-pi-digiamp + '' + ) + ]; } diff --git a/raspberry-pi/4/dwc2.nix b/raspberry-pi/4/dwc2.nix index 5d49f9a1..b0e1d49b 100644 --- a/raspberry-pi/4/dwc2.nix +++ b/raspberry-pi/4/dwc2.nix @@ -1,86 +1,34 @@ -{ config, lib, ... }: +{ lib, ... }: -let - cfg = config.hardware.raspberry-pi."4".dwc2; -in { - options.hardware = { - raspberry-pi."4".dwc2 = { - enable = lib.mkOption { - type = lib.types.bool; - default = false; - example = true; - description = '' - Enable the UDC controller to support USB OTG gadget functions. + imports = [ + (lib.mkRemovedOptionModule + [ + "hardware" + "raspberry-pi" + "4" + "dwc2" + ] + '' + Use the stock dwc2 firmware overlay instead: - In order to verify that this works, connect the Raspberry Pi with - another computer via the USB C cable, and then do one of: + { + boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = + false; - - `modprobe g_serial` - - `modprobe g_mass_storage file=/path/to/some/iso-file.iso` + hardware.raspberry-pi.configtxt.deviceTreeOverlays.pi4 = [ + { dwc2 = { }; } + ]; + } - On the Raspberry Pi, `dmesg` should then show success-indicating output - that is related to the dwc2 and g_serial/g_mass_storage modules. - On the other computer, a serial/mass-storage device should pop up in - the system logs. + If you set dr_mode on the old option, add it to the overlay. For + example: - For more information about what gadget functions exist along with handy - guides on how to test them, please refer to: - https://www.kernel.org/doc/Documentation/usb/gadget-testing.txt - ''; - }; - dr_mode = lib.mkOption { - type = lib.types.enum [ - "host" - "peripheral" - "otg" - ]; - default = "otg"; - description = '' - Dual role mode setting for the dwc2 USB controller driver. - ''; - }; - }; - }; + { dwc2.dr_mode = "host"; } - config = lib.mkIf cfg.enable { - # Configure for modesetting in the device tree - hardware.deviceTree = { - overlays = [ - # this *should* be equivalent to (which doesn't work): - # https://github.com/raspberrypi/linux/blob/rpi-5.10.y/arch/arm/boot/dts/overlays/dwc2-overlay.dts - # but actually it's obtained using - # dtc -I dtb -O dts ${config.hardware.deviceTree.kernelPackage}/dtbs/overlays/dwc2.dtbo - # (changes: modified top-level "compatible" field) - # which is slightly different and works - { - name = "dwc2-overlay"; - dtsText = '' - /dts-v1/; - /plugin/; - - / { - compatible = "brcm,bcm2711"; - - fragment@0 { - target = <&usb>; - #address-cells = <0x01>; - #size-cells = <0x01>; - - __overlay__ { - compatible = "brcm,bcm2835-usb"; - dr_mode = "${cfg.dr_mode}"; - g-np-tx-fifo-size = <0x20>; - g-rx-fifo-size = <0x22e>; - g-tx-fifo-size = <0x200 0x200 0x200 0x200 0x200 0x100 0x100>; - status = "okay"; - phandle = <0x01>; - }; - }; - }; - ''; - } - ]; - }; - }; + For CM4 and firmware-partition setup, see "DWC2 USB controller" in + raspberry-pi/README.md. + '' + ) + ]; } diff --git a/raspberry-pi/4/poe-hat.nix b/raspberry-pi/4/poe-hat.nix index ac2381e1..c40de143 100644 --- a/raspberry-pi/4/poe-hat.nix +++ b/raspberry-pi/4/poe-hat.nix @@ -1,232 +1,35 @@ -{ config, lib, ... }: +{ lib, ... }: -let - cfg = config.hardware.raspberry-pi."4".poe-hat; -in { - options.hardware = { - raspberry-pi."4".poe-hat = { - enable = lib.mkEnableOption "support for the Raspberry Pi POE Hat"; - fan = lib.mkOption { - type = lib.types.submodule { - options = { - temperature0 = lib.mkOption { - type = lib.types.int; - default = 40000; - description = "Temperature threshold 0."; - }; - hysteresis0 = lib.mkOption { - type = lib.types.int; - default = 2000; - description = "Temperature hysteresis 0."; - }; - temperature1 = lib.mkOption { - type = lib.types.int; - default = 45000; - description = "Temperature threshold 1."; - }; - hysteresis1 = lib.mkOption { - type = lib.types.int; - default = 2000; - description = "Temperature hysteresis 1."; - }; - temperature2 = lib.mkOption { - type = lib.types.int; - default = 50000; - description = "Temperature threshold 2."; - }; - hysteresis2 = lib.mkOption { - type = lib.types.int; - default = 2000; - description = "Temperature hysteresis 2."; - }; - temperature3 = lib.mkOption { - type = lib.types.int; - default = 55000; - description = "Temperature threshold 3."; - }; - hysteresis3 = lib.mkOption { - type = lib.types.int; - default = 5000; - description = "Temperature hysteresis 3."; - }; - }; - }; + imports = [ + (lib.mkRemovedOptionModule + [ + "hardware" + "raspberry-pi" + "4" + "poe-hat" + ] + '' + Use the stock rpi-poe firmware overlay instead: - default = { }; - description = "Fan configuration."; - }; - }; - }; - - config = lib.mkIf cfg.enable { - hardware.raspberry-pi."4".apply-overlays-dtmerge.enable = lib.mkDefault true; - # doesn't work for the CM module, so we exclude e.g. bcm2711-rpi-cm4.dts - hardware.deviceTree.filter = "bcm2711-rpi-4*.dtb"; - - hardware.deviceTree = { - overlays = [ - # Equivalent to: https://github.com/raspberrypi/linux/blob/rpi-6.6.y/arch/arm/boot/dts/overlays/rpi-poe-overlay.dts - { - name = "rpi-poe-overlay"; - dtsText = '' - /* - * Overlay for the Raspberry Pi POE HAT. - */ - /dts-v1/; - /plugin/; - - / { - compatible = "brcm,bcm2711"; - - fragment@0 { - target-path = "/"; - __overlay__ { - fan: pwm-fan { - compatible = "pwm-fan"; - cooling-levels = <0 1 10 100 255>; - #cooling-cells = <2>; - pwms = <&fwpwm 0 80000 0>; - }; - }; + hardware.raspberry-pi.configtxt.deviceTreeOverlays."board-type=0x11" = [ + { + rpi-poe = { + poe_fan_temp0 = 40000; + poe_fan_temp0_hyst = 2000; + poe_fan_temp1 = 45000; + poe_fan_temp1_hyst = 2000; + poe_fan_temp2 = 50000; + poe_fan_temp2_hyst = 2000; + poe_fan_temp3 = 55000; + poe_fan_temp3_hyst = 5000; }; + } + ]; - fragment@1 { - target = <&cpu_thermal>; - __overlay__ { - polling-delay = <2000>; /* milliseconds */ - }; - }; - - fragment@2 { - target = <&thermal_trips>; - __overlay__ { - trip0: trip0 { - temperature = <${toString cfg.fan.temperature0}>; - hysteresis = <${toString cfg.fan.hysteresis0}>; - type = "active"; - }; - trip1: trip1 { - temperature = <${toString cfg.fan.temperature1}>; - hysteresis = <${toString cfg.fan.hysteresis1}>; - type = "active"; - }; - trip2: trip2 { - temperature = <${toString cfg.fan.temperature2}>; - hysteresis = <${toString cfg.fan.hysteresis2}>; - type = "active"; - }; - trip3: trip3 { - temperature = <${toString cfg.fan.temperature3}>; - hysteresis = <${toString cfg.fan.hysteresis3}>; - type = "active"; - }; - }; - }; - - fragment@3 { - target = <&cooling_maps>; - __overlay__ { - map0 { - trip = <&trip0>; - cooling-device = <&fan 0 1>; - }; - map1 { - trip = <&trip1>; - cooling-device = <&fan 1 2>; - }; - map2 { - trip = <&trip2>; - cooling-device = <&fan 2 3>; - }; - map3 { - trip = <&trip3>; - cooling-device = <&fan 3 4>; - }; - }; - }; - - fragment@4 { - target-path = "/__overrides__"; - params: __overlay__ { - poe_fan_temp0 = <&trip0>,"temperature:0"; - poe_fan_temp0_hyst = <&trip0>,"hysteresis:0"; - poe_fan_temp1 = <&trip1>,"temperature:0"; - poe_fan_temp1_hyst = <&trip1>,"hysteresis:0"; - poe_fan_temp2 = <&trip2>,"temperature:0"; - poe_fan_temp2_hyst = <&trip2>,"hysteresis:0"; - poe_fan_temp3 = <&trip3>,"temperature:0"; - poe_fan_temp3_hyst = <&trip3>,"hysteresis:0"; - poe_fan_i2c = <&fwpwm>,"status=disabled", - <&poe_mfd>,"status=okay", - <&fan>,"pwms:0=",<&poe_mfd_pwm>; - }; - }; - - fragment@5 { - target = <&firmware>; - __overlay__ { - fwpwm: pwm { - compatible = "raspberrypi,firmware-poe-pwm"; - #pwm-cells = <2>; - }; - }; - }; - - fragment@6 { - target = <&i2c0>; - i2c_bus: __overlay__ { - #address-cells = <1>; - #size-cells = <0>; - - poe_mfd: poe@51 { - compatible = "raspberrypi,poe-core"; - reg = <0x51>; - status = "disabled"; - - poe_mfd_pwm: poe_pwm@f0 { - compatible = "raspberrypi,poe-pwm"; - reg = <0xf0>; - status = "okay"; - #pwm-cells = <2>; - }; - }; - }; - }; - - fragment@7 { - target = <&i2c0if>; - __dormant__ { - status = "okay"; - }; - }; - - fragment@8 { - target = <&i2c0mux>; - __dormant__ { - status = "okay"; - }; - }; - - __overrides__ { - poe_fan_temp0 = <&trip0>,"temperature:0"; - poe_fan_temp0_hyst = <&trip0>,"hysteresis:0"; - poe_fan_temp1 = <&trip1>,"temperature:0"; - poe_fan_temp1_hyst = <&trip1>,"hysteresis:0"; - poe_fan_temp2 = <&trip2>,"temperature:0"; - poe_fan_temp2_hyst = <&trip2>,"hysteresis:0"; - poe_fan_temp3 = <&trip3>,"temperature:0"; - poe_fan_temp3_hyst = <&trip3>,"hysteresis:0"; - i2c = <0>, "+5+6", - <&fwpwm>,"status=disabled", - <&i2c_bus>,"status=okay", - <&poe_mfd>,"status=okay", - <&fan>,"pwms:0=",<&poe_mfd_pwm>; - }; - }; - ''; - } - ]; - }; - }; + These are the overlay defaults. Parameters that were not customized can + be omitted. + '' + ) + ]; } diff --git a/raspberry-pi/4/poe-plus-hat.nix b/raspberry-pi/4/poe-plus-hat.nix index 59f91608..4403510e 100644 --- a/raspberry-pi/4/poe-plus-hat.nix +++ b/raspberry-pi/4/poe-plus-hat.nix @@ -1,282 +1,35 @@ -{ config, lib, ... }: +{ lib, ... }: -let - cfg = config.hardware.raspberry-pi."4".poe-plus-hat; -in { - options.hardware = { - raspberry-pi."4".poe-plus-hat = { - enable = lib.mkEnableOption "support for the Raspberry Pi PoE+ HAT"; - fan = lib.mkOption { - type = lib.types.submodule { - options = { - temperature0 = lib.mkOption { - type = lib.types.int; - default = 40000; - description = "Temperature threshold 0."; - }; - hysteresis0 = lib.mkOption { - type = lib.types.int; - default = 2000; - description = "Temperature hysteresis 0."; - }; - temperature1 = lib.mkOption { - type = lib.types.int; - default = 45000; - description = "Temperature threshold 1."; - }; - hysteresis1 = lib.mkOption { - type = lib.types.int; - default = 2000; - description = "Temperature hysteresis 1."; - }; - temperature2 = lib.mkOption { - type = lib.types.int; - default = 50000; - description = "Temperature threshold 2."; - }; - hysteresis2 = lib.mkOption { - type = lib.types.int; - default = 2000; - description = "Temperature hysteresis 2."; - }; - temperature3 = lib.mkOption { - type = lib.types.int; - default = 55000; - description = "Temperature threshold 3."; - }; - hysteresis3 = lib.mkOption { - type = lib.types.int; - default = 5000; - description = "Temperature hysteresis 3."; - }; - }; - }; + imports = [ + (lib.mkRemovedOptionModule + [ + "hardware" + "raspberry-pi" + "4" + "poe-plus-hat" + ] + '' + Use the stock rpi-poe-plus firmware overlay instead: - default = { }; - description = "Fan configuration."; - }; - }; - }; - - config = lib.mkIf cfg.enable { - hardware.raspberry-pi."4".apply-overlays-dtmerge.enable = lib.mkDefault true; - # doesn't work for the CM module, so we exclude e.g. bcm2711-rpi-cm4.dts - hardware.deviceTree.filter = "bcm2711-rpi-4*.dtb"; - - hardware.deviceTree = { - overlays = [ - # Combined equivalent to: - # * https://github.com/raspberrypi/linux/blob/rpi-6.6.y/arch/arm/boot/dts/overlays/rpi-poe-overlay.dts - # * https://github.com/raspberrypi/linux/blob/rpi-6.6.y/arch/arm/boot/dts/overlays/rpi-poe-plus-overlay.dts - { - name = "rpi-poe-plus-overlay"; - dtsText = '' - /* - * Overlay for the Raspberry Pi POE HAT. - */ - /dts-v1/; - /plugin/; - - / { - compatible = "brcm,bcm2711"; - - fragment@0 { - target-path = "/"; - __overlay__ { - fan: pwm-fan { - compatible = "pwm-fan"; - cooling-levels = <0 1 10 100 255>; - #cooling-cells = <2>; - pwms = <&fwpwm 0 80000 0>; - }; - }; + hardware.raspberry-pi.configtxt.deviceTreeOverlays."board-type=0x11" = [ + { + rpi-poe-plus = { + poe_fan_temp0 = 40000; + poe_fan_temp0_hyst = 2000; + poe_fan_temp1 = 45000; + poe_fan_temp1_hyst = 2000; + poe_fan_temp2 = 50000; + poe_fan_temp2_hyst = 2000; + poe_fan_temp3 = 55000; + poe_fan_temp3_hyst = 5000; }; + } + ]; - fragment@1 { - target = <&cpu_thermal>; - __overlay__ { - polling-delay = <2000>; /* milliseconds */ - }; - }; - - fragment@2 { - target = <&thermal_trips>; - __overlay__ { - trip0: trip0 { - temperature = <${toString cfg.fan.temperature0}>; - hysteresis = <${toString cfg.fan.hysteresis0}>; - type = "active"; - }; - trip1: trip1 { - temperature = <${toString cfg.fan.temperature1}>; - hysteresis = <${toString cfg.fan.hysteresis1}>; - type = "active"; - }; - trip2: trip2 { - temperature = <${toString cfg.fan.temperature2}>; - hysteresis = <${toString cfg.fan.hysteresis2}>; - type = "active"; - }; - trip3: trip3 { - temperature = <${toString cfg.fan.temperature3}>; - hysteresis = <${toString cfg.fan.hysteresis3}>; - type = "active"; - }; - }; - }; - - fragment@3 { - target = <&cooling_maps>; - __overlay__ { - map0 { - trip = <&trip0>; - cooling-device = <&fan 0 1>; - }; - map1 { - trip = <&trip1>; - cooling-device = <&fan 1 2>; - }; - map2 { - trip = <&trip2>; - cooling-device = <&fan 2 3>; - }; - map3 { - trip = <&trip3>; - cooling-device = <&fan 3 4>; - }; - }; - }; - - fragment@4 { - target-path = "/__overrides__"; - params: __overlay__ { - poe_fan_temp0 = <&trip0>,"temperature:0"; - poe_fan_temp0_hyst = <&trip0>,"hysteresis:0"; - poe_fan_temp1 = <&trip1>,"temperature:0"; - poe_fan_temp1_hyst = <&trip1>,"hysteresis:0"; - poe_fan_temp2 = <&trip2>,"temperature:0"; - poe_fan_temp2_hyst = <&trip2>,"hysteresis:0"; - poe_fan_temp3 = <&trip3>,"temperature:0"; - poe_fan_temp3_hyst = <&trip3>,"hysteresis:0"; - poe_fan_i2c = <&fwpwm>,"status=disabled", - <&poe_mfd>,"status=okay", - <&fan>,"pwms:0=",<&poe_mfd_pwm>; - }; - }; - - fragment@5 { - target = <&firmware>; - __overlay__ { - fwpwm: pwm { - compatible = "raspberrypi,firmware-poe-pwm"; - #pwm-cells = <2>; - }; - }; - }; - - fragment@6 { - target = <&i2c0>; - i2c_bus: __overlay__ { - #address-cells = <1>; - #size-cells = <0>; - - poe_mfd: poe@51 { - compatible = "raspberrypi,poe-core"; - reg = <0x51>; - status = "disabled"; - - poe_mfd_pwm: poe_pwm@f0 { - compatible = "raspberrypi,poe-pwm"; - reg = <0xf0>; - status = "okay"; - #pwm-cells = <2>; - }; - }; - }; - }; - - fragment@7 { - target = <&i2c0if>; - __dormant__ { - status = "okay"; - }; - }; - - fragment@8 { - target = <&i2c0mux>; - __dormant__ { - status = "okay"; - }; - }; - - __overrides__ { - poe_fan_temp0 = <&trip0>,"temperature:0"; - poe_fan_temp0_hyst = <&trip0>,"hysteresis:0"; - poe_fan_temp1 = <&trip1>,"temperature:0"; - poe_fan_temp1_hyst = <&trip1>,"hysteresis:0"; - poe_fan_temp2 = <&trip2>,"temperature:0"; - poe_fan_temp2_hyst = <&trip2>,"hysteresis:0"; - poe_fan_temp3 = <&trip3>,"temperature:0"; - poe_fan_temp3_hyst = <&trip3>,"hysteresis:0"; - i2c = <0>, "+5+6", - <&fwpwm>,"status=disabled", - <&i2c_bus>,"status=okay", - <&poe_mfd>,"status=okay", - <&fan>,"pwms:0=",<&poe_mfd_pwm>; - }; - }; - - // SPDX-License-Identifier: (GPL-2.0 OR MIT) - // Overlay for the Raspberry Pi PoE+ HAT. - - / { - compatible = "brcm,bcm2711"; - - fragment@10 { - target-path = "/"; - __overlay__ { - rpi_poe_power_supply: rpi-poe-power-supply { - compatible = "raspberrypi,rpi-poe-power-supply"; - firmware = <&firmware>; - status = "okay"; - }; - }; - }; - fragment@11 { - target = <&poe_mfd>; - __overlay__ { - rpi-poe-power-supply@f2 { - compatible = "raspberrypi,rpi-poe-power-supply"; - reg = <0xf2>; - status = "okay"; - }; - }; - }; - - __overrides__ { - i2c = <0>, "+5+6", - <&fwpwm>,"status=disabled", - <&rpi_poe_power_supply>,"status=disabled", - <&i2c_bus>,"status=okay", - <&poe_mfd>,"status=okay", - <&fan>,"pwms:0=",<&poe_mfd_pwm>; - }; - }; - - &fan { - cooling-levels = <0 32 64 128 255>; - }; - - ¶ms { - poe_fan_i2c = <&fwpwm>,"status=disabled", - <&rpi_poe_power_supply>,"status=disabled", - <&poe_mfd>,"status=okay", - <&fan>,"pwms:0=",<&poe_mfd_pwm>; - }; - ''; - } - ]; - }; - }; + These are the overlay defaults. Parameters that were not customized can + be omitted. + '' + ) + ]; } diff --git a/raspberry-pi/README.md b/raspberry-pi/README.md index 8db72bd6..4d894b18 100644 --- a/raspberry-pi/README.md +++ b/raspberry-pi/README.md @@ -6,7 +6,7 @@ NixOS profiles and modules for Raspberry Pi boards. - `common/` has the shared bits: the `linux-rpi` kernel build (vendor defconfig, matching firmware), the `config.txt` generation module, a pinned wireless firmware, and the firmware-partition install module. - `2/`, `3/`, `4/`, `5/` are the board profiles. Each one picks the right kernel and kernel params. Pi 4 and 5 also set DT filters and the initrd modules they need. -- The extra files under `4/` are opt-in toggles for Pi 4 hardware: audio, dwc2, GPIO, I2C, LEDs, the PoE HATs, touchscreens, and so on. +- The extra files under `4/` are opt-in toggles for Pi 4 hardware: audio, GPIO, I2C, LEDs, touchscreens, and so on. ## Using a board profile @@ -68,7 +68,7 @@ dtparam=audio=on dtparam=i2c_arm=on ``` -Top-level attrs are conditional sections (`all`, `pi4`, `pi5`, `cm4`, and so on). Nesting stacks filters. To drop a default, set the key to `null` with `mkForce`. +Top-level attrs are conditional sections (`all`, `pi4`, `pi5`, `cm4`, and so on). Nesting stacks filters. Set a board profile's `mkDefault` value to `null` to remove it. Use `mkForce null` when overriding a value with normal priority. Every rendered group opens with `[all]` and then its own filters. Filters of different types stack rather than replace, so `[all]` is what clears the previous group before the next one starts. @@ -80,6 +80,8 @@ Overlays go in `configtxt.deviceTreeOverlays`, not in a `dtoverlay` key under `s ```nix { + boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = false; + hardware.raspberry-pi.configtxt.deviceTreeOverlays.pi4 = [ { dwc2.dr_mode = "host"; } { @@ -114,6 +116,58 @@ Each parameter becomes its own `dtparam` line rather than an addition to the `dt The module concatenates lists from separate modules, but the order is not the order of definition. If one overlay must load before another, set the order with `mkBefore` or `mkAfter`. +The Raspberry Pi firmware applies these overlays before U-Boot starts. Set `boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = false` so U-Boot keeps that device tree instead of loading one from the NixOS generation. Enabling `hardware.raspberry-pi.firmware.uboot.enable` sets this automatically. + +The firmware partition must contain the generated `config.txt` and stock overlays. SD image builds populate it automatically. On a running system, set `hardware.raspberry-pi.firmware.enable = true`. + +#### DWC2 USB controller + +Use the stock `dwc2` overlay to enable the USB 2.0 controller on the Pi 4B USB-C connector: + +```nix +{ + hardware.raspberry-pi.configtxt.deviceTreeOverlays."board-type=0x11" = [ + { dwc2 = { }; } + ]; +} +``` + +`board-type=0x11` matches the Pi 4B. The broader `pi4` filter also matches Pi 400, CM4, and CM4S. + +[Raspberry Pi OS sets `otg_mode=1` on CM4](https://github.com/RPi-Distro/pi-gen/blob/master/stage1/00-boot-files/files/config.txt#L39-L43), and [nixos-hardware sets the same default](./common/config-txt-defaults.nix). Set it to `null` before loading DWC2: + +```nix +{ + hardware.raspberry-pi.configtxt = { + settings.cm4.otg_mode = null; + deviceTreeOverlays.cm4 = [ + { dwc2 = { }; } + ]; + }; +} +``` + +The `cm4` filter matches CM4 only. Set `dwc2.dr_mode` to `host`, `peripheral`, or `otg` to override the overlay default. The overlay also accepts `g-rx-fifo-size` and `g-np-tx-fifo-size`. + +#### PoE HATs + +The original [PoE HAT](https://www.raspberrypi.com/products/poe-hat/) and the [PoE+ HAT](https://www.raspberrypi.com/products/poe-plus-hat/) use the stock `rpi-poe` and `rpi-poe-plus` overlays. Both HATs support the Pi 3B+ and Pi 4B. + +```nix +{ + hardware.raspberry-pi.configtxt.deviceTreeOverlays."board-type=0x11" = [ + { + rpi-poe = { + poe_fan_temp0 = 50000; + poe_fan_temp0_hyst = 2000; + }; + } + ]; +} +``` + +Use `board-type=0x0d` for the Pi 3B+ and `board-type=0x11` for the Pi 4B. Replace `rpi-poe` with `rpi-poe-plus` for the PoE+ HAT. All overlay parameters are optional. + To supply your own file, set `configtxt.file`. The module then ignores `settings` and `deviceTreeOverlays`. ## Current limits