blob: e4e10fe892a210fdd0802a1d4c32b32409fe7617 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
{
config,
lib,
pkgs,
...
}: let
inherit (lib) mkOption types mkMerge mkIf;
configTxt = pkgs.writeText "config.txt" ''
[pi3]
kernel=u-boot-rpi3.bin
# Boot in 64-bit mode.
arm_64bit=1
# Otherwise the serial output will be garbled.
core_freq=250
# Boot in 64-bit mode.
arm_64bit=1
[all]
# U-Boot needs this to work, regardless of whether UART is actually used or not.
# Look in arch/arm/mach-bcm283x/Kconfig in the U-Boot tree to see if this is still
# a requirement in the future.
enable_uart=1
# Prevent the firmware from smashing the framebuffer setup done by the mainline kernel
# when attempting to show low-voltage or overtemperature warnings.
avoid_warnings=1
'';
in {
options.cynerd.rpi = mkOption {
type = with types; nullOr (enum [2 3]);
default = null;
description = "If machine is RaspberryPi and which version";
};
config = mkMerge [
(mkIf (config.cynerd.rpi == 2) {
nixpkgs.hostPlatform.system = "armv7l-linux";
})
(mkIf (config.cynerd.rpi == 3) {
nixpkgs.hostPlatform.system = "aarch64-linux";
boot.kernelParams = ["console=ttyS1,115200n8"];
})
(mkIf (config.cynerd.rpi != null) {
boot.loader = {
systemd-boot.enable = false;
efi.canTouchEfiVariables = false;
generic-extlinux-compatible.enable = true;
};
boot.consoleLogLevel = 7;
fileSystems = {
"/" = {
device = "/dev/mmcblk0p2";
fsType = "ext4";
};
#"/" = {
# device = "/dev/mmcblk0p2";
# fsType = "btrfs";
# options = ["compress=lzo"];
#};
"/boot/firmware" = {
device = "/dev/mmcblk0p1";
fsType = "vfat";
options = ["nofail"];
};
};
services.journald.extraConfig = ''
SystemMaxUse=512M
'';
system.build.firmware = pkgs.callPackage ({stdenvNoCC}:
stdenvNoCC.mkDerivation {
name = "${config.system.name}-firmware";
buildCommand = ''
mkdir $out
cp -r ${pkgs.raspberrypifw}/share/raspberrypi/boot/* $out/
cp ${configTxt} $out/config.txt
# TODO support rpi2
cp ${pkgs.ubootRaspberryPi3_btrfs}/u-boot.bin $out/u-boot-rpi3.bin
'';
}) {};
})
];
}
|