-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve device-tree overlay support #79370
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introduces a breaking change for users of hardware.deviceTree.base which is now renamed to hardware.deviceTree.kernelPackage and requires actual kernel package for dtc recompilation to work.
We'll need the release notes to show the breaking change.
I don't have the setup to test, exactly, but I do have some hardware I should setup to test. Otherwise, at a glance this looks fine, though not super thrilled about any breaking change, but the change is for the best considering it allows multiple representations of device trees to be used here. |
You can test on rPi with https://gist.github.com/sorki/c72dfbf1af51f7a42693622fbd020f07 I think that the previous |
Release note added |
cc @bennofs who played with out of tree DTBs recently. Might have some thoughts about this. |
When I said "hardware to test" I meant I have a raspberry pi touch screen I can test this with, still hadn't looked at how to make it work. My main issue is that I would prefer the mainline kernel, but there's a dire lack of documentation about "raspberry pi special hardware" and mainline. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, especially the recompiling the kernel dts with symbols part 👍 Because I didn't have the patience to figure out how that works, I just compiled a completely new device tree for my own use case.
I added two review comments, but I would also be fine with the current state of the PR.
installPhase = '' | ||
make dtbs_install INSTALL_DTBS_PATH=$out/dtbs | ||
''; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to move this function, and maybe also filterDTBs
and compileDTS
to nixpkgs (next to applyOverlays
)? I think these functions might sometimes be useful for users to build their own device tree packages, and having them inside the module makes it hard to reuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compileDTS
sounds good, not sure about filterDTBs
as that is a pretty generic store path filter which resembles filterSource
but for store paths..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I'm keeping this internal, if you would like to have this exposed from pkgs
let me know and I'll try to fit it somewhere but I'm bad at namespaces and naming :) It also needs a better name in that case, something like pkgs.compileDeviceTreeOverlays
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't be able to test this until Monday, but at first glance I like the overlayType
and filterDtbs
.
I don't like the testing for /compatible
, I feel like trying to apply an overlay to an incompatible device-tree should give a visible error rather than being silently ignored. Any thoughts from others?
At first I've tried applying overlays to all devices but that results in tons of errors on the output as most are incompatible (I've thought Then my second version had
Which I think is better than seeing bunch of errors due to incompatibilities. |
Would it make sense to do the filtering in
And then only copying based on Pros:
Cons:
I'm not 100% opposed to the current solution, it is very flexible. |
Not sure if that would be an improvement - often you want to patch only few files but preserve the rest, |
Removed option is now addressed via |
OK, I'm convinced by the current approach for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hmm, this is a bit annoying... Either:
Otherwise looks fine to me. |
@sorki Okay, merged. |
I believe the merge of this PR has broken the "With GPU" instructions on the wiki (https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi_4#With_GPU). I get the following error now:
I tried deleting the |
cc @samueldr @NixOS/exotic-platform-maintainers |
I too am struggling with these changes. It's not clear to me how the wiki instructions for using the RPi4 GPU should be now, and separately I'm trying to apply a
I thought this would be sufficient (with |
During build, you should see a line saying
Setting a kernel package shouldn't be needed but I have some trouble reproducing this (wiki vp4 instructions) with
I'll try native build later. |
I'm trying to use this module on a Raspberry Pi 3B to mirror the effect of a # Unkown if needed, but read in some relevant thread that RPI overlays do not merge with mainline.
boot.kernelPackages = pkgs.linuxPackages_rpi3;
hardware.deviceTree = {
enable = true;
filter = "*-rpi-*.dtb";
overlays = [{
name = "spi";
dtboFile = "${pkgs.device-tree_rpi.overlays}/spi0-hw-cs.dtbo";
}]; the image from |
@tmplt If there's no specific reason to use
If you switch compatible of the overlay to "raspberrypi" or "brcm,bcm2837" it would apply it. |
@sorki I'm trying to build with that overlay using I also have a aarch64-linux cross-compilation in progress via binfmt, but it's taking ages to build on my local system. I don't know if it works yet, but it did not stumble upon the error mentioned above.
|
@tmplt It contains cross compilation parts and it works for me with mainline kernels (yes I'm mostly using |
@sorki Mainline EDIT: just tried a build without the overlay and got the same error. Is support for older kernel versions possible? |
It finished, and it works: |
This commit pins nixpkgs for a recent modification of the deviceTree module [0] that is needed to properly apply an overlay that enables SPI for communication with the BrickPi3. Additionally, all required libs are installed into a modified Python environment. Resolves #9. [0] NixOS/nixpkgs#79370
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/enabling-spi-on-the-raspberry-pi-3/9122/4 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/cross-compiling-problem-with-devicetree-on-armv6/9254/1 |
I had another excursion into building device tree overlays with NixOS. I wanted to use After some time of debugging and I tried adding support for this into Maybe someone in here feels a bit more brave and wants to add this. It'd certainly be very useful. |
I have a device tree overlay (hifiberry-dacplus.dtbo from
I created my own device tree file and copied it to the On the |
@leifhelm see #107637 (comment) - the raspberry-pi provided device tree overlays don't compile with the kernel-provided As written in that comment, there's kwohlfahrt@7ba456e, which could probably be upstreamed to nixpkgs and provide an alternative mechanism of compiling device tree overlays. |
That would be welcome addition and was discussed on IRC some time ago. I might try to incorporate it to the next PR related to this and |
I think you can craft ${optionalString (config.hardware.deviceTree.package != null) ''
ln -s ${config.hardware.deviceTree.package} $out/dtbs
''} |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/boot-config-txt-related-questions-for-raspbarry-pi/3650/3 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Now allows applying external overlays either in form of
.dts
file, literal dts contents added to store or precompiled.dtbo
file.If overlays are defined, kernel device-trees are compiled with
-@
so the
.dtb
files contain symbols which we can reference in ouroverlays.
Since
fdtoverlay
doesn't respect/ compatible
by itselfwe query compatible strings of both
dtb
anddtbo(verlay)
and apply only if latter is substring of the former.
Also adds support for filtering
.dtb
files (as there are now nearly 1kdtbs).
Mashup of
Introduces a breaking change for users of
hardware.deviceTree.base
which is now renamed tohardware.deviceTree.kernelPackage
and requires actual kernel package fordtc
recompilation to work.Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)