Raspberry PI Zero 2 W, 64-bit kernel recommendations

Hi everyone,

When building an image for a Raspberry PI Zero 2 W using pkgs.linuxPackages_rpi0 kernel, I had to compile for armv7l-linux.

mainline and “normal” kernels do work, I’m looking at getting Pi’s specific features though, hardware compatibility, etc.


With the following config, some packages will not build:

{ modulesPath, pkgs, ... }:

{
  imports = [
    "${modulesPath}/installer/sd-card/sd-image-aarch64.nix"
  ];

  boot = {
    kernelPackages = pkgs.linuxPackages_rpi0;
  };
}

Compiling to arm instead of aarch64 works:

{
++  nixpkgs.hostPlatform = "armv7l-linux";
}
# then run
nix-build ... --option system armv7l-linux --extra-platforms armv7l-linux

From nixpkgs repo, it seems that all models below 3 (excluded) target arm:

From Raspberry hardware doc for Zero W RP3A0 chip:

The Raspberry Pi RP3A0 is our first System-in-Package (SiP) consisting of a Broadcom BCM2710A1 — which is the silicon die packaged inside the Broadcom BCM2837 chip which is used on the Raspberry Pi 3 — along with 512MB of DRAM.

Does that mean that pkgs.linuxPackages_rpi3 kernel should be “compatible” with the Zero 2 W model to target aarch64?
Are there any recommendations / suggestions?

There seems to be a slight misunderstanding here. The original Pi Zero is a trimmed down Pi 1 with an armv7l system. The Zero 2 is a trimmed down Pi 3 and needs aarch64.

I used the build instructions here to build the inital sd-card, but you could probably just build a system for Pi 3 and put the sd into the Zero 2.

1 Like

thanks for the example and clarification, FYI i’m not yet comfortable with hardware / low-level stuff

yeah i was under that impression from Rapberry hardware doc (see quote above)
how does that work then for device tree overlays? (that is still a bit obscure to me but learning)
will it sill build with the ones for and compatible with the Zero 2 W (or other models)?

it does look like .dtb for all compatible models are in regardless:

EDIT:
From your repo, it seems that it should be ok and correct .dtb are loaded then only need to find the matching filter if additional overlays:

Also noted the use of linuxPackages_rpi02w which is an alias for rpi3 kernel, didn’t see any references of that in NixOS docs though
nixpkgs/pkgs/top-level/aliases.nix at master · NixOS/nixpkgs · GitHub

the config.txt part is quit neat - i was looking for a solution to populate config.txt since boot.loader.raspberrypi has been removed