raspberrypi-bootloader: allow custom target directory and support 64-bit Raspberry Pi 3 #47250
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation for this change
This PR is the collection of changes needed to get my Raspberry Pis to boot in the variety of configurations I use. I needed to be able to generate SD card images for Pi Zeroes that used the RPi bootloader without U-Boot (to support DT overlays), and a Pi 1 using U-Boot. I also needed to support the Raspberry Pi 3 in 64-bit mode w/o U-Boot (again for DT overlays).
Things done
I refactored (and renamed) the RPi bootloader builder scripts to be more like the
generic-extlinux-compatible
builder. They now take an argument specifying the target directory, allowing them to be used insdImage.populateBootCommands
. For the RPi bootloader builder, I had to change the logic a bit to allow writing a default generation when there were no generations in the system profile (when building an SD card image). The changes to the U-Boot builder should make it possible to useboot.loader.raspberryPi.uboot
instead ofboot.loader.generic-extlinux-compatible
in the NixOS SD images, but this PR does not do that. See here for an example of how I generate SD card images for my Pi Zeroes.This PR also allows a 64-bit kernel to be booted on the Pi 3 without U-Boot. The problem was that the kernel was written to
/boot/kernel7.img
, while the Pi was looking forkernel8.img
. This PR causes the kernel to always be written tokernel.img
and adds a line toconfig.txt
explicitly specifying that location. I also had to copy the device trees from the correct location in the 64 bit kernel.While I was at it, I also added
0
as a allowable value forboot.loader.raspberryPi.version
which causes the correct U-Boot build to be used. The RPi 1 U-Boot generally works fine on the Zero, so this change isn't that important.Some possible issues with this PR are that Pi 2 and 3 users will have unused
kernel7.img
files in/boot
, which will take up the limited space in/boot
and will have to be deleted manually. Also/boot/defaultgeneration
is no longer created (because there are now files nameddefault-{cmdline.txt,init,initrd,kernel,system}
in/boot/old
which serve the same purpose), but the existing file is not deleted, which might confuse users.cc @dezgeg
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)