<?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://aioue.net/feed.xml" rel="self" type="application/atom+xml" /><link href="https://aioue.net/" rel="alternate" type="text/html" /><updated>2026-11-14T01:47:31+00:00</updated><id>https://aioue.net/feed.xml</id><title type="html">aioue.net</title><subtitle>Technical notes. Nondescript.</subtitle><entry><title type="html">llama.cpp on a Vega 7 iGPU: the GPU won, the tuning knobs did not</title><link href="https://aioue.net/2026/10/19/llama-cpp-vulkan-tuning-vega7-igpu/" rel="alternate" type="text/html" title="llama.cpp on a Vega 7 iGPU: the GPU won, the tuning knobs did not" /><published>2026-10-19T04:20:00+00:00</published><updated>2026-10-19T00:00:00+00:00</updated><id>https://aioue.net/2026/10/19/llama-cpp-vulkan-tuning-vega7-igpu</id><content type="html" xml:base="https://aioue.net/2026/10/19/llama-cpp-vulkan-tuning-vega7-igpu/"><![CDATA[<p>Two days of benchmarking Qwen3 on an integrated Radeon Vega 7, first on CPU and then on the iGPU through Vulkan, with a llama-bench tuning sweep in between. The headline: full GPU offload doubled real-world decode and cut time-to-answer by a third. Every tuning knob that looked promising in synthetic benchmarks lost or drew in real serving, so production kept its plain settings.</p>

<h2 id="the-box">The box</h2>

<table>
  <thead>
    <tr>
      <th>Component</th>
      <th>Detail</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>APU</td>
      <td>AMD Ryzen 5 PRO 5650G (6C/12T Zen 3)</td>
    </tr>
    <tr>
      <td>iGPU</td>
      <td>Radeon Vega 7, gfx90c, full offload via Vulkan (<code class="language-plaintext highlighter-rouge">RADV</code>, Mesa 26.0.8)</td>
    </tr>
    <tr>
      <td>RAM</td>
      <td>32 GB DDR4 at stock 3200 MT/s, shared with the iGPU</td>
    </tr>
    <tr>
      <td>Guest</td>
      <td>LXC container, Ubuntu 26.04, 12 GB RAM, <code class="language-plaintext highlighter-rouge">llama-server</code> behind an authenticated Caddy</td>
    </tr>
    <tr>
      <td>llama.cpp</td>
      <td>pinned <code class="language-plaintext highlighter-rouge">620d2225</code> (v0.7.0-dev), one build for bench and serve</td>
    </tr>
  </tbody>
</table>

<p>Serving configuration: <code class="language-plaintext highlighter-rouge">ctx 8192</code>, <code class="language-plaintext highlighter-rouge">threads 12</code>, <code class="language-plaintext highlighter-rouge">ubatch 512</code>, f16 KV cache, flash attention at the build default, <code class="language-plaintext highlighter-rouge">n-gpu-layers</code> full. Benchmarks ran with the machine otherwise idle, GPU legs with the server stopped and CPU legs with it stopped too, each number from its own server process.</p>

<h2 id="gpu-against-cpu">GPU against CPU</h2>

<p>Qwen3 4B (Q4_K_M), measured two ways. The HTTP numbers are the honest ones: a prompt and a 128-token generation through <code class="language-plaintext highlighter-rouge">llama-server</code>, median over a full run.</p>

<table>
  <thead>
    <tr>
      <th>Path</th>
      <th style="text-align: right">Decode t/s</th>
      <th style="text-align: right">HTTP median</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>CPU only, 12 threads</td>
      <td style="text-align: right">3.52</td>
      <td style="text-align: right">25.9 / 26.4 s</td>
    </tr>
    <tr>
      <td>Vulkan, all layers</td>
      <td style="text-align: right">6.99</td>
      <td style="text-align: right">16.98 s</td>
    </tr>
  </tbody>
</table>

<p>Twice the tokens, a third less waiting. The <code class="language-plaintext highlighter-rouge">llama-bench</code> decode number and the served number agree closely (6.6 to 7.0 t/s), which is worth knowing: on this box the server adds little to per-token cost.</p>

<p>The 900-second soak passed 38/38 on the GPU path, and a 12-question quality battery looked no worse than CPU output.</p>

<h2 id="the-9b-result-is-the-interesting-one">The 9B result is the interesting one</h2>

<p>Qwen3 9B (IQ3_M), a model 2.7 times larger: <strong>7.48 t/s decode, 85.5 t/s prefill</strong> in a clean <code class="language-plaintext highlighter-rouge">llama-bench</code>, a 900-second soak at <code class="language-plaintext highlighter-rouge">ctx 8192</code> passing 29/29 with a 23.6 s median, and 12/12 on the quality battery.</p>

<p>The 9B decodes at the same speed as the 4B. On a shared-memory iGPU, decode is bound by a fixed per-token cost of about 133 ms that has nothing to do with model size in this range. Prefill still scales with compute (85 t/s for the 9B, 160 for the 4B), so long prompts got slower; token generation did not.</p>

<h2 id="the-knobs">The knobs</h2>

<p><code class="language-plaintext highlighter-rouge">llama-bench</code> sweep against the 4B, <code class="language-plaintext highlighter-rouge">-p 512 -n 128</code>, all Vulkan, all layers offloaded, server stopped. Baseline is the production configuration.</p>

<table>
  <thead>
    <tr>
      <th>Change</th>
      <th style="text-align: right">Decode t/s</th>
      <th style="text-align: right">vs baseline</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>baseline (<code class="language-plaintext highlighter-rouge">ub 512</code>, f16 KV, stock env)</td>
      <td style="text-align: right">6.58</td>
      <td style="text-align: right">-</td>
    </tr>
    <tr>
      <td>disable GTT spill + host-visible vidmem off (combo)</td>
      <td style="text-align: right">7.08</td>
      <td style="text-align: right">+7.7%</td>
    </tr>
    <tr>
      <td>larger Vulkan heap (scoped <code class="language-plaintext highlighter-rouge">drirc</code>)</td>
      <td style="text-align: right">6.90</td>
      <td style="text-align: right">+4.9%</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">--no-mmap</code>, limit 50</td>
      <td style="text-align: right">6.88</td>
      <td style="text-align: right">+4.6%</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">ubatch 2048</code></td>
      <td style="text-align: right">6.87</td>
      <td style="text-align: right">+1.5%</td>
    </tr>
    <tr>
      <td>flash attention on</td>
      <td style="text-align: right">6.66</td>
      <td style="text-align: right">+1.3%</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">ctx 4096</code></td>
      <td style="text-align: right">6.74</td>
      <td style="text-align: right">flat</td>
    </tr>
    <tr>
      <td>GTT spill disable alone</td>
      <td style="text-align: right">6.73</td>
      <td style="text-align: right">+2.2%</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">--no-mmap</code>, limit 20</td>
      <td style="text-align: right">6.74</td>
      <td style="text-align: right">flat</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">ctx 8192</code></td>
      <td style="text-align: right">6.51</td>
      <td style="text-align: right">flat</td>
    </tr>
    <tr>
      <td>prefer host memory</td>
      <td style="text-align: right">6.47</td>
      <td style="text-align: right">-1.7%</td>
    </tr>
    <tr>
      <td>KV cache q8_0 at depth 8064</td>
      <td style="text-align: right">6.41</td>
      <td style="text-align: right">-2.6%</td>
    </tr>
  </tbody>
</table>

<p>KV depth made no difference at all: depth 4096 and depth 8064 landed within noise of each other, and context length moved nothing.</p>

<h2 id="how-to-read-it">How to read it</h2>

<table>
  <thead>
    <tr>
      <th>Question</th>
      <th>Answer</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Which path for serving?</td>
      <td>Vulkan, all layers. It wins decode outright and needs no patching</td>
    </tr>
    <tr>
      <td>Did any knob earn production adoption?</td>
      <td>No</td>
    </tr>
    <tr>
      <td>Why not the +7.7% combo?</td>
      <td>See below: it lost in real serving</td>
    </tr>
    <tr>
      <td>Is the 9B viable?</td>
      <td>Yes, same decode speed as the 4B, slower prefill</td>
    </tr>
  </tbody>
</table>

<h2 id="synthetic-wins-real-losses">Synthetic wins, real losses</h2>

<p>The +7.7% combo was the one knob worth chasing, so it got an HTTP trial through the real server: <strong>17.28 s median against 16.98 s for plain settings</strong>. The synthetic gain inverted at the serving layer, so the environment overrides came back off the box and production stayed where it was.</p>

<p>This is the result I would want to find before adopting anything: a tuning leg that only runs <code class="language-plaintext highlighter-rouge">llama-bench</code> would have shipped a regression. The 4.6% and 4.9% rows probably hold the same cargo, and I did not spend HTTP trials on them because the best candidate already failed.</p>

<h2 id="the-thread-count-trap-discarded">The thread-count trap, discarded</h2>

<p>The sweep originally contained rows for running the GPU path at 2, 4, 6 and 8 threads. Those numbers showed decode jumping dramatically at every thread count except 12. Verification runs proved the pattern was an artifact of <code class="language-plaintext highlighter-rouge">llama-bench</code> timing on Vulkan at non-default thread counts, not real throughput: interleaved controls at 12 threads sat at the production value while the same run reported inflated figures for the others. Those rows are discarded rather than published. If you benchmark Vulkan on an APU, keep <code class="language-plaintext highlighter-rouge">-t</code> at your physical core count and be suspicious of anything that wins by changing it.</p>

<h2 id="why-other-people-quote-higher-numbers">Why other people quote higher numbers</h2>

<p>Community posts for these APUs regularly claim 10 to 12 t/s on models this size. Nothing in this sweep contradicts them:</p>

<ul>
  <li>Most quoted numbers are raw <code class="language-plaintext highlighter-rouge">llama-bench</code>, often <code class="language-plaintext highlighter-rouge">-p 0</code> with short generation and cache reuse. This post separates bench from serving for exactly that reason.</li>
  <li>The per-token overhead floor dominates here. A setup with less of it shows a higher number on identical silicon.</li>
  <li>Speculative decoding from the model’s own MTP head is the legitimate way to break the floor, and the pinned build here loads MTP weights but never uses them. <a href="https://github.com/daimonionnn/amd-vega-rocm-vulkan-llm-toolkit">daimonionnn’s amd-vega-rocm-vulkan-llm-toolkit</a> measured +38% decode on an MoE model and -5% on a dense 9B with it, which fits the overhead picture: a bandwidth-saturated dense model has no headroom left to buy tokens with.</li>
  <li>Lighter serving settings (shorter context, cheaper cache, faster RAM) all help an iGPU. This box runs <code class="language-plaintext highlighter-rouge">ctx 8192</code> for reliability and stock 3200 MT/s memory, and decode scales with DDR4 bandwidth on shared-memory graphics.</li>
</ul>

<h2 id="when-the-host-wedges">When the host wedges</h2>

<p>One operational note from the middle of the sweep: two overlapping benchmark sessions starved the Proxmox host badly enough to cost it an SSH login, and it took a console reset. The guard that watches the host had tripped on a PVE probe timeout and stayed latched after recovery. It now disarms when the operator clears the marker, and benchmark legs hold a lock file plus a remote lease so a second session cannot start while one is running. Bench your own box serially; shared-memory iGPUs do not degrade gracefully under contention.</p>

<h2 id="raw-data">Raw data</h2>

<p>All numbers above come from JSON results captured per run, plus a written report for the tuning leg, in the homelab repo. The 4B GPU profile and both soak logs were accepted by the tooling only at <code class="language-plaintext highlighter-rouge">ctx 8192</code>; the 9B’s first soak at 4096 was rejected by the acceptance rule and re-run at depth, which is why the two soaks cite the same context.</p>]]></content><author><name></name></author><category term="llama.cpp" /><category term="vulkan" /><category term="amd" /><category term="igpu" /><category term="homelab" /><category term="benchmark" /><summary type="html"><![CDATA[Two days of benchmarking Qwen3 on an integrated Radeon Vega 7, first on CPU and then on the iGPU through Vulkan, with a llama-bench tuning sweep in between. The headline: full GPU offload doubled real-world decode and cut time-to-answer by a third. Every tuning knob that looked promising in synthetic benchmarks lost or drew in real serving, so production kept its plain settings.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aioue.net/og-image.png" /><media:content medium="image" url="https://aioue.net/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Multi-app audio on Android, and why the toggle waits for a reboot</title><link href="https://aioue.net/2026/10/17/multi-app-audio-on-android/" rel="alternate" type="text/html" title="Multi-app audio on Android, and why the toggle waits for a reboot" /><published>2026-10-17T04:30:00+00:00</published><updated>2026-10-17T00:00:00+00:00</updated><id>https://aioue.net/2026/10/17/multi-app-audio-on-android</id><content type="html" xml:base="https://aioue.net/2026/10/17/multi-app-audio-on-android/"><![CDATA[<p>Sometimes I want VLC or a browser to play at the same time as YouTube and Spotify. Sometimes I want the normal one-app-at-a-time behaviour back. On a Pixel 8a running GrapheneOS (Android 17), no root, this turned into a longer dig than expected.</p>

<h2 id="the-flag">The flag</h2>

<p>Android’s audio focus policy is controlled by a single settings key:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>adb shell settings put system multi_audio_focus_enabled 1
</code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">audioserver</code> reads it once, in <code class="language-plaintext highlighter-rouge">MediaFocusControl</code>’s constructor. You can check the live state with:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>adb shell dumpsys audio | <span class="nb">grep</span> <span class="nt">-i</span> multi
</code></pre></div></div>

<p>which shows <code class="language-plaintext highlighter-rouge">Multi Audio Focus enabled :true</code> or <code class="language-plaintext highlighter-rouge">false</code>.</p>

<p>The catch: nothing watches that setting after startup. The only runtime setter is the hidden <code class="language-plaintext highlighter-rouge">AudioManager.setMultiAudioFocusEnabled</code>, which calls <code class="language-plaintext highlighter-rouge">updateMultiAudioFocus</code>. On this phone that hidden call is a oneway binder, and when it arrives from adb or Shizuku (uid 2000), <code class="language-plaintext highlighter-rouge">AudioService</code> then does <code class="language-plaintext highlighter-rouge">Settings.System.putIntForUser</code> as package <code class="language-plaintext highlighter-rouge">android</code> without <code class="language-plaintext highlighter-rouge">clearCallingIdentity</code>. Logcat tells the story:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>SecurityException: Package android does not belong to 2000
</code></pre></div></div>

<p>The live flag does not change. <code class="language-plaintext highlighter-rouge">settings put</code> on its own does not change what <code class="language-plaintext highlighter-rouge">dumpsys</code> reports either. A reboot does: with the setting at 0, <code class="language-plaintext highlighter-rouge">dumpsys</code> came back <code class="language-plaintext highlighter-rouge">false</code>; set it back to 1, reboot, and it reports <code class="language-plaintext highlighter-rouge">true</code>. Shell cannot <code class="language-plaintext highlighter-rouge">stop</code> or <code class="language-plaintext highlighter-rouge">kill</code> audioserver to shortcut the restart.</p>

<h2 id="why-new-players-can-still-pick-it-up">Why new players can still pick it up</h2>

<p><code class="language-plaintext highlighter-rouge">isMultiFocus()</code> reads the setting when a new focus environment is created, so an app launched after the <code class="language-plaintext highlighter-rouge">settings put</code> sees the new policy. Apps that already hold focus stay on the cached flag - which is why turning the setting off does not stop what is already playing. Practical sequence: set the flag, then start the second player.</p>

<h2 id="state-of-the-art">State of the art</h2>

<ul>
  <li><a href="https://github.com/channelramble/multiAPPaudio">channelramble/multiAPPaudio</a> - <code class="language-plaintext highlighter-rouge">settings put</code> plus reboot. Their notes say the live API is not possible.</li>
  <li><a href="https://github.com/legendsayantan/ShizuTools">legendsayantan/ShizuTools</a> MixedAudio - does not touch the flag. Per-app <code class="language-plaintext highlighter-rouge">appops set &lt;pkg&gt; TAKE_AUDIO_FOCUS ignore</code> applies immediately and lets that app keep playing over others. It does not restore one-at-a-time.</li>
  <li><code class="language-plaintext highlighter-rouge">PLAY_AUDIO ignore</code> mutes one app.</li>
  <li>crDroid updates the flag from inside audioserver. Not portable to a Pixel.</li>
  <li>Root-only routes: kill audioserver, or an LSPosed module. Not available here.</li>
</ul>

<p>No public non-root command flips the live flag. The defect belongs in AOSP - the uid 2000 path in <code class="language-plaintext highlighter-rouge">setMultiAudioFocusEnabled</code> - not as a GrapheneOS-only patch. Filed as <a href="https://issuetracker.google.com/issues/574515432">issue 574515432</a>.</p>

<h2 id="pausing-from-an-app-is-not-the-same-thing">Pausing from an app is not the same thing</h2>

<p>An app can pause other <code class="language-plaintext highlighter-rouge">MediaSession</code>s, and that looks similar from the couch. It is not: both apps are allowed to start, you hear a short overlap, and anything without a media session - games, many browser tabs, alarms - never gets paused. The paused app can also resume itself, because it never lost audio focus.</p>

<h2 id="the-app">The app</h2>

<p>I wrapped this in my phone app. The screen keeps two switches: “Let media apps play at the same time” (saved immediately, applied at next reboot) and “Restore music after calls”, which resumes media after a phone call while multi-app is on. That one did resume in testing because the player restarted itself - the app only presses play if the session is still paused. A red “Reboot to apply” chip shows when the saved setting and the live <code class="language-plaintext highlighter-rouge">dumpsys</code> flag disagree. After a reboot they match and the chip goes away.</p>]]></content><author><name></name></author><category term="android" /><category term="audio" /><category term="grapheneos" /><category term="shizuku" /><summary type="html"><![CDATA[Sometimes I want VLC or a browser to play at the same time as YouTube and Spotify. Sometimes I want the normal one-app-at-a-time behaviour back. On a Pixel 8a running GrapheneOS (Android 17), no root, this turned into a longer dig than expected.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aioue.net/og-image.png" /><media:content medium="image" url="https://aioue.net/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Reading an ASM2464PD enclosure’s firmware before flashing it</title><link href="https://aioue.net/2026/10/12/asm2464pd-firmware-before-flashing/" rel="alternate" type="text/html" title="Reading an ASM2464PD enclosure’s firmware before flashing it" /><published>2026-10-12T00:30:00+00:00</published><updated>2026-10-12T00:30:00+00:00</updated><id>https://aioue.net/2026/10/12/asm2464pd-firmware-before-flashing</id><content type="html" xml:base="https://aioue.net/2026/10/12/asm2464pd-firmware-before-flashing/"><![CDATA[<p>My UGREEN CM642 is a USB4 NVMe enclosure built on an ASMedia ASM2464PD. Under sustained load it drops off my Mac mini, and it runs hot. UGREEN support has no fan-curve firmware and offered the public ASMedia <code class="language-plaintext highlighter-rouge">250717</code> zip, which <a href="https://www.reddit.com/r/UsbCHardware/comments/1bt10ue/ugreen_40gbps_nvme_ssd_enclosure_mac_os/">one owner</a> reports made their disconnects worse. I wanted to know what ASMedia’s flasher (MPTool) would do to the unit before I let it, and whether I could read enough of the chip to undo it.</p>

<p>Two existing projects did much of the groundwork: <a href="https://github.com/tinygrad/asm2464pd-firmware">tinygrad/asm2464pd-firmware</a> (stock ASM2464PD firmware, decompilation, an 8051 emulator, and <code class="language-plaintext highlighter-rouge">flash.py</code>/<code class="language-plaintext highlighter-rouge">e4_flash.py</code> host tools) and <a href="https://github.com/cyrozap/usb-to-pcie-re">cyrozap/usb-to-pcie-re</a> (notes on the ASM236x/246x vendor SCSI commands). I checked what they say against this Ugreen firmware and unit using <a href="https://www.npmjs.com/package/rea-agents">REA</a> (a reverse-engineering MCP server), Ghidra, radare2 and a few Cursor agents. The unit shipped on <code class="language-plaintext highlighter-rouge">240229850000</code>, and I flashed <code class="language-plaintext highlighter-rouge">250417_85_00_00</code> early on 2026-10-12.</p>

<p>Most of what follows is what static analysis could and could not tell me. Whether the flash fixes the disconnects is not known yet.</p>

<h2 id="what-update-fw-touches">What Update FW touches</h2>

<p>Update FW rewrites the config tables as well as the code. Every row in ASMedia’s production logs fills VID, PID, revision and strings from the INI. The INI on the tools ISO would have turned this unit into PID <code class="language-plaintext highlighter-rouge">2464</code>, serial <code class="language-plaintext highlighter-rouge">AAAABBBB...</code>, strings <code class="language-plaintext highlighter-rouge">USB4_TBT</code> / <code class="language-plaintext highlighter-rouge">SSD Enclosure</code>. I wrote an INI holding the unit’s live values and used only that. MPTool quirks that cost time:</p>

<ul>
  <li>The INI must be called <code class="language-plaintext highlighter-rouge">as_mp_Toolv0.6.ini</code> and sit beside the EXE. Any line starting with <code class="language-plaintext highlighter-rouge">;</code> gives an invalid-line dialog, so the file cannot carry comments.</li>
  <li>Start refuses with “FW check is incorrect” unless the bin is named <code class="language-plaintext highlighter-rouge">AS_USB4_*</code>. My backup, saved as <code class="language-plaintext highlighter-rouge">firmware-240229850000.bin</code>, was rejected until I renamed it <code class="language-plaintext highlighter-rouge">AS_USB4_240229_85_00_00.bin</code> and matched <code class="language-plaintext highlighter-rouge">fw_binary_name</code> in the INI.</li>
  <li>Standalone Config Check plus Play did nothing on my build. The Check Configuration dialog’s Read Config and Read U4 Config buttons work, and I used them to record both tables before unplugging.</li>
  <li>W/R Test, Format Type and Partition Type all write to the SSD. Only Update FW is safe.</li>
</ul>

<p>There is no downgrade gate. The EXE’s embedded defaults set every <code class="language-plaintext highlighter-rouge">check_*</code> key (<code class="language-plaintext highlighter-rouge">check_fw_version</code>, <code class="language-plaintext highlighter-rouge">check_vid</code>, <code class="language-plaintext highlighter-rouge">check_pid</code> and so on) to 0, and the ISO’s INI has no <code class="language-plaintext highlighter-rouge">[chk_item]</code> section, so nothing compares versions. Browsing to an older bin raised no complaint. The same Reddit owner reports going <code class="language-plaintext highlighter-rouge">250717</code> down to <code class="language-plaintext highlighter-rouge">241129</code> and back up to <code class="language-plaintext highlighter-rouge">250417</code>. I have not flashed backwards from <code class="language-plaintext highlighter-rouge">250417</code> myself.</p>

<h2 id="flash-the-same-image-back-first">Flash the same image back first</h2>

<p>Before the real flash I flashed the existing <code class="language-plaintext highlighter-rouge">240229</code> image over itself with the exact-identity INI, then read everything back. After that, Update FW had changed:</p>

<table>
  <thead>
    <tr>
      <th>Area</th>
      <th>Change</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>SPI window (130,560 B)</td>
      <td>2 bytes at 98049-98050, <code class="language-plaintext highlighter-rouge">60 13</code> to <code class="language-plaintext highlighter-rouge">FF FF</code>, in the padding after the image</td>
    </tr>
    <tr>
      <td>Config table 0</td>
      <td>16 bytes, mostly <code class="language-plaintext highlighter-rouge">FF</code> replaced by the INQUIRY text <code class="language-plaintext highlighter-rouge">ASMT</code> and <code class="language-plaintext highlighter-rouge">2462 NVME</code>, plus the CRC tail</td>
    </tr>
    <tr>
      <td>Config table 1</td>
      <td>2 bytes</td>
    </tr>
    <tr>
      <td>Serial, strings, VID/PID</td>
      <td>none</td>
    </tr>
  </tbody>
</table>

<p>So the config tables are rewritten from the INI, and the padding past the image survives, so within the window I can read there was no full-chip erase on the Update FW path. Static analysis of the firmware had only reached “likely” on that point. The null flash was the evidence. If you are about to flash a unit you cannot replace, this is the cheapest drill I know of.</p>

<h2 id="what-the-old-firmware-shows-statically">What the old firmware shows statically</h2>

<p>The flash file is a wrapped image:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>0x0000   little-endian uint32 length (98006)
0x0004   8051 image body
 +0x200  BCD version, 24 02 29 85 00 00 = 240229850000
end      6-byte trailer, a5 b6 5b 36 08 54
</code></pre></div></div>

<p>It is 8051 code. The bank layout below matches tinygrad’s emulator (<code class="language-plaintext highlighter-rouge">BANK1_FILE_BASE = 0xFF6B</code>) and I confirmed it against this image. The low 32 KiB is fixed and the upper 32 KiB is banked by SFR <code class="language-plaintext highlighter-rouge">0x96</code> bit 0, with bank 1 starting at file offset <code class="language-plaintext highlighter-rouge">0xFF6B</code>. In Ghidra, import the two banks as separate programs at <code class="language-plaintext highlighter-rouge">0x0000</code> and <code class="language-plaintext highlighter-rouge">0x8000</code>, with processor <code class="language-plaintext highlighter-rouge">8051:BE:16:default</code>. Disassembling straight through the file produces nonsense around the jump tables, so start from <code class="language-plaintext highlighter-rouge">lcall</code> targets.</p>

<p>Vendor commands are SCSI CDBs dispatched from a table in bank 1. The table keys in this image are <code class="language-plaintext highlighter-rouge">E0</code> to <code class="language-plaintext highlighter-rouge">E5</code> and <code class="language-plaintext highlighter-rouge">E8</code>. The meanings are from tinygrad’s <code class="language-plaintext highlighter-rouge">flash.py</code> and cyrozap’s notes (cyrozap documents <code class="language-plaintext highlighter-rouge">E2</code> as a flash read taking a byte and a 32-bit count), and I checked the <code class="language-plaintext highlighter-rouge">E0</code>, <code class="language-plaintext highlighter-rouge">E1</code>, <code class="language-plaintext highlighter-rouge">E2</code> and <code class="language-plaintext highlighter-rouge">E4</code> behaviour on the unit:</p>

<table>
  <thead>
    <tr>
      <th>Opcode</th>
      <th>Use</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">E0 50 &lt;slot&gt;</code></td>
      <td>read a 128-byte config table</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">E1 50 &lt;slot&gt;</code></td>
      <td>write a config table</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">E2</code></td>
      <td>read SPI flash</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">E3</code></td>
      <td>write SPI flash</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">E4</code></td>
      <td>firmware version, 6 bytes BCD</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">E5</code></td>
      <td>poke, the route to reading arbitrary flash</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">E8 51</code></td>
      <td>reset</td>
    </tr>
  </tbody>
</table>

<p>The firmware’s SPI driver uses the same registers as <a href="https://github.com/tinygrad/asm2464pd-firmware">tinygrad’s asm2464pd-firmware</a> (<code class="language-plaintext highlighter-rouge">0xC8A1</code> to <code class="language-plaintext highlighter-rouge">0xC8AD</code>, buffer at XDATA <code class="language-plaintext highlighter-rouge">0x7000</code>, found by scanning for <code class="language-plaintext highlighter-rouge">MOV DPTR,#imm16</code>). So tinygrad’s register map is valid for this Ugreen build.</p>

<p>The write path matters for erase scope. The <code class="language-plaintext highlighter-rouge">E3</code> worker only does write-enable and page program (<code class="language-plaintext highlighter-rouge">0x02</code>). Erase appears to be a separate state machine using 4 KiB sector erase (<code class="language-plaintext highlighter-rouge">0x20</code>) with a preset address of <code class="language-plaintext highlighter-rouge">0x18000</code>. A 64 KiB block erase (<code class="language-plaintext highlighter-rouge">0xD8</code>) routine appears reachable from the <code class="language-plaintext highlighter-rouge">E1</code> config write, but only on slot 0. Config shares the first erase block with the start of the firmware, which is why tinygrad’s <code class="language-plaintext highlighter-rouge">flash.py</code> saves and restores config around its erase. I first read that routine as the slot 1 path, and a second model reviewing my notes caught it. I only ever drilled slot 1.</p>

<p>Two other REA findings are about tooling. REA’s firmware tools lean on binwalk, which finds no signatures in this custom container, so the layout above was worked out by hand. Ghidra ships no native decompiler for arm64 Linux, so my arm64 devcontainer could import and disassemble but not decompile. I ran decompilation on an x86_64 VM.</p>

<h2 id="e2-and-the-dump-you-cannot-get">E2 and the dump you cannot get</h2>

<p><code class="language-plaintext highlighter-rouge">E2 &lt;region&gt; &lt;len u32 big-endian&gt;</code> reads the flash. It cannot seek: each read returns the start of the selected window, capped at <code class="language-plaintext highlighter-rouge">0xFF00</code> (65,280) bytes per transfer. Two reads, <code class="language-plaintext highlighter-rouge">E2 50</code> then <code class="language-plaintext highlighter-rouge">E2 D0</code>, give 130,560 bytes. That covers the 98,016-byte image plus <code class="language-plaintext highlighter-rouge">FF</code> padding. A longer second read fails with CHECK CONDITION, ILLEGAL REQUEST 05/24. The flash is a 512 KiB Puya P25D40H (per a <a href="https://www.chongdiantou.com/archives/304319.html">CM642 teardown on chongdiantou.com</a>), so about 381 KiB is out of reach over <code class="language-plaintext highlighter-rouge">E2</code>.</p>

<p>The unreachable part includes things you would want in a backup. The config tables sit at SPI <code class="language-plaintext highlighter-rouge">0x000-0x0FF</code> and the bootstub at <code class="language-plaintext highlighter-rouge">0x100</code>, below the window. The config bytes appear nowhere in the 130,560 bytes I read (that layout comes from <a href="https://github.com/tinygrad/asm2464pd-firmware/commit/c2c36aa9023fa15d40ffb77ea54c54221ff07bec">tinygrad commit c2c36aa</a>, not from reading the chip). Config comes out over <code class="language-plaintext highlighter-rouge">E0</code> instead, and the bootstub is not backed up at all.</p>

<p>The remaining routes are <code class="language-plaintext highlighter-rouge">E5</code> poke reads, which I did not try on a unit I wanted to keep, and a hardware programmer. I own one, but I judged this board to have no usable pads. A USB-dead brick would have been unrecoverable, and I flashed knowing that.</p>

<p>The second <code class="language-plaintext highlighter-rouge">E2</code> region byte also contradicts the disassembly. The gate at the start of the handler accepts only <code class="language-plaintext highlighter-rouge">0x50</code> and <code class="language-plaintext highlighter-rouge">0x51</code>, and there is no <code class="language-plaintext highlighter-rouge">0xD0</code> compare anywhere in the image. On the live unit <code class="language-plaintext highlighter-rouge">D0</code> returns the rest of the image, seamless with the first read, while <code class="language-plaintext highlighter-rouge">51</code> returns <code class="language-plaintext highlighter-rouge">FF</code> padding. I could not explain that statically, and the mechanism is still open. Probe the device read-only before trusting a gate you found in a disassembler. Two tool traps from the same exercise: an old “full dump” script requested a 459,008-byte second leg that always failed, and tinygrad’s <code class="language-plaintext highlighter-rouge">flash.py</code> writes placeholder tables and ends with <code class="language-plaintext highlighter-rouge">E8 51</code>, which leaves the bridge down until you unplug it.</p>

<h2 id="config-tables-and-the-thunderbolt-drom">Config tables and the Thunderbolt DROM</h2>

<p>Table 0 holds the USB identity: serial, manufacturer, product strings and VID/PID. Table 1 holds the USB4 identity: strings, a component ID, test ID, <code class="language-plaintext highlighter-rouge">bcdDevice</code>, and the TBT3 vendor, model and revision. <code class="language-plaintext highlighter-rouge">E0</code> slots 2 to 7 all return ILLEGAL REQUEST, so there are only two. The INI field names map straight onto the bytes.</p>

<p>On a Mac, none of that is what you see. The enclosure shows up as a USB4 PCIe tunnel (<code class="language-plaintext highlighter-rouge">IOThunderboltSwitchUSB4</code>, <code class="language-plaintext highlighter-rouge">Protocol: PCI-Express</code>), and the identity macOS reads is a 102-byte Thunderbolt DROM. Its strings and IDs derive from the config tables. Its first 16 bytes, a UUID-like ID, do not appear in the firmware, the SPI window, either config table or the MPTool EXE (I searched as-is, reversed and word-swapped). They look per-unit and unbacked. Capture the DROM with <code class="language-plaintext highlighter-rouge">ioreg</code>, because <code class="language-plaintext highlighter-rouge">system_profiler</code> returns empty over SSH (TCC).</p>

<h2 id="what-250417-changed">What 250417 changed</h2>

<p>After the flash I read back over SCSI and from the Mac:</p>

<ul>
  <li>Both config tables are byte-identical to before, and so is the DROM.</li>
  <li>84,169 of the 130,560 SPI bytes differ. The version field at <code class="language-plaintext highlighter-rouge">0x200</code> accounts for three of them (<code class="language-plaintext highlighter-rouge">24 02 29</code> to <code class="language-plaintext highlighter-rouge">25 04 17</code>, suffix unchanged). Code moved everywhere, so a raw diff says little.</li>
  <li><code class="language-plaintext highlighter-rouge">Chg2 10G</code> and <code class="language-plaintext highlighter-rouge">Chg2 20G</code> became <code class="language-plaintext highlighter-rouge">[Spd 10G]</code> and <code class="language-plaintext highlighter-rouge">[Spd 20G]</code>, and <code class="language-plaintext highlighter-rouge">UPS_Rst_Assert</code> became <code class="language-plaintext highlighter-rouge">USP_Rst_Assert</code>.</li>
  <li>New strings: <code class="language-plaintext highlighter-rouge">L1:Training OS2</code>, <code class="language-plaintext highlighter-rouge">Fail-Auto</code>, <code class="language-plaintext highlighter-rouge">[TargetErr]</code>, <code class="language-plaintext highlighter-rouge">[TxRtyErr]</code>. <code class="language-plaintext highlighter-rouge">[1 sec time out]</code> is still there, relocated.</li>
</ul>

<p>That points at USB4 link training and error handling. The <a href="https://www.reddit.com/r/UsbCHardware/comments/1bt10ue/ugreen_40gbps_nvme_ssd_enclosure_mac_os/">same Reddit owner</a> reports <code class="language-plaintext highlighter-rouge">250417</code> staying on USB4, but I have no evidence tying these strings to that.</p>

<p>Right after the flash, <code class="language-plaintext highlighter-rouge">E4</code> and MPTool’s FW column still showed <code class="language-plaintext highlighter-rouge">240229850000</code> while the image body said <code class="language-plaintext highlighter-rouge">250417850000</code>. The version buffer at XDATA <code class="language-plaintext highlighter-rouge">0x07F0</code> is filled at init: Ghidra shows code in the new image at <code class="language-plaintext highlighter-rouge">0x5E44</code> writing <code class="language-plaintext highlighter-rouge">25 04 17 85 00 00</code> there. Judge a flash by the body at <code class="language-plaintext highlighter-rouge">0x200</code> and the identity, and re-read <code class="language-plaintext highlighter-rouge">E4</code> after a power cycle, which I have not done yet.</p>

<h2 id="the-fan">The fan</h2>

<p>I found nothing in the bridge’s flash window or its vendor commands that touches the fan. ASMedia’s <a href="https://egpu.io/wp-content/uploads/wpforo/attachments/16981/16713-ASM2464PDMPToolUserManual.pdf">MPTool manual</a> lists a separate <code class="language-plaintext highlighter-rouge">mcu_fw_enable</code> key, which I left at 0. Over USB there is no hwmon node or temperature sensor, and with no SSD fitted there was no NVMe SMART either. I have no evidence that this update changes fan behaviour.</p>

<h2 id="so-far">So far</h2>

<p>Not worse, will comment after using the upgraded FW for a while.</p>

<p>The INI I flashed with, serial blanked:</p>

<div class="language-ini highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nn">[ini_version]</span>
<span class="py">version</span><span class="p">=</span><span class="s">1008</span>
<span class="nn">[usb_func]</span>
<span class="py">format_enable</span><span class="p">=</span><span class="s">0</span>
<span class="py">format_drive_type</span><span class="p">=</span><span class="s">2</span>
<span class="py">partition_drive_type</span><span class="p">=</span><span class="s">1</span>
<span class="py">drive_label_name</span><span class="p">=</span><span class="s">gpt-exfat</span>
<span class="py">wr_test_enable</span><span class="p">=</span><span class="s">0</span>
<span class="py">wr_test_binary_name</span><span class="p">=</span><span class="s">rwtest.bin</span>
<span class="py">wr_test_count</span><span class="p">=</span><span class="s">1</span>
<span class="py">auto_mp</span><span class="p">=</span><span class="s">0</span>
<span class="py">auto_mp_DevNum</span><span class="p">=</span><span class="s">1</span>
<span class="py">preload_enable</span><span class="p">=</span><span class="s">0</span>
<span class="py">preload_folder_path</span><span class="p">=</span><span class="s">D:</span><span class="se">\t</span><span class="s">emp</span>
<span class="py">Check_USBStatus_enable</span><span class="p">=</span><span class="s">0</span>
<span class="py">Check_USBStatus</span><span class="p">=</span><span class="s">0</span>
<span class="py">Check_SerialNumber</span><span class="p">=</span><span class="s">0</span>
<span class="py">Auto_Safe_Remove</span><span class="p">=</span><span class="s">0</span>
<span class="py">Scan_BarCode</span><span class="p">=</span><span class="s">0</span>
<span class="py">uiRemove_after_finish</span><span class="p">=</span><span class="s">0</span>
<span class="py">Speed_test_enable</span><span class="p">=</span><span class="s">0</span>
<span class="py">Scan_HDDSN</span><span class="p">=</span><span class="s">0</span>
<span class="py">check_config</span><span class="p">=</span><span class="s">0</span>
<span class="py">SN_EditType</span><span class="p">=</span><span class="s">1</span>
<span class="py">USB4_ComponentID_EditType</span><span class="p">=</span><span class="s">5</span>
<span class="py">CmdLineTimeOut</span><span class="p">=</span><span class="s">35</span>
<span class="py">USB4_BcdSync</span><span class="p">=</span><span class="s">0</span>

<span class="nn">[Speed_Test]</span>
<span class="py">read_speed</span><span class="p">=</span>
<span class="py">write_speed</span><span class="p">=</span>
<span class="py">speed_test_file_size</span><span class="p">=</span><span class="s">123</span>

<span class="nn">[usb_fw]</span>
<span class="py">fw_enable</span><span class="p">=</span><span class="s">0</span>
<span class="py">fw_binary_name</span><span class="p">=</span><span class="s">AS_USB4_250417_85_00_00.bin</span>
<span class="py">fw_reload</span><span class="p">=</span><span class="s">0</span>
<span class="py">rescan_after_relink</span><span class="p">=</span><span class="s">0</span>
<span class="py">ext_fw_enable</span><span class="p">=</span><span class="s">0</span>
<span class="py">pd_fw_enable</span><span class="p">=</span><span class="s">0</span>
<span class="py">mcu_fw_enable</span><span class="p">=</span><span class="s">0</span>
<span class="py">pd_binary_name</span><span class="p">=</span>
<span class="py">mcu_binary_name</span><span class="p">=</span>

<span class="nn">[usb_config]</span>
<span class="py">config_format</span><span class="p">=</span><span class="s">4</span>
<span class="py">vendor_id</span><span class="p">=</span><span class="s">174C</span>
<span class="py">product_id</span><span class="p">=</span><span class="s">2463</span>
<span class="py">device_revision</span><span class="p">=</span><span class="s">2942</span>
<span class="py">manufacturer_string</span><span class="p">=</span><span class="s">Ugreen</span>
<span class="py">product_string</span><span class="p">=</span><span class="s">Ugreen Storage Device</span>
<span class="py">manufacturer_string_T10</span><span class="p">=</span><span class="s">ASMT</span>
<span class="py">product_string_T10</span><span class="p">=</span><span class="s">2462 NVME</span>
<span class="py">SN_Numbers</span><span class="p">=</span><span class="s">12</span>
<span class="py">serial_number</span><span class="p">=</span><span class="s">XXXXXXXXXXXX</span>
<span class="py">serial_number_increase</span><span class="p">=</span><span class="s">0</span>
<span class="py">serial_number_increase_HEX</span><span class="p">=</span><span class="s">1</span>
<span class="py">serial_number_increase_DEC</span><span class="p">=</span><span class="s">0</span>
<span class="py">SN_fix_length</span><span class="p">=</span><span class="s">0</span>
<span class="py">SN_remain_value_enable</span><span class="p">=</span><span class="s">1</span>
<span class="py">SN_remain_value_length</span><span class="p">=</span><span class="s">12</span>
<span class="py">standby_timer</span><span class="p">=</span><span class="s">0</span>
<span class="py">hdd_standby</span><span class="p">=</span><span class="s">0</span>
<span class="py">image0</span><span class="p">=</span><span class="s">1</span>
<span class="py">image1</span><span class="p">=</span><span class="s">1</span>
<span class="py">crc32</span><span class="p">=</span><span class="s">0</span>

<span class="nn">[USB4_Config]</span>
<span class="py">USB4_VendorName</span><span class="p">=</span><span class="s">Ugreen</span>
<span class="py">USB4_ModelName</span><span class="p">=</span><span class="s">Ugreen Storage Device</span>
<span class="py">USB4_VendorID</span><span class="p">=</span><span class="s">174C</span>
<span class="py">USB4_ProductID</span><span class="p">=</span><span class="s">2463</span>
<span class="py">USB4_TestID</span><span class="p">=</span><span class="s">C0000666</span>
<span class="py">USB4_BcdProductFWRevision</span><span class="p">=</span><span class="s">2942</span>
<span class="py">USB4_ProductHWRevision</span><span class="p">=</span><span class="s">5A</span>
<span class="py">USB4_TBT3VendorID</span><span class="p">=</span><span class="s">00B8</span>
<span class="py">USB4_TBT3ModelID</span><span class="p">=</span><span class="s">2463</span>
<span class="py">USB4_TBT3ModelRevision</span><span class="p">=</span><span class="s">E3</span>
<span class="py">USB4_U4Mode</span><span class="p">=</span><span class="s">3</span>

<span class="nn">[PCIE]</span>
<span class="py">PCIE_Scan</span><span class="p">=</span><span class="s">1</span>
<span class="py">PCIE_VendorID</span><span class="p">=</span><span class="s">1B21</span>
<span class="py">PCIE_DeviceID</span><span class="p">=</span><span class="s">2463</span>
<span class="py">PCIE_SSDRelinkTime</span><span class="p">=</span><span class="s">10</span>

<span class="nn">[usb_mode]</span>
<span class="py">cd_rom_mode</span><span class="p">=</span><span class="s">0</span>

<span class="nn">[Target_Chip]</span>
<span class="py">target_chip</span><span class="p">=</span>
</code></pre></div></div>

<h2 id="sources">Sources</h2>

<ul>
  <li><a href="https://github.com/tinygrad/asm2464pd-firmware">tinygrad/asm2464pd-firmware</a>: <code class="language-plaintext highlighter-rouge">flash.py</code> CDB shapes, SPI register map, 8051 bank layout, flash layout notes</li>
  <li><a href="https://github.com/cyrozap/usb-to-pcie-re">cyrozap/usb-to-pcie-re</a>: ASM236x/246x vendor opcode notes</li>
  <li><a href="https://egpu.io/wp-content/uploads/wpforo/attachments/16981/16713-ASM2464PDMPToolUserManual.pdf">ASMedia MPTool user manual</a> (egpu.io mirror): Update FW scope, INI keys</li>
  <li><a href="https://www.station-drivers.com/index.php/en/component/remository/Drivers/Asmedia/ASM-2464-NVMe-USB-4.x-Controller-(40Gbps)/orderby,2/page,3/lang,en-gb/?Itemid=0">Station-Drivers ASM2464 list</a>: the <code class="language-plaintext highlighter-rouge">250417_85_00_00</code> bin</li>
  <li><a href="https://www.reddit.com/r/UsbCHardware/comments/1bt10ue/ugreen_40gbps_nvme_ssd_enclosure_mac_os/">r/UsbCHardware thread</a>: one CM642-15976 owner’s firmware history</li>
  <li><a href="https://www.chongdiantou.com/archives/304319.html">CM642 teardown on chongdiantou.com</a>: flash chip part number</li>
  <li><code class="language-plaintext highlighter-rouge">ASM246xMPTool.exe</code>, its INI and the production logs on UGREEN’s and ASMedia’s tools: downgrade gate, identity rewrite</li>
</ul>

<p>I did this with Cursor agents (Composer doing most of the work, with GLM models reviewing the notes before the writes). I made the decisions about what to write to the unit.</p>]]></content><author><name></name></author><category term="firmware" /><category term="reverse-engineering" /><category term="usb4" /><category term="nvme" /><category term="asmedia" /><category term="ugreen" /><category term="homelab" /><summary type="html"><![CDATA[My UGREEN CM642 is a USB4 NVMe enclosure built on an ASMedia ASM2464PD. Under sustained load it drops off my Mac mini, and it runs hot. UGREEN support has no fan-curve firmware and offered the public ASMedia 250717 zip, which one owner reports made their disconnects worse. I wanted to know what ASMedia’s flasher (MPTool) would do to the unit before I let it, and whether I could read enough of the chip to undo it.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aioue.net/og-image.png" /><media:content medium="image" url="https://aioue.net/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">TRMNL e-ink dashboard</title><link href="https://aioue.net/2026/10/04/trmnl-e-ink-dashboard/" rel="alternate" type="text/html" title="TRMNL e-ink dashboard" /><published>2026-10-04T01:00:00+00:00</published><updated>2026-10-19T00:00:00+00:00</updated><id>https://aioue.net/2026/10/04/trmnl-e-ink-dashboard</id><content type="html" xml:base="https://aioue.net/2026/10/04/trmnl-e-ink-dashboard/"><![CDATA[<p>I have a TRMNL OG and a TRMNL X on my desk. Both are e-paper dashboards from <a href="https://usetrmnl.com">usetrmnl.com</a>. They refresh on a schedule and do not ping me like a phone. I wanted a screen I could read without another notification surface in the room.</p>

<p>TRMNL has a plugin marketplace and a private-plugin webhook. You POST JSON, they render it on the device. I already run small pollers on the homelab for similar jobs. Battery and firmware show up in Home Assistant through their integration.</p>

<p>For todos I run <a href="https://aioue.net/2026/03/22/anydown-backup-any-do-tasks/">anydown</a> on Proxmox to back up Any.do. A Python sidecar polls that backup and POSTs a short task list to a TRMNL private plugin. The OG cycles through due items while I am at the desk.</p>

<p>If you want one, my referral link: <a href="https://trmnl.com?ref=tom10">https://trmnl.com?ref=tom10</a> (disclosure: I get credit if you buy through it).</p>]]></content><author><name></name></author><category term="homelab" /><category term="gadgets" /><summary type="html"><![CDATA[I have a TRMNL OG and a TRMNL X on my desk. Both are e-paper dashboards from usetrmnl.com. They refresh on a schedule and do not ping me like a phone. I wanted a screen I could read without another notification surface in the room.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aioue.net/og-image.png" /><media:content medium="image" url="https://aioue.net/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Restoring a GrapheneOS home screen from XML</title><link href="https://aioue.net/2026/10/01/grapheneos-home-screen-layout/" rel="alternate" type="text/html" title="Restoring a GrapheneOS home screen from XML" /><published>2026-10-01T22:30:00+00:00</published><updated>2026-10-01T22:30:00+00:00</updated><id>https://aioue.net/2026/10/01/grapheneos-home-screen-layout</id><content type="html" xml:base="https://aioue.net/2026/10/01/grapheneos-home-screen-layout/"><![CDATA[<p>I wanted the launcher cache gone and ran:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>adb shell pm clear com.android.launcher3 <span class="nt">--cache-only</span>
</code></pre></div></div>

<p>The help text is <code class="language-plaintext highlighter-rouge">pm clear [--user USER_ID] [--cache-only] PACKAGE</code>. With the flag after the package, the command still printed <code class="language-plaintext highlighter-rouge">Success</code> and deleted the launcher database. The home screen came back as the default grid: no folders, no widgets, and none of the placed icons. The same command against <code class="language-plaintext highlighter-rouge">com.android.systemui</code> clears the Quick Settings layout. The file below does not restore that.</p>

<p>Placing icons with <code class="language-plaintext highlighter-rouge">input draganddrop</code> works, one at a time. It is a slow way to rebuild a screen.</p>

<p>A backup from before the clear is how you get the old database back. On GrapheneOS that is Seedvault, under Settings, System, Backup. With no snapshot, Launcher3 can still load a workspace XML. The shell is not allowed to write it.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>adb shell content call <span class="nt">--uri</span> content://com.android.launcher3.settings <span class="nt">--method</span> EXPORT_LAYOUT_XML
</code></pre></div></div>

<p>That fails with <code class="language-plaintext highlighter-rouge">SecurityException: requires android.permission.ACCESS_LAUNCHER_DATA</code>. <code class="language-plaintext highlighter-rouge">pm grant</code> says the permission is not a changeable type. There is no developer option for it, and a production GrapheneOS build has no <code class="language-plaintext highlighter-rouge">adb root</code>.</p>

<p>The hook that does work is the first-run layout. On an empty favorites database, <code class="language-plaintext highlighter-rouge">ModelDbController</code> reads the secure setting <code class="language-plaintext highlighter-rouge">launcher3.layout.provider</code>. If that value is a content-provider authority, the launcher opens:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>content://AUTHORITY/launcher_layout?version=1&amp;gridWidth=4&amp;gridHeight=5&amp;hotseatSize=4
</code></pre></div></div>

<p>and parses the body with <code class="language-plaintext highlighter-rouge">AutoInstallsLayout</code>. I installed a small app that serves the XML. The sample, using Settings, Clock, Dialer and the desk clock widget, is <a href="https://github.com/aioue/graphene-home-screen-restore">graphene-home-screen-restore</a>. Replace those activities with your own.</p>

<p>JDK 17 and an Android SDK:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">export </span><span class="nv">ANDROID_HOME</span><span class="o">=</span><span class="s2">"</span><span class="nv">$HOME</span><span class="s2">/Android/Sdk"</span>
./build.sh
<span class="nv">CONFIRM</span><span class="o">=</span><span class="nb">yes</span> ./apply.sh
</code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">apply.sh</code> installs the apk, sets the secure setting, and checks that <code class="language-plaintext highlighter-rouge">content read</code> prints XML. Then it runs <code class="language-plaintext highlighter-rouge">pm clear com.android.launcher3</code>, which is what makes the database empty so the hook runs. The clear replaces whatever is on the screen.</p>

<p>Logcat:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>LauncherLayout: serving layout for content://com.example.launcherlayout/launcher_layout?version=1&amp;gridWidth=4&amp;gridHeight=5&amp;hotseatSize=4
LayoutParserFactory: Loading layout from com.example.launcherlayout
</code></pre></div></div>

<p>The root tag is <code class="language-plaintext highlighter-rouge">workspace</code>. <code class="language-plaintext highlighter-rouge">appicon</code> takes <code class="language-plaintext highlighter-rouge">packageName</code> and <code class="language-plaintext highlighter-rouge">className</code>, plus <code class="language-plaintext highlighter-rouge">screen</code>, <code class="language-plaintext highlighter-rouge">x</code> and <code class="language-plaintext highlighter-rouge">y</code>. <code class="language-plaintext highlighter-rouge">folder</code> takes <code class="language-plaintext highlighter-rouge">titleText</code> and at least two children that resolve, or the folder is removed. <code class="language-plaintext highlighter-rouge">appwidget</code> takes the provider class from <code class="language-plaintext highlighter-rouge">dumpsys appwidget</code>, plus <code class="language-plaintext highlighter-rouge">spanX</code> and <code class="language-plaintext highlighter-rouge">spanY</code>. The dock is <code class="language-plaintext highlighter-rouge">container="hotseat"</code> and <code class="language-plaintext highlighter-rouge">rank</code>.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>adb shell cmd package resolve-activity <span class="nt">--brief</span> <span class="se">\</span>
  <span class="nt">-a</span> android.intent.action.MAIN <span class="se">\</span>
  <span class="nt">-c</span> android.intent.category.LAUNCHER com.android.settings
</code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">com.android.settings/.Settings</code> means class <code class="language-plaintext highlighter-rouge">com.android.settings.Settings</code>. A missing component logs <code class="language-plaintext highlighter-rouge">Favorite not found</code> and is skipped. If the file adds no rows, the launcher loads its built-in default instead.</p>

<p>The grid is chosen when the database is created. Nothing is saved yet, so Launcher3 picks the device profile closest to the display size. <code class="language-plaintext highlighter-rouge">gridWidth</code> and <code class="language-plaintext highlighter-rouge">gridHeight</code> in that log line are the grid the XML was parsed against. Icons past the last column or row do not show.</p>

<p>I wanted 5 columns. The default profile was 4. In Launcher3 <code class="language-plaintext highlighter-rouge">device_profiles.xml</code>, <code class="language-plaintext highlighter-rouge">5_by_5</code> “Large Phone” is 406 dp by 694 dp. Override the display size so that profile is the nearest one, clear, then reset the size:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">CONFIRM</span><span class="o">=</span><span class="nb">yes </span><span class="nv">GRID_SIZE</span><span class="o">=</span>1100x2100 ./apply.sh
</code></pre></div></div>

<p>The script resets <code class="language-plaintext highlighter-rouge">wm size</code> after Home has started. The grid name is written into launcher prefs on that first start, so the reset leaves the 5-column grid in place. If <code class="language-plaintext highlighter-rouge">gridWidth</code> is wrong, choose another size and clear again.</p>

<p>The secure setting is only read for an empty database. Icons moved afterwards stay across a reboot. Stop a later clear from loading this file with:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>adb shell settings delete secure launcher3.layout.provider
adb uninstall com.example.launcherlayout
</code></pre></div></div>

<div class="github-embed" data-repo="aioue/graphene-home-screen-restore" data-ref="main" data-file="src/com/example/launcherlayout/LayoutProvider.java">
  <p class="github-embed-meta">
    <a href="https://github.com/aioue/graphene-home-screen-restore/blob/main/src/com/example/launcherlayout/LayoutProvider.java">src/com/example/launcherlayout/LayoutProvider.java</a>
    on
    <a href="https://github.com/aioue/graphene-home-screen-restore">aioue/graphene-home-screen-restore</a>
  </p>
  <div class="highlighter-rouge">
    <div class="highlight">
      <pre class="highlight"><code>Loading src/com/example/launcherlayout/LayoutProvider.java…</code></pre>
    </div>
  </div>
</div>]]></content><author><name></name></author><category term="grapheneos" /><category term="android" /><category term="launcher" /><summary type="html"><![CDATA[I wanted the launcher cache gone and ran:]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aioue.net/og-image.png" /><media:content medium="image" url="https://aioue.net/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Getting Proxmox root off USB on a DeskMini with no free slots</title><link href="https://aioue.net/2026/10/01/proxmox-root-off-usb-deskmini/" rel="alternate" type="text/html" title="Getting Proxmox root off USB on a DeskMini with no free slots" /><published>2026-10-01T00:20:00+00:00</published><updated>2026-10-01T00:20:00+00:00</updated><id>https://aioue.net/2026/10/01/proxmox-root-off-usb-deskmini</id><content type="html" xml:base="https://aioue.net/2026/10/01/proxmox-root-off-usb-deskmini/"><![CDATA[<p>The DeskMini X300M-STX that runs my Proxmox host has four storage connectors, and all of them were already taken by data:</p>

<table>
  <thead>
    <tr>
      <th>Connector</th>
      <th>Drive</th>
      <th>Pool</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>M.2 M-key x2</td>
      <td>2x Crucial P3 4TB</td>
      <td><code class="language-plaintext highlighter-rouge">fast</code> (mirror)</td>
    </tr>
    <tr>
      <td>SATA x2</td>
      <td>2x Samsung 870 QVO 2TB</td>
      <td><code class="language-plaintext highlighter-rouge">slow</code> (mirror)</td>
    </tr>
    <tr>
      <td>M.2 E-key</td>
      <td>Intel AX200</td>
      <td>Bluetooth passed to Home Assistant</td>
    </tr>
  </tbody>
</table>

<p>So the OS lived on a WD SN530 256GB in an RTL9210 USB-C enclosure on the front port. It worked, but it caused trouble in several ways:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">rpool</code> filled to 100% on 2026-09-23 and took journald, pvescheduler and chrony down with it.</li>
  <li>The enclosure shares an xHCI controller (<code class="language-plaintext highlighter-rouge">05:00.3</code>) with the front USB-A port, where the rotating zrepl backup HDD lives. Backups corrupted after I raised the zrepl bandwidth limit from 50 to 75MiB/s.</li>
  <li>The initramfs needed <code class="language-plaintext highlighter-rouge">ZFS_INITRD_*_SLEEP</code> delays so the USB bridge had time to enumerate before the pool import.</li>
</ul>

<h2 id="what-i-considered">What I considered</h2>

<p>Rear USB 3 SSD. The rear USB_3 port is on the other controller (<code class="language-plaintext highlighter-rouge">05:00.4</code>), so moving root there would end the contention with the backup HDD. Several ways to fill it:</p>

<ul>
  <li>The existing SN530 in a different NVMe enclosure (JMS583 rather than RTL9210), so only the bridge changes</li>
  <li>A spare 2.5” SATA SSD in a ~£7 JMS578 USB-A enclosure, or a new 256GB SATA SSD in one (~£40 total). SATA bridges pass TRIM and are boring</li>
  <li>A one-piece stick SSD with real NAND and a native USB-A plug, such as the KingSpec MemoStone US4 or Transcend ESD310C (~£25-35)</li>
  <li>Not the 20Gbps USB-C stick SSDs. The rear port is 5Gbps Gen1, so the extra speed is wasted and they need a C-to-A adapter</li>
</ul>

<p>All of these still left root on a USB bridge, and the RTL9210 enumeration races had already caused BIOS boot failures once.</p>

<p>Repartitioning the NVMe mirror. The layout would be 1G ESP, 256G <code class="language-plaintext highlighter-rouge">rpool</code> and the rest for <code class="language-plaintext highlighter-rouge">fast</code>, on both P3s. Mirrored, native NVMe, and the “proper” answer. But <code class="language-plaintext highlighter-rouge">fast</code> used whole disks, so this meant destroying the pool, booting a rescue ISO and restoring ~900G from a USB backup HDD that had just been corrupting data. Too much risk for a cleaner boot layout.</p>

<p>NVMe in the E-key slot. The Wi-Fi slot’s root port (<code class="language-plaintext highlighter-rouge">00:02.4</code>) advertises PCIe Gen3 x1, and the AX200 only uses it at Gen2. The idea was to pull the AX200, fit a passive E-key-to-M-key adapter with a spare WD 512GB SSD, and move the AX200 to a powered M.2-to-USB carrier, since Home Assistant only uses its Bluetooth (USB <code class="language-plaintext highlighter-rouge">8087:0029</code>). Gen3 x1 is plenty for a root disk, and Linux would very likely enumerate it. The unknowns were physical and firmware:</p>

<ul>
  <li>Passive E-to-M adapters vary in how they route the pins</li>
  <li>The slot is sized for a 2230 card, so a longer SSD plus adapter has to clear the chassis and antenna leads</li>
  <li>Nothing showed whether the X300 firmware lists an NVMe device in the Wi-Fi socket as bootable. Many boards treat that socket separately from storage</li>
</ul>

<p>The smallest test would have been to swap in the adapter and SSD and check the BIOS boot list before installing anything. The internal Bluetooth has been reliable for Home Assistant, and the carrier would need a hookscript rewrite, so I parked this.</p>

<p>Rear USB 2.0. A fallback for the first option, never a plan.</p>

<p>Root on the data pool, with only the bootloader on USB. This is what I did. Boot files are read once at power-on and written on kernel updates, so cheap flash sticks are fine for them, and cheap enough to run two in parallel.</p>

<h2 id="what-i-did">What I did</h2>

<p>Root became a plain dataset on the existing <code class="language-plaintext highlighter-rouge">fast</code> mirror, and the only things left on USB are EFI system partitions:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>fast/ROOT/pve-1     root, quota 64G, reservation 32G
fast/swap           8G zvol, volblocksize 4K
fast/proxmox/vms    guest disks (storage fast-vms)
fast/proxmox/vz     /var/lib/vz
2x SanDisk Ultra Fit 32GB: 2 GiB ESP (shim, GRUB, kernels, initramfs) + exFAT scratch
</code></pre></div></div>

<p>The sticks cost £14.18 for two. <code class="language-plaintext highlighter-rouge">proxmox-boot-tool</code> keeps both ESPs identical, and Secure Boot still works because they carry the same signed shim and GRUB. The quota stops a runaway root from eating data space, and the reservation stops data from squeezing the OS out, which is what killed <code class="language-plaintext highlighter-rouge">rpool</code> in September.</p>

<p>The trade-off is that root now shares <code class="language-plaintext highlighter-rouge">fast</code>’s failure domain. Losing one P3 still boots (degraded mirror, bootloader on the sticks). Losing both loses the data too, which was already true.</p>

<p>A stick ESP uses 273MB with three kernels, so 2 GiB is plenty. The sticks write at about 9MB/s sustained, which only matters during kernel updates.</p>

<h2 id="order-of-operations">Order of operations</h2>

<p>Everything except the cutover was online:</p>

<ol>
  <li><code class="language-plaintext highlighter-rouge">f3probe</code>, <code class="language-plaintext highlighter-rouge">f3write</code> and <code class="language-plaintext highlighter-rouge">f3read</code> on both sticks. Each took about an hour at that write speed. Both were genuine 28.67GB with zero bad sectors.</li>
  <li>Moved guest disks to <code class="language-plaintext highlighter-rouge">fast</code> with <code class="language-plaintext highlighter-rouge">qm move-disk</code> / <code class="language-plaintext highlighter-rouge">pct move-volume</code>, keeping the source copies. Moved <code class="language-plaintext highlighter-rouge">/var/lib/vz</code> with rsync.</li>
  <li>Partitioned stick A, ran <code class="language-plaintext highlighter-rouge">proxmox-boot-tool format</code> and <code class="language-plaintext highlighter-rouge">init ... grub</code>, then rebooted with <code class="language-plaintext highlighter-rouge">efibootmgr --bootnext</code>. This rehearsal booted the <em>old</em> root from the stick, without the console.</li>
  <li>Initial <code class="language-plaintext highlighter-rouge">zfs send rpool/ROOT/pve-1@migrate-1 | zfs recv -u ... fast/ROOT/pve-1</code> while running.</li>
</ol>

<p>The cutover itself took about 20 minutes of downtime:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># guests down, pve-cluster stopped</span>
zfs snapshot rpool/ROOT/pve-1@migrate-final
zfs send <span class="nt">-i</span> @migrate-1 rpool/ROOT/pve-1@migrate-final | zfs recv <span class="nt">-u</span> <span class="nt">-F</span> fast/ROOT/pve-1
mount <span class="nt">-t</span> zfs <span class="nt">-o</span> zfsutil fast/ROOT/pve-1 /mnt/newroot
<span class="c"># on the new root: root=ZFS=fast/ROOT/pve-1 in /etc/kernel/cmdline and grub.d/zfs.cfg,</span>
<span class="c"># swap in fstab, proxmox-boot-uuids = sticks only, zpool.cache without rpool</span>
zpool <span class="nb">set </span><span class="nv">bootfs</span><span class="o">=</span>fast/ROOT/pve-1 fast
<span class="c"># chroot with /dev /proc /sys efivars bound:</span>
update-initramfs <span class="nt">-u</span> <span class="nt">-k</span> all <span class="o">&amp;&amp;</span> proxmox-boot-tool refresh
<span class="c"># on the old root: drop the sticks from proxmox-boot-uuids, canmount=noauto</span>
</code></pre></div></div>

<p>To build a cache file without <code class="language-plaintext highlighter-rouge">rpool</code>, point the pools you want at a temporary cache file, copy it, then set the property back:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>zpool <span class="nb">set </span><span class="nv">cachefile</span><span class="o">=</span>/tmp/newcache fast
zpool <span class="nb">set </span><span class="nv">cachefile</span><span class="o">=</span>/tmp/newcache slow
<span class="nb">cp</span> /tmp/newcache /mnt/newroot/etc/zfs/zpool.cache
zpool <span class="nb">set </span><span class="nv">cachefile</span><span class="o">=</span><span class="s2">""</span> fast<span class="p">;</span> zpool <span class="nb">set </span><span class="nv">cachefile</span><span class="o">=</span><span class="s2">""</span> slow
zdb <span class="nt">-C</span> <span class="nt">-U</span> /tmp/newcache | <span class="nb">grep</span> <span class="nt">-E</span> <span class="s1">'^[a-z]+:$'</span>   <span class="c"># zdb wants an absolute path</span>
</code></pre></div></div>

<p>The old SSD stayed bootable and untouched as rollback media until I unplugged it.</p>

<h2 id="gotchas">Gotchas</h2>

<p>Port-based USB passthrough grabs whatever is plugged in. An old <code class="language-plaintext highlighter-rouge">usb0: host=2-1</code> on an unrelated VM claimed the front stick the moment it went in, and crashed QEMU. Pass devices through by <code class="language-plaintext highlighter-rouge">vendor:product</code>. That stale passthrough may also explain some of the backup trouble.</p>

<p><code class="language-plaintext highlighter-rouge">proxmox-boot-tool init &lt;part&gt;</code> without <code class="language-plaintext highlighter-rouge">grub</code> installs systemd-boot, which is unsigned, so Secure Boot rejects it. Always <code class="language-plaintext highlighter-rouge">init &lt;part&gt; grub</code>.</p>

<p>Stopping <code class="language-plaintext highlighter-rouge">pve-cluster</code> breaks key-based SSH. On PVE <code class="language-plaintext highlighter-rouge">/root/.ssh/authorized_keys</code> is a symlink into <code class="language-plaintext highlighter-rouge">/etc/pve/priv</code>, and <code class="language-plaintext highlighter-rouge">/etc/pve</code> disappears with pmxcfs. An Ansible ControlMaster socket that happened to still be open saved me. sshd also reads <code class="language-plaintext highlighter-rouge">authorized_keys2</code>, so the controller key now lives there too.</p>

<p>The <code class="language-plaintext highlighter-rouge">zfspool</code> storage plugin imports its pool when the storage activates. With the old SSD still plugged in, <code class="language-plaintext highlighter-rouge">local-zfs</code> would have imported <code class="language-plaintext highlighter-rouge">rpool</code> on the new root. <code class="language-plaintext highlighter-rouge">pvesm set local-zfs --disable 1</code> before copying <code class="language-plaintext highlighter-rouge">config.db</code>.</p>

<p><code class="language-plaintext highlighter-rouge">umount -R</code> on chroot bind mounts under a shared-propagation <code class="language-plaintext highlighter-rouge">/</code> can unmount the host’s own <code class="language-plaintext highlighter-rouge">/dev</code> and <code class="language-plaintext highlighter-rouge">/run</code>. Run <code class="language-plaintext highlighter-rouge">mount --make-rprivate /mnt/newroot</code> first.</p>

<p><code class="language-plaintext highlighter-rouge">grub-install</code> owns the NVRAM entry called <code class="language-plaintext highlighter-rouge">proxmox</code>. Every <code class="language-plaintext highlighter-rouge">proxmox-boot-tool init</code> deletes all entries with that label and adds one, first in BootOrder, for whichever stick was just initialised. Initialising stick B silently took stick A’s entry. Each stick now has its own labelled entry:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>efibootmgr <span class="nt">-c</span> <span class="nt">-d</span> /dev/disk/by-id/usb-...A <span class="nt">-p</span> 1 <span class="nt">-L</span> <span class="s2">"PVE stick A"</span> <span class="nt">-l</span> <span class="s1">'\EFI\proxmox\shimx64.efi'</span>
efibootmgr <span class="nt">-c</span> <span class="nt">-d</span> /dev/disk/by-id/usb-...B <span class="nt">-p</span> 1 <span class="nt">-L</span> <span class="s2">"PVE stick B"</span> <span class="nt">-l</span> <span class="s1">'\EFI\proxmox\shimx64.efi'</span>
</code></pre></div></div>

<p>A small script deletes stray <code class="language-plaintext highlighter-rouge">proxmox</code> entries and restores A, B first. It runs at boot and from an apt <code class="language-plaintext highlighter-rouge">DPkg::Post-Invoke</code> hook, so GRUB upgrades cannot reorder things.</p>

<p>The firmware drops a disk’s NVRAM entry by itself once the disk has been absent for a boot. Rolling back to the old SSD now means F11, or recreating its entry with <code class="language-plaintext highlighter-rouge">efibootmgr -c</code>.</p>

<h2 id="keeping-a-pulled-stick-current">Keeping a pulled stick current</h2>

<p>The <code class="language-plaintext highlighter-rouge">zz-proxmox-boot</code> kernel hook refreshes every ESP that is present and skips the rest with a warning. Plug a stick back in after a kernel update and it still carries the old kernels. A udev rule fixes that:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ACTION=="add", SUBSYSTEM=="block", KERNEL!="zd*", ENV{DEVTYPE}=="partition", \
  ENV{ID_PART_ENTRY_TYPE}=="c12a7328-f81f-11d2-ba4b-00a0c93ec93b", ENV{ID_FS_UUID}=="?*", \
  TAG+="systemd", ENV{SYSTEMD_WANTS}+="proxmox-esp-sync@%E{ID_FS_UUID}.service"
</code></pre></div></div>

<p>The service compares the stick’s <code class="language-plaintext highlighter-rouge">vmlinuz-*</code> and <code class="language-plaintext highlighter-rouge">initrd.img-*</code> with <code class="language-plaintext highlighter-rouge">/boot</code> and runs <code class="language-plaintext highlighter-rouge">proxmox-boot-tool refresh</code> only if they differ, so the coldplug event on every boot writes nothing. <code class="language-plaintext highlighter-rouge">KERNEL!="zd*"</code> skips guest EFI disks, which are zvols with their own ESPs.</p>

<p>In the unit, use <code class="language-plaintext highlighter-rouge">%i</code>, not <code class="language-plaintext highlighter-rouge">%I</code>. Unescaping turns the <code class="language-plaintext highlighter-rouge">-</code> in a FAT UUID like <code class="language-plaintext highlighter-rouge">A096-CEFC</code> into <code class="language-plaintext highlighter-rouge">/</code>, and the script then could not find the stick.</p>

<h2 id="result">Result</h2>

<p>Both sticks have boot-tested, and the host runs from internal NVMe with nothing on USB in the boot path except the bootloader. The box is also more portable: the NVMe mirror plus either stick is the whole system.</p>

<p>zrepl stays at 50MiB/s until the backup HDD is back and has scrubbed clean. It will share a controller with stick B, not with root.</p>

<p>I did this with a Cursor agent (Claude) doing the SSH work and Composer subagents running the stick tests, validation and repo changes in parallel, much as in the <a href="/2026/07/22/deskmini-idle-power-tuning-with-an-llm/">idle power tuning</a>. It wrote a runbook first, asked before anything destructive, and caught the NVRAM and SSH gotchas as they happened. I made the storage decisions.</p>]]></content><author><name></name></author><category term="proxmox" /><category term="zfs" /><category term="uefi" /><category term="usb" /><category term="homelab" /><category term="deskmini" /><summary type="html"><![CDATA[The DeskMini X300M-STX that runs my Proxmox host has four storage connectors, and all of them were already taken by data:]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aioue.net/og-image.png" /><media:content medium="image" url="https://aioue.net/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Sharing a devcontainer without extends</title><link href="https://aioue.net/2026/08/27/sharing-a-devcontainer-without-extends/" rel="alternate" type="text/html" title="Sharing a devcontainer without extends" /><published>2026-08-27T18:15:00+00:00</published><updated>2026-08-27T00:00:00+00:00</updated><id>https://aioue.net/2026/08/27/sharing-a-devcontainer-without-extends</id><content type="html" xml:base="https://aioue.net/2026/08/27/sharing-a-devcontainer-without-extends/"><![CDATA[<p>I keep two Ansible trees that talk to OpenNebula. They share a CLI gem, a PyONE pin, Cursor rules, and bind-mounts for <code class="language-plaintext highlighter-rouge">~/.one</code> and <code class="language-plaintext highlighter-rouge">~/.ssh</code>. Copying <code class="language-plaintext highlighter-rouge">.devcontainer/</code> between them lasted until the first non-trivial fix landed in only one copy.</p>

<p><a href="https://github.com/aioue/pocket-nebula">pocket-nebula</a> is the shared layer those trees consume. <code class="language-plaintext highlighter-rouge">devcontainer.json</code> has no <code class="language-plaintext highlighter-rouge">extends</code> (<a href="https://github.com/devcontainers/spec/issues/22">spec#22</a>, 2022). I simulate it with an image label, a git clone on the host, and 13 committed copies of someone else’s scripts. Each of those exists for one missing merge.</p>

<h2 id="the-consumer-file">The consumer file</h2>

<div class="language-jsonc highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"acorp-ansible"</span><span class="p">,</span><span class="w">
  </span><span class="nl">"extends"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ghcr.io/aioue/pocket-nebula-base:v1"</span><span class="p">,</span><span class="w">
  </span><span class="nl">"build"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nl">"dockerfile"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Dockerfile"</span><span class="p">,</span><span class="w"> </span><span class="nl">"args"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nl">"vscodedevcontainer"</span><span class="p">:</span><span class="w"> </span><span class="s2">"true"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">},</span><span class="w">
  </span><span class="nl">"runArgs"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"--dns=1.1.1.1"</span><span class="p">,</span><span class="w"> </span><span class="s2">"--dns=8.8.8.8"</span><span class="p">],</span><span class="w">
  </span><span class="nl">"features"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="nl">"ghcr.io/devcontainers/features/python:1"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
      </span><span class="nl">"toolsToInstall"</span><span class="p">:</span><span class="w"> </span><span class="s2">"virtualenv, argcomplete"</span><span class="w">
    </span><span class="p">}</span><span class="w">
  </span><span class="p">},</span><span class="w">
  </span><span class="nl">"postStartCommand"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ssh-add -q ~/.ssh/id_ed25519 2&gt;/dev/null; true"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<p>Plus a one-line <code class="language-plaintext highlighter-rouge">FROM ghcr.io/aioue/pocket-nebula-base:v1</code> and a <code class="language-plaintext highlighter-rouge">site.env</code> of XML-RPC URLs. Name, DNS, extra features, one extra lifecycle line, endpoints.</p>

<p>spec#22 writes <code class="language-plaintext highlighter-rouge">extends</code> as a relative path in the same repo, merged with Compose rules (arrays union, scalars overwrite, new keys add). The <code class="language-plaintext highlighter-rouge">ghcr.io/...</code> form above is the follow-on the issue already lists: a parent outside the repo. The tool would load that parent as part of parsing <code class="language-plaintext highlighter-rouge">devcontainer.json</code>. There is no second channel.</p>

<h2 id="glue-i-would-delete">Glue I would delete</h2>

<p>A thin Dockerfile, the json above without <code class="language-plaintext highlighter-rouge">extends</code>, and then:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">sync-common.sh</code> as <code class="language-plaintext highlighter-rouge">initializeCommand</code></li>
  <li><code class="language-plaintext highlighter-rouge">common.ref</code> (a second pin, independent of the image tag)</li>
  <li>13 files under <code class="language-plaintext highlighter-rouge">.devcontainer/common/</code>, committed in every consumer: <code class="language-plaintext highlighter-rouge">setup.sh</code>, git hooks, the version probe, a drift checker, Cursor rules, and so on</li>
</ul>

<div class="github-embed" data-repo="aioue/pocket-nebula" data-ref="main" data-file=".devcontainer-shared/scripts/sync-common.sh" data-start="1" data-end="23">
  <p class="github-embed-meta">
    <a href="https://github.com/aioue/pocket-nebula/blob/main/.devcontainer-shared/scripts/sync-common.sh#L1-L23">.devcontainer-shared/scripts/sync-common.sh (lines 1-23)</a>
    on
    <a href="https://github.com/aioue/pocket-nebula">aioue/pocket-nebula</a>
  </p>
  <div class="highlighter-rouge">
    <div class="highlight">
      <pre class="highlight"><code>Loading .devcontainer-shared/scripts/sync-common.sh…</code></pre>
    </div>
  </div>
</div>

<p>That comment is the design. The spec runs <code class="language-plaintext highlighter-rouge">initializeCommand</code> on the host before <code class="language-plaintext highlighter-rouge">docker build</code>, and after it has already parsed <code class="language-plaintext highlighter-rouge">devcontainer.json</code>. Shared json therefore cannot travel with the scripts. It travels as a <code class="language-plaintext highlighter-rouge">devcontainer.metadata</code> LABEL on the image, which is a different merge with a different property set.</p>

<h2 id="each-extra-piece">Each extra piece</h2>

<p><code class="language-plaintext highlighter-rouge">common/</code> (13 committed files). <code class="language-plaintext highlighter-rouge">postCreateCommand</code> is a path relative to the workspace, so <code class="language-plaintext highlighter-rouge">setup.sh</code> has to be in git. I cannot point at a file that only exists in the parent image, because the parent config is not a json file I extend. It is a LABEL, and the lifecycle entry it carries is <code class="language-plaintext highlighter-rouge">.devcontainer/common/setup.sh</code>. With <code class="language-plaintext highlighter-rouge">extends</code>, the parent json can name <code class="language-plaintext highlighter-rouge">/usr/local/lib/pocket-nebula/setup.sh</code> (a path in the image). The consumer tree does not need a copy.</p>

<p><code class="language-plaintext highlighter-rouge">sync-common.sh</code>. Those 13 files are deliberately not baked into every image rebuild, so a hook fix can land without republishing Ubuntu. The only hook early enough to fetch them is <code class="language-plaintext highlighter-rouge">initializeCommand</code>, which means a <code class="language-plaintext highlighter-rouge">git clone</code> on the laptop, with a fallback to the committed copy when offline. With <code class="language-plaintext highlighter-rouge">extends</code> of a published config, the tool fetches the parent while it is loading json. The clone, the offline fallback, and the “ask on a TTY / apply silently in Cursor” branch all go away.</p>

<p><code class="language-plaintext highlighter-rouge">common.ref</code>. A shell script is a package manager for those 13 files, with its own pin, distinct from <code class="language-plaintext highlighter-rouge">:v1</code>. <code class="language-plaintext highlighter-rouge">extends</code> is how the tool would resolve the parent. The clone-your-own-ref path goes away. The image tag can still exist for apt and <code class="language-plaintext highlighter-rouge">uv</code>; it would not need a parallel git ref fetched in bash.</p>

<p>The drift checker. Shared extensions and <code class="language-plaintext highlighter-rouge">containerEnv</code> keys live in the LABEL. If a consumer repeats one in local json, last-value-wins: the local copy is now the source of truth and will not see the next image change. The tool does not warn. I warn in a shell script, and the script is not allowed to fail the create (failing create was worse). With <code class="language-plaintext highlighter-rouge">extends</code>, inheriting a key does not mean copying it. A repeated key is an override you wrote, which is the Compose rule.</p>

<p>Restating <code class="language-plaintext highlighter-rouge">remoteUser: vscode</code>. Docker <code class="language-plaintext highlighter-rouge">LABEL</code> replaces a key. The child image’s <code class="language-plaintext highlighter-rouge">devcontainer.metadata</code> does not inherit the parent’s label, so omitting <code class="language-plaintext highlighter-rouge">remoteUser</code> drops it from <code class="language-plaintext highlighter-rouge">mcr.microsoft.com/devcontainers/base</code>. Lifecycle then runs as root, credentials land in <code class="language-plaintext highlighter-rouge">/root</code>, and <code class="language-plaintext highlighter-rouge">ONE_AUTH</code> points at a 0600 file <code class="language-plaintext highlighter-rouge">vscode</code> cannot read. Config <code class="language-plaintext highlighter-rouge">extends</code> is a json merge in the tool. It does not go through <code class="language-plaintext highlighter-rouge">LABEL</code>, so the parent image’s metadata is not discarded when the child sets a label.</p>

<p>PATH in that LABEL. <code class="language-plaintext highlighter-rouge">containerEnv</code> is <code class="language-plaintext highlighter-rouge">docker run -e</code>. Docker does not expand <code class="language-plaintext highlighter-rouge">${PATH}</code> there. A metadata value of <code class="language-plaintext highlighter-rouge">/usr/local/ansible-venv/bin:${PATH}</code> made <code class="language-plaintext highlighter-rouge">/usr/bin</code> disappear. The keep-alive loop is <code class="language-plaintext highlighter-rouge">while sleep 1000; do :; done</code>. The container exited on start. Inheritance had been stuffed into <code class="language-plaintext highlighter-rouge">containerEnv</code>, which is the wrong mechanism for PATH: Dockerfile <code class="language-plaintext highlighter-rouge">ENV</code> expands, <code class="language-plaintext highlighter-rouge">docker run -e</code> does not. CI now rejects it:</p>

<div class="github-embed" data-repo="aioue/pocket-nebula" data-ref="main" data-file=".devcontainer-shared/image/verify-metadata-label.py" data-start="21" data-end="28">
  <p class="github-embed-meta">
    <a href="https://github.com/aioue/pocket-nebula/blob/main/.devcontainer-shared/image/verify-metadata-label.py#L21-L28">.devcontainer-shared/image/verify-metadata-label.py (lines 21-28)</a>
    on
    <a href="https://github.com/aioue/pocket-nebula">aioue/pocket-nebula</a>
  </p>
  <div class="highlighter-rouge">
    <div class="highlight">
      <pre class="highlight"><code>Loading .devcontainer-shared/image/verify-metadata-label.py…</code></pre>
    </div>
  </div>
</div>

<div class="github-embed" data-repo="aioue/pocket-nebula" data-ref="main" data-file=".devcontainer-shared/image/Dockerfile" data-start="135" data-end="151">
  <p class="github-embed-meta">
    <a href="https://github.com/aioue/pocket-nebula/blob/main/.devcontainer-shared/image/Dockerfile#L135-L151">.devcontainer-shared/image/Dockerfile (lines 135-151)</a>
    on
    <a href="https://github.com/aioue/pocket-nebula">aioue/pocket-nebula</a>
  </p>
  <div class="highlighter-rouge">
    <div class="highlight">
      <pre class="highlight"><code>Loading .devcontainer-shared/image/Dockerfile…</code></pre>
    </div>
  </div>
</div>

<p>PATH belongs in the parent Dockerfile <code class="language-plaintext highlighter-rouge">ENV</code>, which the shell expands. It does not belong in json. The CI guard exists because the LABEL channel made json the only place to share environment with the consumer, and that channel is <code class="language-plaintext highlighter-rouge">docker run -e</code>.</p>

<p>None of this touches project secrets. XML-RPC URLs still belong in <code class="language-plaintext highlighter-rouge">site.env</code>. <code class="language-plaintext highlighter-rouge">user:password</code> still belongs in <code class="language-plaintext highlighter-rouge">~/.one/</code> on the host. Those are data, not inheritance.</p>

<h2 id="the-spec-gap">The spec gap</h2>

<p>spec#22 is a same-repo file. That slice removes the LABEL-as-parent inside one git tree.</p>

<p>Two Ansible repos are two git trees. The issue lists configuration outside the repository as future work. <a href="https://github.com/devcontainers/spec/issues/716">spec#716</a> is the versioned-package form of that. Image metadata is the stand-in that already shipped, and it cannot express <code class="language-plaintext highlighter-rouge">runArgs</code> or <code class="language-plaintext highlighter-rouge">features</code>, cannot change json after parse, and inherits <code class="language-plaintext highlighter-rouge">LABEL</code> replace.</p>

<p>Same-repo <code class="language-plaintext highlighter-rouge">extends</code> plus a parent that other repos can name is the whole pitch. The consumer json at the top is that combined primitive. Until it exists, the image label and the host clone are the two halves I have to keep in step by hand.</p>]]></content><author><name></name></author><category term="devcontainers" /><category term="docker" /><category term="opennebula" /><category term="ansible" /><summary type="html"><![CDATA[I keep two Ansible trees that talk to OpenNebula. They share a CLI gem, a PyONE pin, Cursor rules, and bind-mounts for ~/.one and ~/.ssh. Copying .devcontainer/ between them lasted until the first non-trivial fix landed in only one copy.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aioue.net/og-image.png" /><media:content medium="image" url="https://aioue.net/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Apache Guacamole in Docker with MariaDB and TOTP</title><link href="https://aioue.net/2026/08/27/apache-guacamole-in-docker-with-mariadb-and-totp/" rel="alternate" type="text/html" title="Apache Guacamole in Docker with MariaDB and TOTP" /><published>2026-08-27T12:00:00+00:00</published><updated>2026-08-27T12:00:00+00:00</updated><id>https://aioue.net/2026/08/27/apache-guacamole-in-docker-with-mariadb-and-totp</id><content type="html" xml:base="https://aioue.net/2026/08/27/apache-guacamole-in-docker-with-mariadb-and-totp/"><![CDATA[<p>Companion to <a href="/2026/01/21/gnome-remote-desktop-rdp-ubuntu-24.04/">headless Wayland RDP with GNOME Remote Desktop</a>. That post configures RDP targets; this one runs Apache Guacamole in Docker so you can reach them from a browser.</p>

<p>Ansible playbook and role: <a href="https://github.com/aioue/ansible-docker-guacamole-example">ansible-docker-guacamole-example</a>. The YAML below is fetched from that repo when the page loads.</p>

<h2 id="overview">Overview</h2>

<p>The example deploys Guacamole 1.6.0 (<code class="language-plaintext highlighter-rouge">guacamole/guacamole:1.6.0</code>), <code class="language-plaintext highlighter-rouge">guacd</code>, and MariaDB LTS. Ansible initialises the JDBC schema, creates a custom admin over the REST API, enables TOTP, and disables the stock <code class="language-plaintext highlighter-rouge">guacadmin</code> account. It does not create regular users or connections.</p>

<ul>
  <li>MariaDB backend with Guacamole’s MySQL JDBC driver and <code class="language-plaintext highlighter-rouge">initdb.sh --mysql</code></li>
  <li>Healthchecks on all three services, with <code class="language-plaintext highlighter-rouge">depends_on: condition: service_healthy</code></li>
  <li>TOTP on first deploy, with a short bootstrap bypass scoped to the compose network gateway</li>
  <li>Default bind <code class="language-plaintext highlighter-rouge">127.0.0.1:8080</code> (Guacamole itself is HTTP; terminate TLS at a reverse proxy)</li>
</ul>

<p>Needs Docker Engine with the Compose v2 plugin, Ansible 2.15+, and the <code class="language-plaintext highlighter-rouge">community.docker</code> collection.</p>

<h2 id="compose">Compose</h2>

<p>MariaDB speaks the MySQL protocol, so Guacamole still uses <code class="language-plaintext highlighter-rouge">MYSQL_*</code> environment variables and the upstream image generates schema SQL with <code class="language-plaintext highlighter-rouge">initdb.sh --mysql</code>. The MariaDB image healthcheck is <code class="language-plaintext highlighter-rouge">healthcheck.sh --connect --innodb_initialized</code>. <code class="language-plaintext highlighter-rouge">mysqladmin ping</code> is the MySQL-image equivalent and will not work here.</p>

<div class="github-embed" data-repo="aioue/ansible-docker-guacamole-example" data-ref="main" data-file="roles/docker_guacamole/templates/docker-compose.yml.j2">
  <p class="github-embed-meta">
    <a href="https://github.com/aioue/ansible-docker-guacamole-example/blob/main/roles/docker_guacamole/templates/docker-compose.yml.j2">roles/docker_guacamole/templates/docker-compose.yml.j2</a>
    on
    <a href="https://github.com/aioue/ansible-docker-guacamole-example">aioue/ansible-docker-guacamole-example</a>
  </p>
  <div class="highlighter-rouge">
    <div class="highlight">
      <pre class="highlight"><code>Loading roles/docker_guacamole/templates/docker-compose.yml.j2…</code></pre>
    </div>
  </div>
</div>

<p>Compared with the stock <a href="https://guacamole.apache.org/doc/gug/guacamole-docker.html">Guacamole Docker guide</a>:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">guacamole</code> waits on both <code class="language-plaintext highlighter-rouge">guacdb</code> and <code class="language-plaintext highlighter-rouge">guacd</code> with <code class="language-plaintext highlighter-rouge">condition: service_healthy</code></li>
  <li><code class="language-plaintext highlighter-rouge">guacd</code>: <code class="language-plaintext highlighter-rouge">nc -z 127.0.0.1 4822</code></li>
  <li><code class="language-plaintext highlighter-rouge">guacamole</code>: <code class="language-plaintext highlighter-rouge">curl --fail http://127.0.0.1:8080/guacamole</code> (the image’s own check; omitting it on a later <code class="language-plaintext highlighter-rouge">docker compose up</code> can replace a working healthcheck with nothing)</li>
  <li><code class="language-plaintext highlighter-rouge">json-file</code> logging with <code class="language-plaintext highlighter-rouge">max-size: 10m</code> and <code class="language-plaintext highlighter-rouge">max-file: 3</code> on every service</li>
  <li>MariaDB <code class="language-plaintext highlighter-rouge">--wait_timeout=86400 --interactive_timeout=86400</code> because RDP sessions through Guacamole can stay open all day (default is 28800 seconds)</li>
  <li><code class="language-plaintext highlighter-rouge">MYSQL_AUTO_RECONNECT=true</code> on the Guacamole container</li>
</ul>

<h2 id="bootstrap">Bootstrap</h2>

<p><code class="language-plaintext highlighter-rouge">bootstrap.yml</code> brings the database up first, loads the schema if needed, then starts the full stack. During bootstrap it sets <code class="language-plaintext highlighter-rouge">TOTP_BYPASS_HOSTS</code> to the Docker network gateway (the source address Tomcat sees for loopback API calls that arrived via docker-proxy), creates the custom admin, grants system permissions, and disables <code class="language-plaintext highlighter-rouge">guacadmin</code>. Add users and RDP connections in the Guacamole UI afterwards, or extend the playbook.</p>

<div class="github-embed" data-repo="aioue/ansible-docker-guacamole-example" data-ref="main" data-file="roles/docker_guacamole/tasks/bootstrap.yml">
  <p class="github-embed-meta">
    <a href="https://github.com/aioue/ansible-docker-guacamole-example/blob/main/roles/docker_guacamole/tasks/bootstrap.yml">roles/docker_guacamole/tasks/bootstrap.yml</a>
    on
    <a href="https://github.com/aioue/ansible-docker-guacamole-example">aioue/ansible-docker-guacamole-example</a>
  </p>
  <div class="highlighter-rouge">
    <div class="highlight">
      <pre class="highlight"><code>Loading roles/docker_guacamole/tasks/bootstrap.yml…</code></pre>
    </div>
  </div>
</div>

<p>On a fresh schema the default admin is <code class="language-plaintext highlighter-rouge">guacadmin</code> / <code class="language-plaintext highlighter-rouge">guacadmin</code>. The example replaces that with a custom admin (username <code class="language-plaintext highlighter-rouge">admin</code> in <code class="language-plaintext highlighter-rouge">group_vars/all.yml.example</code>).</p>

<h2 id="key-steps-explained">Key steps explained</h2>

<h3 id="1-schema-initialisation">1. Schema initialisation</h3>

<p>Ansible runs <code class="language-plaintext highlighter-rouge">docker run --rm guacamole/guacamole:1.6.0 /opt/guacamole/bin/initdb.sh --mysql</code> to generate <code class="language-plaintext highlighter-rouge">initdb.sql</code>, starts MariaDB alone, waits for it, then loads the script if the <code class="language-plaintext highlighter-rouge">guacamole_user</code> table is missing. Generating the SQL from the pinned image keeps the schema aligned with 1.6.0.</p>

<h3 id="2-healthchecks-and-startup-order">2. Healthchecks and startup order</h3>

<p>Without healthchecks, Compose only waits for the container process to start, not for MariaDB or Tomcat to accept connections. The three checks above let <code class="language-plaintext highlighter-rouge">guacamole</code> wait until the database and <code class="language-plaintext highlighter-rouge">guacd</code> are actually ready.</p>

<h3 id="3-long-lived-rdp-sessions-and-the-database">3. Long-lived RDP sessions and the database</h3>

<p>Guacamole holds JDBC connections open while users stay connected. MariaDB’s default <code class="language-plaintext highlighter-rouge">wait_timeout</code> of 28800 seconds (8 hours) can drop idle connections mid-session. Raising both <code class="language-plaintext highlighter-rouge">wait_timeout</code> and <code class="language-plaintext highlighter-rouge">interactive_timeout</code> to 86400 (24 hours) avoids that. <code class="language-plaintext highlighter-rouge">MYSQL_AUTO_RECONNECT=true</code> covers the case where a connection still goes stale.</p>

<h3 id="4-totp-bootstrap-and-guacamole-2140">4. TOTP bootstrap and GUACAMOLE-2140</h3>

<p>TOTP is enabled from the first full stack deploy (<code class="language-plaintext highlighter-rouge">TOTP_ENABLED=true</code>). Guacamole 1.6.0 will not persist TOTP-related user attributes over the REST API while TOTP is enforced for the caller (<a href="https://issues.apache.org/jira/browse/GUACAMOLE-2140">GUACAMOLE-2140</a>). Bootstrap works around that by temporarily setting <code class="language-plaintext highlighter-rouge">TOTP_BYPASS_HOSTS</code> to the compose network gateway only, so automation can call the API from the host while off-box logins still require TOTP. After the custom admin exists and <code class="language-plaintext highlighter-rouge">guacadmin</code> is disabled, Ansible clears the bypass and redeploys.</p>

<p>The first browser login as the custom admin prompts TOTP enrollment (QR code). See the <a href="https://guacamole.apache.org/doc/gug/totp-auth.html">TOTP auth guide</a>.</p>

<h3 id="5-custom-admin-via-rest-api">5. Custom admin via REST API</h3>

<p>Bootstrap authenticates as <code class="language-plaintext highlighter-rouge">guacadmin</code>, creates the custom admin if missing, and grants system permissions: <code class="language-plaintext highlighter-rouge">ADMINISTER</code>, <code class="language-plaintext highlighter-rouge">CREATE_USER</code>, <code class="language-plaintext highlighter-rouge">CREATE_USER_GROUP</code>, <code class="language-plaintext highlighter-rouge">CREATE_CONNECTION</code>, <code class="language-plaintext highlighter-rouge">CREATE_CONNECTION_GROUP</code>, <code class="language-plaintext highlighter-rouge">CREATE_SHARING_PROFILE</code>. It then disables <code class="language-plaintext highlighter-rouge">guacadmin</code> with a PUT (<code class="language-plaintext highlighter-rouge">disabled: true</code>). No connections or non-admin users are provisioned.</p>

<h2 id="run">Run</h2>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://github.com/aioue/ansible-docker-guacamole-example.git
<span class="nb">cd </span>ansible-docker-guacamole-example
<span class="nb">cp </span>group_vars/all.yml.example group_vars/all.yml
<span class="c"># Edit group_vars/all.yml: set passwords and guacamole_admin_username</span>
ansible-galaxy collection <span class="nb">install</span> <span class="nt">-r</span> requirements.yml
ansible-playbook playbook.yml
</code></pre></div></div>

<p>The inventory defaults to <code class="language-plaintext highlighter-rouge">localhost</code> with <code class="language-plaintext highlighter-rouge">ansible_connection: local</code>. Point <code class="language-plaintext highlighter-rouge">ansible_host</code> at another machine if Docker runs elsewhere.</p>

<p>By default Guacamole publishes on <code class="language-plaintext highlighter-rouge">127.0.0.1:8080</code>. Set <code class="language-plaintext highlighter-rouge">guacamole_bind_address</code> in <code class="language-plaintext highlighter-rouge">group_vars/all.yml</code> when a reverse proxy on another host needs to reach the container. Terminate TLS at the proxy.</p>

<h2 id="verifying-the-setup">Verifying the setup</h2>

<p>Check the login page responds:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>curl <span class="nt">-sS</span> <span class="nt">-o</span> /dev/null <span class="nt">-w</span> <span class="s1">'%{http_code}\n'</span> http://127.0.0.1:8080/guacamole/
</code></pre></div></div>

<p>Expect <code class="language-plaintext highlighter-rouge">200</code>. Confirm all services are healthy:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker compose <span class="nt">--project-directory</span> ~/docker/guacamole ps
</code></pre></div></div>

<p>(<code class="language-plaintext highlighter-rouge">guacamole_dir</code> defaults to <code class="language-plaintext highlighter-rouge">~/docker/guacamole</code> on the target host.)</p>

<p>Open <code class="language-plaintext highlighter-rouge">http://127.0.0.1:8080/guacamole/</code> in a browser, sign in as the custom admin (default <code class="language-plaintext highlighter-rouge">admin</code>), and complete TOTP enrollment. A login attempt as <code class="language-plaintext highlighter-rouge">guacadmin</code> should fail because that account is disabled.</p>

<p>Add an RDP connection in the Guacamole UI to a target configured per the <a href="/2026/01/21/gnome-remote-desktop-rdp-ubuntu-24.04/">companion RDP post</a>.</p>

<h2 id="references">References</h2>

<ul>
  <li><a href="https://github.com/aioue/ansible-docker-guacamole-example">ansible-docker-guacamole-example</a></li>
  <li><a href="https://guacamole.apache.org/doc/gug/guacamole-docker.html">Guacamole Docker installation guide</a></li>
  <li><a href="https://guacamole.apache.org/doc/gug/totp-auth.html">Guacamole TOTP authentication</a></li>
  <li><a href="https://guacamole.apache.org/doc/1.6.0/gug/mysql-auth.html">Guacamole 1.6.0 MySQL/MariaDB auth</a></li>
  <li><a href="https://issues.apache.org/jira/browse/GUACAMOLE-2140">GUACAMOLE-2140</a></li>
  <li><a href="/2026/01/21/gnome-remote-desktop-rdp-ubuntu-24.04/">Headless Wayland RDP with GNOME Remote Desktop on Ubuntu 24.04</a></li>
</ul>]]></content><author><name></name></author><category term="guacamole" /><category term="ansible" /><category term="docker" /><category term="mariadb" /><category term="totp" /><summary type="html"><![CDATA[Companion to headless Wayland RDP with GNOME Remote Desktop. That post configures RDP targets; this one runs Apache Guacamole in Docker so you can reach them from a browser.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aioue.net/og-image.png" /><media:content medium="image" url="https://aioue.net/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Bulk edit Ansible vault files with pilfer</title><link href="https://aioue.net/2026/08/07/pilfer-bulk-ansible-vault-edit/" rel="alternate" type="text/html" title="Bulk edit Ansible vault files with pilfer" /><published>2026-08-07T17:00:00+00:00</published><updated>2026-08-09T00:00:00+00:00</updated><id>https://aioue.net/2026/08/07/pilfer-bulk-ansible-vault-edit</id><content type="html" xml:base="https://aioue.net/2026/08/07/pilfer-bulk-ansible-vault-edit/"><![CDATA[<p>If you run Ansible at any scale, you eventually want to search across vaulted files or edit several secrets in one sitting. <code class="language-plaintext highlighter-rouge">ansible-vault edit</code> is one file at a time. Grep is useless on ciphertext. Decrypting by hand makes it easy to leave a file open.</p>

<p><a href="https://github.com/aioue/pilfer">pilfer</a> is the CLI I wanted for that: <code class="language-plaintext highlighter-rouge">pilfer open</code> decrypts every vault file in the tree (and optionally inline <code class="language-plaintext highlighter-rouge">!vault</code> values), you edit or search in plaintext, then <code class="language-plaintext highlighter-rouge">pilfer close</code> re-encrypts only what changed. Unchanged files keep their original ciphertext byte-for-byte.</p>

<p>It uses Ansible’s own vault implementation (no custom crypto).</p>

<h2 id="install">Install</h2>

<p>Requires <strong>Python 3.10+</strong> and <strong>Ansible</strong> on your PATH.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pipx <span class="nb">install </span>pilfer
pilfer <span class="nt">--help</span>
</code></pre></div></div>

<p>Or from source:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://github.com/aioue/pilfer.git
<span class="nb">cd </span>pilfer
pip <span class="nb">install</span> <span class="nt">-e</span> <span class="nb">.</span>
</code></pre></div></div>

<h2 id="basic-workflow">Basic workflow</h2>

<p>From your Ansible project root:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pilfer open
rg <span class="s1">'old-token'</span> roles/ inventory/
<span class="c"># edit secrets.yml, group_vars, whatever you opened</span>
pilfer close
</code></pre></div></div>

<p>pilfer reads <code class="language-plaintext highlighter-rouge">vault_password_file</code> from <code class="language-plaintext highlighter-rouge">ansible.cfg</code> if you have one:</p>

<div class="language-ini highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nn">[defaults]</span>
<span class="py">vault_password_file</span> <span class="p">=</span> <span class="s">~/.ansible-vault/.vault-file</span>
</code></pre></div></div>

<p>Otherwise pass <code class="language-plaintext highlighter-rouge">-p /path/to/password-file</code>. It also checks a few common locations (<code class="language-plaintext highlighter-rouge">~/.ansible-vault/.vault-file</code>, <code class="language-plaintext highlighter-rouge">.vault_password</code>, and similar).</p>

<p>While a session is open, pilfer writes session metadata locally:</p>

<pre><code class="language-gitignore">vaultedFileList.json
.vault/
**/*.pilfer-open
</code></pre>

<p>Add those to <code class="language-plaintext highlighter-rouge">.gitignore</code>. Do not commit while a session is open.</p>

<h2 id="inline-encrypt_string-values">Inline <code class="language-plaintext highlighter-rouge">encrypt_string</code> values</h2>

<p>Whole-file vaults are opened by default. Inline <code class="language-plaintext highlighter-rouge">!vault</code> scalars are opt-in:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pilfer open <span class="nt">--include-encrypted-vars</span>
</code></pre></div></div>

<p>pilfer rewrites each opened value with a marker comment:</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">db_password</span><span class="pi">:</span> <span class="s2">"</span><span class="s">the-secret"</span>  <span class="c1"># pilfer:vault:0</span>
</code></pre></div></div>

<p>Leave the marker in place until you run <code class="language-plaintext highlighter-rouge">pilfer close</code>. <code class="language-plaintext highlighter-rouge">close</code> does not need the flag - it re-encrypts whatever the session opened.</p>

<h2 id="re-keying-not-the-same-as-close">Re-keying (not the same as close)</h2>

<p><code class="language-plaintext highlighter-rouge">pilfer close</code> is <strong>not</strong> password rotation. It refuses a different password than the one used for <code class="language-plaintext highlighter-rouge">open</code>.</p>

<p>To rotate the vault password across a tree:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pilfer rekey <span class="se">\</span>
  <span class="nt">--old-vault-password-file</span> ~/.ansible-vault/.vault-file <span class="se">\</span>
  <span class="nt">--new-vault-password-file</span> /tmp/new-vault-pass <span class="se">\</span>
  <span class="nt">--dry-run</span>
</code></pre></div></div>

<p>Drop <code class="language-plaintext highlighter-rouge">--dry-run</code> when the plan looks right. It prompts before mutating files.</p>

<h2 id="fail-closed">Fail closed</h2>

<p>pilfer prefers leaving secrets visible over silently corrupting them:</p>

<ul>
  <li>refuses a second <code class="language-plaintext highlighter-rouge">open</code> while a session exists</li>
  <li>refuses <code class="language-plaintext highlighter-rouge">close</code> with the wrong password (no accidental re-key)</li>
  <li>keeps <code class="language-plaintext highlighter-rouge">.vault/</code> backups if <code class="language-plaintext highlighter-rouge">close</code> fails partway; fix the issue and run <code class="language-plaintext highlighter-rouge">close</code> again</li>
  <li>refuses ambiguous edits (for example stripping a <code class="language-plaintext highlighter-rouge"># pilfer:vault:N</code> marker but leaving plaintext)</li>
</ul>

<p>That is fussy when you are in a hurry, on purpose.</p>

<h2 id="when-i-use-it">When I use it</h2>

<p>Ansible repos with vault files under <code class="language-plaintext highlighter-rouge">inventory/</code>, <code class="language-plaintext highlighter-rouge">group_vars/</code>, and role <code class="language-plaintext highlighter-rouge">vars/</code>:</p>

<ul>
  <li>bulk find/replace after a token rotation</li>
  <li>editing several role secrets in one pass</li>
  <li>checking what is still referenced before deleting a key</li>
</ul>

<p>For a single vault file, <code class="language-plaintext highlighter-rouge">ansible-vault edit</code> is enough. For decrypt-the-whole-tree editing, use pilfer.</p>

<p>Source: <a href="https://github.com/aioue/pilfer">aioue/pilfer</a> · PyPI: <a href="https://pypi.org/project/pilfer/">pilfer</a></p>]]></content><author><name></name></author><category term="ansible" /><category term="vault" /><category term="secrets" /><category term="python" /><category term="cli" /><summary type="html"><![CDATA[If you run Ansible at any scale, you eventually want to search across vaulted files or edit several secrets in one sitting. ansible-vault edit is one file at a time. Grep is useless on ciphertext. Decrypting by hand makes it easy to leave a file open.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aioue.net/og-image.png" /><media:content medium="image" url="https://aioue.net/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">AtomS3 Lite + ENV IV: ESPHome BLE proxy and room sensors in one box</title><link href="https://aioue.net/2026/08/01/atoms3-lite-esphome-ble-proxy-env-iv/" rel="alternate" type="text/html" title="AtomS3 Lite + ENV IV: ESPHome BLE proxy and room sensors in one box" /><published>2026-08-01T11:00:00+00:00</published><updated>2026-08-09T00:00:00+00:00</updated><id>https://aioue.net/2026/08/01/atoms3-lite-esphome-ble-proxy-env-iv</id><content type="html" xml:base="https://aioue.net/2026/08/01/atoms3-lite-esphome-ble-proxy-env-iv/"><![CDATA[<p>I wanted a Bluetooth proxy near two <a href="https://www.vent-axia.com/">Vent-Axia Svara</a> extractors (<a href="https://github.com/eriknn/ha-pax_ble">Pax</a> BLE fans), plus temperature, humidity, and pressure in the same spot. An M5Stack AtomS3 Lite (~£9, ESP32-S3) and Unit ENV IV (~£6; <a href="https://shop.m5stack.com/products/env-iv-unit-with-temperature-humidity-air-pressure-sensor-sht40-bmp280">EOL from M5Stack</a>, still sold by resellers) cover both in one ESPHome firmware for about £15. ENV IV is <code class="language-plaintext highlighter-rouge">SHT40</code> + <code class="language-plaintext highlighter-rouge">BMP280</code> on Grove I2C.</p>

<p>Hardware, HA sensors, RAM budget, and sanitized YAML below.</p>

<p style="text-align:center"><img src="/ext/m5stack/atoms3-lite-env-iv-scale.jpg" alt="M5Stack AtomS3 Lite and Unit ENV IV sensor with a two-pence coin for scale" width="640" style="max-width:100%;height:auto;" /></p>

<h2 id="the-two-parts-one-firmware">The two parts (one firmware)</h2>

<h3 id="m5stack-atoms3-lite-9">M5Stack AtomS3 Lite (~£9)</h3>

<p>Tiny ESP32-S3 board with Wi-Fi, Bluetooth 5 LE, a button, and four RGB LEDs under the cap.</p>

<p>From <code class="language-plaintext highlighter-rouge">esptool</code> when the board is connected over USB:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Chip type:          ESP32-S3 (QFN56) (revision v0.2)
Features:           Wi-Fi, BT 5 (LE), Dual Core + LP Core, 240MHz, Embedded Flash 8MB (GD)
Crystal frequency:  40MHz
</code></pre></div></div>

<p>In practice that means: enough flash for ESP-IDF + BLE proxy + sensors, dual-core headroom for Wi-Fi/BLE coexistence, and native USB-CDC for first flash (no separate USB-UART chip).</p>

<h3 id="m5stack-unit-env-iv-6">M5Stack Unit ENV IV (~£6)</h3>

<p>Grove/STEMMA QT breakout:</p>

<ul>
  <li>Sensirion <code class="language-plaintext highlighter-rouge">SHT40</code>: temperature and relative humidity (I2C <code class="language-plaintext highlighter-rouge">0x44</code>)</li>
  <li>Bosch <code class="language-plaintext highlighter-rouge">BMP280</code>: barometric pressure (I2C <code class="language-plaintext highlighter-rouge">0x76</code>)</li>
</ul>

<p>On the AtomS3 Lite the Grove port is <code class="language-plaintext highlighter-rouge">SDA = GPIO2</code>, <code class="language-plaintext highlighter-rouge">SCL = GPIO1</code>. A short Grove cable is enough; if I2C scan finds nothing, swap the yellow/white data lines (AtomS3 Grove pin order is not always the cable default).</p>

<h2 id="what-it-does-in-home-assistant">What it does in Home Assistant</h2>

<p>Main job: ESPHome Bluetooth proxy so Home Assistant can reach Pax fans that only speak BLE GATT. I use Erik Nordby’s <a href="https://github.com/eriknn/ha-pax_ble">ha-pax_ble</a>; it is maintained and fits Vent-Axia Svara when there is no official HA integration.</p>

<p>Secondary job: publish room environment every five minutes (slow interval keeps the chip cooler and keeps I2C out of BLE’s way).</p>

<p>After OTA to firmware <code class="language-plaintext highlighter-rouge">1.1.1</code> (ESPHome <code class="language-plaintext highlighter-rouge">2026.7.3</code>), a typical live snapshot:</p>

<table>
  <thead>
    <tr>
      <th>Check</th>
      <th>Status</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>ESPHome integration</td>
      <td>Loaded (<code class="language-plaintext highlighter-rouge">AtomS3 Lite Temp 5e5b70</code>)</td>
    </tr>
    <tr>
      <td>Firmware</td>
      <td><code class="language-plaintext highlighter-rouge">1.1.1</code> (ESPHome <code class="language-plaintext highlighter-rouge">2026.7.3</code>)</td>
    </tr>
    <tr>
      <td>Connectivity (Status)</td>
      <td>On</td>
    </tr>
    <tr>
      <td>Uptime</td>
      <td>~5 min (post-OTA)</td>
    </tr>
    <tr>
      <td>Wi-Fi signal</td>
      <td><code class="language-plaintext highlighter-rouge">-53 dBm</code> (IoT VLAN)</td>
    </tr>
    <tr>
      <td>Temperature</td>
      <td><code class="language-plaintext highlighter-rouge">25.0 °C</code></td>
    </tr>
    <tr>
      <td>Humidity</td>
      <td><code class="language-plaintext highlighter-rouge">47.7 %</code></td>
    </tr>
    <tr>
      <td>Pressure</td>
      <td><code class="language-plaintext highlighter-rouge">1017 hPa</code></td>
    </tr>
    <tr>
      <td>Absolute humidity</td>
      <td><code class="language-plaintext highlighter-rouge">11.0 g/m³</code></td>
    </tr>
    <tr>
      <td>Dew point</td>
      <td><code class="language-plaintext highlighter-rouge">13.2 °C</code></td>
    </tr>
    <tr>
      <td>Altitude (barometric)</td>
      <td><code class="language-plaintext highlighter-rouge">~-32 m</code> vs ISA <code class="language-plaintext highlighter-rouge">1013.25 hPa</code></td>
    </tr>
    <tr>
      <td>LED</td>
      <td>Blue when Wi-Fi up; green/red 10 s flash after each env publish</td>
    </tr>
  </tbody>
</table>

<h3 id="pax-fans-via-the-proxy"><a href="https://github.com/eriknn/ha-pax_ble">Pax</a> fans via the proxy</h3>

<p>With the Atom on the IoT VLAN and the proxy active, both Svara units stay reachable:</p>

<table>
  <thead>
    <tr>
      <th>Fan</th>
      <th>State</th>
      <th>RPM</th>
      <th>Temperature</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">top_bathroom_extractor</code></td>
      <td>Trickle ventilation</td>
      <td>1000</td>
      <td>25.4 °C</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">tom_bedroom_ensuite_extractor</code></td>
      <td>Trickle ventilation</td>
      <td>1641</td>
      <td>22.9 °C</td>
    </tr>
  </tbody>
</table>

<p>Home Assistant sees full Pax entities (flow, humidity sensor on the unit, boost mode, silent hours, etc.) through <a href="https://github.com/eriknn/ha-pax_ble">ha-pax_ble</a>. The Atom only forwards BLE; the integration on the HA host runs the Pax logic.</p>

<h2 id="ram-and-flash-budget">RAM and flash budget</h2>

<p>Compiled with ESPHome <code class="language-plaintext highlighter-rouge">2026.7.3</code>, ESP-IDF <code class="language-plaintext highlighter-rouge">5.5.5</code>, project version <code class="language-plaintext highlighter-rouge">1.1.1</code>:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>RAM:   [====      ]  42.6% (used 145515 bytes from 341760 bytes)
Flash: [========  ]  75.1% (used 1377767 bytes from 1835008 bytes)
</code></pre></div></div>

<p>That leaves headroom for three BLE <code class="language-plaintext highlighter-rouge">connection_slots</code> (Pax may hold active GATT sessions), Wi-Fi, captive portal fallback, and the LED/env scripts. I stayed at <code class="language-plaintext highlighter-rouge">connection_slots: 3</code>: each costs roughly 1 KB RAM, and Wi-Fi proxies rarely need more unless you saturate connections.</p>

<h2 id="led-feedback-v111">LED feedback (<code class="language-plaintext highlighter-rouge">v1.1.1</code>)</h2>

<p>The four WS2812 LEDs under the button are status-only:</p>

<ul>
  <li>Blue: Wi-Fi connected to HA</li>
  <li>Red pulse: fallback AP / Wi-Fi down</li>
  <li>Green for 10 s: env reading published and HA API reachable</li>
  <li>Solid red for 10 s: reading OK but Wi-Fi or API unreachable</li>
  <li>Short press toggles the LED; long press (~1 s) reboots</li>
</ul>

<p>Useful when the puck sits on a USB charger away from the desk.</p>

<h2 id="sanitized-esphome-config">Sanitized ESPHome config</h2>

<p>Secrets (<code class="language-plaintext highlighter-rouge">wifi_ssid</code>, <code class="language-plaintext highlighter-rouge">wifi_password</code>, <code class="language-plaintext highlighter-rouge">api_encryption_key</code>, <code class="language-plaintext highlighter-rouge">wifi_ap_password</code>) live in <code class="language-plaintext highlighter-rouge">secrets.yaml</code> on the HA host, not in git. Example placeholders:</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">wifi_ssid</span><span class="pi">:</span> <span class="s2">"</span><span class="s">your-ssid"</span>
<span class="na">wifi_password</span><span class="pi">:</span> <span class="s2">"</span><span class="s">your-wifi-password"</span>
<span class="na">api_encryption_key</span><span class="pi">:</span> <span class="s2">"</span><span class="s">generate-with-esphome</span><span class="nv"> </span><span class="s">secrets</span><span class="nv"> </span><span class="s">create"</span>
<span class="na">wifi_ap_password</span><span class="pi">:</span> <span class="s2">"</span><span class="s">fallback-ap-password"</span>
</code></pre></div></div>

<p>Full public YAML (no credentials):</p>

<details>
  <summary><code>atoms3-lite-temp.yaml</code> (click to expand)</summary>

  <div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># Public/sanitized ESPHome config for AtomS3 Lite + Unit ENV IV (SHT40 + BMP280).</span>
<span class="c1"># Secrets: copy secrets.yaml.example -&gt; secrets.yaml and fill in locally.</span>
<span class="c1"># BLE proxy baseline: https://github.com/esphome/bluetooth-proxies/tree/main/m5stack</span>

<span class="na">substitutions</span><span class="pi">:</span>
  <span class="na">name</span><span class="pi">:</span> <span class="s">atoms3-lite-temp</span>
  <span class="na">friendly_name</span><span class="pi">:</span> <span class="s">AtomS3 Lite Temp</span>
  <span class="na">sea_level_pressure_hpa</span><span class="pi">:</span> <span class="s2">"</span><span class="s">1013.25"</span>
  <span class="na">wifi_ap_ssid</span><span class="pi">:</span> <span class="s2">"</span><span class="s">AtomS3-Lite-Fallback"</span>

<span class="na">esphome</span><span class="pi">:</span>
  <span class="na">name</span><span class="pi">:</span> <span class="s">${name}</span>
  <span class="na">friendly_name</span><span class="pi">:</span> <span class="s">${friendly_name}</span>
  <span class="na">min_version</span><span class="pi">:</span> <span class="s">2025.8.0</span>
  <span class="na">name_add_mac_suffix</span><span class="pi">:</span> <span class="no">true</span>
  <span class="na">project</span><span class="pi">:</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s">homelab.atoms3-ble-proxy</span>
    <span class="na">version</span><span class="pi">:</span> <span class="s2">"</span><span class="s">1.1.1"</span>

<span class="na">esp32</span><span class="pi">:</span>
  <span class="na">variant</span><span class="pi">:</span> <span class="s">esp32s3</span>
  <span class="na">framework</span><span class="pi">:</span>
    <span class="na">type</span><span class="pi">:</span> <span class="s">esp-idf</span>

<span class="na">logger</span><span class="pi">:</span>
  <span class="na">baud_rate</span><span class="pi">:</span> <span class="m">0</span>
  <span class="na">level</span><span class="pi">:</span> <span class="s">INFO</span>

<span class="na">api</span><span class="pi">:</span>
  <span class="na">encryption</span><span class="pi">:</span>
    <span class="na">key</span><span class="pi">:</span> <span class="kt">!secret</span> <span class="s">api_encryption_key</span>

<span class="na">ota</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">platform</span><span class="pi">:</span> <span class="s">esphome</span>
    <span class="na">id</span><span class="pi">:</span> <span class="s">ota_esphome</span>

<span class="na">wifi</span><span class="pi">:</span>
  <span class="na">ssid</span><span class="pi">:</span> <span class="kt">!secret</span> <span class="s">wifi_ssid</span>
  <span class="na">password</span><span class="pi">:</span> <span class="kt">!secret</span> <span class="s">wifi_password</span>
  <span class="na">ap</span><span class="pi">:</span>
    <span class="na">ssid</span><span class="pi">:</span> <span class="s">${wifi_ap_ssid}</span>
    <span class="na">password</span><span class="pi">:</span> <span class="kt">!secret</span> <span class="s">wifi_ap_password</span>
  <span class="na">on_connect</span><span class="pi">:</span>
    <span class="pi">-</span> <span class="na">script.execute</span><span class="pi">:</span> <span class="s">led_wifi_connected</span>
  <span class="na">on_disconnect</span><span class="pi">:</span>
    <span class="pi">-</span> <span class="na">script.execute</span><span class="pi">:</span> <span class="s">led_wifi_ap</span>

<span class="na">captive_portal</span><span class="pi">:</span>

<span class="na">esp32_ble_tracker</span><span class="pi">:</span>

<span class="na">bluetooth_proxy</span><span class="pi">:</span>
  <span class="na">active</span><span class="pi">:</span> <span class="no">true</span>
  <span class="na">cache_services</span><span class="pi">:</span> <span class="no">true</span>
  <span class="na">connection_slots</span><span class="pi">:</span> <span class="m">3</span>

<span class="na">i2c</span><span class="pi">:</span>
  <span class="na">sda</span><span class="pi">:</span> <span class="s">GPIO2</span>
  <span class="na">scl</span><span class="pi">:</span> <span class="s">GPIO1</span>
  <span class="na">scan</span><span class="pi">:</span> <span class="no">true</span>
  <span class="na">id</span><span class="pi">:</span> <span class="s">bus_grove</span>

<span class="na">light</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">platform</span><span class="pi">:</span> <span class="s">esp32_rmt_led_strip</span>
    <span class="na">rgb_order</span><span class="pi">:</span> <span class="s">GRB</span>
    <span class="na">pin</span><span class="pi">:</span> <span class="s">GPIO35</span>
    <span class="na">num_leds</span><span class="pi">:</span> <span class="m">4</span>
    <span class="na">chipset</span><span class="pi">:</span> <span class="s">ws2812</span>
    <span class="na">id</span><span class="pi">:</span> <span class="s">atom_led</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">${friendly_name}</span><span class="nv"> </span><span class="s">LED"</span>
    <span class="na">restore_mode</span><span class="pi">:</span> <span class="s">RESTORE_DEFAULT_OFF</span>
    <span class="na">effects</span><span class="pi">:</span>
      <span class="pi">-</span> <span class="na">pulse</span><span class="pi">:</span>
          <span class="na">name</span><span class="pi">:</span> <span class="s">Pulse</span>
          <span class="na">transition_length</span><span class="pi">:</span> <span class="s">1s</span>

<span class="na">script</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">id</span><span class="pi">:</span> <span class="s">led_wifi_connected</span>
    <span class="na">then</span><span class="pi">:</span>
      <span class="pi">-</span> <span class="na">light.turn_on</span><span class="pi">:</span>
          <span class="na">id</span><span class="pi">:</span> <span class="s">atom_led</span>
          <span class="na">brightness</span><span class="pi">:</span> <span class="s">30%</span>
          <span class="na">red</span><span class="pi">:</span> <span class="s">0%</span>
          <span class="na">green</span><span class="pi">:</span> <span class="s">0%</span>
          <span class="na">blue</span><span class="pi">:</span> <span class="s">100%</span>
  <span class="pi">-</span> <span class="na">id</span><span class="pi">:</span> <span class="s">led_wifi_ap</span>
    <span class="na">then</span><span class="pi">:</span>
      <span class="pi">-</span> <span class="na">light.turn_on</span><span class="pi">:</span>
          <span class="na">id</span><span class="pi">:</span> <span class="s">atom_led</span>
          <span class="na">brightness</span><span class="pi">:</span> <span class="s">30%</span>
          <span class="na">red</span><span class="pi">:</span> <span class="s">100%</span>
          <span class="na">green</span><span class="pi">:</span> <span class="s">40%</span>
          <span class="na">blue</span><span class="pi">:</span> <span class="s">0%</span>
          <span class="na">effect</span><span class="pi">:</span> <span class="s">Pulse</span>
  <span class="pi">-</span> <span class="na">id</span><span class="pi">:</span> <span class="s">led_update_sent</span>
    <span class="na">mode</span><span class="pi">:</span> <span class="s">restart</span>
    <span class="na">then</span><span class="pi">:</span>
      <span class="pi">-</span> <span class="na">light.turn_on</span><span class="pi">:</span>
          <span class="na">id</span><span class="pi">:</span> <span class="s">atom_led</span>
          <span class="na">brightness</span><span class="pi">:</span> <span class="s">30%</span>
          <span class="na">red</span><span class="pi">:</span> <span class="s">0%</span>
          <span class="na">green</span><span class="pi">:</span> <span class="s">100%</span>
          <span class="na">blue</span><span class="pi">:</span> <span class="s">0%</span>
      <span class="pi">-</span> <span class="na">delay</span><span class="pi">:</span> <span class="s">10s</span>
      <span class="pi">-</span> <span class="na">if</span><span class="pi">:</span>
          <span class="na">condition</span><span class="pi">:</span>
            <span class="na">wifi.connected</span><span class="pi">:</span>
          <span class="na">then</span><span class="pi">:</span>
            <span class="pi">-</span> <span class="na">script.execute</span><span class="pi">:</span> <span class="s">led_wifi_connected</span>
          <span class="na">else</span><span class="pi">:</span>
            <span class="pi">-</span> <span class="na">script.execute</span><span class="pi">:</span> <span class="s">led_wifi_ap</span>
  <span class="pi">-</span> <span class="na">id</span><span class="pi">:</span> <span class="s">led_update_failed</span>
    <span class="na">mode</span><span class="pi">:</span> <span class="s">restart</span>
    <span class="na">then</span><span class="pi">:</span>
      <span class="pi">-</span> <span class="na">light.turn_on</span><span class="pi">:</span>
          <span class="na">id</span><span class="pi">:</span> <span class="s">atom_led</span>
          <span class="na">brightness</span><span class="pi">:</span> <span class="s">30%</span>
          <span class="na">red</span><span class="pi">:</span> <span class="s">100%</span>
          <span class="na">green</span><span class="pi">:</span> <span class="s">0%</span>
          <span class="na">blue</span><span class="pi">:</span> <span class="s">0%</span>
      <span class="pi">-</span> <span class="na">delay</span><span class="pi">:</span> <span class="s">10s</span>
      <span class="pi">-</span> <span class="na">if</span><span class="pi">:</span>
          <span class="na">condition</span><span class="pi">:</span>
            <span class="na">wifi.connected</span><span class="pi">:</span>
          <span class="na">then</span><span class="pi">:</span>
            <span class="pi">-</span> <span class="na">script.execute</span><span class="pi">:</span> <span class="s">led_wifi_connected</span>
          <span class="na">else</span><span class="pi">:</span>
            <span class="pi">-</span> <span class="na">script.execute</span><span class="pi">:</span> <span class="s">led_wifi_ap</span>

<span class="na">sensor</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">platform</span><span class="pi">:</span> <span class="s">sht4x</span>
    <span class="na">i2c_id</span><span class="pi">:</span> <span class="s">bus_grove</span>
    <span class="na">address</span><span class="pi">:</span> <span class="s">0x44</span>
    <span class="na">update_interval</span><span class="pi">:</span> <span class="s">300s</span>
    <span class="na">precision</span><span class="pi">:</span> <span class="s">High</span>
    <span class="na">heater_max_duty</span><span class="pi">:</span> <span class="m">0.0</span>
    <span class="na">temperature</span><span class="pi">:</span>
      <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">${friendly_name}</span><span class="nv"> </span><span class="s">Temperature"</span>
      <span class="na">id</span><span class="pi">:</span> <span class="s">sht40_temperature</span>
    <span class="na">humidity</span><span class="pi">:</span>
      <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">${friendly_name}</span><span class="nv"> </span><span class="s">Humidity"</span>
      <span class="na">id</span><span class="pi">:</span> <span class="s">sht40_humidity</span>

  <span class="pi">-</span> <span class="na">platform</span><span class="pi">:</span> <span class="s">bmp280_i2c</span>
    <span class="na">i2c_id</span><span class="pi">:</span> <span class="s">bus_grove</span>
    <span class="na">address</span><span class="pi">:</span> <span class="s">0x76</span>
    <span class="na">update_interval</span><span class="pi">:</span> <span class="s">300s</span>
    <span class="na">iir_filter</span><span class="pi">:</span> <span class="s">4x</span>
    <span class="na">temperature</span><span class="pi">:</span>
      <span class="na">id</span><span class="pi">:</span> <span class="s">bmp280_temperature</span>
      <span class="na">internal</span><span class="pi">:</span> <span class="no">true</span>
    <span class="na">pressure</span><span class="pi">:</span>
      <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">${friendly_name}</span><span class="nv"> </span><span class="s">Pressure"</span>
      <span class="na">id</span><span class="pi">:</span> <span class="s">bmp280_pressure</span>
      <span class="na">on_value</span><span class="pi">:</span>
        <span class="na">then</span><span class="pi">:</span>
          <span class="pi">-</span> <span class="na">if</span><span class="pi">:</span>
              <span class="na">condition</span><span class="pi">:</span>
                <span class="na">and</span><span class="pi">:</span>
                  <span class="pi">-</span> <span class="na">wifi.connected</span><span class="pi">:</span>
                  <span class="pi">-</span> <span class="na">api.connected</span><span class="pi">:</span>
              <span class="na">then</span><span class="pi">:</span>
                <span class="pi">-</span> <span class="na">script.execute</span><span class="pi">:</span> <span class="s">led_update_sent</span>
              <span class="na">else</span><span class="pi">:</span>
                <span class="pi">-</span> <span class="na">script.execute</span><span class="pi">:</span> <span class="s">led_update_failed</span>

  <span class="pi">-</span> <span class="na">platform</span><span class="pi">:</span> <span class="s">absolute_humidity</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">${friendly_name}</span><span class="nv"> </span><span class="s">Absolute</span><span class="nv"> </span><span class="s">Humidity"</span>
    <span class="na">temperature</span><span class="pi">:</span> <span class="s">sht40_temperature</span>
    <span class="na">humidity</span><span class="pi">:</span> <span class="s">sht40_humidity</span>

  <span class="pi">-</span> <span class="na">platform</span><span class="pi">:</span> <span class="s">template</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">${friendly_name}</span><span class="nv"> </span><span class="s">Dew</span><span class="nv"> </span><span class="s">Point"</span>
    <span class="na">unit_of_measurement</span><span class="pi">:</span> <span class="s2">"</span><span class="s">°C"</span>
    <span class="na">device_class</span><span class="pi">:</span> <span class="s">temperature</span>
    <span class="na">icon</span><span class="pi">:</span> <span class="s">mdi:thermometer-alert</span>
    <span class="na">update_interval</span><span class="pi">:</span> <span class="s">300s</span>
    <span class="na">lambda</span><span class="pi">:</span> <span class="pi">|-</span>
      <span class="s">return (243.5 * (log(id(sht40_humidity).state / 100.0) +</span>
        <span class="s">((17.67 * id(sht40_temperature).state) /</span>
        <span class="s">(243.5 + id(sht40_temperature).state)))) /</span>
        <span class="s">(17.67 - log(id(sht40_humidity).state / 100.0) -</span>
        <span class="s">((17.67 * id(sht40_temperature).state) /</span>
        <span class="s">(243.5 + id(sht40_temperature).state)));</span>

  <span class="pi">-</span> <span class="na">platform</span><span class="pi">:</span> <span class="s">template</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">${friendly_name}</span><span class="nv"> </span><span class="s">Altitude"</span>
    <span class="na">unit_of_measurement</span><span class="pi">:</span> <span class="s2">"</span><span class="s">m"</span>
    <span class="na">icon</span><span class="pi">:</span> <span class="s">mdi:image-filter-hdr</span>
    <span class="na">update_interval</span><span class="pi">:</span> <span class="s">300s</span>
    <span class="na">lambda</span><span class="pi">:</span> <span class="pi">|-</span>
      <span class="s">const float sea_level = ${sea_level_pressure_hpa};</span>
      <span class="s">return ((id(sht40_temperature).state + 273.15) / 0.0065) *</span>
        <span class="s">(powf(sea_level / id(bmp280_pressure).state, 0.190234) - 1);</span>

  <span class="pi">-</span> <span class="na">platform</span><span class="pi">:</span> <span class="s">wifi_signal</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">${friendly_name}</span><span class="nv"> </span><span class="s">WiFi</span><span class="nv"> </span><span class="s">Signal"</span>
    <span class="na">update_interval</span><span class="pi">:</span> <span class="s">60s</span>

  <span class="pi">-</span> <span class="na">platform</span><span class="pi">:</span> <span class="s">uptime</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">${friendly_name}</span><span class="nv"> </span><span class="s">Uptime"</span>
    <span class="na">update_interval</span><span class="pi">:</span> <span class="s">60s</span>

<span class="na">binary_sensor</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">platform</span><span class="pi">:</span> <span class="s">status</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">${friendly_name}</span><span class="nv"> </span><span class="s">Status"</span>

  <span class="pi">-</span> <span class="na">platform</span><span class="pi">:</span> <span class="s">gpio</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">${friendly_name}</span><span class="nv"> </span><span class="s">Button"</span>
    <span class="na">id</span><span class="pi">:</span> <span class="s">atom_button</span>
    <span class="na">pin</span><span class="pi">:</span>
      <span class="na">number</span><span class="pi">:</span> <span class="s">GPIO41</span>
      <span class="na">inverted</span><span class="pi">:</span> <span class="no">true</span>
      <span class="na">mode</span><span class="pi">:</span>
        <span class="na">input</span><span class="pi">:</span> <span class="no">true</span>
        <span class="na">pullup</span><span class="pi">:</span> <span class="no">true</span>
    <span class="na">filters</span><span class="pi">:</span>
      <span class="pi">-</span> <span class="na">delayed_on_off</span><span class="pi">:</span> <span class="s">50ms</span>
    <span class="na">on_click</span><span class="pi">:</span>
      <span class="pi">-</span> <span class="na">min_length</span><span class="pi">:</span> <span class="s">50ms</span>
        <span class="na">max_length</span><span class="pi">:</span> <span class="s">800ms</span>
        <span class="na">then</span><span class="pi">:</span>
          <span class="pi">-</span> <span class="na">light.toggle</span><span class="pi">:</span> <span class="s">atom_led</span>
      <span class="pi">-</span> <span class="na">min_length</span><span class="pi">:</span> <span class="s">1000ms</span>
        <span class="na">max_length</span><span class="pi">:</span> <span class="s">5000ms</span>
        <span class="na">then</span><span class="pi">:</span>
          <span class="pi">-</span> <span class="na">button.press</span><span class="pi">:</span> <span class="s">device_restart</span>

<span class="na">button</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">platform</span><span class="pi">:</span> <span class="s">restart</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">${friendly_name}</span><span class="nv"> </span><span class="s">Restart"</span>
    <span class="na">id</span><span class="pi">:</span> <span class="s">device_restart</span>
    <span class="na">internal</span><span class="pi">:</span> <span class="no">true</span>

  <span class="pi">-</span> <span class="na">platform</span><span class="pi">:</span> <span class="s">safe_mode</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">${friendly_name}</span><span class="nv"> </span><span class="s">Safe</span><span class="nv"> </span><span class="s">Mode</span><span class="nv"> </span><span class="s">Boot"</span>
    <span class="na">id</span><span class="pi">:</span> <span class="s">button_safe_mode</span>

  <span class="pi">-</span> <span class="na">platform</span><span class="pi">:</span> <span class="s">factory_reset</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">${friendly_name}</span><span class="nv"> </span><span class="s">Factory</span><span class="nv"> </span><span class="s">Reset"</span>
    <span class="na">id</span><span class="pi">:</span> <span class="s">factory_reset_btn</span>
</code></pre></div>  </div>

</details>

<p>Config outline:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">esp-idf</code> on ESP32-S3 (not Arduino; lower RAM for BLE + Wi-Fi)</li>
  <li><code class="language-plaintext highlighter-rouge">bluetooth_proxy</code> with <code class="language-plaintext highlighter-rouge">active: true</code>, <code class="language-plaintext highlighter-rouge">cache_services: true</code>, <code class="language-plaintext highlighter-rouge">connection_slots: 3</code></li>
  <li><code class="language-plaintext highlighter-rouge">sht4x</code> + <code class="language-plaintext highlighter-rouge">bmp280_i2c</code> on Grove I2C, <code class="language-plaintext highlighter-rouge">update_interval: 300s</code></li>
  <li>Absolute humidity, dew point, and altitude templates</li>
  <li><code class="language-plaintext highlighter-rouge">wifi_signal</code> and <code class="language-plaintext highlighter-rouge">uptime</code> sensors for placement debugging</li>
  <li>Captive portal plus a named fallback AP for recovery</li>
</ul>

<p>Official BLE proxy starting point: <a href="https://github.com/esphome/bluetooth-proxies/tree/main/m5stack">esphome/bluetooth-proxies (M5Stack Atom S3)</a>.</p>

<h2 id="links">Links</h2>

<ul>
  <li>Pax BLE for Home Assistant: <a href="https://github.com/eriknn/ha-pax_ble">github.com/eriknn/ha-pax_ble</a></li>
  <li>ESPHome Bluetooth proxies: <a href="https://github.com/esphome/bluetooth-proxies">github.com/esphome/bluetooth-proxies</a></li>
  <li>M5Stack AtomS3 Lite: <a href="https://docs.m5stack.com/en/core/AtomS3%20Lite">docs.m5stack.com</a></li>
  <li>M5Stack Unit ENV IV: <a href="https://docs.m5stack.com/en/unit/env%20IV">docs.m5stack.com</a></li>
</ul>]]></content><author><name></name></author><category term="esphome" /><category term="home-assistant" /><category term="bluetooth" /><category term="homelab" /><category term="m5stack" /><summary type="html"><![CDATA[I wanted a Bluetooth proxy near two Vent-Axia Svara extractors (Pax BLE fans), plus temperature, humidity, and pressure in the same spot. An M5Stack AtomS3 Lite (~£9, ESP32-S3) and Unit ENV IV (~£6; EOL from M5Stack, still sold by resellers) cover both in one ESPHome firmware for about £15. ENV IV is SHT40 + BMP280 on Grove I2C.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aioue.net/og-image.png" /><media:content medium="image" url="https://aioue.net/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>