1
0
Fork 0
mirror of https://github.com/NixOS/nixos-hardware synced 2024-11-27 05:19:43 +01:00

Pine64 PinePhone Pro

This commit is contained in:
zimward 2024-08-07 00:04:14 +02:00
parent 14c333162b
commit 0b82ff9b47
No known key found for this signature in database
GPG key ID: 4CAC61D6A482FCD9
12 changed files with 2835 additions and 0 deletions

View file

@ -301,6 +301,7 @@ See code for all available configurations.
| [Panasonic Let's Note CF-LX4](panasonic/letsnote/cf-lx4) | `<nixos-hardware/panasonic/letsnote/cf-lx4>` |
| [PC Engines APU](pcengines/apu) | `<nixos-hardware/pcengines/apu>` |
| [PINE64 Pinebook Pro](pine64/pinebook-pro/) | `<nixos-hardware/pine64/pinebook-pro>` |
| [PINE64 Pinephone Pro](pine64/pinephone-pro/) | `<nixos-hardware/pine64/pinephone-pro>` |
| [PINE64 RockPro64](pine64/rockpro64/) | `<nixos-hardware/pine64/rockpro64>` |
| [PINE64 STAR64](pine64/star64/) | `<nixos-hardware/pine64/star64>` |
| [Protectli VP4670](protectli/vp4670/) | `<nixos-hardware/protectli/vp4670>` |

View file

@ -247,6 +247,7 @@
olimex-teres_i = import ./olimex/teres_i;
pcengines-apu = import ./pcengines/apu;
pine64-pinebook-pro = import ./pine64/pinebook-pro;
pine64-pinephone-pro = import ./pine64/pinephone-pro;
pine64-rockpro64 = import ./pine64/rockpro64;
pine64-star64 = import ./pine64/star64;
protectli-vp4670 = import ./protectli/vp4670;

View file

@ -0,0 +1,13 @@
# Pine64 PinePhone Pro
## Bootloader
Either [Tow-Boot](https://github.com/Tow-Boot/Tow-Boot) or Megi's [rk2aw](https://xnux.eu/rk2aw/) are recommended to
allow boot via `boot.loader.generic-extlinux-compatible`. rk2aw features a touch-based boot selection which should
provide the ability to choose the NixOS generation.
## Known Issues
- Audio is currently broken
- The `brcmfmac` driver regularly spews the following error `brcmf_set_channel: set chanspec 0x???? fail, reason -52`
this has been somewhat alleviated by [disabling SAE](./wifi.nix#L7) to the point of allowing WiFi to function
but the issue still remains.
- The cameras are curretly broken, patches exist but need to be rebased to be applicable
- panfrost crashes sometimes

View file

@ -0,0 +1,41 @@
{
pkgs,
lib,
config,
...
}:
let
cfg = config.hardware.pinephone-pro;
in
{
imports = [ ./wifi.nix ];
options.hardware.pinephone-pro = {
install-ucm2-rules = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to install PinePhone Pro specific UCM2 rules.
These provide audio usecaseses for HiFi audio and Voice calls.
'';
};
};
config = {
nixpkgs.overlays = [
(final: _prev: {
pine64-alsa-ucm = final.callPackage ./pine64-alsa-ucm { };
firmware_pinephone-pro = pkgs.callPackage ./firmware.nix { };
linuxPackages_pinephone-pro = pkgs.callPackage ./kernel { inherit (config.boot) kernelPatches; };
})
];
hardware.firmware = [ pkgs.firmware_pinephone-pro ];
environment.systemPackages = lib.optionals cfg.install-ucm2-rules [ pkgs.pine64-alsa-ucm ];
boot = {
kernelPackages = pkgs.linuxPackagesFor pkgs.linuxPackages_pinephone-pro;
loader = {
generic-extlinux-compatible.enable = true;
grub.enable = false;
};
};
};
}

View file

@ -0,0 +1,70 @@
# MIT License
# Copyright (c) 2018-2020 Samuel Dionne-Riel and the Mobile NixOS contributors
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
{
runCommand,
firmwareLinuxNonfree,
fetchgit,
fetchFromGitLab,
}:
let
pinephonepro-firmware = fetchFromGitLab {
domain = "gitlab.manjaro.org";
owner = "tsys";
repo = "pinebook-firmware";
rev = "937f0d52d27d7712da6a008d35fd7c2819e2b077";
sha256 = "sha256-Ij5u4IF55kPFs1BGq/sLlI3fjufwSjqrf8OZ2WnvjWI=";
};
ap6256-firmware = fetchFromGitLab {
domain = "gitlab.manjaro.org";
owner = "manjaro-arm";
repo = "packages%2Fcommunity%2Fap6256-firmware";
rev = "a30bf312b268eab42d38fab0cc3ed3177895ff5d";
sha256 = "sha256-i2OEkn7RtEMbJd0sYEE2Hpkvw6KRppz5AbwXJFNa/pE=";
};
brcm-firmware = fetchgit {
url = "https://megous.com/git/linux-firmware";
rev = "6e8e591e17e207644dfe747e51026967bb1edab5";
sha256 = "sha256-TaGwT0XvbxrfqEzUAdg18Yxr32oS+RffN+yzSXebtac=";
};
in
# The minimum set of firmware files required for the device.
runCommand "pine64-pinephonepro-firmware" { src = firmwareLinuxNonfree; } ''
for firmware in \
rockchip/dptx.bin \
; do
mkdir -p "$(dirname $out/lib/firmware/$firmware)"
cp -vrf "$src/lib/firmware/$firmware" $out/lib/firmware/$firmware
done
(PS4=" $ "; set -x
mkdir -p $out/lib/firmware/{brcm,rockchip}
(cd ${ap6256-firmware}
cp -fv *.hcd *blob *.bin *.txt $out/lib/firmware/brcm/
)
cp -fv ${pinephonepro-firmware}/brcm/* $out/lib/firmware/brcm/
cp -fv ${pinephonepro-firmware}/rockchip/* $out/lib/firmware/rockchip/
cp -fv ${brcm-firmware}/brcm/*43455* $out/lib/firmware/brcm/
)
''

View file

@ -0,0 +1,3 @@
source $stdenv/setup
cat $patches | unxz | patch -p1 -N -r -||true
cp -r $src $out

View file

@ -0,0 +1,53 @@
{
lib,
fetchFromGitLab,
fetchurl,
kernelPatches,
callPackage,
buildLinux,
...
}@args:
let
pver = "6.6.44";
src_pine64 = fetchFromGitLab {
owner = "pine64-org";
repo = "linux";
rev = "ppp-6.6-20231104-22589";
sha256 = "sha256-wz2g+wE1DmhQQoldeiWEju3PaxSTIcqLSwamjzry+nc=";
};
#apply mainline fixver patches
upstream_patch = fetchurl {
url = "https://cdn.kernel.org/pub/linux/kernel/v6.x/patch-${pver}.xz";
hash = "sha256-SSDqB/mqUmEWcf7fhZ3RRvGc2wvauORBuVl2ovJjX5M=";
};
ksrc = import ./source.nix;
apply_patch = (
path: {
name = builtins.baseNameOf path;
patch = path;
}
);
patches = [ ./pinephonepro_defconfig.patch ];
in
buildLinux (
args
// {
version = pver;
# todo: find out why builder complains about patch-version
modDirVersion = "${lib.versions.majorMinor pver}.0";
src = callPackage ksrc {
inherit pver upstream_patch;
src = src_pine64;
};
defconfig = "pinephonepro_defconfig";
kernelPatches = kernelPatches ++ map apply_patch patches;
extraMeta = {
platforms = lib.platforms.aarch64;
hydraPlatforms = [ "aarch64-linux" ];
};
}
// args.argsOverride or { }
)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,21 @@
{
pkgs,
stdenv,
pver,
src,
upstream_patch,
...
}@args:
# Applies the full patch since last mainline which contains some previous patches causing it to fail
# which will work here as the builder doesn't use "set -e"
stdenv.mkDerivation {
name = "kernel-source";
version = pver;
src = src;
patches = upstream_patch;
buildInputs = [
pkgs.patch
pkgs.xz
];
builder = ./builder.sh;
}

View file

@ -0,0 +1,46 @@
# MIT License
# Copyright (c) 2018-2020 Samuel Dionne-Riel and the Mobile NixOS contributors
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
{ stdenv, pkgs, ... }:
stdenv.mkDerivation rec {
name = "pine64-alsa-ucm";
version = "ec0ef36b8b897ed1ae6bb0d0de13d5776f5d3659";
src = pkgs.fetchFromGitLab {
owner = "pine64-org";
repo = "pine64-alsa-ucm";
rev = version;
sha256 = "sha256-nsZXBB5VpF0YpfIS+/SSHMlPXSyIGLZSOkovjag8ifU=";
};
patches = [ ./repoint-pinephone-pro.patch ];
installPhase = ''
ucm_path=$out/share/alsa/ucm2/
mkdir -p $ucm_path/PinePhone $ucm_path/PinePhonePro $ucm_path/conf.d/simple-card
ln -s ../../PinePhonePro/PinePhonePro.conf $ucm_path/conf.d/simple-card/PinePhonePro.conf
cp -r ucm2/* $ucm_path/
'';
}

View file

@ -0,0 +1,19 @@
diff --git a/ucm2/PinePhonePro/PinePhonePro.conf b/ucm2/PinePhonePro/PinePhonePro.conf
index 18b544a..c333958 100644
--- a/ucm2/PinePhonePro/PinePhonePro.conf
+++ b/ucm2/PinePhonePro/PinePhonePro.conf
@@ -2,12 +2,12 @@ Syntax 4
Comment "PinePhone Pro"
SectionUseCase."HiFi" {
- File "HiFi.conf"
+ File "/PinePhonePro/HiFi.conf"
Comment "Default"
}
SectionUseCase."Voice Call" {
- File "VoiceCall.conf"
+ File "/PinePhonePro/VoiceCall.conf"
Comment "Phone call"
}

View file

@ -0,0 +1,27 @@
{ config, lib, ... }:
let
cfg = config.hardware.pinephone-pro;
in
{
options.hardware.pinephone-pro = {
wifi.workaround-sae = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
A bug in the brcmfmac module causes it to attempt to offload SAE.
This will cause connection failures and the following error message
brcmfmac: brcmf_set_channel: set chanspec 0x???? fail, reason -52
Related: https://github.com/raspberrypi/linux/issues/6049
'';
};
};
config = lib.mkIf cfg.wifi.workaround-sae {
#Disable SAE and FWSUP
#See: https://iwd.wiki.kernel.org/offloading
boot.extraModprobeConfig = lib.mkDefault ''
options brcmfmac feature_disable=0x82000
'';
};
}