From eaaa3980f056e12e8cb959575043f9f8135c3074 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 1 Jun 2020 18:58:05 -0400 Subject: [PATCH 1/3] initrd: Add `tree` output to initrd-meta This ends up being useful to peek into the initrd cpio without actually having to crack it open. I have used this to track down a bad symlink. --- modules/initrd.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/initrd.nix b/modules/initrd.nix index ec4fbdf1..954ebfc2 100644 --- a/modules/initrd.nix +++ b/modules/initrd.nix @@ -187,6 +187,7 @@ let nativeBuildInputs = with pkgs.buildPackages; [ ncdu cpio + tree ]; } '' mkdir initrd @@ -194,6 +195,7 @@ let mkdir -p $out ncdu -0x -o $out/initrd.ncdu ./initrd + tree -a ./initrd > $out/tree ''; in { From d9cd7b336ba93262aeac573ab8519fda1cb04437 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 1 Jun 2020 18:58:59 -0400 Subject: [PATCH 2/3] initrd-firmware: Init module to add firmware to stage-1 Much better than the ad-hoc way used in a previous PR --- modules/initrd-firmware.nix | 32 ++++++++++++++++++++++++++++++++ modules/module-list.nix | 1 + 2 files changed, 33 insertions(+) create mode 100644 modules/initrd-firmware.nix diff --git a/modules/initrd-firmware.nix b/modules/initrd-firmware.nix new file mode 100644 index 00000000..e4219bc2 --- /dev/null +++ b/modules/initrd-firmware.nix @@ -0,0 +1,32 @@ +{ pkgs, lib, config, ... }: + +let + inherit (lib) types; + inherit (config.mobile.boot.stage-1) firmware; +in +{ + options = { + mobile.boot.stage-1.firmware = lib.mkOption { + type = types.listOf types.package; + default = []; + description = '' + List of packages containing firmware files to be included in the + stage-1 for the device. + ''; + apply = list: pkgs.buildEnv { + name = "firmware"; + paths = list; + pathsToLink = [ "/lib/firmware" ]; + ignoreCollisions = true; + }; + }; + }; + config = { + mobile.boot.stage-1.contents = [ + { + object = "${firmware}/lib/firmware"; + symlink = "/lib/firmware"; + } + ]; + }; +} diff --git a/modules/module-list.nix b/modules/module-list.nix index 6b60b5a1..63822689 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -18,6 +18,7 @@ ./initrd-boot-gui.nix ./initrd-fbterm.nix ./initrd-fail.nix + ./initrd-firmware.nix ./initrd-kernel.nix ./initrd-logs.nix ./initrd-network.nix From 141ffff3601d99fa909b3d5a86ff16b2448e28a8 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 1 Jun 2020 18:59:32 -0400 Subject: [PATCH 3/3] asus-dumo: Provide minimal firmware for stage-1 The firmware is part of the unfree redistributable set already in nixpkgs, so unlike some other devices in-tree (asus-z00t) we can directly add the firmware to the build without any issue. --- devices/asus-dumo/default.nix | 5 +++++ devices/asus-dumo/firmware/default.nix | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 devices/asus-dumo/firmware/default.nix diff --git a/devices/asus-dumo/default.nix b/devices/asus-dumo/default.nix index 83a9bd39..f4947127 100644 --- a/devices/asus-dumo/default.nix +++ b/devices/asus-dumo/default.nix @@ -33,6 +33,11 @@ mobile.system.type = "depthcharge"; + mobile.device.firmware = pkgs.callPackage ./firmware {}; + mobile.boot.stage-1.firmware = [ + config.mobile.device.firmware + ]; + mobile.boot.stage-1.tasks = [ # This hack unbinds and rebinds the currently problematic storage driver. # TODO: move into a generic "gru family" thing. diff --git a/devices/asus-dumo/firmware/default.nix b/devices/asus-dumo/firmware/default.nix new file mode 100644 index 00000000..151d49fd --- /dev/null +++ b/devices/asus-dumo/firmware/default.nix @@ -0,0 +1,19 @@ +{ lib +, runCommandNoCC +, firmwareLinuxNonfree +}: + +# The minimum set of firmware files required for the device. +runCommandNoCC "asus-dumo-firmware" { + src = firmwareLinuxNonfree; +} '' + for firmware in \ + ath10k/QCA6174/hw3.0 \ + qca/nvm_usb_00000302.bin \ + qca/rampatch_usb_00000302.bin \ + rockchip/dptx.bin \ + ; do + mkdir -p "$(dirname $out/lib/firmware/$firmware)" + cp -vrf "$src/lib/firmware/$firmware" $out/lib/firmware/$firmware + done +''