this requires a patch to uboot: - uboot thinks the drive has a capacity of 0 (i.e. 'unknown'). unclear precisely why. could be noncompliant drive firmware, or a timeout somewhere. and a patch to the rpi bootloader: - in order to trampoline into the rpi-4 uboot. and custom kernel modules in the initrd: - in order to detect the USB hub (rpi fw). additionally, i'm MANUALLY placing `bcm2711-rpi-400.dtb` into `/boot/nixos/..-linux-5.10.111-dtbs/broadcom`. i'll want to do this automatically over time. i hope to simplify much of this over time: this is just the first thing which works after a couple days of hacking at it.
42 lines
1.0 KiB
Nix
42 lines
1.0 KiB
Nix
{ pkgs, version, configTxt }:
|
|
|
|
let
|
|
isAarch64 = pkgs.stdenv.hostPlatform.isAarch64;
|
|
|
|
uboot =
|
|
if version == 0 then
|
|
pkgs.ubootRaspberryPiZero
|
|
else if version == 1 then
|
|
pkgs.ubootRaspberryPi
|
|
else if version == 2 then
|
|
pkgs.ubootRaspberryPi2
|
|
else if version == 3 then
|
|
if isAarch64 then
|
|
pkgs.ubootRaspberryPi3_64bit
|
|
else
|
|
pkgs.ubootRaspberryPi3_32bit
|
|
else if version == 4 then
|
|
if isAarch64 then
|
|
pkgs.ubootRaspberryPi4_64bit
|
|
else
|
|
pkgs.ubootRaspberryPi4_32bit
|
|
else
|
|
throw "U-Boot is only supported on the raspberry pi {1,2,3,4}.";
|
|
|
|
extlinuxConfBuilder =
|
|
import ../generic-extlinux-compatible/extlinux-conf-builder.nix {
|
|
pkgs = pkgs.buildPackages;
|
|
};
|
|
in
|
|
pkgs.substituteAll {
|
|
src = ./uboot-builder.sh;
|
|
isExecutable = true;
|
|
inherit (pkgs) bash;
|
|
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
|
|
firmware = pkgs.raspberrypifw;
|
|
inherit uboot;
|
|
inherit configTxt;
|
|
inherit extlinuxConfBuilder;
|
|
inherit version;
|
|
}
|