about summary refs log tree commit diff
path: root/nixos/modules/system/boot/loader/raspberrypi
diff options
context:
space:
mode:
authorLluís Batlle i Rossell <viric@viric.name>2015-05-09 17:05:24 +0000
committerLluís Batlle i Rossell <viric@viric.name>2015-05-09 17:05:24 +0000
commitd8a2bb86c0e52bd5c41b2404ed3bbc7f80768842 (patch)
treed0ec4a44e0291f27d2045b95c18b4a42ce5908a3 /nixos/modules/system/boot/loader/raspberrypi
parent916b95b82989ee86dad62cb4a310ff82e784b404 (diff)
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.
Diffstat (limited to 'nixos/modules/system/boot/loader/raspberrypi')
-rw-r--r--nixos/modules/system/boot/loader/raspberrypi/builder.sh17
-rw-r--r--nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix14
2 files changed, 26 insertions, 5 deletions
diff --git a/nixos/modules/system/boot/loader/raspberrypi/builder.sh b/nixos/modules/system/boot/loader/raspberrypi/builder.sh
index f6ccfe493d8a9..ccb88ca1c5290 100644
--- a/nixos/modules/system/boot/loader/raspberrypi/builder.sh
+++ b/nixos/modules/system/boot/loader/raspberrypi/builder.sh
@@ -60,22 +60,26 @@ addEntry() {
     fi
 
     local kernel=$(readlink -f $path/kernel)
-    # local initrd=$(readlink -f $path/initrd)
+    local initrd=$(readlink -f $path/initrd)
 
     if test -n "@copyKernels@"; then
         copyToKernelsDir $kernel; kernel=$result
-        # copyToKernelsDir $initrd; initrd=$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
-    # echo $initrd > $outdir/$generation-initrd
+    echo $initrd > $outdir/$generation-initrd
     echo $kernel > $outdir/$generation-kernel
 
     if test $(readlink -f "$path") = "$default"; then
-      copyForced $kernel /boot/kernel.img
-      # copyForced $initrd /boot/initrd
+      if [ @version@ -eq 1 ]; then
+        copyForced $kernel /boot/kernel.img
+      else
+        copyForced $kernel /boot/kernel7.img
+      fi
+      copyForced $initrd /boot/initrd
       cp "$(readlink -f "$path/init")" /boot/nixos-init
       echo "`cat $path/kernel-params` init=$path/init" >/boot/cmdline.txt
 
@@ -98,8 +102,11 @@ fwdir=@firmware@/share/raspberrypi/boot/
 copyForced $fwdir/bootcode.bin  /boot/bootcode.bin
 copyForced $fwdir/fixup.dat     /boot/fixup.dat
 copyForced $fwdir/fixup_cd.dat  /boot/fixup_cd.dat
+copyForced $fwdir/fixup_db.dat  /boot/fixup_db.dat
 copyForced $fwdir/start.elf     /boot/start.elf
 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
diff --git a/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix b/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix
index 1ea3ddd8867c3..b7400e333e21f 100644
--- a/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix
+++ b/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix
@@ -3,6 +3,7 @@
 with lib;
 
 let
+  cfg = config.boot.loader.raspberryPi;
 
   builder = pkgs.substituteAll {
     src = ./builder.sh;
@@ -10,6 +11,7 @@ let
     inherit (pkgs) bash;
     path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
     firmware = pkgs.raspberrypifw;
+    version = cfg.version;
   };
 
   platform = pkgs.stdenv.platform;
@@ -29,11 +31,23 @@ in
       '';
     };
 
+    boot.loader.raspberryPi.version = mkOption {
+      default = 2;
+      type = types.int;
+      description = ''
+      '';
+    };
+
   };
 
   config = mkIf config.boot.loader.raspberryPi.enable {
     system.build.installBootLoader = builder;
     system.boot.loader.id = "raspberrypi";
     system.boot.loader.kernelFile = platform.kernelTarget;
+    assertions = [
+      { assertion = (cfg.version == 1 || cfg.version == 2);
+        message = "loader.raspberryPi.version should be 1 or 2";
+      }
+    ];
   };
 }