From 1afff7c10bdacbdd2d5c2d7010ee96987fdffb0e Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer <benwolsieffer@gmail.com> Date: Mon, 10 Sep 2018 23:21:41 -0400 Subject: [PATCH] raspberrypi-bootloader: support Raspberry Pi 3 w/o U-Boot and explicitly support Raspberry Pi Zero --- .../boot/loader/raspberrypi/raspberrypi-builder.nix | 4 ++-- .../boot/loader/raspberrypi/raspberrypi-builder.sh | 8 ++------ .../system/boot/loader/raspberrypi/raspberrypi.nix | 12 +++++++----- .../{builder_uboot.nix => uboot-builder.nix} | 13 +++++++------ .../{builder_uboot.sh => uboot-builder.sh} | 0 5 files changed, 18 insertions(+), 19 deletions(-) rename nixos/modules/system/boot/loader/raspberrypi/{builder_uboot.nix => uboot-builder.nix} (74%) rename nixos/modules/system/boot/loader/raspberrypi/{builder_uboot.sh => uboot-builder.sh} (100%) diff --git a/nixos/modules/system/boot/loader/raspberrypi/raspberrypi-builder.nix b/nixos/modules/system/boot/loader/raspberrypi/raspberrypi-builder.nix index 27fea4e623e9..7eb52e3d021f 100644 --- a/nixos/modules/system/boot/loader/raspberrypi/raspberrypi-builder.nix +++ b/nixos/modules/system/boot/loader/raspberrypi/raspberrypi-builder.nix @@ -1,4 +1,4 @@ -{ pkgs, version, configTxt }: +{ pkgs, configTxt }: pkgs.substituteAll { src = ./raspberrypi-builder.sh; @@ -6,5 +6,5 @@ pkgs.substituteAll { inherit (pkgs) bash; path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep]; firmware = pkgs.raspberrypifw; - inherit version configTxt; + inherit configTxt; } diff --git a/nixos/modules/system/boot/loader/raspberrypi/raspberrypi-builder.sh b/nixos/modules/system/boot/loader/raspberrypi/raspberrypi-builder.sh index 68be4e28cd0c..0fb07de10c04 100644 --- a/nixos/modules/system/boot/loader/raspberrypi/raspberrypi-builder.sh +++ b/nixos/modules/system/boot/loader/raspberrypi/raspberrypi-builder.sh @@ -85,13 +85,9 @@ addEntry() { echo $kernel > $outdir/$generation-kernel if test "$generation" = "default"; then - if [ @version@ -eq 1 ]; then - copyForced $kernel $target/kernel.img - else - copyForced $kernel $target/kernel7.img - fi + copyForced $kernel $target/kernel.img copyForced $initrd $target/initrd - for dtb in $dtb_path/bcm*.dtb; do + for dtb in $dtb_path/{broadcom,}/bcm*.dtb; do dst="$target/$(basename $dtb)" copyForced $dtb "$dst" filesCopied[$dst]=1 diff --git a/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix b/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix index bef66bfd41a6..17c09d7c4f60 100644 --- a/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix +++ b/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix @@ -7,8 +7,8 @@ let inherit (pkgs.stdenv.hostPlatform) platform; - builderUboot = import ./builder_uboot.nix { inherit config pkgs configTxt; }; - builderGeneric = import ./raspberrypi-builder.nix { inherit pkgs configTxt; inherit (cfg) version; }; + builderUboot = import ./uboot-builder.nix { inherit pkgs configTxt; inherit (cfg) version; }; + builderGeneric = import ./raspberrypi-builder.nix { inherit pkgs configTxt; }; builder = if cfg.uboot.enable then @@ -34,9 +34,11 @@ let '' + optional isAarch64 '' # Boot in 64-bit mode. arm_control=0x200 - '' + optional cfg.uboot.enable '' + '' + (if cfg.uboot.enable then '' kernel=u-boot-rpi.bin - '' + optional (cfg.firmwareConfig != null) cfg.firmwareConfig); + '' else '' + kernel=kernel.img + '') + optional (cfg.firmwareConfig != null) cfg.firmwareConfig); in @@ -56,7 +58,7 @@ in version = mkOption { default = 2; - type = types.enum [ 1 2 3 ]; + type = types.enum [ 0 1 2 3 ]; description = '' ''; }; diff --git a/nixos/modules/system/boot/loader/raspberrypi/builder_uboot.nix b/nixos/modules/system/boot/loader/raspberrypi/uboot-builder.nix similarity index 74% rename from nixos/modules/system/boot/loader/raspberrypi/builder_uboot.nix rename to nixos/modules/system/boot/loader/raspberrypi/uboot-builder.nix index 47f25a9c2b1b..e929c33c6ee3 100644 --- a/nixos/modules/system/boot/loader/raspberrypi/builder_uboot.nix +++ b/nixos/modules/system/boot/loader/raspberrypi/uboot-builder.nix @@ -1,13 +1,14 @@ -{ config, pkgs, configTxt }: +{ pkgs, version, configTxt }: let - cfg = config.boot.loader.raspberryPi; isAarch64 = pkgs.stdenv.isAarch64; uboot = - if cfg.version == 1 then + if version == 0 then + pkgs.ubootRaspberryPiZero + else if version == 1 then pkgs.ubootRaspberryPi - else if cfg.version == 2 then + else if version == 2 then pkgs.ubootRaspberryPi2 else if isAarch64 then @@ -21,7 +22,7 @@ let }; in pkgs.substituteAll { - src = ./builder_uboot.sh; + src = ./uboot-builder.sh; isExecutable = true; inherit (pkgs) bash; path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep]; @@ -29,6 +30,6 @@ pkgs.substituteAll { inherit uboot; inherit configTxt; inherit extlinuxConfBuilder; - version = cfg.version; + inherit version; } diff --git a/nixos/modules/system/boot/loader/raspberrypi/builder_uboot.sh b/nixos/modules/system/boot/loader/raspberrypi/uboot-builder.sh similarity index 100% rename from nixos/modules/system/boot/loader/raspberrypi/builder_uboot.sh rename to nixos/modules/system/boot/loader/raspberrypi/uboot-builder.sh