NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.46k stars 13.66k forks source link

Raspberry Pi 4 support #63720

Closed majewsky closed 3 years ago

majewsky commented 5 years ago

Raspberry Pi just announced immediate availability of the Model 4. It will probably be some time until the aarch64 maintainers can get their hands on these, but I figured this can go into the backlog already.

tfc commented 3 years ago

@mohe2015 just tried, did not change anything unfortunately. Your assumptions are correct, i am building on an x86 box. although the raspi image boots just fine on the raspi4 without --system aarch64-linux when i deleted those sun4i_* things.

mohe2015 commented 3 years ago

@tfc See https://github.com/NixOS/nixpkgs/issues/111683 so it's expected behaviour that it doesn't work right now. The arg I posted isn't needed - nix detects it automatically that it has to build using emulation.

tfc commented 3 years ago

I just bisected the wifi problem. Wifi doesn't work on the rpi4 since this commit: https://github.com/NixOS/nixpkgs/commit/d7c4ca2de61c27ccc

It updates the nonfree firmware...

tfc commented 3 years ago

With these two patches, the nixpkgs master successfully builds the sd image for the rpi4 with working wifi:

1.) remove the sun4i_* modules as known from https://github.com/NixOS/nixpkgs/issues/111683

index 96ebb7537da..dbeb4897ae0 100644
--- a/nixos/modules/installer/sd-card/sd-image-aarch64.nix
+++ b/nixos/modules/installer/sd-card/sd-image-aarch64.nix
@@ -21,8 +21,6 @@
   boot.initrd.availableKernelModules = [
     # Allows early (earlier) modesetting for the Raspberry Pi
     "vc4" "bcm2835_dma" "i2c_bcm2835"
-    # Allows early (earlier) modesetting for Allwinner SoCs
-    "sun4i_drm" "sun8i_drm_hdmi" "sun8i_mixer"
   ];

   sdImage = {

2.) update the nonfree linux firmware blobs again, since the pre-latest version that d7c4ca2 introduced does not work:

diff --git a/pkgs/os-specific/linux/firmware/firmware-linux-nonfree/default.nix b/pkgs/os-specific/linux/firmware/firmware-linux-nonfree/default.nix
index 6e7f8d89dde..b66c4e73084 100644
--- a/pkgs/os-specific/linux/firmware/firmware-linux-nonfree/default.nix
+++ b/pkgs/os-specific/linux/firmware/firmware-linux-nonfree/default.nix
@@ -2,12 +2,12 @@

 stdenvNoCC.mkDerivation rec {
   pname = "firmware-linux-nonfree";
-  version = "2021-02-08";
+  version = "2021-03-15";

   src = fetchgit {
     url = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git";
     rev = "refs/tags/" + lib.replaceStrings ["-"] [""] version;
-    sha256 = "0c85cd659312isfz1r87qswsgfhy0rljagcwspnvjljqrh9bsgzq";
+    sha256 = "sha256-BnYqveVFJk/tVYgYuggXgYGcUCZT9iPkCQIi48FOTWc=";
   };

   installFlags = [ "DESTDIR=$(out)" ];
@@ -17,7 +17,7 @@ stdenvNoCC.mkDerivation rec {

   outputHashMode = "recursive";
   outputHashAlgo = "sha256";
-  outputHash = "0l4xsgxdvjffad7a98n42nyqy3ihs6m6hy3qsfkqin9z10413x5n";
+  outputHash = "sha256-TzAMGj7IDhzXcFhHAd15aZvAqyN+OKlJTkIhVGoTkIs=";

   meta = with lib; {
     description = "Binary firmware collection packaged by kernel.org";

i'm going to upstream the blob thing another MR that does this was merged on monday already, so the raspi4 image has working wifi since monday again.

cyntheticfox commented 3 years ago

Is the Hydra builds failing a known issue? I tried following the Wiki Guide and updating to NixOS-Unstable, and my boot device can't find NIXOS_SD after rebooting.

Based on the most recent commits, it looks like the Allwinner stuff was removed, but the Hydra build logs show a failure looking for it.

Edit: I see now what's happening: #111683

MarcoPolo commented 3 years ago

For getting usb only boot working I replaced the files in partition 1 with the versions from the raspberry pi os image. Not config.txt; and I didn't add any new files. I'm not sure what the difference is here, maybe some new change to support booting from USB? The original files booted the SD card fine, but failed when only the usb was present (no SD card).

necrophcodr commented 3 years ago

It appears to still be broken. Booting the latest image from Hydra ( https://hydra.nixos.org/build/142828023 ) results in the image being unable to find /nix/.../init, and failing to continue booting from there.

domenkozar commented 3 years ago

I've written a draft for Raspberry Pi tutorial. I'd be happy if someone gives it a try and reports back if it works and if they got lost at some point. Bonus karma for a screencast :)

I've also opened NixOS-hardware PR.

domenkozar commented 3 years ago

I've moved GPU/acceleration issues into a separate thread: https://github.com/NixOS/nixpkgs/issues/122726

kwaerner commented 3 years ago

I've written a draft for Raspberry Pi tutorial. I'd be happy if someone gives it a try and reports back if it works and if they got lost at some point. Bonus karma for a screencast :)

I've also opened NixOS-hardware PR.

I just finished your tutorial - works great! Tried it on an 8GB Raspberry Pi 4B. Only issue I had was that I had to unplug my keyboard and plug it back in after each reboot for it to work. I also saw some messages about bluetooth at the login shell (found an ArchLinux post about this - you are probably aware of any issues).

Btw: completely new to NixOS, but I will try my best if there is something you want me to test on my installation. :)

06kellyjac commented 3 years ago

@kwaerner welcome to NixOS/nix!

If you need any help there's the discourse, irc, or posting an issue here. And the docs + wiki are pretty solid. More details on the nixos.org website.

domenkozar commented 3 years ago

That's warming to hear @kwaerner :)

The tutorial is now live at https://nix.dev/tutorials/installing-nixos-on-a-raspberry-pi

As @samueldr has aced https://github.com/NixOS/nixpkgs/issues/122726, I believe we can close this issue.

There are probably still some issues with configuring hardware, please open specific issues for those.

n8henrie commented 3 years ago

If this issue is closed, should the asterisk be removed from the support column in the table here?

samueldr commented 3 years ago

YES

cmacrae commented 3 years ago

Just want to run this by others who may still be following this before opening a specific issue: I don't seem to be able to get past Starting kernel... when booting any images generated by the Hydra build job (mentioned in the guide) - including images as recent as yesterday evening.

To be clear, this is straight from dd'ing the image to an SD card and trying to boot, not after a rebuild (I've seen this comment which suggests a fix for that scenario).

Is anyone else experiencing this?

mohe2015 commented 3 years ago

@cmacrae I would try a self-built image first if you have the resources to do so (qemu binfmt may work well). I booted a self-built image with boot.kernelPackages = pkgs.linuxPackages_latest; yesterday over USB on the 8GB edition so maybe that's also needed. AFAIR the Starting kernel... usually means the kernel has actually started (aah that's what the referenced comment says) but the display driver or whatever isn't able to boot. So maybe you also want to build an image with ssh if you would build one yourself.

cmacrae commented 3 years ago

Thanks @mohe2015 :) Alright, I'll give that a shot, then

cmacrae commented 3 years ago

Just want to run this by others who may still be following this before opening a specific issue: I don't seem to be able to get past Starting kernel... when booting any images generated by the Hydra build job (mentioned in the guide) - including images as recent as yesterday evening.

To be clear, this is straight from dd'ing the image to an SD card and trying to boot, not after a rebuild (I've seen this comment >which suggests a fix for that scenario).

Is anyone else experiencing this?

Just to update others who may have a similar issue to the one I experienced above: my problem was that I hadn't updated my Pi's firmware. After following the steps outlined here, I was able to boot the Hydra provided images :)

mohe2015 commented 3 years ago

Just to update others who may have a similar issue to the one I experienced above: my problem was that I hadn't updated my Pi's firmware. After following the steps outlined here, I was able to boot the Hydra provided images :)

Nice that you could fix it. I would've recommended you to check for firmware updates if you would've used USB boot but I didn't know it's also needed for SD card boot.

domenkozar commented 3 years ago

That's why I recommend updating firmware as an installation step.

Maybe that needs to move further up before even booting the image?

domenkozar commented 3 years ago

Thanks @cmacrae - https://github.com/nix-dot-dev/nix.dev/pull/166

cmacrae commented 3 years ago

Perfect, that's exactly what I was going to suggest :) Thanks @domenkozar 🙇