Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for the RaspberryPi CM4 #170528

Merged
merged 15 commits into from
Apr 27, 2022

Conversation

lovesegfault
Copy link
Member

@lovesegfault lovesegfault commented Apr 26, 2022

Description of changes

With this, you can boot NixOS on the CM4 via SD, eMMC, USB, or NVMe using u-boot
and the mainline kernel. Wi-Fi and Bluetooth are also working.

The main caution is you must use the sd-image with a new kernel, 5.17 or later.

Huge thanks to @cleverca22, @ElvishJerricco, and @samueldr who helped me hack on
this in the last couple of days.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Apr 26, 2022
@@ -19,10 +20,10 @@
}:

let
defaultVersion = "2021.10";
defaultVersion = "2022.01";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not the newer version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because our precious patches don't work there yet.

I might try rebasing them later, but I must admit I'm running out of gas :P

Copy link
Member

@samueldr samueldr Apr 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[See other comment too]

I know I haven't been updating the last two releases (I wonder why r-ryantm didn't notice, and no one else did), but the goal is to prevent any kind of foward-incompatible drift; so we shouldn't block the upgrade to the current version.

@ofborg ofborg bot requested review from lopsided98 and dezgeg April 26, 2022 23:25
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Apr 26, 2022
@lovesegfault
Copy link
Member Author

Result of nixpkgs-review pr 170528 run on aarch64-linux 1

1 package marked as broken and skipped:
  • odroid-xu3-bootloader
1 package blacklisted:
  • nixos-install-tools
20 packages built:
  • raspberrypiWirelessFirmware
  • ubootBananaPim64
  • ubootNanoPCT4
  • ubootOdroidC2
  • ubootOlimexA64Olinuxino
  • ubootOrangePiZero2
  • ubootOrangePiZeroPlus2H5
  • ubootPine64
  • ubootPine64LTS
  • ubootPinebook
  • ubootPinebookPro
  • ubootQemuAarch64
  • ubootROCPCRK3399
  • ubootRaspberryPi3_64bit
  • ubootRaspberryPi4_64bit
  • ubootRock64
  • ubootRockPi4
  • ubootRockPro64
  • ubootSopine
  • ubootTools

@lovesegfault
Copy link
Member Author

Result of nixpkgs-review pr 170528 run on x86_64-linux 1

1 package blacklisted:
  • nixos-install-tools
4 packages built:
  • diffoscope
  • raspberrypiWirelessFirmware
  • ubootQemuX86
  • ubootTools

Copy link
Member

@samueldr samueldr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only two outright problems, everything else is nitpicky or small issues.

  • Patches going against mainline
  • USB being enabled outright on the CM4

@@ -19,10 +20,10 @@
}:

let
defaultVersion = "2021.10";
defaultVersion = "2022.01";
Copy link
Member

@samueldr samueldr Apr 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[See other comment too]

I know I haven't been updating the last two releases (I wonder why r-ryantm didn't notice, and no one else did), but the goal is to prevent any kind of foward-incompatible drift; so we shouldn't block the upgrade to the current version.

pkgs/misc/uboot/default.nix Outdated Show resolved Hide resolved
pkgs/misc/uboot/default.nix Outdated Show resolved Hide resolved
Comment on lines -45 to -48
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "sha256-Fw8EC1jzszWg9rNH01oaOIHnSYDuF6ov6ulmIAPuNz4=";

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK all firmware packages should use FOD to reduce unneeded rebuilds. [citation needed].

(Personally I find it is an abuse of FODs, though that might only apply to the big linux-firmware package.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this doesn't really cause any big rebuilds AFAICT

pkgs/misc/uboot/default.nix Show resolved Hide resolved
nixos/modules/installer/sd-card/sd-image-aarch64.nix Outdated Show resolved Hide resolved
Comment on lines +48 to +51
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be problematic, depending on the CM4 usage. Is it a good idea to outright apply this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the vast majority of users will want this, and the minority who don't can still override it.

@ofborg ofborg bot requested a review from samueldr April 27, 2022 02:25
@lovesegfault lovesegfault merged commit d6b9960 into NixOS:master Apr 27, 2022
@lovesegfault lovesegfault deleted the rpi-full-tree branch April 27, 2022 03:55
@colemickens
Copy link
Member

This actually fixes wifi on the rpizero (and likely others) that had been broken. Found out when my own version of it didn't rebase when I went to send it... -_-. thanks @lovesegfault !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants