The Odd Count Rule: A Cautionary Tale from the ESP32 Cottage

PETERESP
Posts: 16
Joined: Mon May 25, 2026 7:45 am

The Odd Count Rule: A Cautionary Tale from the ESP32 Cottage

Postby PETERESP » Fri Jul 31, 2026 6:15 pm

The Odd Count Rule: What the Cottage Did to the Eighth

I came across something strange while working with a batch of ESP32s that had Flash Encryption enabled. I'm not sure if this is a known quirk or something deeper in the silicon, but I wanted to share what I found—and the story that came with it.

This might sound like a fairy tale. Read it anyway.

----------------------------------------------------

The Cottage

Snow White pushed the cottage door open. Before she could step inside, her eyes caught the bark pinned to its back. The edges were charred. The letters were scratched in with charcoal.

She read the first line.

Then she saw the cellar door in the far corner—and the words scratched into its iron hinge:
"Even opens. Odd holds."
She turned back to the bark. It said the same thing, but with more detail.

----------------------------------------------------

The Rules (as transcribed from the bark)
  1. This house records the number of the dead dwarves. The number must always be odd.
  2. If the number is even at any moment, the house will add one to it by dawn. You are not required to assist. You are not permitted to prevent it.
  3. Do not attempt to erase a death. Erasure is not possible here. What is counted remains counted.
  4. There are exactly seven beds. When the count reaches seven, the rules cease to apply. The house enters its final state. The cellar door will never open again.
  5. If you are the eighth, you are not counted. But you are not safe.
  6. The house does not explain. The house does not warn. The house only counts.
----------------------------------------------------

What She Saw

She counted the still forms on the beds.

Three.

Three dead dwarves. Odd. The cellar door was shut.

She needed what was inside that cellar—a shard of silver mirror that could show her the way out of the forest. The bark said nothing about the mirror, but the iron hinge made it clear: even opens, odd holds.

She was not the first to stand here. The bark said so in a postscript scratched later, in a different hand:
To the new occupant: you are the eighth. The previous seven each tried to change the count. They each succeeded—once. The house always corrected it by dawn. They are now part of the count.
----------------------------------------------------

Her Action

She did what seemed logical. If three was odd and the door was locked, then four would be even and the door would open. She needed to add one.

She did.

A dwarf died. The count became four. The cellar door swung open. She reached in, took the shard, and held it up. The mirror showed her paths through the forest, the ones that led out, the ones that doubled back, the ones that ended in clearings with more cottages, all identical.

She slept.

----------------------------------------------------

Dawn

She woke to the sound of nothing. The house was silent. She counted the beds again.

Five.

The count had become five. Odd again.

She had not done it. No one had entered. No one had left. The house had added one—just as the bark had promised. No warning. No explanation. Just a new corpse on a bed she had sworn was empty the night before.

The cellar door was shut again. The iron hinge read the same words.

She tried again. She added another. The count became six. The cellar opened. She looked inside—there was nothing else worth taking. She slept.

Dawn. Count: seven.

The house had added another.

----------------------------------------------------

The Final State

Seven beds. Seven corpses. The count was odd. The maximum possible count, as the bark had said. The rules no longer applied. The cellar door would never open again.

Snow White stood in the center of the room. She counted herself.

She was the eighth.

If she died, the count would become eight—even. But the rules were inactive now. The house would not add another. There was no ninth bed. There was no correction coming. She would remain the sole living thing in a house where the dead outnumbered the living, and the number could not be changed—not by her, not by the house, not by anyone.

She held the shard of silver mirror. It showed her the paths out of the forest.

But the paths all led to cottages. And the cottages all had barks on their doors. And the barks all said the same thing.

----------------------------------------------------

What This Means for Your ESP32

If this sounds familiar, it should. The FLASH_CRYPT_CNT eFuse field behaves exactly like the count in that cottage:
  • Odd number of burned bits → encryption enabled (door shut).
  • Even number of burned bits → encryption disabled (door open).
  • You can change the parity by burning one more bit, but you can never erase a burned bit.
  • Each "disable" attempt burns a bit. The bootloader automatically burns another on reboot if the count is even.
  • At 7 bits burned (0x7F), encryption is permanently locked. No more changes. Ever.
The story is not a metaphor. It is a direct map.

Snow White was the developer who wanted to disable encryption to update the firmware. The cellar door was the serial bootloader access. The shard of mirror was the new application image.

She succeeded in opening the door. She failed to understand that every opening consumed a bit—and that the house would always close it again by morning.

The eighth dwarf is the developer who stands in the room after the seventh bit is burned, holding a mirror that shows all the paths, but cannot take any of them because the door no longer opens.

----------------------------------------------------

A Personal Note

I've seen this pattern in production. A developer disables encryption once, twice, three times. The field increments. The bootloader increments again. Suddenly you're at 7 bits and the chip is permanently locked. No warning. No rollback. Just a count that can only go up, and a parity rule that never forgives.

If you're using Flash Encryption, I suggest you treat the FLASH_CRYPT_CNT like the bark on that cottage door:

Read it. Obey it. Do not ask why.

And never assume you can subtract.

----------------------------------------------------

— posted by a developer who now counts beds before sleeping

ESP32 Forum, General Discussion

MicroController
Posts: 2705
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: The Odd Count Rule: A Cautionary Tale from the ESP32 Cottage

Postby MicroController » Sat Aug 01, 2026 11:35 pm

I'm not sure if this is a known quirk
It's the designed behavior:

https://docs.espressif.com/projects/esp ... on-process

Who is online

Users browsing this forum: Baidu [Spider], Corand, Google [Bot], PerplexityBot, Qwantbot and 2 guests