Skip to content

Commit

Permalink
Merge pull request #170528 from lovesegfault/rpi-full-tree
Browse files Browse the repository at this point in the history
feat: add support for the RaspberryPi CM4
  • Loading branch information
lovesegfault authored Apr 27, 2022
2 parents d9e593e + 80d4480 commit d6b9960
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 38 deletions.
9 changes: 9 additions & 0 deletions nixos/modules/installer/sd-card/sd-image-aarch64.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
# Supported in newer board revisions
arm_boost=1
[cm4]
# 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
[all]
# Boot in 64-bit mode.
arm_64bit=1
Expand All @@ -65,6 +71,9 @@
cp ${pkgs.ubootRaspberryPi4_64bit}/u-boot.bin firmware/u-boot-rpi4.bin
cp ${pkgs.raspberrypi-armstubs}/armstub8-gic.bin firmware/armstub8-gic.bin
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb firmware/
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-400.dtb firmware/
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-cm4.dtb firmware/
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-cm4s.dtb firmware/
'';
populateRootCommands = ''
mkdir -p ./files/boot
Expand Down
3 changes: 3 additions & 0 deletions nixos/modules/profiles/all-hardware.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ in
# SD cards.
"sdhci_pci"

# NVMe drives
"nvme"

# Firewire support. Not tested.
"ohci1394" "sbp2"

Expand Down
35 changes: 6 additions & 29 deletions pkgs/misc/uboot/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
, openssl
, swig
, meson-tools
, which
, armTrustedFirmwareAllwinner
, armTrustedFirmwareAllwinnerH616
, armTrustedFirmwareRK3328
Expand All @@ -19,10 +20,10 @@
}:

let
defaultVersion = "2021.10";
defaultVersion = "2022.01";
defaultSrc = fetchurl {
url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${defaultVersion}.tar.bz2";
sha256 = "1m0bvwv8r62s4wk4w3cmvs888dhv9gnfa98dczr4drk2jbhj7ryd";
hash = "sha256-gbRUMifbIowD+KG/XdvIE7C7j2VVzkYGTvchpvxoBBM=";
};
buildUBoot = {
version ? null
Expand Down Expand Up @@ -66,11 +67,14 @@ let
p.setuptools # for pkg_resources
]))
swig
which # for scripts/dtc-version.sh
];
depsBuildBuild = [ buildPackages.stdenv.cc ];

hardeningDisable = [ "all" ];

enableParallelBuilding = true;

makeFlags = [
"DTC=dtc"
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
Expand Down Expand Up @@ -102,9 +106,6 @@ let
runHook postInstall
'';

# make[2]: *** No rule to make target 'lib/efi_loader/helloworld.efi', needed by '__build'. Stop.
enableParallelBuilding = false;

dontStrip = true;

meta = with lib; {
Expand Down Expand Up @@ -373,14 +374,6 @@ in {
CONFIG_USB_EHCI_GENERIC=y
CONFIG_USB_XHCI_HCD=y
'';
extraPatches = [
# https://patchwork.ozlabs.org/project/uboot/list/?series=268007&state=%2A&archive=both
# Remove when upgrading to 2022.01
(fetchpatch {
url = "https://patchwork.ozlabs.org/series/268007/mbox/";
sha256 = "sha256-xn4Q959dgoB63zlmJepI41AXAf1kCycIGcmu4IIVjmE=";
})
];
extraMeta.platforms = [ "i686-linux" "x86_64-linux" ];
filesToInstall = [ "u-boot.rom" ];
};
Expand All @@ -401,28 +394,12 @@ in {
defconfig = "rpi_3_32b_defconfig";
extraMeta.platforms = ["armv7l-linux"];
filesToInstall = ["u-boot.bin"];
extraPatches = [
# Remove when updating to 2022.01
# https://patchwork.ozlabs.org/project/uboot/list/?series=273129&archive=both&state=*
(fetchpatch {
url = "https://patchwork.ozlabs.org/series/273129/mbox/";
sha256 = "sha256-/Gu7RNvBNYCGqdFRzQ11qPDDxgGVpwKYYw1CpumIGfU=";
})
];
};

ubootRaspberryPi3_64bit = buildUBoot {
defconfig = "rpi_3_defconfig";
extraMeta.platforms = ["aarch64-linux"];
filesToInstall = ["u-boot.bin"];
extraPatches = [
# Remove when updating to 2022.01
# https://patchwork.ozlabs.org/project/uboot/list/?series=273129&archive=both&state=*
(fetchpatch {
url = "https://patchwork.ozlabs.org/series/273129/mbox/";
sha256 = "sha256-/Gu7RNvBNYCGqdFRzQ11qPDDxgGVpwKYYw1CpumIGfU=";
})
];
};

ubootRaspberryPi4_32bit = buildUBoot {
Expand Down
17 changes: 8 additions & 9 deletions pkgs/os-specific/linux/firmware/raspberrypi-wireless/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,19 @@ stdenv.mkDerivation {
mkdir -p "$out/lib/firmware/brcm"
# Wifi firmware
shopt -s extglob
for filename in firmware-nonfree/brcm/brcmfmac434??{,s}-sdio.*; do
cp "$filename" "$out/lib/firmware/brcm"
done
cp -rv "$NIX_BUILD_TOP/firmware-nonfree/debian/config/brcm80211/." "$out/lib/firmware/"
# Bluetooth firmware
cp bluez-firmware/broadcom/*.hcd "$out/lib/firmware/brcm"
cp -rv "$NIX_BUILD_TOP/bluez-firmware/broadcom/." "$out/lib/firmware/brcm"
# CM4 symlink must be added since it's missing from upstream
pushd $out/lib/firmware/brcm &>/dev/null
ln -s "./brcmfmac43455-sdio.txt" "$out/lib/firmware/brcm/brcmfmac43455-sdio.raspberrypi,4-compute-module.txt"
popd &>/dev/null
runHook postInstall
'';

outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "sha256-Fw8EC1jzszWg9rNH01oaOIHnSYDuF6ov6ulmIAPuNz4=";

meta = with lib; {
description = "Firmware for builtin Wifi/Bluetooth devices in the Raspberry Pi 3+ and Zero W";
homepage = "https://github.com/RPi-Distro/firmware-nonfree";
Expand Down

0 comments on commit d6b9960

Please sign in to comment.