Skip to content

Commit

Permalink
nixos rpi bootloader: install files for rpi4
Browse files Browse the repository at this point in the history
  • Loading branch information
colemickens committed Apr 30, 2021
1 parent 9716947 commit d2fd002
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
3 changes: 3 additions & 0 deletions nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ let
'' else ''
kernel=kernel.img
initramfs initrd followkernel
'') + (optional (cfg.version == 4) ''
enable_gic=1
armstub=armstub8-gic.bin
'') + optional (cfg.firmwareConfig != null) cfg.firmwareConfig);

in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ let
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 not yet supported on the raspberry pi 4.";
throw "U-Boot is not yet supported on the raspberry pi ${toString version}.";

extlinuxConfBuilder =
import ../generic-extlinux-compatible/extlinux-conf-builder.nix {
Expand All @@ -29,6 +34,7 @@ pkgs.substituteAll {
inherit (pkgs) bash;
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
firmware = pkgs.raspberrypifw;
armstubs = pkgs.raspberrypi-armstubs;
inherit uboot;
inherit configTxt;
inherit extlinuxConfBuilder;
Expand Down
26 changes: 23 additions & 3 deletions nixos/modules/system/boot/loader/raspberrypi/uboot-builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ done
copyForced() {
local src="$1"
local dst="$2"
cp $src $dst.tmp
cp -r $src $dst.tmp
rm -rf $dst
mv $dst.tmp $dst
}

Expand All @@ -21,6 +22,7 @@ copyForced() {

# Add the firmware files
fwdir=@firmware@/share/raspberrypi/boot/
copyForced $fwdir/overlays $target/overlays
copyForced $fwdir/bootcode.bin $target/bootcode.bin
copyForced $fwdir/fixup.dat $target/fixup.dat
copyForced $fwdir/fixup_cd.dat $target/fixup_cd.dat
Expand All @@ -31,8 +33,26 @@ copyForced $fwdir/start_cd.elf $target/start_cd.elf
copyForced $fwdir/start_db.elf $target/start_db.elf
copyForced $fwdir/start_x.elf $target/start_x.elf

# Add the config.txt
copyForced @configTxt@ $target/config.txt

# Add the uboot file
copyForced @uboot@/u-boot.bin $target/u-boot-rpi.bin

# Add the config.txt
copyForced @configTxt@ $target/config.txt
# Add the raspberry pi 4 specific files
if [[ "@version@" == "4" ]]; then
copyForced @armstubs@/armstub8-gic.bin $target/armstub8-gic.bin

copyForced $fwdir/fixup4.dat $target/fixup4.dat
copyForced $fwdir/fixup4cd.dat $target/fixup4cd.dat
copyForced $fwdir/fixup4db.dat $target/fixup4db.dat
copyForced $fwdir/fixup4x.dat $target/fixup4x.dat
copyForced $fwdir/start4.elf $target/start4.elf
copyForced $fwdir/start4cd.elf $target/start4cd.elf
copyForced $fwdir/start4db.elf $target/start4db.elf
copyForced $fwdir/start4x.elf $target/start4x.elf

copyForced @firmware@/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb $target/bcm2711-rpi-4-b.dtb
copyForced @firmware@/share/raspberrypi/boot/bcm2711-rpi-400.dtb $target/bcm2711-rpi-400.dtb
copyForced @firmware@/share/raspberrypi/boot/bcm2711-rpi-cm4.dtb $target/bcm2711-rpi-cm4.dtb
fi

0 comments on commit d2fd002

Please sign in to comment.