I'm trying to build a NixOS image for my Raspberry Pi 4b with the dwc2 device tree overlay applied.
Per advice from the #nixos-aarch64 IRC channel, doing this the Nix Way calls for configuring hardware.deviceTree, and letting the build process apply the overlay. I'm attempting to do so as follows:
hardware.deviceTree.base = "${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb";
hardware.deviceTree.overlays = [
"${pkgs.raspberrypifw}/share/raspberrypi/boot/overlays/dwc2.dtbo"
];
...which results in the build process doing the following:
for dtb in $(find /nix/store/dn9n503g8ckl8r9xnz68wwb5zvfx48s1-raspberrypi-firmware-1.20190925/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb -name "*.dtb" ); do
outDtb=$out/$(realpath --relative-to "/nix/store/dn9n503g8ckl8r9xnz68wwb5zvfx48s1-raspberrypi-firmware-1.20190925/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb" "$dtb")
mkdir -p "$(dirname "$outDtb")"
fdtoverlay -o "$outDtb" -i "$dtb" "/nix/store/dn9n503g8ckl8r9xnz68wwb5zvfx48s1-raspberrypi-firmware-1.20190925/share/raspberrypi/boot/overlays/dwc2.dtbo";
done
Extracting the command from the script and running it on its own (with -v added for verbosity), I can manually reproduce the same error shown in the Nix build logs:
+ /nix/store/p3g23lbda8cnzxq84ya63wn34ca5imz9-dtc-1.5.1/bin/fdtoverlay -v -o /home/chaduffy/tmp/dtb-test/bcm2711-rpi-4-b.dtb -i /nix/store/dn9n503g8ckl8r9xnz68wwb5zvfx48s1-raspberrypi-firmware-1.20190925/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb /nix/store/dn9n503g8ckl8r9xnz68wwb5zvfx48s1-raspberrypi-firmware-1.20190925/share/raspberrypi/boot/overlays/dwc2.dtbo
input = /nix/store/dn9n503g8ckl8r9xnz68wwb5zvfx48s1-raspberrypi-firmware-1.20190925/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb
output = /home/chaduffy/tmp/dtb-test/bcm2711-rpi-4-b.dtb
overlay[0] = /nix/store/dn9n503g8ckl8r9xnz68wwb5zvfx48s1-raspberrypi-firmware-1.20190925/share/raspberrypi/boot/overlays/dwc2.dtbo
Failed to apply '/nix/store/dn9n503g8ckl8r9xnz68wwb5zvfx48s1-raspberrypi-firmware-1.20190925/share/raspberrypi/boot/overlays/dwc2.dtbo': FDT_ERR_NOTFOUND
Behavior is identical if instead of trying to use ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb as the base DTB against which the overlay is applied I use ${pkgs.linux_rpi4}/dtbs/broadcom/bcm2838-rpi-4-b.dtb.
How can I create a device tree for the Raspberry Pi 4b that has dwc2.dtbo folded in ahead-of-time? Why does this FDT_ERR_NOTFOUND occur?
/boot/overlays/dwc2.dtboor the existing dtoverlay? – Milliways Jan 28 '20 at 23:19/boot/overlaysby hand and add adtoverlay=dwc2line toconfig.txt, but the NixOS image builder doesn't create theoverlaysdirectory at all, and according to feedback I've gotten on IRC from the nixos-aarch64 peeps, settinghardware.deviceTree.overlays(which runsfdtoverlayas described above) is the only mechanism they intend to support. – Charles Duffy Jan 28 '20 at 23:38overlays = [ "${pkgs.device-tree_rpi.overlays}/vc4-fkms-v3d.dtbo" ];– Julian Stecklina Jul 27 '20 at 00:27