From 87a68c455e7a5475e2a899a6f956da521afec715 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Fri, 3 Nov 2017 15:49:51 +0200 Subject: [PATCH 01/11] kernel: Allow kernel packages to specify a custom default defconfig --- pkgs/os-specific/linux/kernel/generic.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index 2b44ff51ad0..249a1ea5cef 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -12,6 +12,9 @@ , # The kernel version. version +, # Allows overriding the default defconfig + defconfig ? null + , # Overrides to the kernel config. extraConfig ? "" @@ -85,7 +88,7 @@ let platformName = hostPlatform.platform.name; # e.g. "defconfig" - kernelBaseConfig = hostPlatform.platform.kernelBaseConfig; + kernelBaseConfig = if defconfig != null then defconfig else hostPlatform.platform.kernelBaseConfig; # e.g. "bzImage" kernelTarget = hostPlatform.platform.kernelTarget; From 96edbe4a0eaf192d970172351a685c9b5585a7ce Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Fri, 3 Nov 2017 15:50:19 +0200 Subject: [PATCH 02/11] linux_rpi: Specify defconfig in kernel expression In particular, now the mainline kernel can be built on the RPi 1 as well (so kernelBaseConfig should always be a mainline defconfig from now on). And RPi 2 users can now use linux_rpi without doing the `nixpkgs.config.platform = lib.systems.platforms.raspberrypi2;` dance. --- lib/systems/platforms.nix | 4 +--- pkgs/os-specific/linux/kernel/linux-rpi.nix | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/systems/platforms.nix b/lib/systems/platforms.nix index 32f055b6b1c..00b2b683db0 100644 --- a/lib/systems/platforms.nix +++ b/lib/systems/platforms.nix @@ -167,7 +167,7 @@ rec { raspberrypi = { name = "raspberrypi"; kernelMajor = "2.6"; - kernelBaseConfig = "bcmrpi_defconfig"; + kernelBaseConfig = "bcm2835_defconfig"; kernelDTB = true; kernelArch = "arm"; kernelAutoModules = false; @@ -254,8 +254,6 @@ rec { raspberrypi2 = armv7l-hf-multiplatform // { name = "raspberrypi2"; - kernelBaseConfig = "bcm2709_defconfig"; - kernelDTB = true; kernelAutoModules = false; kernelExtraConfig = '' BLK_DEV_RAM y diff --git a/pkgs/os-specific/linux/kernel/linux-rpi.nix b/pkgs/os-specific/linux/kernel/linux-rpi.nix index a96a910c68c..d8558324221 100644 --- a/pkgs/os-specific/linux/kernel/linux-rpi.nix +++ b/pkgs/os-specific/linux/kernel/linux-rpi.nix @@ -15,6 +15,11 @@ stdenv.lib.overrideDerivation (buildLinux (args // rec { sha256 = "19lb1gxz21x1d5zdznzqfq60kxg7iqmyl6l0mb9qg2vrl8fcgnxk"; }; + defconfig = { + "armv6l-linux" = "bcmrpi_defconfig"; + "armv7l-linux" = "bcm2709_defconfig"; + }.${stdenv.system} or (throw "linux_rpi not supported on '${stdenv.system}'"); + features = { efiBootStub = false; } // (args.features or {}); From db2988f7bd579b984d98fbdbcbc157b9eb9fd387 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Sun, 5 Nov 2017 19:32:19 +0200 Subject: [PATCH 03/11] platforms.nix: Clean up obsolete cruft from raspberrypi Works fine without, and the 'DRM n' is actually preventing the mainline VC4 driver from building. --- lib/systems/platforms.nix | 69 --------------------------------------- 1 file changed, 69 deletions(-) diff --git a/lib/systems/platforms.nix b/lib/systems/platforms.nix index 00b2b683db0..ccfad9543e3 100644 --- a/lib/systems/platforms.nix +++ b/lib/systems/platforms.nix @@ -172,83 +172,14 @@ rec { kernelArch = "arm"; kernelAutoModules = false; kernelExtraConfig = '' - BLK_DEV_RAM y - BLK_DEV_INITRD y - BLK_DEV_CRYPTOLOOP m - BLK_DEV_DM m - DM_CRYPT m - MD y - REISERFS_FS m - BTRFS_FS y - XFS_FS m - JFS_FS y - EXT4_FS y - - IP_PNP y - IP_PNP_DHCP y - NFS_FS y - ROOT_NFS y - TUN m - NFS_V4 y - NFS_V4_1 y - NFS_FSCACHE y - NFSD m - NFSD_V2_ACL y - NFSD_V3 y - NFSD_V3_ACL y - NFSD_V4 y - NETFILTER y - IP_NF_IPTABLES y - IP_NF_FILTER y - IP_NF_MATCH_ADDRTYPE y - IP_NF_TARGET_LOG y - IP_NF_MANGLE y - IPV6 m - VLAN_8021Q m - - CIFS y - CIFS_XATTR y - CIFS_POSIX y - CIFS_FSCACHE y - CIFS_ACL y - - ZRAM m - # Disable OABI to have seccomp_filter (required for systemd) # https://github.com/raspberrypi/firmware/issues/651 OABI_COMPAT n - - # Fail to build - DRM n - SCSI_ADVANSYS n - USB_ISP1362_HCD n - SND_SOC n - SND_ALI5451 n - FB_SAVAGE n - SCSI_NSP32 n - ATA_SFF n - SUNGEM n - IRDA n - ATM_HE n - SCSI_ACARD n - BLK_DEV_CMD640_ENHANCED n - - FUSE_FS m - - # nixos mounts some cgroup - CGROUPS y - - # Latencytop - LATENCYTOP y ''; kernelTarget = "zImage"; gcc = { arch = "armv6"; fpu = "vfp"; - # TODO(@Ericson2314) what is this and is it a good idea? It was - # used in some cross compilation examples but not others. - # - # abi = "aapcs-linux"; }; }; From 3abdd4f1e3d85bd258caa92baf42b30286109d10 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Sun, 5 Nov 2017 19:34:00 +0200 Subject: [PATCH 04/11] platforms.nix: Clean up obsolete cruft from raspberrypi2 --- lib/systems/platforms.nix | 77 ++------------------------------------- 1 file changed, 4 insertions(+), 73 deletions(-) diff --git a/lib/systems/platforms.nix b/lib/systems/platforms.nix index ccfad9543e3..14a0c4eb696 100644 --- a/lib/systems/platforms.nix +++ b/lib/systems/platforms.nix @@ -186,79 +186,6 @@ rec { raspberrypi2 = armv7l-hf-multiplatform // { name = "raspberrypi2"; kernelAutoModules = false; - kernelExtraConfig = '' - BLK_DEV_RAM y - BLK_DEV_INITRD y - BLK_DEV_CRYPTOLOOP m - BLK_DEV_DM m - DM_CRYPT m - MD y - REISERFS_FS m - BTRFS_FS y - XFS_FS m - JFS_FS y - EXT4_FS y - - IP_PNP y - IP_PNP_DHCP y - NFS_FS y - ROOT_NFS y - TUN m - NFS_V4 y - NFS_V4_1 y - NFS_FSCACHE y - NFSD m - NFSD_V2_ACL y - NFSD_V3 y - NFSD_V3_ACL y - NFSD_V4 y - NETFILTER y - IP_NF_IPTABLES y - IP_NF_FILTER y - IP_NF_MATCH_ADDRTYPE y - IP_NF_TARGET_LOG y - IP_NF_MANGLE y - IPV6 m - VLAN_8021Q m - - CIFS y - CIFS_XATTR y - CIFS_POSIX y - CIFS_FSCACHE y - CIFS_ACL y - - ZRAM m - - # Disable OABI to have seccomp_filter (required for systemd) - # https://github.com/raspberrypi/firmware/issues/651 - OABI_COMPAT n - - # Fail to build - DRM n - SCSI_ADVANSYS n - USB_ISP1362_HCD n - SND_SOC n - SND_ALI5451 n - FB_SAVAGE n - SCSI_NSP32 n - ATA_SFF n - SUNGEM n - IRDA n - ATM_HE n - SCSI_ACARD n - BLK_DEV_CMD640_ENHANCED n - - FUSE_FS m - - # nixos mounts some cgroup - CGROUPS y - - # Latencytop - LATENCYTOP y - - # Disable the common config Xen, it doesn't build on ARM - XEN? n - ''; kernelTarget = "zImage"; }; @@ -353,6 +280,10 @@ rec { # Hangs ODROID-XU4 ARM_BIG_LITTLE_CPUIDLE n + + # Disable OABI to have seccomp_filter (required for systemd) + # https://github.com/raspberrypi/firmware/issues/651 + OABI_COMPAT n ''; gcc = { # Some table about fpu flags: From 27bb4da3441eed128574e5e4eabf5762fe4f68be Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Mon, 6 Nov 2017 15:26:52 +0200 Subject: [PATCH 05/11] platforms.nix: More rpi2 cleanup --- lib/systems/platforms.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/systems/platforms.nix b/lib/systems/platforms.nix index 14a0c4eb696..f624a5c140a 100644 --- a/lib/systems/platforms.nix +++ b/lib/systems/platforms.nix @@ -183,11 +183,8 @@ rec { }; }; - raspberrypi2 = armv7l-hf-multiplatform // { - name = "raspberrypi2"; - kernelAutoModules = false; - kernelTarget = "zImage"; - }; + # Legacy attribute, for compatibility with existing configs only. + raspberrypi2 = armv7l-hf-multiplatform; scaleway-c1 = armv7l-hf-multiplatform // { gcc = { From 85952d850e40d40f801d6653db24448fb375d8e3 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Sat, 21 Apr 2018 18:30:12 +0300 Subject: [PATCH 06/11] raspberrypifw: 1.20180328 -> 1.20180417 --- pkgs/os-specific/linux/firmware/raspberrypi/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/firmware/raspberrypi/default.nix b/pkgs/os-specific/linux/firmware/raspberrypi/default.nix index d00f1b14837..344d224df94 100644 --- a/pkgs/os-specific/linux/firmware/raspberrypi/default.nix +++ b/pkgs/os-specific/linux/firmware/raspberrypi/default.nix @@ -2,13 +2,13 @@ stdenv.mkDerivation rec { name = "raspberrypi-firmware-${version}"; - version = "1.20180328"; + version = "1.20180417"; src = fetchFromGitHub { owner = "raspberrypi"; repo = "firmware"; rev = version; - sha256 = "19h4lv11idy268pyrq21c5gsff77d5xr9xjkpmzfpcq34gjh3x21"; + sha256 = "17mnnhni0wgdnc3mw60nfhcj9v6p5dwcqkwnbpvzczab3r2hziji"; }; installPhase = '' From b71f5830fa5a56251ca675a26e7066ec5d0a88a7 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Tue, 3 Apr 2018 02:20:05 +0300 Subject: [PATCH 07/11] linux_rpi: 1.20171029 -> 1.20180417 --- pkgs/os-specific/linux/kernel/linux-rpi.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/linux-rpi.nix b/pkgs/os-specific/linux/kernel/linux-rpi.nix index d8558324221..d6b174a43d4 100644 --- a/pkgs/os-specific/linux/kernel/linux-rpi.nix +++ b/pkgs/os-specific/linux/kernel/linux-rpi.nix @@ -1,8 +1,8 @@ { stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args: let - modDirVersion = "4.9.59"; - tag = "1.20171029"; + modDirVersion = "4.14.34"; + tag = "1.20180417"; in stdenv.lib.overrideDerivation (buildLinux (args // rec { version = "${modDirVersion}-${tag}"; @@ -12,7 +12,7 @@ stdenv.lib.overrideDerivation (buildLinux (args // rec { owner = "raspberrypi"; repo = "linux"; rev = "raspberrypi-kernel_${tag}-1"; - sha256 = "19lb1gxz21x1d5zdznzqfq60kxg7iqmyl6l0mb9qg2vrl8fcgnxk"; + sha256 = "1xgisvmcq50lpnd4rpqhaw52399n0rx2n8mp6k0bf8qm1g3vnza2"; }; defconfig = { From 964bd06bbc35bb26d9b0166d085f43cc9e8e53f0 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Fri, 20 Apr 2018 14:58:32 +0300 Subject: [PATCH 08/11] U-Boot: 2018.03 -> 2018.05 --- pkgs/misc/uboot/default.nix | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/pkgs/misc/uboot/default.nix b/pkgs/misc/uboot/default.nix index 4cf1748bad4..d9cc1c077d3 100644 --- a/pkgs/misc/uboot/default.nix +++ b/pkgs/misc/uboot/default.nix @@ -7,8 +7,8 @@ let # Various changes for 64-bit sunxi boards, (hopefully) destined for 2018.05 sunxiPatch = fetchpatch { name = "sunxi.patch"; - url = "https://github.com/u-boot/u-boot/compare/v2018.03...dezgeg:2018-03-sunxi.patch"; - sha256 = "1pqn7c6c06hfygwpcgaraqvqxcjhz99j0rx5psfhj8igy0qvk2dq"; + url = "https://github.com/u-boot/u-boot/compare/v2018.05...dezgeg:2018-05-sunxi.patch"; + sha256 = "1dfv4s1f71iv80vjxgyghv4pcwjv4mjphk75a8hfl3jdbpd66d36"; }; buildUBoot = { filesToInstall @@ -21,21 +21,21 @@ let stdenv.mkDerivation (rec { name = "uboot-${defconfig}-${version}"; - version = "2018.03"; + version = "2018.05"; src = fetchurl { url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${version}.tar.bz2"; - sha256 = "1z9x635l5164c5hnf7qs19w7j3qghbkgs7rpn673dm898i9pfx3y"; + sha256 = "0j60p4iskzb4hamxgykc6gd7xchxfka1zwh8hv08r9rrc4m3r8ad"; }; patches = [ (fetchpatch { - url = https://github.com/dezgeg/u-boot/commit/rpi-2017-11-patch1.patch; - sha256 = "067yq55vv1slv4xy346px7h329pi14abdn04chg6s1s6hmf6c1x9"; + url = https://github.com/dezgeg/u-boot/commit/rpi-2018-05-patch1.patch; + sha256 = "0xvw16mp6mm36987rd5yb8bw0n5b3p1gq35wch2gbj15wx55450p"; }) (fetchpatch { - url = https://github.com/dezgeg/u-boot/commit/rpi-2017-11-patch2.patch; - sha256 = "0bbw0q027xvzvdxxvpzjajg4rm30a8mb7z74b6ma9q0l7y7bi0c4"; + url = https://github.com/dezgeg/u-boot/commit/rpi-2018-05-patch2.patch; + sha256 = "0q1a5l5rfgddncxrjk59qr1f5587dwbvcf6z15bsfl2invs19m2b"; }) (fetchpatch { url = https://github.com/dezgeg/u-boot/commit/pythonpath-2018-03.patch; @@ -100,8 +100,7 @@ in rec { hardeningDisable = []; dontStrip = false; extraMeta.platforms = stdenv.lib.platforms.linux; - # build tools/kwboot - extraMakeFlags = [ "CONFIG_KIRKWOOD=y" "CROSS_BUILD_TOOLS=1" "NO_SDL=1" "tools" ]; + extraMakeFlags = [ "HOST_TOOLS_ALL=y" "CROSS_BUILD_TOOLS=1" "NO_SDL=1" "tools" ]; postConfigure = '' sed -i '/CONFIG_SYS_TEXT_BASE/c\CONFIG_SYS_TEXT_BASE=0x00000000' .config ''; From 912e87c45cc4ffbdb80a606d01fe2fa6545386a3 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Sat, 5 May 2018 14:44:04 +0300 Subject: [PATCH 09/11] U-Boot: Add ubootRaspberryPiZero variant --- pkgs/misc/uboot/default.nix | 6 ++++++ pkgs/top-level/all-packages.nix | 1 + 2 files changed, 7 insertions(+) diff --git a/pkgs/misc/uboot/default.nix b/pkgs/misc/uboot/default.nix index d9cc1c077d3..9486a504ac3 100644 --- a/pkgs/misc/uboot/default.nix +++ b/pkgs/misc/uboot/default.nix @@ -217,6 +217,12 @@ in rec { filesToInstall = ["u-boot.bin"]; }; + ubootRaspberryPiZero = buildUBoot rec { + defconfig = "rpi_0_w_defconfig"; + extraMeta.platforms = ["armv6l-linux"]; + filesToInstall = ["u-boot.bin"]; + }; + ubootSheevaplug = buildUBoot rec { defconfig = "sheevaplug_defconfig"; extraMeta.platforms = ["armv5tel-linux"]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9c8acb7cff0..b7bb3ab70e6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14206,6 +14206,7 @@ with pkgs; ubootRaspberryPi2 ubootRaspberryPi3_32bit ubootRaspberryPi3_64bit + ubootRaspberryPiZero ubootSheevaplug ubootSopine ubootUtilite From f49906d80c30dbb37a2d2d188ab9bd9793a4ac3f Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Sat, 5 May 2018 19:02:00 +0300 Subject: [PATCH 10/11] nixos/sd-image-raspberrypi: Support Raspberry Pi Zero --- .../installer/cd-dvd/sd-image-raspberrypi.nix | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/nixos/modules/installer/cd-dvd/sd-image-raspberrypi.nix b/nixos/modules/installer/cd-dvd/sd-image-raspberrypi.nix index 212013b5e28..fe6cc416163 100644 --- a/nixos/modules/installer/cd-dvd/sd-image-raspberrypi.nix +++ b/nixos/modules/installer/cd-dvd/sd-image-raspberrypi.nix @@ -31,11 +31,24 @@ in users.extraUsers.root.initialHashedPassword = ""; sdImage = { - populateBootCommands = '' - (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/boot/) - cp ${pkgs.ubootRaspberryPi}/u-boot.bin boot/u-boot-rpi.bin - echo 'kernel u-boot-rpi.bin' > boot/config.txt - ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./boot - ''; + populateBootCommands = let + configTxt = pkgs.writeText "config.txt" '' + # 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 + + [pi0] + kernel=u-boot-rpi0.bin + + [pi1] + kernel=u-boot-rpi1.bin + ''; + in '' + (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/boot/) + cp ${pkgs.ubootRaspberryPiZero}/u-boot.bin boot/u-boot-rpi0.bin + cp ${pkgs.ubootRaspberryPi}/u-boot.bin boot/u-boot-rpi1.bin + cp ${configTxt} boot/config.txt + ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./boot + ''; }; } From a8c898be6071c461961b4572afe3b72b7c831fc7 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Mon, 7 May 2018 21:59:15 +0300 Subject: [PATCH 11/11] linux_rpi: More downstream device tree name fixups Also remove the upstream device trees beforehand so we don't accidentally end using them if we mess up in postFixup. Also on the topic of mess ups, make the copy unconditional since they always seem to be built on all architectures anyway so checking for their existence just hides typos. --- pkgs/os-specific/linux/kernel/linux-rpi.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/linux-rpi.nix b/pkgs/os-specific/linux/kernel/linux-rpi.nix index d6b174a43d4..d869ea09036 100644 --- a/pkgs/os-specific/linux/kernel/linux-rpi.nix +++ b/pkgs/os-specific/linux/kernel/linux-rpi.nix @@ -32,16 +32,15 @@ stdenv.lib.overrideDerivation (buildLinux (args // rec { ''; postFixup = '' - # Make copies of the DTBs so that U-Boot finds them, as it is looking for the upstream names. - # This is ugly as heck. + # Make copies of the DTBs named after the upstream names so that U-Boot finds them. + # This is ugly as heck, but I don't know a better solution so far. + rm $out/dtbs/bcm283*.dtb copyDTB() { - if [ -f "$out/dtbs/$1" ]; then - cp -v "$out/dtbs/$1" "$out/dtbs/$2" - fi + cp -v "$out/dtbs/$1" "$out/dtbs/$2" } - # I am not sure if all of these are correct... - copyDTB bcm2708-rpi-0-w.dts bcm2835-rpi-zero.dtb + copyDTB bcm2708-rpi-0-w.dtb bcm2835-rpi-zero.dtb + copyDTB bcm2708-rpi-0-w.dtb bcm2835-rpi-zero-w.dtb copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-a.dtb copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-b.dtb copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-b-rev2.dtb @@ -51,6 +50,7 @@ stdenv.lib.overrideDerivation (buildLinux (args // rec { copyDTB bcm2708-rpi-cm.dtb bcm2835-rpi-cm.dtb copyDTB bcm2709-rpi-2-b.dtb bcm2836-rpi-2-b.dtb copyDTB bcm2710-rpi-3-b.dtb bcm2837-rpi-3-b.dtb - # bcm2710-rpi-cm3.dts is yet unknown. + copyDTB bcm2710-rpi-3-b-plus.dtb bcm2837-rpi-3-b-plus.dtb + copyDTB bcm2710-rpi-cm3.dtb bcm2837-rpi-cm3.dtb ''; })