Open sbourdeauducq opened 3 years ago
There might be some clues in https://github.com/NixOS/nixos-hardware/blob/master/raspberry-pi/4/modesetting.nix
That's doing pretty much the same as my code above...
@sorki @georgewhewell @kwohlfahrt you authored the patch that changed things (6c9df40a4bc819fcab0836ad28ee944c8ce66db0), do you have an idea?
It's actually not straightforward at all since the overlays distributed by RPi foundation (part of device-tree_rpi
work with their kernel but we're using the upstream one by default. The most important bit is the compatible = "brcm,bcm2711";
line, which governs where the overlay is actually applied.
Try the nixos-hardware
solution and if it doesn't work we can debug further. Also please add which linuxPackages
you're using.
I am using pkgs.linuxPackages_rpi3
, on a Raspberry Pi 3 Model B+, which is not in nixos-hardware
.
I am looking at the files inside the directories pointed to by FDTDIR
in extlinux.conf
using fdtdump
.
On 21.05, I don't get an entry for rpi-poe-fan
.
On the previous 20.09 generations where it was working, the entry is present (in all the files AFAICT):
rpi-poe-fan@0 {
phandle = <0x00000072>;
status = "okay";
cooling-levels = <0x00000000 0x0000001f 0x0000003f 0x00000096 0x000000ff>;
#cooling-cells = <0x00000002>;
cooling-max-state = <0x00000004>;
cooling-min-state = <0x00000000>;
firmware = <0x00000007>;
compatible = "raspberrypi,rpi-poe-fan";
};
So this just looks like an issue with overlay application in NixOS.
Seems to be a problem with the compat string...
$ fdtget -t s nixos/lqf1bm3m39i9q1z6agrbr0m3xik4mpr1-device-tree-overlays/broadcom/bcm2710-rpi-3-b-plus.dtb / compatible
raspberrypi,3-model-b-plus brcm,bcm2837 # from the extlinux.conf files
$ dtbCompat="raspberrypi,3-model-b-plus brcm,bcm2837"
$ overlayCompat="raspberrypi,rpi-poe-fan"
$ if [[ "$dtbCompat" =~ "$overlayCompat" ]]; then # from pkgs/os-specific/linux/device-tree/default.nix
> echo ok
> else
> echo fail
> fi
fail
Nice, looks like you need to adjust the overlay to have to only have raspberrypi
in compatible. I'm open to suggestion how to make this less cranky to diagnose / override the compatible string.
The overlay is directly from nixpkgs, so this is a bug in nixpkgs.
Sure, removal of pkgs.device-tree_rpi
is also a solution.
Please don't - this package contains important files for correct Rasberry Pi hardware support.
I couldn't get things to work on Raspberry Pi 3 by tweaking the compatible
strings or the compatibility detection code - with the new code there would always be some conflicting DTB files that would cause some problem at build or at boot time. It did work on Raspberry Pi 4.
If anyone comes here trying to get their PoE fan (or other DTB hardware) to work on a Raspberry Pi 3, this workaround will do it: https://git.m-labs.hk/M-Labs/it-infra/commit/8924e769f0b4ca9c701ea0ced27203a962051d0f
I've also been facing this issue. Could it be a bug in the RPI firmware as the RPI3 has this compatible string (boot/bcm2710-rpi-3-b.dtb):
compatible = "raspberrypi,3-model-b\0brcm,bcm2837";
while most overlays use:
compatible = "brcm,bcm2835";
AFAIK the RPI3 is also compatible with bcm2835, so I would expect it to be in the compatible string of boot/bcm2710-rpi-3-b.dtb
(and all RPI < 4).
Please don't - this package contains important files for correct Rasberry Pi hardware support.
I never needed anything from it for correct Pi support.
If you use overlays maintained by vendor (RPi foundation) and their fork of Linux in form linuxPackages_rpiX
and their custom bootloader you should also use config.txt
and their custom mechanism of applying overlays.
IMHO none of these things have their place in nixpkgs
and would be better if they were part of e.g. nixos-hardware
(or ideally not existed at all).
It was probably a mistake to make the mechanism compatible with binary RPi specific overlays since it only creates trouble. It's also trivial to grab a DTS file, adjust compatible string and use the NixOS mechanism.
As I've said before - suggestions to improve the situation welcome but please stop repeating "This is a bug in nixpkgs" since that doesn't help at all.
I never needed anything from it for correct Pi support.
Without this package, things like the PoE fan cannot work AFAICT.
It's also trivial to grab a DTS file, adjust compatible string and use the NixOS mechanism.
It would appear that it is not trivial (or maybe I'm an idiot) since this only worked on RPI 4 when I tried it.
The older code is simpler and works with RPI 3 and 4. What was the motivation for the change?
It's also trivial to grab a DTS file, adjust compatible string and use the NixOS mechanism.
It would appear that it is not trivial (or maybe I'm an idiot) since this only worked on RPI 4 when I tried it.
It depends on which kernel you try to apply it.
The older code is simpler and works with RPI 3 and 4. What was the motivation for the change?
It was a bit RPi specific since it only allowed applying binary overlays to all DTBs (edit: which was only applicable to pkgs.device-tree_rpi
and linuxPackages_rpiX
, not mainline Linux).
Is there an update on this? I'd love to get my poe fan working.
I've tried the device tree setup in https://github.com/NixOS/nixos-hardware/blob/master/raspberry-pi/4/poe-hat.nix I've also tried a newer copy from https://github.com/raspberrypi/linux/blob/rpi-5.15.y/arch/arm/boot/dts/overlays/rpi-poe-overlay.dts
I've tried generic-extlinux-compatible
and raspberryPi
bootloaders but no luck so far
Is there an update on this? I'd love to get my poe fan working.
There's no much to fix here I'm afraid maybe except documentation or error messages.
I've tried the device tree setup in https://github.com/NixOS/nixos-hardware/blob/master/raspberry-pi/4/poe-hat.nix I've also tried a newer copy from https://github.com/raspberrypi/linux/blob/rpi-5.15.y/arch/arm/boot/dts/overlays/rpi-poe-overlay.dts
Is this Pi4? Do you also use toplevel module which configures rpi specific kernel (https://github.com/NixOS/nixos-hardware/blob/master/raspberry-pi/4/default.nix#L15)?
Does the newer copy match the kernel version?
I've tried
generic-extlinux-compatible
andraspberryPi
bootloaders but no luck so far
This should be bootloader independent, both load a device tree built by the module - difference is that raspberryPi
bootloader can also apply overlays on boot via config.txt
as is custom on Raspbian (not sure if this works with our images).
@06kellyjac it may not be kosher, but the commit I posted above does get PoE fans spinning on RPI 3 and 4 using the latest 21.11.
Is this Pi4? Do you also use toplevel module which configures rpi specific kernel (https://github.com/NixOS/nixos-hardware/blob/master/raspberry-pi/4/default.nix#L15)?
Yes and yes
Does the newer copy match the kernel version?
Yep linuxPackages_rpi4
is now 5.15 so I pulled the config from 5.15.y
https://github.com/06kellyjac/nixos-hardware/blob/rpi-poe/raspberry-pi/4/poe-hat.nix#L18-L167
I'm very tempted to apply the revert commit just to get it working again but I'd rather have it fixed properly, especially ahead of 22.05
Note that nixos-hardware overlay has adjusted compatible
https://github.com/NixOS/nixos-hardware/blob/master/raspberry-pi/4/poe-hat.nix#L29
You can consult logs to see if the overlay is applied to the right DTB. The mechanism compares comatible
of the DTB https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/linux/device-tree/default.nix#L16 vs compatible
of the overlay https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/linux/device-tree/default.nix#L19 and only applies overlay if they match (in which case you get Applying overlay
log message https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/linux/device-tree/default.nix#L22).
For further debugging you can build just a config.hardware.deviceTree.package
fdtget -t s ./result/bcm2711-rpi-4-b.dtb / compatible
dtc -I dtb -O dts ./result/bcm2711-rpi-4-b.dtb | less
That said, your compatible won't match pi4 - you either need to set it to raspberrypi
(in which case it applies to all rpi device trees) or brcm,bcm2711
for just pi4.
Thanks for the help.
I updated it to brcm,bcm2711
(https://github.com/06kellyjac/nixos-hardware/blob/rpi-poe/raspberry-pi/4/poe-hat.nix#L29) and got this:
$ nix build .#nixosConfigurations.rpi4.config.hardware.deviceTree.package -L
rpi-poe-overlay-dtbo> /nix/store/ihnivsgxfp9qqm2438cywajp9qyql80a-dts:108.11-24: Warning (reg_format): /fragment@4/__overlay__/poe@51/poe_pwm@f0:reg: property has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)
rpi-poe-overlay-dtbo> /nix/store/ihnivsgxfp9qqm2438cywajp9qyql80a-dts:116.14-121.5: Warning (unit_address_vs_reg): /fragment@5: node has a unit name, but no reg or ranges property
rpi-poe-overlay-dtbo> /nix/store/ihnivsgxfp9qqm2438cywajp9qyql80a-dts:123.14-128.5: Warning (unit_address_vs_reg): /fragment@6: node has a unit name, but no reg or ranges property
rpi-poe-overlay-dtbo> /nix/store/r28rra8q081qirjx227m3rjgqp42cv2y-rpi-poe-overlay-dtbo: Warning (pci_device_reg): Failed prerequisite 'reg_format'
rpi-poe-overlay-dtbo> /nix/store/r28rra8q081qirjx227m3rjgqp42cv2y-rpi-poe-overlay-dtbo: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
rpi-poe-overlay-dtbo> /nix/store/r28rra8q081qirjx227m3rjgqp42cv2y-rpi-poe-overlay-dtbo: Warning (simple_bus_reg): Failed prerequisite 'reg_format'
rpi-poe-overlay-dtbo> /nix/store/r28rra8q081qirjx227m3rjgqp42cv2y-rpi-poe-overlay-dtbo: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
rpi-poe-overlay-dtbo> /nix/store/r28rra8q081qirjx227m3rjgqp42cv2y-rpi-poe-overlay-dtbo: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
rpi-poe-overlay-dtbo> /nix/store/ihnivsgxfp9qqm2438cywajp9qyql80a-dts:106.33-111.11: Warning (avoid_default_addr_size): /fragment@4/__overlay__/poe@51/poe_pwm@f0: Relying on default #address-cells value
rpi-poe-overlay-dtbo> /nix/store/ihnivsgxfp9qqm2438cywajp9qyql80a-dts:106.33-111.11: Warning (avoid_default_addr_size): /fragment@4/__overlay__/poe@51/poe_pwm@f0: Relying on default #size-cells value
rpi-poe-overlay-dtbo> /nix/store/r28rra8q081qirjx227m3rjgqp42cv2y-rpi-poe-overlay-dtbo: Warning (avoid_unnecessary_addr_size): Failed prerequisite 'avoid_default_addr_size'
rpi-poe-overlay-dtbo> /nix/store/r28rra8q081qirjx227m3rjgqp42cv2y-rpi-poe-overlay-dtbo: Warning (unique_unit_address): Failed prerequisite 'avoid_default_addr_size'
dtbs-with-symbols> unpacking sources
# ...
dtbs-with-symbols> checking for references to /build/ in /nix/store/94773gzx4hsa48cvpipcxkyzj06i50fc-dtbs-with-symbols...
dtbs-filtered> ./broadcom -> /nix/store/lr2jh1v4ra9vjlsasy9drss5xj04spac-dtbs-filtered/./broadcom
dtbs-filtered> './broadcom/bcm2711-rpi-400.dtb' -> '/nix/store/lr2jh1v4ra9vjlsasy9drss5xj04spac-dtbs-filtered/./broadcom/bcm2711-rpi-400.dtb'
dtbs-filtered> './broadcom/bcm2711-rpi-4-b.dtb' -> '/nix/store/lr2jh1v4ra9vjlsasy9drss5xj04spac-dtbs-filtered/./broadcom/bcm2711-rpi-4-b.dtb'
dtbs-filtered> './broadcom/bcm2711-rpi-cm4.dtb' -> '/nix/store/lr2jh1v4ra9vjlsasy9drss5xj04spac-dtbs-filtered/./broadcom/bcm2711-rpi-cm4.dtb'
device-tree-overlays> ./broadcom -> /nix/store/iy7n6hsniv5in9d70x0ahv95hjpzkhg9-device-tree-overlays/./broadcom
device-tree-overlays> './broadcom/bcm2711-rpi-400.dtb' -> '/nix/store/iy7n6hsniv5in9d70x0ahv95hjpzkhg9-device-tree-overlays/./broadcom/bcm2711-rpi-400.dtb'
device-tree-overlays> './broadcom/bcm2711-rpi-4-b.dtb' -> '/nix/store/iy7n6hsniv5in9d70x0ahv95hjpzkhg9-device-tree-overlays/./broadcom/bcm2711-rpi-4-b.dtb'
device-tree-overlays> './broadcom/bcm2711-rpi-cm4.dtb' -> '/nix/store/iy7n6hsniv5in9d70x0ahv95hjpzkhg9-device-tree-overlays/./broadcom/bcm2711-rpi-cm4.dtb'
device-tree-overlays> Applying overlay rpi-poe-overlay to bcm2711-rpi-400.dtb
device-tree-overlays> Failed to apply '/nix/store/r28rra8q081qirjx227m3rjgqp42cv2y-rpi-poe-overlay-dtbo': FDT_ERR_NOTFOUND
$ fdtget -t s /nix/store/r28rra8q081qirjx227m3rjgqp42cv2y-rpi-poe-overlay-dtbo / compatible
brcm,bcm2711
Decompile looks the same AFAIK and after quitting less the same warnings are logged
$ dtc -I dtb -O dts /nix/store/r28rra8q081qirjx227m3rjgqp42cv2y-rpi-poe-overlay-dtbo | less
<stdout>: Warning (reg_format): /fragment@4/__overlay__/poe@51/poe_pwm@f0:reg: property has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)
<stdout>: Warning (unit_address_vs_reg): /fragment@5: node has a unit name, but no reg or ranges property
<stdout>: Warning (unit_address_vs_reg): /fragment@6: node has a unit name, but no reg or ranges property
<stdout>: Warning (pci_device_reg): Failed prerequisite 'reg_format'
<stdout>: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
<stdout>: Warning (simple_bus_reg): Failed prerequisite 'reg_format'
<stdout>: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
<stdout>: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
<stdout>: Warning (avoid_default_addr_size): /fragment@4/__overlay__/poe@51/poe_pwm@f0: Relying on default #address-cells value
<stdout>: Warning (avoid_default_addr_size): /fragment@4/__overlay__/poe@51/poe_pwm@f0: Relying on default #size-cells value
<stdout>: Warning (avoid_unnecessary_addr_size): Failed prerequisite 'avoid_default_addr_size'
<stdout>: Warning (unique_unit_address): Failed prerequisite 'avoid_default_addr_size'
So is this meant to apply to rpi-400? Sadly FDT_ERR_NOTFOUND
is sort-of a catch all error.
IDK, I just care about rpi-4-b I think, I guess I can change the filter to hardware.deviceTree.filter = "bcm2711-rpi-4-b.dtb";
?
I'm not seeing a way to set an individual overlay to have a different filter
Edit: even just applying it to 4-b it's getting upset:
tbs-filtered> ./broadcom -> /nix/store/m70x6ncf157p0hp5viwz9z8z36r8gdx9-dtbs-filtered/./broadcom
dtbs-filtered> './broadcom/bcm2711-rpi-4-b.dtb' -> '/nix/store/m70x6ncf157p0hp5viwz9z8z36r8gdx9-dtbs-filtered/./broadcom/bcm2711-rpi-4-b.dtb'
device-tree-overlays> ./broadcom -> /nix/store/qvjw2lr8wyg9jkymm2bgv1g825zf60jc-device-tree-overlays/./broadcom
device-tree-overlays> './broadcom/bcm2711-rpi-4-b.dtb' -> '/nix/store/qvjw2lr8wyg9jkymm2bgv1g825zf60jc-device-tree-overlays/./broadcom/bcm2711-rpi-4-b.dtb'
device-tree-overlays> Applying overlay rpi-poe-overlay to bcm2711-rpi-4-b.dtb
device-tree-overlays> Failed to apply '/nix/store/r28rra8q081qirjx227m3rjgqp42cv2y-rpi-poe-overlay-dtbo': FDT_ERR_NOTFOUND
Yes, I hoped more specific filter would help. I'm out of ideas at this point :confused:
mmm. I had a look to see if fdtoverlay
had a verbose output that could help. It has a verbose flag but it does next to nothign
Chatting in the matrix there's a lot of stuff upstreamed into modern mainline like: https://github.com/torvalds/linux/blob/v5.15/drivers/pwm/pwm-raspberrypi-poe.c etc but applying against that didn't work either :upside_down_face:
cc @samueldr @Mic92 @walkah any advice here? Is there some other changes that need to be made to the upstream dts to make it work?
On 22.05, even with the workaround I posted, it now fails with:
Failed to apply '/nix/store/fg6al7jd2l69jy8glphbl6h9cy4za661-raspberrypi-firmware-1.20220331/share/raspberrypi/boot/overlays/rpi-poe.dtbo': FDT_ERR_NOTFOUND
If you're tired of this mess and just want the damn fan to spin, you can simply short-circuit the MOSFET at the top-right:
I just wanted to chime in with my experience on the same topic. In my case I just want to use an i2s hat which seems straight forward enough; however I was getting the same FTD_OVERLAY error as everyone else here.
I documented my experience here https://discourse.nixos.org/t/fdt-err-notfound-when-trying-to-apply-device-tree-overlay-on-raspberry-pi-4/19650
I'm not sure if #205595 will fix the original issue but it may help
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/raspberry-pi-and-config-txt/24529/3
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/raspberry-pi-compute-module-3-compatibility/16210/11
Excuse me all of you that will be take some minutes to say if that, I think yes. AN OS TO Install on one dev board PINE A64 lts v2, which ones we can access with programmes have access easily to some many GPio's ? Thanks so much...
In NixOS 21.05, the
hardware.deviceTree.base
option can no longer be used. After trying to do some research, I figured out that the lines that I was using successfully:could be replaced with:
However this did not work, the device tree overlay is no longer applied.
I suppose this is a straightforward problem for who made the change. Could the documentation be updated to explain how to migrate from
hardware.deviceTree.base
?