Skip to content

Commit

Permalink
[WIP] motorola-addison: Build firmware and enable wcnss
Browse files Browse the repository at this point in the history
TODO: scheme so the end-user provides the files...

The bigger problem is that we cannot be sure the files are the exact
same! So we can't use `requireFile` as the end-user may be unable to
provide the firmware files.

Another option could be to make the `modem` an input of the derivation,
requiring `.override` to be used by the end-user with a path to a copy
of the contents of the modem partition. (With strong discouragement to
directly use it?)
  • Loading branch information
samueldr committed Aug 20, 2020
1 parent f6b77ac commit 568edf3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions devices/motorola-addison/default.nix
Expand Up @@ -19,6 +19,8 @@
kernel.package = pkgs.callPackage ./kernel { kernelPatches = pkgs.defaultKernelPatches; };
};

mobile.device.firmware = pkgs.callPackage ./firmware {};

mobile.system.android.bootimg = {
dt = "${config.mobile.boot.stage-1.kernel.package}/dtbs/motorola-addison.img";
flash = {
Expand Down Expand Up @@ -52,4 +54,6 @@
mobile.system.type = "android";

mobile.quirks.qualcomm.fb-notify.enable = true;

mobile.quirks.qualcomm.wcnss-wlan.enable = true;
}
40 changes: 40 additions & 0 deletions devices/motorola-addison/firmware/default.nix
@@ -0,0 +1,40 @@
{ lib, runCommandNoCC, fetchFromGitHub, fetchurl }:

let
# FIXME: somehow get the user to provide the contents of the "modem" partition
# sudo blkid | grep -i '"modem"'
# /dev/mmcblk0p19: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="modem" PARTUUID="e9018b02-0068-cb79-4fb4-b0b9027c4c80"

# Contents of the "modem" partition.
modem = ./modem;

# The following files, though required, are not present in the modem
# partition.
cfg = fetchurl {
url = "https://raw.githubusercontent.com/LineageOS/android_device_motorola_addison/f99c3591c83c19da6db096eb3f2e5fb0e0d91eed/wifi/WCNSS_qcom_cfg.ini";
sha256 = "1dkmjm2j5l5c6a4q1xsdjkfqqy8d5aj9qd35al4lz6ma58gcy62y";
};
dict = muppets "/etc/firmware/wlan/prima/WCNSS_wlan_dictionary.dat" "sha256:0mjzc2pqn95dkgp3g8ks9qyqzpjc74a7yx1y71hqfnqr7jarbv7f";
nv = muppets "/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin" "sha256:0vrsvbilnjyyqjp2i0xsl4nv3sydzv7dmqfv2j539294la4j7imz";

# Helper to download the proprietary files.
muppets = file: sha256: fetchurl {
url = "https://github.com/TheMuppets/proprietary_vendor_motorola/raw/d04e011847bddb3f92eddaac64453cbfcda9cd32/addison/proprietary${file}";
inherit sha256;
};
in
runCommandNoCC "motorola-addison-firmware" {
inherit modem cfg dict nv;
meta.license = [
# We make no claims that it can be redistributed.
lib.licenses.unfree
];
} ''
fwpath="$out/lib/firmware"
mkdir -p $fwpath
cp -vr $modem/image/* $fwpath/
mkdir -p $fwpath/wlan/prima/
cp -v $cfg $fwpath/wlan/prima/WCNSS_qcom_cfg.ini
cp -v $dict $fwpath/wlan/prima/WCNSS_wlan_dictionary.dat
cp -v $nv $fwpath/wlan/prima/WCNSS_qcom_wlan_nv.bin
''

0 comments on commit 568edf3

Please sign in to comment.