The daemon now powers the sensor and initialises the trustlet against it. On
the phone, every step of the chain returning rc=0:
gpiochip 'f100000.pinctrl' is /dev/gpiochip5 (168 lines)
sensor powered, reset released, irq=1
CMD 0x1006 INIT_SPI rc=0
CMD 0x100a PROBE_DEVICE rc=0
CMD 0x100b INIT_DEVICE rc=0
CMD 0x1004 TA_INIT rc=0
CMD 0x1020 WORK_MODE rc=0
CMD 0x100e SYNC_STATISTICS rc=0
GPIO v2 chardev ioctls directly rather than libgpiod, which is on neither the
phone nor the sysroot and would be a dependency for three lines.
The chip is found by label, and the label is not what the device tree calls it:
the node is pinctrl@f100000 so the chardev advertises "f100000.pinctrl", while
every DT reference says "tlmm". Matching on "tlmm" finds nothing, which is how
the first run failed. There is a second check on the line count, because this
SoC has another pinctrl with 23 lines and driving line 75 of the wrong
controller is not something you recover from over ssh.
The XPU guard is enforced where the line is actually opened, not only asserted
in the core. gpio8-11 are the fingerprint SPI pads and touching one is an
immediate SError with the phone rebooting where it stands, so a refusal has to
sit in front of the ioctl.
Owning the rail is what makes the session recoverable at all: one reset buys
exactly one trustlet init and a second answers -205, so a failed session needs
the rail cycled rather than the chain retried. The harness split these across
two processes and every run began by restarting the one holding the rail.
CAPTURE_IMAGE answers -201 here and that is correct, not a regression: it needs
a shared memory region whose address QTEE patches into the payload, and none is
supplied yet. That is the next piece.
95 lines
3.9 KiB
C++
95 lines
3.9 KiB
C++
// SPDX-License-Identifier: GPL-3.0-only
|
|
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
// lint-disable-file no-char-pointer
|
|
import std;
|
|
import Crafter.Build;
|
|
#include "lint-rules.h"
|
|
namespace fs = std::filesystem;
|
|
using namespace Crafter;
|
|
|
|
// libqcomtee — Qualcomm's BSD-3 userspace client for QTEE, built by
|
|
// packaging/make-libqcomtee.sh into a per-target cache dir. It is not vendored
|
|
// here: it is upstream code we pin, and the script builds it WITHOUT QCBOR
|
|
// (see the script for why that dependency is avoidable).
|
|
static void ApplyQcomteeFlags(Configuration& cfg) {
|
|
fs::path base = fs::path(std::getenv("HOME") ? std::getenv("HOME") : ".")
|
|
/ ".cache" / "fingerprintd";
|
|
// make-libqcomtee.sh names its output dir after --target, and plain
|
|
// "libqcomtee" when built for the host. cfg.target is always populated
|
|
// (it defaults to the host triple), so try the target-specific dir first
|
|
// and fall back to the host one.
|
|
std::error_code ec;
|
|
fs::path root = base / ("libqcomtee-" + cfg.target);
|
|
if (!fs::exists(root / "libqcomtee.a", ec))
|
|
root = base / "libqcomtee";
|
|
|
|
if (!fs::exists(root / "libqcomtee.a", ec)) {
|
|
std::println(std::cerr,
|
|
"libqcomtee not built for '{}'. Run:\n"
|
|
" packaging/make-libqcomtee.sh{}{}",
|
|
cfg.target.empty() ? std::string("native") : cfg.target,
|
|
cfg.target.empty() ? std::string() : " --target=" + cfg.target,
|
|
cfg.sysroot.empty() ? std::string() : " --sysroot=" + cfg.sysroot);
|
|
}
|
|
cfg.compileFlags.push_back("-I" + (root / "include").string());
|
|
cfg.linkFlags.push_back((root / "libqcomtee.a").string());
|
|
}
|
|
|
|
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
|
// fingerprintd-core — the wire formats and state machines as a static
|
|
// library of pure C++ modules. Deliberately free of GLib, libqcomtee and
|
|
// every system header: the byte-level decisions in here were the whole
|
|
// cost of this project, so they are pinned by tests that run on a dev box
|
|
// with no phone, no TEE and no sensor.
|
|
static auto Core = std::make_unique<Configuration>();
|
|
Core->path = "./";
|
|
Core->name = "fingerprintd-core";
|
|
Core->outputName = "fingerprintd-core";
|
|
ApplyStandardArgs(*Core, args);
|
|
Core->type = ConfigurationType::LibraryStatic;
|
|
{
|
|
std::array<fs::path, 8> ifaces = {
|
|
"interfaces/Fingerprintd",
|
|
"interfaces/Fingerprintd-Sfs",
|
|
"interfaces/Fingerprintd-Rpmb",
|
|
"interfaces/Fingerprintd-Ta",
|
|
"interfaces/Fingerprintd-Engine",
|
|
"interfaces/Fingerprintd-Store",
|
|
"interfaces/Fingerprintd-Tee",
|
|
"interfaces/Fingerprintd-Sensor",
|
|
};
|
|
std::array<fs::path, 0> impls = {};
|
|
Core->GetInterfacesAndImplementations(ifaces, impls);
|
|
}
|
|
|
|
// fingerprintd — the daemon: sensor rail, QTEE session, the gpfile and
|
|
// RPMB listeners, and the bus surface, wrapped around the core.
|
|
Configuration cfg;
|
|
cfg.path = "./";
|
|
cfg.name = "fingerprintd";
|
|
cfg.outputName = "fingerprintd";
|
|
ApplyStandardArgs(cfg, args);
|
|
cfg.type = ConfigurationType::Executable;
|
|
cfg.dependencies = { Core.get() };
|
|
{
|
|
std::array<fs::path, 0> ifaces = {};
|
|
std::array<fs::path, 1> impls = { "implementations/main" };
|
|
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
|
}
|
|
|
|
ApplyQcomteeFlags(cfg);
|
|
cfg.linkFlags.push_back("-lpthread"); // the supplicant thread
|
|
|
|
cfg.AddTest("Sfs").Dependencies({ Core.get() });
|
|
cfg.AddTest("Rpmb").Dependencies({ Core.get() });
|
|
cfg.AddTest("Ta").Dependencies({ Core.get() });
|
|
cfg.AddTest("Engine").Dependencies({ Core.get() });
|
|
cfg.AddTest("Store").Dependencies({ Core.get() });
|
|
cfg.AddTest("Tee").Dependencies({ Core.get() });
|
|
cfg.AddTest("Sensor").Dependencies({ Core.get() });
|
|
|
|
ProjectLint::AddProjectLintRules(cfg);
|
|
|
|
return cfg;
|
|
}
|