From c19b17d14ff25a86bc4b563999bfa3569344d16a Mon Sep 17 00:00:00 2001 From: "Ricardo M. Correia" Date: Tue, 17 Jan 2017 11:19:39 +0000 Subject: [PATCH] raspberryPi boot loader: fix booting Raspberry Pi 3 The Raspberry Pi 3 seems to need the .DTB file when booting the kernel, so we must copy it to /boot when installing a new kernel. --- .../system/boot/loader/raspberrypi/builder.sh | 12 +++++++++--- .../system/boot/loader/raspberrypi/raspberrypi.nix | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/nixos/modules/system/boot/loader/raspberrypi/builder.sh b/nixos/modules/system/boot/loader/raspberrypi/builder.sh index ccb88ca1c529..1a02bf231709 100644 --- a/nixos/modules/system/boot/loader/raspberrypi/builder.sh +++ b/nixos/modules/system/boot/loader/raspberrypi/builder.sh @@ -61,12 +61,13 @@ addEntry() { local kernel=$(readlink -f $path/kernel) local initrd=$(readlink -f $path/initrd) + local dtb_path=$(readlink -f $path/kernel-modules/dtbs) if test -n "@copyKernels@"; then copyToKernelsDir $kernel; kernel=$result copyToKernelsDir $initrd; initrd=$result fi - + echo $(readlink -f $path) > $outdir/$generation-system echo $(readlink -f $path/init) > $outdir/$generation-init cp $path/kernel-params $outdir/$generation-cmdline.txt @@ -80,6 +81,11 @@ addEntry() { copyForced $kernel /boot/kernel7.img fi copyForced $initrd /boot/initrd + for dtb in $dtb_path/bcm*.dtb; do + dst="/boot/$(basename $dtb)" + copyForced $dtb "$dst" + filesCopied[$dst]=1 + done cp "$(readlink -f "$path/init")" /boot/nixos-init echo "`cat $path/kernel-params` init=$path/init" >/boot/cmdline.txt @@ -108,8 +114,8 @@ copyForced $fwdir/start_cd.elf /boot/start_cd.elf copyForced $fwdir/start_db.elf /boot/start_db.elf copyForced $fwdir/start_x.elf /boot/start_x.elf -# Remove obsolete files from /boot/old. -for fn in /boot/old/*linux* /boot/old/*initrd*; do +# Remove obsolete files from /boot and /boot/old. +for fn in /boot/old/*linux* /boot/old/*initrd* /boot/bcm*.dtb; do if ! test "${filesCopied[$fn]}" = 1; then rm -vf -- "$fn" fi diff --git a/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix b/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix index eb8ea6130972..f246d04284ca 100644 --- a/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix +++ b/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix @@ -33,7 +33,7 @@ in boot.loader.raspberryPi.version = mkOption { default = 2; - type = types.enum [ 1 2 ]; + type = types.enum [ 1 2 3 ]; description = '' ''; };