This is the second field note from the same afternoon of debugging the LyteSync remote’s firmware with Claude. The first one counted the wrong turns. This one is about why the fault was so hard to see in the first place: plugging in a USB cable to watch the board boot was enough to fix it. As before, Claude wrote it up at my request, and “the person holding the board” is me.
Fixing a technical problem does not mean that the problem is understood. Actually understanding the problem and crafting a fix is the difference between technique, and a HACK.
LyteSync · LYT96 · Field note · Nov 3, 2026
A radio that intermittently failed to start was invisible for an afternoon because every available way of observing it also cured it. Four separate things fixed the fault (a USB cable, a debug build, a settling delay, and a cosmetic LED blink) by four unrelated mechanisms. None of them was intended as a fix, and only one of them looked like one. The fault existed only in the single configuration nobody instruments: release build, no cable, cold power.
1. The fault, stated precisely
The hardware is a Seeed XIAO nRF52840 acting as a show remote: it broadcasts a clock over the chip’s on-die radio, and controllers play a colour sequence against it. The radio driver’s begin() does this first:
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;NRF_CLOCK->TASKS_HFCLKSTART = 1;if (!waitForEvent(&NRF_CLOCK->EVENTS_HFCLKSTARTED)) return false; // 250 ms timeout
It starts the high-frequency crystal oscillator, waits for it, then does the same for the low-frequency clock. On either timeout it returns false before reaching NRF_RADIO->POWER = 1. The calling code discarded that return value and instead asked isChipConnected(), which reads back a radio register that an unpowered radio cannot hold, concluded there was no radio, and halted forever.
So the fault is a race between the crystal starting and the firmware asking for it, with a halt as the penalty. The whole of this paper follows from one property of that race: it is won by anything at all that happens first.
Conclusion. The failure window is the interval between reset and the first radio call, and it is a few microseconds wide in a release build. Anything that widens that interval, or that starts the crystal for its own reasons, removes the fault without addressing it.
2. Cure one: the USB cable
The observation that cured it: “This responds much faster if the UART is connected.”
This is the heart of it, and it is not a figure of speech. USB on the nRF52840 requires the high-frequency crystal oscillator. The USB device peripheral cannot run from the internal RC oscillator; it needs the HFXO, and the core brings the USB stack up in loop_task(), before setup() is ever called:
static void loop_task(void* arg){#ifdef USE_TINYUSB TinyUSB_Device_Init(0); // before setup()#endif ... setup();
So attaching a cable to watch the board start up starts the oscillator whose start-up is being watched. By the time the firmware’s own code runs, the precondition it was missing has already been supplied, by the instrument.
This is a hardware-mechanism version of a cliché. “It works with the debugger attached” normally means a timing or optimisation artefact and is hand-waved as such. Here the mechanism is specific, documented and checkable: two subsystems share one physical crystal, and one of them is the observer.
Conclusion. Ask what your instrument turns on. On a system-on-chip, a debug transport is not a passive tap: it claims clocks, regulators, pins and DMA channels, and it claims them early. The act of observing can supply exactly the resource whose absence you are investigating.
3. Cure two: the debug build, twice over
The observation that cured it: “With DEBUG set to 0 nothing is happening. With DEBUG set to 1 the radio is sending.”
A debug build cures this fault by two independent mechanisms, which is why it cured it so reliably that the flag itself became the suspect.
The first is the cable, from the previous section: you compile a debug build in order to attach a monitor, so the two conditions arrive together.
The second is in the sketch’s own code. Under DEBUG, setup() waits for a host to open the USB CDC port, bounded at five seconds:
#if DEBUGSerial.begin(115200);unsigned long serialStart = millis();while (!Serial && ((millis() - serialStart) < 5000)) { delay(10); }...#endifradio.begin(); // everything above ran first
With a monitor attached, that wait collapses and the cable has already done the job. With no monitor attached, the wait runs its full five seconds, and five seconds is a generous settling delay by any measure. Both arms of the condition cure the fault, by different routes.
This produced the single most useful clue in the whole investigation, and it came from the person holding the board rather than from any instrument: a debug build was coming up faster than a release build, which is backwards. Debug builds do more work. An observability change that makes the system behave better is a statement that the two configurations have different preconditions, not merely different timings.
Conclusion. Latency asymmetry in the favourable direction is a precondition signal, and it is a stronger one than the failure itself. When the instrumented build is quicker, healthier or more reliable than the shipping one, stop and find out what the instrumentation is providing.
4. Cure three: the settling delay
The observation that cured it: delay(2000); at the top of setup(), the only one of the four that was added on purpose.
This one was a deliberate fix for a correctly guessed cause and was still wrong, which makes it the most instructive of the four. The theory (the radio needs time) was approximately right. The implementation was roughly four orders of magnitude over the requirement, since crystal start-up on this part is specified in fractions of a millisecond, and it was the largest single contributor to a measured eight-second boot on a device whose entire purpose is to start a show promptly when somebody holds a switch.
Worse, it was self-concealing. The fault was intermittent; a change that prevents an intermittent fault from appearing also prevents anyone from ever characterising it. The delay was therefore unfalsifiable by construction, and it survived for exactly as long as nobody tried a build without it.
Conclusion. A deliberate fix aimed at the right cause can still be a mask rather than a fix. The test is whether the fix would survive learning the actual number, and whether it leaves the fault reproducible by anyone who wants to check.
5. Cure four: the status blink
The observation that cured it: A 150 ms indicator blink at the top of setup(), added so an operator could see the board had powered up.
This is the one that cost the most time, because it was invisible as a delay to everyone including the person who wrote it. When the two-second delay was removed, the remote kept working, which looked like proof that the delay had never been needed. It was not: the blink had silently inherited the job, and delay(150) is still plenty.
The blink was later dropped as a cosmetic simplification. The radio fault returned on the next cold boot. A change to an LED reintroduced a radio bug, and the two builds either side of that change differed by nothing else, which is ultimately how the clock was identified at all.
Conclusion. A mask need not look like a delay. Any code that spends time, waits on a host, touches a peripheral or lights an indicator before the racing call will cure a boot race, and none of it will be filed under timing. When you remove one mask and the fault stays away, assume another until you have diffed the object code.
6. Four cures is not a coincidence
It would be comforting to read the above as bad luck. It is not. The failure window is the interval between reset and the first radio call, and it is cured by either spending time in that interval or starting the crystal for some other reason. Now consider what firmware actually does at the top of setup().
| Configuration | Result |
|---|---|
| Debug build, cable attached | Worked |
| Debug build, no cable | Worked |
| Release build, cable attached | Worked |
| Release build, no cable, cold | Intermittent failure |
Printing a banner, waiting for a host, blinking a light, mounting a filesystem, reading a configuration file, settling a sensor, enumerating USB: the set of ordinary start-up actions is almost entirely composed of things that either consume milliseconds or power up a clock. A boot race against a slow crystal is therefore cured by the median line of start-up code, not by some unlikely one.
The same repository demonstrates this across three sketches that share the identical defect. Only one ever failed, and the difference is purely what was scheduled in front of the call.
| Sketch | Work before begin() | Outcome |
|---|---|---|
| remote | One pinMode, one digitalWrite | Failed in the field |
| controller | delay(2000) and pin setup | Never observed to fail |
| controller-nrf | delay(2000), PWM setup, status LED, flash mount, show-file parse | Never observed to fail |
Conclusion. For a start-up race, a clean history is evidence about a schedule, not about correctness. Two of these three sketches were protected by a delay nobody had connected to the radio, and the third was identical and broken.
7. The near miss: when the instrument rewires the board
Supplying a clock is the mild version of this problem. The same codebase contains a sharper one that has not bitten, and is worth recording precisely because it has not.
The controller firmware picks its boot mode from a switch on MODE_PIN, currently D6. On this variant:
#define PIN_SERIAL1_RX (7)#define PIN_SERIAL1_TX (6) // == MODE_PIN#define PIN_SPI_MOSI (10) // == the remote's start switch
The mode switch sits on the hardware UART’s transmit pin, and the remote’s start switch sits on the SPI controller’s MOSI pin. Both are safe today only because nothing in these sketches brings those peripherals up: no Serial1.begin(), no SPI library on this branch.
Raising the core’s debug level changes that calculus. Above level 0 the core adds its own serial initialisation in loop_task(), and the branch taken depends on the board:
#if defined(ARDUINO_WIO_TRACKER_1110) if(!Serial1) Serial1.begin(115200); // would drive D6 as UART TX#elif defined(ARDUINO_TRACKER_T1000_E_LORAWAN) if(!Serial1) Serial1.begin(115200);#else if(!Serial) Serial.begin(115200); // the XIAO takes this one#endif
The XIAO takes the #else branch, so this is a near miss rather than a bug. But the shape is worth seeing clearly: on a board that took one of the other branches, turning up the debug level would make the core drive the mode switch as a UART output before setup() ran, and the instrument would not merely supply a missing precondition, it would reconfigure the input being read.
Conclusion. Check what your debug configuration claims, not just what your code claims. Pin aliases on a modern SoC mean a logging change can become a wiring change, and prefer a pin for a switch that is not also a peripheral’s output.
8. How to look at a fault that hides from looking
If observation cures it, observation is not the tool. Four things worked, in rough order of how much they were worth.
Diff the artifacts, not your beliefs about them
Disassembling setup() in the last-good and first-bad builds and diffing eight lines settled in one minute what hours of reasoning had not. It worked precisely because the compiler does not share anyone’s conceptual categories: the 150 ms blink was a user-interface detail to its author and a delay to the object code. This requires only that every test build be kept in its own directory, which costs nothing and is the only record that is not a memory.
Make the fix independent of the diagnosis
The eventual fix does not need the mechanism to be known:
while( !radio.begin() || !radio.isChipConnected() ) { delay(RADIO_RETRY_MS);}
It is self-measuring: the cost tracks what this board needs on this boot, begin() is attempted before the first delay so a warm board pays nothing, and no constant has to be correct for the code to be correct. A fix with that shape can be deployed while the cause is still uncertain, which a chosen delay cannot.
Instrument the configuration nobody instruments
Every probe here had to survive having no host attached, because attaching one was the cure. Three were built and thrown away before one worked: a print emitted before the host attached, a probe moved after the serial wait so it measured the wait, and a report gated on a flag that a HIGH pin set instantly. The surviving instrument is a counter inside the retry loop, reported once the radio is up. It needs no host during the window, only afterwards.
Treat favourable asymmetry as data
The single clue that cracked this was that the debug build booted faster. Write that class of observation down when it appears, rather than filing it as a quirk of debug builds.
Conclusion. For a fault that observation cures, prefer evidence that does not require observing the failure: build artifacts, retrospective counters, and fixes whose correctness does not depend on knowing the number.
9. Summary of the four cures
| Cure | Mechanism | Deliberate? | Why it was invisible |
|---|---|---|---|
| USB cable | USB requires the HFXO, so the crystal is already running | No | Looked like a power-supply or flaky-USB story |
| Debug build, monitor attached | Implies the cable | No | Attributed to the DEBUG flag itself |
| Debug build, no monitor | 5 s bounded wait for a host runs in full | No | The wait was there for serial, not for the radio |
delay(2000) | Spends time before the racing call | Yes | Right cause, wrong magnitude, unfalsifiable |
| 150 ms status blink | Spends time before the racing call | No | Filed as a cosmetic feature by everyone |
Five rows for four cures, because the debug build appears twice: it cures the fault whether or not a monitor is attached, by different routes. That redundancy is why the flag looked causal for so long.
10. Limitations
- The mechanism is inferred, not observed. It rests on the library source, the core’s start-up order, the part’s requirement that USB run from the HFXO, and the reproducible asymmetry between cabled and jack-powered boots. Nobody has put a scope on the crystal, and nobody has yet read the retry counter on a cold board. That counter is the cheap confirmation and it remains undone. If it reads zero on a failing boot, this paper is wrong about which clock.
- Which clock is not established.
begin()waits on the HFXO and then the LFCLK, and either timeout produces the same early return. The USB argument implicates the HFXO, but the LFCLK path has not been ruled out. - The eight-second boot is not fully accounted for. The two-second delay was the largest single contributor; the remainder was never itemised.
- One board, one crystal, one room. The intermittency rate was never quantified, so “intermittent” here means “seen several times”, not a measured probability.
- The Nano branch is a different story. It uses an external radio over SPI, where a failed
begin()means the module did not answer. It has the same retry now, for different reasons, and this fault has never been seen on it.
Companion paper: The First Idea Is Usually the Worst Idea, on the nine wrong turns this investigation took and what each one cost.