Raspberry Pi 2 changes to make it boot.

It boots, but some things still don't work:
1) Installation of DTBs
2) Boot of initrd

Booting still needs a proper config.txt in /boot, which could probably be
managed by NixOS.

+28 -7
+12 -5
nixos/modules/system/boot/loader/raspberrypi/builder.sh
··· 60 fi 61 62 local kernel=$(readlink -f $path/kernel) 63 - # local initrd=$(readlink -f $path/initrd) 64 65 if test -n "@copyKernels@"; then 66 copyToKernelsDir $kernel; kernel=$result 67 - # copyToKernelsDir $initrd; initrd=$result 68 fi 69 70 echo $(readlink -f $path) > $outdir/$generation-system 71 echo $(readlink -f $path/init) > $outdir/$generation-init 72 cp $path/kernel-params $outdir/$generation-cmdline.txt 73 - # echo $initrd > $outdir/$generation-initrd 74 echo $kernel > $outdir/$generation-kernel 75 76 if test $(readlink -f "$path") = "$default"; then 77 - copyForced $kernel /boot/kernel.img 78 - # copyForced $initrd /boot/initrd 79 cp "$(readlink -f "$path/init")" /boot/nixos-init 80 echo "`cat $path/kernel-params` init=$path/init" >/boot/cmdline.txt 81 ··· 98 copyForced $fwdir/bootcode.bin /boot/bootcode.bin 99 copyForced $fwdir/fixup.dat /boot/fixup.dat 100 copyForced $fwdir/fixup_cd.dat /boot/fixup_cd.dat 101 copyForced $fwdir/start.elf /boot/start.elf 102 copyForced $fwdir/start_cd.elf /boot/start_cd.elf 103 104 # Remove obsolete files from /boot/old. 105 for fn in /boot/old/*linux* /boot/old/*initrd*; do
··· 60 fi 61 62 local kernel=$(readlink -f $path/kernel) 63 + local initrd=$(readlink -f $path/initrd) 64 65 if test -n "@copyKernels@"; then 66 copyToKernelsDir $kernel; kernel=$result 67 + copyToKernelsDir $initrd; initrd=$result 68 fi 69 70 echo $(readlink -f $path) > $outdir/$generation-system 71 echo $(readlink -f $path/init) > $outdir/$generation-init 72 cp $path/kernel-params $outdir/$generation-cmdline.txt 73 + echo $initrd > $outdir/$generation-initrd 74 echo $kernel > $outdir/$generation-kernel 75 76 if test $(readlink -f "$path") = "$default"; then 77 + if [ @version@ -eq 1 ]; then 78 + copyForced $kernel /boot/kernel.img 79 + else 80 + copyForced $kernel /boot/kernel7.img 81 + fi 82 + copyForced $initrd /boot/initrd 83 cp "$(readlink -f "$path/init")" /boot/nixos-init 84 echo "`cat $path/kernel-params` init=$path/init" >/boot/cmdline.txt 85 ··· 102 copyForced $fwdir/bootcode.bin /boot/bootcode.bin 103 copyForced $fwdir/fixup.dat /boot/fixup.dat 104 copyForced $fwdir/fixup_cd.dat /boot/fixup_cd.dat 105 + copyForced $fwdir/fixup_db.dat /boot/fixup_db.dat 106 copyForced $fwdir/start.elf /boot/start.elf 107 copyForced $fwdir/start_cd.elf /boot/start_cd.elf 108 + copyForced $fwdir/start_db.elf /boot/start_db.elf 109 + copyForced $fwdir/start_x.elf /boot/start_x.elf 110 111 # Remove obsolete files from /boot/old. 112 for fn in /boot/old/*linux* /boot/old/*initrd*; do
+14
nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix
··· 3 with lib; 4 5 let 6 7 builder = pkgs.substituteAll { 8 src = ./builder.sh; ··· 10 inherit (pkgs) bash; 11 path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep]; 12 firmware = pkgs.raspberrypifw; 13 }; 14 15 platform = pkgs.stdenv.platform; ··· 29 ''; 30 }; 31 32 }; 33 34 config = mkIf config.boot.loader.raspberryPi.enable { 35 system.build.installBootLoader = builder; 36 system.boot.loader.id = "raspberrypi"; 37 system.boot.loader.kernelFile = platform.kernelTarget; 38 }; 39 }
··· 3 with lib; 4 5 let 6 + cfg = config.boot.loader.raspberryPi; 7 8 builder = pkgs.substituteAll { 9 src = ./builder.sh; ··· 11 inherit (pkgs) bash; 12 path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep]; 13 firmware = pkgs.raspberrypifw; 14 + version = cfg.version; 15 }; 16 17 platform = pkgs.stdenv.platform; ··· 31 ''; 32 }; 33 34 + boot.loader.raspberryPi.version = mkOption { 35 + default = 2; 36 + type = types.int; 37 + description = '' 38 + ''; 39 + }; 40 + 41 }; 42 43 config = mkIf config.boot.loader.raspberryPi.enable { 44 system.build.installBootLoader = builder; 45 system.boot.loader.id = "raspberrypi"; 46 system.boot.loader.kernelFile = platform.kernelTarget; 47 + assertions = [ 48 + { assertion = (cfg.version == 1 || cfg.version == 2); 49 + message = "loader.raspberryPi.version should be 1 or 2"; 50 + } 51 + ]; 52 }; 53 }
+2 -2
pkgs/os-specific/linux/firmware/raspberrypi/default.nix
··· 2 3 let 4 5 - rev = "3ab17ac25e"; 6 7 in stdenv.mkDerivation { 8 name = "raspberrypi-firmware-${rev}"; 9 10 src = fetchurl { 11 url = "https://github.com/raspberrypi/firmware/archive/${rev}.tar.gz"; 12 - sha256 = "080va4zz858bwwgxam8zy58gpwjpxfg7v5h1q5b4cpbzjihsxcx9"; 13 }; 14 15 installPhase = ''
··· 2 3 let 4 5 + rev = "b7bbd3d1683e9f3bb11ef86b952adee71e83862f"; 6 7 in stdenv.mkDerivation { 8 name = "raspberrypi-firmware-${rev}"; 9 10 src = fetchurl { 11 url = "https://github.com/raspberrypi/firmware/archive/${rev}.tar.gz"; 12 + sha256 = "16wpwa1y3imd3la477b3rfbfypssvlh0zjdag3hgkm33aysizijp"; 13 }; 14 15 installPhase = ''