<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://luca.magrone.cc/feed.xml" rel="self" type="application/atom+xml" /><link href="https://luca.magrone.cc/" rel="alternate" type="text/html" /><updated>2026-10-25T08:28:24+00:00</updated><id>https://luca.magrone.cc/feed.xml</id><title type="html">Luca Magrone</title><subtitle>Freedom and open source projects.</subtitle><entry><title type="html">Porting CentOS Stream 10 to the Radxa Orion O6N</title><link href="https://luca.magrone.cc/blog/2026/10/22/orion-o6n/" rel="alternate" type="text/html" title="Porting CentOS Stream 10 to the Radxa Orion O6N" /><published>2026-10-22T00:00:00+00:00</published><updated>2026-10-22T00:00:00+00:00</updated><id>https://luca.magrone.cc/blog/2026/10/22/orion-o6n</id><content type="html" xml:base="https://luca.magrone.cc/blog/2026/10/22/orion-o6n/"><![CDATA[<p>This is the first post on this blog. Rather than open with a polite hello and a promise to write more often, I am
going to inaugurate the thing with a full-blast unhinged hell of a post: five weeks of dragging CentOS Stream 10
onto a Radxa Orion O6N, kernel and firmware and installer and a TPM I soldered on by hand. Settle in, or skim the
headings. Both are legitimate.</p>

<p>The whole port was also a stress test, and not of the board: of the coding agents. I wanted to know how far they have
actually come, so I pointed them at the least forgiving thing I could think of: customising software for an ARM
single-board computer. Vendor kernels frozen at some fork point, out-of-tree drivers, firmware you cannot see into,
and a forum thread where the answer is a cloud-storage link that died two years ago. Chinese boards carry the worst
of that reputation, and Radxa's usually get filed under it.</p>

<p>That reputation did not survive contact with this one. CIX and Radxa have open-sourced very nearly all of it: the
kernel tree, the EDK2 platform, the vendor patch series, the build tooling, and schematics detailed enough to find an
unpopulated TPM footprint on sheet 31 of 46 and read its part number off the page. There are gaps (the NPU compiler
is closed, and the boot chain below UEFI, the flash tools and a dozen binary UEFI modules carry no stated licence),
but nearly every hard problem below was solved by finding the answer in a source file rather than bisecting blind.
Point the most capable frontier model available at that much open source and the arithmetic changes: most of the
code, the commit messages and this write-up came out of agents. My part was direction, judgement calls, and anything
needing a soldering iron. I would not have attempted it by hand.</p>

<p>So: the sustained insanity that is the Orion O6N, counted in days from the one it arrived on.</p>

<h2 id="day-1-the-board">Day 1: The board</h2>

<p>The Orion O6N is a CIX Sky1 board with twelve cores in three tiers of four: four Cortex-A720 at up to 2.5-2.6 GHz, four
more A720 at 2.2-2.3 GHz, and four A520 at 1.8 GHz. The A720s are clocked in pairs, hence the ranges. Around them sit
LPDDR5, an Immortalis-G720 GPU, an Arm China Zhouyi NPU and a Linlon video engine. CIX's upstream work is device-tree
only (their <a href="https://github.com/cixtech/linux-mainline/wiki">linux-mainline wiki</a> lists the VPU as "won't do"), which
helps nobody booting a distro through UEFI and ACPI.</p>

<figure class="figure d-block mx-auto mt-0 mb-3" style="max-width: 360px">
<img src="/images/blog/orion-o6n/board.jpg" class="figure-img img-fluid rounded mb-1" width="900" height="702" loading="lazy" alt="The Radxa Orion O6N with its fan heatsink, an NVMe SSD and a small green TPM module on the 40-pin header" />
<figcaption class="figure-caption text-center">The star of the show</figcaption>
</figure>

<p>It ran Fedora 44 on my desk at first. I did try CentOS early: it came up, would not talk to the network, and did not get
five more minutes of my patience. I set it aside and used Fedora's kernel-ark tree as a proving ground, with CS10 as the
destination. A stock CS10 kernel carries none of the Sky1 vendor series, so it sees generic ACPI devices and little
else.</p>

<p>The real cost, though, was everything that broke <em>specifically</em> on an enterprise kernel. CS10 backports aggressively
into 6.12, so vendor code that tests <code class="language-plaintext highlighter-rouge">LINUX_VERSION_CODE</code> takes the wrong branch. An audit of the NPU and VPU drivers
found 78 version guards, five of them wrong on CS10: four compile errors and one silent bug, the nastiest thing in
this post. The NPU keeps a private copy of <code class="language-plaintext highlighter-rouge">struct iommu_dma_cookie</code> with its layout picked by kernel version, so on
CS10 it read eight bytes past the real field on every IOMMU path, quietly. The VPU could not be built out of tree at
all, because CS10 leaves <code class="language-plaintext highlighter-rouge">CONFIG_VIDEOBUF2_DMA_SG</code> unset and the symbol has no Kconfig prompt, so it is carried
in-tree, where its own Kconfig can select it. And CS10's DRM is backported from Linux 7.0, so the display and GPU
patches came from the vendor's <code class="language-plaintext highlighter-rouge">patches-7.0</code> set while everything else came from <code class="language-plaintext highlighter-rouge">patches-6.18</code>. None of this shows
up on Fedora. There was also no RPM packaging for any of it since the vendor ships only Debian-compatible packages.</p>

<p>One other project shares the ACPI path: <a href="https://github.com/Sky1-Linux/linux-sky1">Sky1-Linux</a>, a Debian-based
distribution. Their patch <code class="language-plaintext highlighter-rouge">0093</code> fixes the same PCIe probe bug I hit, in mainline's driver rather than the vendor's.
Two commits in this port come straight from their tree: the fan-control driver and the SPI controller's ACPI ID.
The rest mostly patches mainline's drivers where this port carries the vendor's, so it does not apply here.</p>

<h2 id="day-4-the-kernel">Day 4: The kernel</h2>

<p>The tree is <a href="https://gitlab.com/Leuca/centos-stream-10/-/tree/sky1"><code class="language-plaintext highlighter-rouge">sky1</code> on gitlab.com/Leuca/centos-stream-10</a>:
CS10's <code class="language-plaintext highlighter-rouge">kernel-6.12.0-275.el10</code> plus 190 commits, published as <code class="language-plaintext highlighter-rouge">kernel-6.12.0-275.sky1.1.el10</code> and built in the
<a href="https://copr.fedorainfracloud.org/coprs/lucamagrone/el10-sky1/">COPR</a>. Most of those commits are vendor drivers with
light edits. Before anything went public, the 102 that were ours went to the frontier model for review;
it found no live bug, just hygiene, and the branch was rebased from 266 to 273 with a <code class="language-plaintext highlighter-rouge">range-diff</code> showing 188 of 190
commits identical. Now a scheduled CI job rebases it onto each new CentOS release on its own.</p>

<p><strong>The PCIe bug that ate the root disk.</strong> <code class="language-plaintext highlighter-rouge">sky1_pcie_probe()</code> replaced every error with <code class="language-plaintext highlighter-rouge">-EINVAL</code>, turning "try again
later" into "give up forever". The reset GPIO comes from <code class="language-plaintext highlighter-rouge">gpio-cadence</code>, which loads later out of the initramfs, so a
controller probed too early asked to defer, got reported as <code class="language-plaintext highlighter-rouge">-22</code>, and was dropped:</p>

<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="go">sky1-pcie-cix sky1-pcie.2.auto: Failed to get reset gpio
sky1-pcie-cix sky1-pcie.2.auto: probe with driver sky1-pcie-cix failed with error -22
</span></code></pre></div></div>

<figure class="figure d-block mx-auto my-4" style="max-width: 480px">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 430 326" width="100%" role="img" aria-labelledby="pcie-defer-cap" font-size="13" fill="currentColor">
<style>.mono { font-family: var(--bs-font-monospace); font-size: 12px; }</style>
<text x="0" y="16" font-weight="bold">Before: every error became -EINVAL</text>
<text x="0" y="50" class="mono">sky1-pcie</text>
<text x="0" y="90" class="mono">gpio-cadence</text>
<path d="M192 46H312M100 86H212M292 86H430" stroke="currentColor" stroke-opacity=".25" />
<rect x="100" y="34" width="92" height="24" rx="4" fill="currentColor" fill-opacity="0.14" stroke="currentColor" stroke-width="1.5" />
<text x="146" y="51" text-anchor="middle">probe</text>
<rect x="212" y="74" width="80" height="24" rx="4" fill="currentColor" fill-opacity="0.14" stroke="currentColor" stroke-width="1.5" />
<text x="252" y="91" text-anchor="middle">loads</text>
<text x="202" y="40" class="mono" opacity="0.75">-517 -&gt; -22</text>
<rect x="312" y="34" width="118" height="24" rx="4" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-width="1.5" stroke-dasharray="5 3" />
<text x="371" y="51" text-anchor="middle" opacity="0.75">never retried</text>
<text x="0" y="126" opacity="0.85">The controller is dropped for good, so the boot waits forever</text>
<text x="0" y="144" opacity="0.85">for a root disk that will never arrive.</text>
<text x="0" y="188" font-weight="bold">After: the deferral passes through</text>
<text x="0" y="222" class="mono">sky1-pcie</text>
<text x="0" y="262" class="mono">gpio-cadence</text>
<path d="M192 218H312M100 258H212M292 258H430" stroke="currentColor" stroke-opacity=".25" />
<rect x="100" y="206" width="92" height="24" rx="4" fill="currentColor" fill-opacity="0.14" stroke="currentColor" stroke-width="1.5" />
<text x="146" y="223" text-anchor="middle">probe</text>
<rect x="212" y="246" width="80" height="24" rx="4" fill="currentColor" fill-opacity="0.14" stroke="currentColor" stroke-width="1.5" />
<text x="252" y="263" text-anchor="middle">loads</text>
<text x="202" y="212" class="mono" opacity="0.75">-517, defer</text>
<path d="M292 258H340V230M336 235L340 230L344 235" fill="none" stroke="currentColor" stroke-width="1.5" />
<rect x="312" y="206" width="118" height="24" rx="4" fill="currentColor" fill-opacity="0.14" stroke="currentColor" stroke-width="1.5" />
<text x="371" y="223" text-anchor="middle">retry: OK</text>
<text x="0" y="298" opacity="0.85">The driver core retries once the GPIO exists; the NVMe root</text>
<text x="0" y="316" opacity="0.85">disk appears and the boot carries on.</text>
</svg>
<figcaption id="pcie-defer-cap" class="figure-caption text-center">The PCIe controller probes before the GPIO driver it needs has loaded.</figcaption>
</figure>

<p>That controller carries the NVMe root disk, so the boot waited forever for a filesystem that would never arrive.
Fixing it exposed the next layer: the retry remapped a live I/O window and panicked at <code class="language-plaintext highlighter-rouge">kernel BUG at
mm/vmalloc.c:116</code>. Parsing firmware properties before allocating anything fixed both: the same reordering Sky1-Linux
landed on independently.</p>

<p><strong>SCMI gated everything else</strong>, and it needs three things at once: the vendor's
<code class="language-plaintext highlighter-rouge">0001-mailbox-add-acpi-support-to-cix-mailbox-driver.patch</code> (the first patch of every <code class="language-plaintext highlighter-rouge">patches-*</code> set in
<a href="https://github.com/cixtech/cix-linux-main">cixtech/cix-linux-main</a>, easy to miss if you start at <code class="language-plaintext highlighter-rouge">0002</code>), a 6.12
backport of upstream's mailbox fwnode change, and <code class="language-plaintext highlighter-rouge">CONFIG_CIX_MBOX=y</code>. The <code class="language-plaintext highlighter-rouge">=y</code> is not taste: built in, the mailbox
claims its register window from <code class="language-plaintext highlighter-rouge">arch_initcall</code>, before the SCMI shared-memory device (<code class="language-plaintext highlighter-rouge">SHM0</code>, whose region sits inside
that window) is probed; as a module it loads seconds later, finds the region taken and gets <code class="language-plaintext highlighter-rouge">-EBUSY</code>. Fedora ships <code class="language-plaintext highlighter-rouge">=m</code>,
which cannot work.</p>

<p><strong>The boot arguments are where the kernel thread and the image thread collide.</strong> The board needed
<code class="language-plaintext highlighter-rouge">clk_ignore_unused</code> because its SCMI firmware predates <code class="language-plaintext highlighter-rouge">CLOCK_GET_PERMISSIONS</code> and cannot say a clock is in use, so
the sweep turns off things the board is running on. It needed <code class="language-plaintext highlighter-rouge">nohibernate</code> because clearing <code class="language-plaintext highlighter-rouge">CONFIG_HIBERNATION</code>
would compile out the sleep callbacks of every driver that references <code class="language-plaintext highlighter-rouge">CONFIG_PM_SLEEP</code>. Both arguments survive on a
running system. Neither survives an installation: an anaconda live install is an <code class="language-plaintext highlighter-rouge">rsync</code> followed by a <em>fresh</em>
bootloader config, which keeps only its <code class="language-plaintext highlighter-rouge">preserved_arguments</code>. And arm64 cannot bake them in: <code class="language-plaintext highlighter-rouge">CMDLINE_EXTEND</code> is
gone, so the Kconfig choice falls through to <code class="language-plaintext highlighter-rouge">CMDLINE_FORCE</code>, which discards <code class="language-plaintext highlighter-rouge">root=</code> and panics.</p>

<p>I spent real time on installer-side workarounds: an anaconda drop-in, a <code class="language-plaintext highlighter-rouge">postinst.d</code> grubby hook, a kickstart
<code class="language-plaintext highlighter-rouge">%post</code> that turned out broken. This was infuriating. Every one of them was there to smuggle an argument that only
existed because the firmware could not describe its own clocks. The fix was to stop needing them: an SCMI quirk that
flags just those 273 clocks, only on firmware that cannot report permissions, and a <code class="language-plaintext highlighter-rouge">HIBERNATION_DISABLED_DEFAULT</code>
that turns the existing <code class="language-plaintext highlighter-rouge">nohibernate</code> flag on by default.</p>

<p>I did not arrive at the first one myself. My initial patch added a global <code class="language-plaintext highlighter-rouge">CLK_IGNORE_UNUSED_DEFAULT</code>, which would
have switched the sweep off for every clock in the kernel, audio and the rest of Sky1's own clock drivers included,
as a build-wide change no upstream tree would take. A review caught it. The quirks framework had been sitting in the
tree the whole time.</p>

<p>The test that mattered took forty-five seconds. I removed <code class="language-plaintext highlighter-rouge">clk_ignore_unused</code> from the boot entry, rebooted, and the
board came back, which it had never done before without that argument:</p>

<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="go">[ 3.527] arm-scmi arm-scmi.5.auto: SCMI Protocol v2.0 'cix:cix' Firmware version 0x20b0000
[ 3.536] arm-scmi arm-scmi.5.auto: Enabling SCMI Quirk [quirk_clock_ignore_unused]
[ 4.358] clk: Disabling unused clocks
</span></code></pre></div></div>

<p>The unused-clock sweep <em>ran</em>: the 273 SCMI clocks were kept out of it and everything else got swept normally.</p>

<p>There was also <code class="language-plaintext highlighter-rouge">pd_ignore_unused</code>, carried in every boot line since the beginning. It was never needed: the firmware
exposes no SCMI power-domain protocol, so every genpd comes from the perf-domain driver with no <code class="language-plaintext highlighter-rouge">power_off</code> at all. It
had been copied from CIX's documented bring-up line and never questioned, including by me. It and <code class="language-plaintext highlighter-rouge">clk_ignore_unused</code>
came off the board together, and nothing has missed them since.</p>

<p><strong>The NIC bug was firmware wearing a kernel costume.</strong> About six boots in ten died with <code class="language-plaintext highlighter-rouge">Asynchronous SError Interrupt</code>
inside <code class="language-plaintext highlighter-rouge">r8169</code>. Radxa's O6N <code class="language-plaintext highlighter-rouge">LinuxAcpiConfig.h</code> swaps the two 2.5 GbE NICs' PERST# GPIOs (their O6 copy of the same file
is correct), and since the PCIe driver pulses PERST# early in probe, whichever port came up second reset the <em>other</em>
port's NIC. If <code class="language-plaintext highlighter-rouge">r8169</code> was mid-access, the next register read aborted. Driving the GPIO from a small module reproduced
it on demand. The fix lives in the firmware, and in the eleven boots that followed there was not a single cross-port
reset.</p>

<h2 id="day-20-tpm2">Day 20: TPM2</h2>

<p>The TPM plan predates the board. A LetsTrust module, an Infineon TPM on a small board for the 40-pin header, was
bought for the Orion before the Orion had even arrived, and soldering anything on was not part of the plan.</p>

<p>It would not talk over the hardware SPI controller. Linux could reach it only through a <code class="language-plaintext highlighter-rouge">spi-gpio</code> bit-bang, which
meant no measured boot, since PCRs 0-7 and the event log belong to firmware, and IMA missed it by a few hundred
milliseconds. It was a key store and nothing more. What followed was three weeks of the agents asking for one more
test: another power cycle, another probe on the header pins with a pocket oscilloscope that could barely see the
signal, on a module whose connector never sat quite right on those pins in the first place. And every round ended
with a new theory about some hardware barrier between the controller and the module.</p>

<p>The best of those theories was this: <code class="language-plaintext highlighter-rouge">spi-cadence.c</code> caps its divisor at 256 against a fixed 200 MHz clock, so the
slowest bus it can produce is <strong>781.25 kHz</strong>, and anything slower is silently clamped. The module answered on the
bit-banged bus up to 638 kHz and not at 781. The floor is real. It was never the problem. But it was convincing
enough, and unsatisfying enough, that I stopped trusting the header. First I bought a new module, because the old
one's connector was so flaky, and it changed nothing. Then I went looking for a TPM that did not need the header at all.</p>

<p>There is one on this board, sort of. The v1.11 schematic, sheet 31, has a site labelled <code class="language-plaintext highlighter-rouge">SPI TPM 2.0 (OPTION)</code>:
<code class="language-plaintext highlighter-rouge">U37</code>, an Infineon SLB9672, 5x5 mm, on the SoC's SPI at 1.8 V. Every component on that sheet is marked NC. So I bought
an SLB9672 to put there. I am no stranger to a soldering iron from other projects, but I had never done an SMD
soldering session in my life.</p>

<p><strong>Soldering.</strong> I followed a step-by-step guide an agent wrote, which started with <code class="language-plaintext highlighter-rouge">U37</code>. Under the
microscope, the site turned out not to be bare: the factory had printed paste on every pad and reflowed it without a
chip. The idea was to pre-heat the board and seat the chip on that solder with hot air. At 350 °C it would not stick:
the board's solder simply did not melt. I raised the temperature a little on each attempt, up to 380 °C, with the
same result. Out of frustration I added some low-temperature Sn-Bi paste and melted that instead, and it took: the
paste wetted the pads and <code class="language-plaintext highlighter-rouge">U37</code> finally went down, square on its pads and looking more than decent.</p>

<figure class="figure d-block mx-auto mt-0 mb-3" style="max-width: 170px">
<img src="/images/blog/orion-o6n/u37.jpg" class="figure-img img-fluid rounded mb-1" width="600" height="720" loading="lazy" alt="Infineon SLB9672 TPM soldered on the U37 footprint, seen under a microscope" />
<figcaption class="figure-caption text-center"><code>U37</code> after reflow.</figcaption>
</figure>

<p>In hindsight the paste belonged there from the start. Factory solder is often hard to reflow with a hot-air gun, and
refreshing it first is the better practice. A stencil would have helped most of all: it puts paste only where it
belongs, so you can place every part and reflow the lot in one go. That idea only came to me once the job was done.</p>

<p>Then the passives. The guide came with a shopping list, and I ordered from it without opening the drawings once. The
first 0402 capacitor overhung its pads at both ends: every passive site on that sheet is 0201. Work stopped and 0201s
went on order.</p>

<p>I am way too impatient to wait for the order. That evening I remembered I had 0201s of my own in a drawer, but by then
it was late and I was tired, so they went on first thing the next morning. The order will not go to waste either: the
flux in it is good for any soldering job, and its 0201s will have a second board to go on once it arrives. The passives
to the right of <code class="language-plaintext highlighter-rouge">U37</code> went on with the same paste trick, mostly: the ones that landed too far off their pads I fixed
with an iron, probably with more solder than they needed. Hand-soldering 0201s with an iron is miserable. And with no 0
Ω resistors in the drawer, those links became bridges of stranded wire and solder. <code class="language-plaintext highlighter-rouge">U37</code> came out fine; the 0201s are
ugly enough that, although I took pictures, you will not be seeing any of them. It works (the TPM answers) and it could
be tidied up, but every rework pass on that site risks the chip, so it stays as it is. <code class="language-plaintext highlighter-rouge">C1218</code>, a bulk capacitor site,
is still empty, and the TPM does not mind.</p>

<p><strong>Firmware saw the chip the same day</strong>, because CIX's own <code class="language-plaintext highlighter-rouge">DTpmDeviceLib</code> knows how to drive it. That library is missing
from Radxa's tree; it had to be brought over from CIX's community tree and adapted. What the firmware still lacked was
an ACPI node for the OS. The firmware now publishes one for each TPM as <code class="language-plaintext highlighter-rouge">PRP0001</code>, so <code class="language-plaintext highlighter-rouge">tpm_tis_spi</code> binds where
<code class="language-plaintext highlighter-rouge">MSFT0101</code> would attract only the memory-mapped <code class="language-plaintext highlighter-rouge">tpm_tis</code>, and a setup-menu option decides which one is visible. Only
one may be: Linux IMA extends the <em>first</em> TPM to register, so if both were visible and the firmware measured into the
header module, the firmware's PCRs would sit on one chip and IMA's on the other. Fair warning if you read the schematic
against the ACPI tables: schematic <code class="language-plaintext highlighter-rouge">SPI1</code> is ACPI <code class="language-plaintext highlighter-rouge">\_SB.SPI0</code>, and schematic <code class="language-plaintext highlighter-rouge">SPI2</code> is <code class="language-plaintext highlighter-rouge">\_SB.SPI1</code>.</p>

<figure class="figure d-block mx-auto my-4" style="max-width: 480px">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 430 220" width="100%" role="img" aria-labelledby="tpm-sites-cap" font-size="13" fill="currentColor">
<style>.mono { font-family: var(--bs-font-monospace); font-size: 12px; }</style>
<rect x="0" y="20" width="86" height="190" rx="4" fill="currentColor" fill-opacity="0.14" stroke="currentColor" stroke-width="1.5" />
<text x="43" y="110" text-anchor="middle" font-weight="bold">Sky1</text>
<text x="43" y="128" text-anchor="middle" opacity="0.7">SoC</text>
<rect x="286" y="20" width="144" height="60" rx="4" fill="currentColor" fill-opacity="0.14" stroke="currentColor" stroke-width="1.5" />
<text x="358" y="45" text-anchor="middle" font-weight="bold">U37, SLB9672</text>
<text x="358" y="64" text-anchor="middle" opacity="0.7">soldered, 1.8 V</text>
<path d="M86 50L286 50M281 46L286 50L281 54" fill="none" stroke="currentColor" stroke-width="1.5" />
<text x="96" y="43" class="mono">schematic SPI1</text>
<text x="96" y="66" class="mono" opacity="0.7">ACPI \_SB.SPI0</text>
<rect x="286" y="130" width="144" height="80" rx="4" fill="currentColor" fill-opacity="0.14" stroke="currentColor" stroke-width="1.5" />
<text x="358" y="158" text-anchor="middle" font-weight="bold">Header module</text>
<text x="358" y="177" text-anchor="middle" opacity="0.7">LetsTrust, SLB9672</text>
<path d="M86 150L286 150M281 146L286 150L281 154" fill="none" stroke="currentColor" stroke-width="1.5" />
<text x="96" y="143" class="mono">schematic SPI2</text>
<text x="96" y="166" class="mono" opacity="0.7">ACPI \_SB.SPI1</text>
<path d="M86 195L286 195M281 191L286 195L281 199" fill="none" stroke="currentColor" stroke-width="1.5" stroke-dasharray="4 3" />
<text x="96" y="188" class="mono">GPIO 44 = pin 18 -&gt; RST#</text>
<text x="96" y="210" opacity="0.7" font-size="12">hogged high</text>
</svg>
<figcaption id="tpm-sites-cap" class="figure-caption text-center">The two TPM options selectable from the firmware configuration menu.</figcaption>
</figure>

<p><strong>And then the real bug.</strong> Sky1's Cadence SPI FIFO is 32 bits wide and shifts MSB first, while stock <code class="language-plaintext highlighter-rouge">spi-cadence</code>
writes one byte per FIFO word, so every byte goes out on the wire as <code class="language-plaintext highlighter-rouge">00 00 00 xx</code> and a TPM never sees a valid header.</p>

<figure class="figure d-block mx-auto my-4" style="max-width: 480px">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 430 350" width="100%" role="img" aria-labelledby="fifo-cap" font-size="13" fill="currentColor">
<style>.hex { font-family: var(--bs-font-monospace); font-size: 14px; }</style>
<text x="0" y="16" font-weight="bold">Stock spi-cadence: one byte per FIFO word</text>
<text x="0" y="34" opacity=".7">Each 32-bit word is shifted out MSB first.</text>
<text x="0" y="69" opacity=".7">FIFO</text>
<text x="0" y="125" opacity=".7">wire</text>
<rect x="70" y="48" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="92.0" y="69" text-anchor="middle" class="hex" opacity="0.5">00</text>
<rect x="70" y="104" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="92.0" y="125" text-anchor="middle" class="hex" opacity="0.5">00</text>
<path d="M92.0 84v14m-4-5 4 5 4-5" fill="none" stroke="currentColor" stroke-opacity=".4" />
<rect x="114" y="48" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="136.0" y="69" text-anchor="middle" class="hex" opacity="0.5">00</text>
<rect x="114" y="104" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="136.0" y="125" text-anchor="middle" class="hex" opacity="0.5">00</text>
<path d="M136.0 84v14m-4-5 4 5 4-5" fill="none" stroke="currentColor" stroke-opacity=".4" />
<rect x="158" y="48" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="180.0" y="69" text-anchor="middle" class="hex" opacity="0.5">00</text>
<rect x="158" y="104" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="180.0" y="125" text-anchor="middle" class="hex" opacity="0.5">00</text>
<path d="M180.0 84v14m-4-5 4 5 4-5" fill="none" stroke="currentColor" stroke-opacity=".4" />
<rect x="202" y="48" width="44" height="32" fill="currentColor" fill-opacity="0.18" stroke="currentColor" stroke-opacity=".35" />
<text x="224.0" y="69" text-anchor="middle" class="hex" opacity="1">80</text>
<rect x="202" y="104" width="44" height="32" fill="currentColor" fill-opacity="0.18" stroke="currentColor" stroke-opacity=".35" />
<text x="224.0" y="125" text-anchor="middle" class="hex" opacity="1">80</text>
<path d="M224.0 84v14m-4-5 4 5 4-5" fill="none" stroke="currentColor" stroke-opacity=".4" />
<rect x="246" y="48" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="268.0" y="69" text-anchor="middle" class="hex" opacity="0.5">00</text>
<rect x="246" y="104" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="268.0" y="125" text-anchor="middle" class="hex" opacity="0.5">00</text>
<path d="M268.0 84v14m-4-5 4 5 4-5" fill="none" stroke="currentColor" stroke-opacity=".4" />
<rect x="290" y="48" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="312.0" y="69" text-anchor="middle" class="hex" opacity="0.5">00</text>
<rect x="290" y="104" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="312.0" y="125" text-anchor="middle" class="hex" opacity="0.5">00</text>
<path d="M312.0 84v14m-4-5 4 5 4-5" fill="none" stroke="currentColor" stroke-opacity=".4" />
<rect x="334" y="48" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="356.0" y="69" text-anchor="middle" class="hex" opacity="0.5">00</text>
<rect x="334" y="104" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="356.0" y="125" text-anchor="middle" class="hex" opacity="0.5">00</text>
<path d="M356.0 84v14m-4-5 4 5 4-5" fill="none" stroke="currentColor" stroke-opacity=".4" />
<rect x="378" y="48" width="44" height="32" fill="currentColor" fill-opacity="0.18" stroke="currentColor" stroke-opacity=".35" />
<text x="400.0" y="69" text-anchor="middle" class="hex" opacity="1">D4</text>
<rect x="378" y="104" width="44" height="32" fill="currentColor" fill-opacity="0.18" stroke="currentColor" stroke-opacity=".35" />
<text x="400.0" y="125" text-anchor="middle" class="hex" opacity="1">D4</text>
<path d="M400.0 84v14m-4-5 4 5 4-5" fill="none" stroke="currentColor" stroke-opacity=".4" />
<rect x="70" y="48" width="176" height="32" fill="none" stroke="currentColor" stroke-width="2" />
<rect x="246" y="48" width="176" height="32" fill="none" stroke="currentColor" stroke-width="2" />
<rect x="70" y="104" width="176" height="32" fill="none" stroke="currentColor" stroke-width="2" stroke-dasharray="5 3" />
<text x="0" y="158">The TPM reads 00 00 00 80 as its header: not a valid one.</text>
<text x="0" y="200" font-weight="bold">Fixed: four bytes packed per word</text>
<text x="0" y="218" opacity=".7">Same FIFO, same shift order.</text>
<text x="0" y="253" opacity=".7">FIFO</text>
<text x="0" y="309" opacity=".7">wire</text>
<rect x="70" y="232" width="44" height="32" fill="currentColor" fill-opacity="0.18" stroke="currentColor" stroke-opacity=".35" />
<text x="92.0" y="253" text-anchor="middle" class="hex" opacity="1">80</text>
<rect x="70" y="288" width="44" height="32" fill="currentColor" fill-opacity="0.18" stroke="currentColor" stroke-opacity=".35" />
<text x="92.0" y="309" text-anchor="middle" class="hex" opacity="1">80</text>
<path d="M92.0 268v14m-4-5 4 5 4-5" fill="none" stroke="currentColor" stroke-opacity=".4" />
<rect x="114" y="232" width="44" height="32" fill="currentColor" fill-opacity="0.18" stroke="currentColor" stroke-opacity=".35" />
<text x="136.0" y="253" text-anchor="middle" class="hex" opacity="1">D4</text>
<rect x="114" y="288" width="44" height="32" fill="currentColor" fill-opacity="0.18" stroke="currentColor" stroke-opacity=".35" />
<text x="136.0" y="309" text-anchor="middle" class="hex" opacity="1">D4</text>
<path d="M136.0 268v14m-4-5 4 5 4-5" fill="none" stroke="currentColor" stroke-opacity=".4" />
<rect x="158" y="232" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="180.0" y="253" text-anchor="middle" class="hex" opacity="0.5">00</text>
<rect x="158" y="288" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="180.0" y="309" text-anchor="middle" class="hex" opacity="0.5">00</text>
<path d="M180.0 268v14m-4-5 4 5 4-5" fill="none" stroke="currentColor" stroke-opacity=".4" />
<rect x="202" y="232" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="224.0" y="253" text-anchor="middle" class="hex" opacity="0.5">00</text>
<rect x="202" y="288" width="44" height="32" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".35" />
<text x="224.0" y="309" text-anchor="middle" class="hex" opacity="0.5">00</text>
<path d="M224.0 268v14m-4-5 4 5 4-5" fill="none" stroke="currentColor" stroke-opacity=".4" />
<rect x="70" y="232" width="176" height="32" fill="none" stroke="currentColor" stroke-width="2" />
<rect x="70" y="288" width="176" height="32" fill="none" stroke="currentColor" stroke-width="2" stroke-dasharray="5 3" />
<text x="0" y="342">The TPM reads 80 D4 00 00: a valid header.</text>
</svg>
<figcaption id="fifo-cap" class="figure-caption text-center">The first header bytes of a TPM read, through Sky1's 32-bit FIFO.</figcaption>
</figure>

<p>Packing four bytes per word fixed it, and with that in, the header module answers on the hardware controller at every
rate from 0.78 MHz to 25 MHz. That 0.78 MHz is the same 781.25 kHz it had supposedly refused. The bit-banged path had
always worked because it bypasses the FIFO, which is exactly what hid the bug. Both TPMs are the same chip, an SLB9672,
on different buses and driven by the same <code class="language-plaintext highlighter-rouge">tpm_tis_spi</code>.</p>

<p>So the module I had planned on from the start would have worked all along. It needed a few dozen lines in the SPI
driver, and it took my first SMD soldering, with the wrong passives, to get around a hardware barrier that did not exist
and find that out. I would still do it again. The long way round is why I now know what <code class="language-plaintext highlighter-rouge">U37</code>'s reset line is really
wired to, why the firmware was holding the other TPM in reset, and what the board does when a measurement fails. The
board now takes a TPM two ways, which nobody set out to build: two TPMs the firmware can choose between, measured boot
into either, and a reset line user space cannot touch.</p>

<p>That reset line, by the way: Radxa's GPIO table drives line 44 low by default, and line 44 is header pin 18, which on
the LetsTrust module is the TPM's <code class="language-plaintext highlighter-rouge">RST#</code>. Firmware had been holding the module in reset through its whole boot and
reading zeros, and Linux only reached it because bringing up the GPIO block released the line by accident. The firmware
now releases it when the header TPM is selected, and has Linux hold it high as a GPIO hog, so user space cannot reset
the chip and replay PCRs behind the log's back. Kernel code could still toggle it, and so could anything writing through
<code class="language-plaintext highlighter-rouge">/dev/mem</code>, which this kernel blocks only when booted with Secure Boot enabled (<code class="language-plaintext highlighter-rouge">LOCK_DOWN_IN_EFI_SECURE_BOOT</code>); without
it, <code class="language-plaintext highlighter-rouge">/dev/mem</code> can still reach the GPIO registers. Anyone using the TPM for measured boot is likely to turn Secure Boot
on anyway.</p>

<p><strong>What the TPM measures now.</strong> The IMA race was a deferred probe: the SPI controller waits on the SCMI clocks, so the
TPM appeared after <code class="language-plaintext highlighter-rouge">init_ima</code> had given up, and probing <code class="language-plaintext highlighter-rouge">tpm_tis_spi</code> synchronously plus a backport of upstream's
<code class="language-plaintext highlighter-rouge">IMA_INIT_LATE_SYNC</code> fixed it; the firmware's event log and IMA's both replay exactly against the chip. Nothing was
measured into PCR0 but a nine-byte <code class="language-plaintext highlighter-rouge">ACPI DATA</code> event. A new DXE driver now logs the firmware version and volumes first,
and getting a digest that matches the image file meant catching PrePi, which runs in place from flash, writing the
detected top of RAM into a variable inside the very volume the DXE driver later measures. PrePi now restores the
build-time value before handing over, and both volume digests match the image file.</p>

<p>It is still self-measurement, not a root of trust: TF-A, OP-TEE and the security-engine and power-management firmware
run unmeasured. Underneath, the chain from the BootROM up to <code class="language-plaintext highlighter-rouge">bootloader3</code> (the UEFI image) is signature-checked, but
until the OEM key fuse is burned, which the factory does not do, there is nothing to anchor it to: an image does not
need the placeholder key published in the repo, and one signed with a freshly generated key, using the vendor's tool on
an x86_64 host, is accepted just as well. And edk2-cix's Makefile had two bugs, a wrong architecture directory and a
variable that was never exported, which made an aarch64 build silently reuse CIX's trusted key certificate. The build
now fails only when the OEM key differs from the shipped certificate and the host cannot run CIX's x86-only tool to
regenerate it.</p>

<figure class="figure d-block mx-auto my-4" style="max-width: 480px">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 430 310" width="100%" role="img" aria-labelledby="boot-chain-cap" font-size="13" fill="currentColor">
<rect x="1" y="2" width="22" height="14" rx="2" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-width="1.5" stroke-dasharray="5 3" />
<text x="29" y="14" font-size="12">runs unmeasured</text>
<rect x="150" y="2" width="22" height="14" rx="2" fill="currentColor" fill-opacity="0.14" stroke="currentColor" stroke-width="1.5" />
<text x="178" y="14" font-size="12">measures into the TPM</text>
<rect x="40" y="32" width="250" height="40" rx="4" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-width="1.5" stroke-dasharray="5 3" />
<text x="165.0" y="57.0" text-anchor="middle" font-weight="bold">BootROM</text>
<rect x="40" y="92" width="250" height="40" rx="4" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-width="1.5" stroke-dasharray="5 3" />
<text x="165.0" y="117.0" text-anchor="middle" font-weight="bold">TF-A, OP-TEE, SE and PM firmware</text>
<path d="M165.0 72L165.0 92M161.0 87L165.0 92L169.0 87" fill="none" stroke="currentColor" stroke-width="1.5" />
<rect x="40" y="152" width="250" height="76" rx="4" fill="currentColor" fill-opacity="0.14" stroke="currentColor" stroke-width="1.5" />
<text x="165.0" y="177.0" text-anchor="middle" font-weight="bold">UEFI (bootloader3)</text>
<text x="165.0" y="195.0" text-anchor="middle" opacity="0.75">measures its own version and</text>
<text x="165.0" y="213.0" text-anchor="middle" opacity="0.75">volumes into PCR0</text>
<path d="M165.0 132L165.0 152M161.0 147L165.0 152L169.0 147" fill="none" stroke="currentColor" stroke-width="1.5" />
<rect x="40" y="248" width="250" height="56" rx="4" fill="currentColor" fill-opacity="0.14" stroke="currentColor" stroke-width="1.5" />
<text x="165.0" y="272.0" text-anchor="middle" font-weight="bold">Linux</text>
<text x="165.0" y="290.0" text-anchor="middle" opacity="0.75">IMA extends PCR 10</text>
<path d="M165.0 228L165.0 248M161.0 243L165.0 248L169.0 243" fill="none" stroke="currentColor" stroke-width="1.5" />
<path d="M30 34H22V226H30" fill="none" stroke="currentColor" stroke-width="1.5" />
<text x="14" y="130" text-anchor="middle" transform="rotate(-90 14 130)" font-size="12">signature chain</text>
<rect x="330" y="152" width="100" height="152" rx="4" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-width="1.5" />
<text x="380" y="222" text-anchor="middle" font-weight="bold">TPM</text>
<text x="380" y="240" text-anchor="middle" opacity="0.7" font-size="12">U37 or header</text>
<path d="M290 190L330 190M325 186L330 190L325 194" fill="none" stroke="currentColor" stroke-width="1.5" />
<path d="M290 276L330 276M325 272L330 276L325 280" fill="none" stroke="currentColor" stroke-width="1.5" />
</svg>
<figcaption id="boot-chain-cap" class="figure-caption text-center">What runs before Linux, what checks it and what gets measured.</figcaption>
</figure>

<h2 id="day-27-packages-and-images">Day 27: Packages and images</h2>

<p>The COPR carries the kernel, a <code class="language-plaintext highlighter-rouge">sky1-release</code> package whose subpackages hold the repo, the boot configuration and the
vendor Mali userspace, and an opt-in <code class="language-plaintext highlighter-rouge">cix-firmware</code> with the VPU and GPU blobs. The specs say the rest.</p>

<p>The GPU has two drivers to choose from. Upstream <code class="language-plaintext highlighter-rouge">panthor</code> works, but the vendor's <code class="language-plaintext highlighter-rouge">mali_kbase</code> is faster: it scores
9477 in glmark2 against panthor's 3252. On a test that only runs shader arithmetic the gap shrinks to 1.24x, and it is
all driver and compiler: panthor's reported 900 MHz against the vendor's 1000 turned out to be a readback of a different
clock, not a lower ceiling. <code class="language-plaintext highlighter-rouge">panthor</code> is the default; installing <code class="language-plaintext highlighter-rouge">sky1-mali</code> switches to the vendor stack by shadowing
the blacklist in <code class="language-plaintext highlighter-rouge">/etc/modprobe.d</code>, and removing it switches back. If the switch fails, you land on a working GPU rather
than none.</p>

<p>The images are <a href="https://github.com/Leuca/el10-images">a fork of the CentOS Stream Alternative Images kiwi descriptions</a>
on a <code class="language-plaintext highlighter-rouge">c10s-sky1</code> branch. The ISO has to fit GitHub's 2 GiB release limit and was already at 1.833 GiB with an lzma-9
payload that no compression flag would shrink further. Dropping the <code class="language-plaintext highlighter-rouge">GNOME-Desktop</code> group, which drags in Firefox,
Flatpak and the multimedia stack, while keeping the <code class="language-plaintext highlighter-rouge">gnome-desktop</code> collection anaconda's GUI actually needs, took it to
<strong>1.342 GiB</strong>. The ISO is now signed in CI and carries no platform-specific kernel arguments at all.</p>

<p>A fresh install then blanked the screen during early boot. <code class="language-plaintext highlighter-rouge">phy_cix_usbdp</code> sits in the
initramfs and resets the USB/DP PHYs, which blanks the firmware framebuffer, and no real display driver loads until
the root filesystem is mounted, so any prompt the initramfs shows, you cannot see. The fix is two drivers added to the
initramfs through a dracut drop-in in <code class="language-plaintext highlighter-rouge">sky1-config</code>.</p>

<p>Page size got a proper look the same day: 16K and 64K both break the VPU and the vendor Mali stack, and 64K costs
about 4 GB of RAM for a 3.4% compile speedup. 4K it is.</p>

<h2 id="day-36-where-it-stands">Day 36: Where it stands</h2>

<p>The kernel is public, and so is <a href="https://gitlab.com/Leuca/edk2-cix-rpm">the firmware package</a>, as source only. The flash
image carries CIX binaries with no stated licence (the bootloaders, config blobs, flash tools and a dozen binary UEFI
modules), so the repository holds only what is needed to build the image yourself: the RPM spec file, 32 patches on top
of CIX's EDK2 sources, and a build guide. The patches include CIX's own backports, two of which (Secure Boot image
verification) matter for this image, and the upstream fix for CVE-2024-38797 with its follow-up cleanup.</p>

<p>The NPU runs vision graphs well, 60 to 500 inferences a second, but not LLMs: decode on the CPU already runs close to
the memory-bandwidth limit, and whether prefill would gain is a question for a compiler only CIX can see into.</p>

<h2 id="porting-tips">Porting tips</h2>

<p>Start with the firmware, not the kernel. The "Enable ACPI SCMI" option in the UEFI Compliance menu is off by default,
and off means the SCMI clock and performance devices report <code class="language-plaintext highlighter-rouge">_STA</code> 0, which looks exactly like a kernel-side SCMI
failure and is not one. The setting is invisible in efivars; check <code class="language-plaintext highlighter-rouge">/sys/bus/acpi/devices/CIXHA008:00/status</code>
instead, where 11 means on.</p>

<p>A few other things that cost me time:</p>

<ul>
  <li>The fan is driven by the power-management firmware (<code class="language-plaintext highlighter-rouge">FAN_OUT0</code>), not by the PWM pin the schematic hints at.</li>
  <li>The UEFI setup menu was painfully slow over a large serial terminal (480x113 here): every arrow key sent about
18 KB of output, most of it spaces. Teaching the firmware's terminal driver to send each run of spaces as a single
erase sequence cut that to about 1.9 KB.</li>
</ul>

<hr />

<p>The moment that made it for me was the 32-bit FIFO theory holding up: four bytes packed per word and the TPM I had
soldered finally answered in Linux. The firmware had seen it before, but only then did I believe the chip, and my
first SMD soldering, actually worked. Add a NIC bug wearing a kernel costume, a
hardware barrier that did not exist and more reboots than I could count, and this is the most fun I have had with a
computer in a long time. If you have a Sky1 board too, or just a question, the comments are open below.</p>

<p class="small">* This post was written and reviewed with the help of AI agents.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[Five weeks of kernel, firmware, packaging and a first SMD soldering session on a CIX Sky1 board.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://luca.magrone.cc/images/blog/orion-o6n/board.jpg" /><media:content medium="image" url="https://luca.magrone.cc/images/blog/orion-o6n/board.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>