On-Flash Format
The bytes nandlog writes to the part and sends over the wire, and how a boot finds its place in them. Read this page if you are writing a parser, a host tool, or a recovery utility.
nandlog writes three kinds of structure to the part and defines a fourth for the wire. Every multi-byte
field is little-endian, every structure is packed, and every one carries a CRC-32 with the IEEE 802.3
polynomial, so a host can check it with Python's zlib.crc32.
- Data pages fill the log region. Each is a 32-byte header followed by records, up to 4,064 bytes of them on a 4 KB page.
- Metadata slots fill the metadata ring, the first eight blocks. Each slot describes an
epoch, one generation of the log begun by
nandlog_begin_epoch(), and each is written to two pages. - The bad-block table belongs to the chip driver. The Alliance driver keeps it in a reserve at the top of the array, and the Winbond part keeps its own remap table inside the chip.
- The offload stream is what a device's firmware sends to a host: a header, then each page with its own framing.
Within an epoch, a page's sequence number is its position, so a reader can locate any page without an
index, and every gap has a sequence number a host can ask for again. At boot, the log finds the newest slot
in the ring and then the write head, the position the next page goes to, by reading alone.
tools/nandlog_parse.py reads everything on this page, independently of the library.
If you are writing a parser, read Layout through Parser. The last two sections, Newest epoch and Write head, describe how a boot recovers and what it reads.
Layout
The array is divided into three regions. The log never writes to the reserve, which belongs to the chip driver.
| Region | Blocks | Contents |
|---|---|---|
| Metadata ring | The first 8 | Metadata slots, written in turn |
| Log region | Everything between | Data pages, written in sequence |
| Reserve | The top 16 (Alliance) or 40 (Winbond) | The Alliance driver's bad-block table and on-device test scratch, or the Winbond part's spare blocks for remapping |
Positions. An epoch's positions are the pages of the log region's good blocks, numbered
from 0 at the block the epoch began in, and wrapping from the end of the region to its start. A retired
block has no positions. A page's sequence number is its position, so the page that holds a given sequence
number is found by arithmetic over the list of retired blocks. The driver persists which blocks are retired,
so the numbering is the same after every reboot. In an earlier epoch, a block retired since then can shift
the positions, so a reader of an old epoch goes by the seq in each header.
Checksums. Every CRC on this page is the reflected IEEE 802.3 CRC-32 (polynomial
0xEDB88320, initial value and final XOR 0xFFFFFFFF), identical to
zlib.crc32. The CRC of zero bytes is 0.
Page header
Every data page begins with a 32-byte header, declared in nandlog.h as
nandlog_page_header_t. The header has its own CRC, so a reader can trust it before reading the
payload. That is why the log can find the write head and resolve time bounds from 32-byte reads.
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 4 | magic | 0x33505454 ('TTP3'): opaque records. 0x34505454 ('TTP4'): framed records |
| 4 | 4 | epoch | The epoch this page belongs to |
| 8 | 4 | seq | Sequence number within the epoch, from 0 |
| 12 | 4 | first_timestamp | Smallest record timestamp in the page, or 0xFFFFFFFF if it has no records |
| 16 | 4 | last_timestamp | Largest record timestamp in the page |
| 20 | 2 | payload_length | Payload bytes after the header, 0 only in a tombstone |
| 22 | 2 | record_count | Complete records in the payload |
| 24 | 4 | payload_crc | CRC-32 over the payload |
| 28 | 4 | header_crc | CRC-32 over bytes 0–27 |
The payload starts at offset 32, and the rest of the page reads FFh.
seq, payload_length, and the timestamps before it reads the payload, so
a 32-byte read is enough to place a page.Validity. A page is valid when its magic is one of the two values, its
header CRC matches, and its payload_length is no more than the page size less 32. A valid page
whose payload CRC fails, or which the part cannot correct, is a gap. The library serves a
gap as a zero-length page that carries its sequence number, and a gap is never the end of the log.
Timestamps. The two time fields are the smallest and the largest timestamps of the page's
records, in the caller's units, which the log never interprets. They need not be those of the first and last
records, because a record may carry an earlier time than the one before it, and keeps it. A record that steps
back by more than NANDLOG_TIMESTAMP_TOLERANCE_MS (250 by default) from the page's largest
timestamp starts a new page instead. A record stamped 0xFFFFFFFF keeps that stamp, but counts as
0xFFFFFFFE in its page's bounds, so 0xFFFFFFFF in a header always means that the page
has no records. Time-bounded reads select pages by these two fields.
Tombstones
A page is only ever committed with records in it, so a valid page with payload_length 0 is a
tombstone. A tombstone keeps a position occupied when its page cannot be kept, so the
position reads as a gap and can never be taken for the write head. The log writes one in two cases:
- Relocation. When a block fails, the log moves the epoch's pages in it to the next good block. A page that does not read as this epoch's page for its position goes over as a tombstone.
- A distrusted block at boot. When nothing below the write head in its block reads whole, the boot may erase the block again and write a tombstone at each of those positions (see Write head).
A tombstone carries the build's magic, the epoch, the position's sequence number, 0xFFFFFFFF for
both timestamps, 0 for the length and the record count, and 0 for payload_crc, which is the CRC
of no bytes.
Record framing
A page's magic says how its records are laid out, so a log that spans a firmware change parses correctly page
by page. Records are never split across pages, and nandlog_store_record() refuses a record that
cannot fit in an empty page with NANDLOG_ERR_TOO_LARGE.
Framed ('TTP4', the default). With NANDLOG_RECORD_FRAMING on, each record
is:
[data length: 2][record type: 1][timestamp: 4][data: data length]
The length is little-endian and counts the data only. A reader steps from record to record by the length
alone, so it can walk a page, and skip a record type it does not recognize, without knowing the application's
types. nandlog_framed_next_record() does this on the device, and stops at a record that would run
past the payload.
Opaque ('TTP3'). With framing off, each record is:
[record type: 1][timestamp: 4][data]
Only the application that wrote the records knows where each ends, so a generic reader hands the payload back whole. A framed record takes 7 bytes more than its data and an opaque one 5, so on a 4 KB page a single framed record holds at most 4,057 bytes of data.
Metadata slot
A metadata slot records an epoch: where it began, the caller's details for it, and what the log has learned
about it since, such as positions it passed over or a page that failed. The log writes a slot when an epoch
begins, and writes the current epoch's slot again whenever that record changes or a boot finds it unsettled.
Each slot goes to both pages
of a pair, an even page of a ring block and the odd page after it, so one unreadable page never loses it.
nandlog.h declares bytes 0–31 as nandlog_meta_header_t and bytes 32–63
as nandlog_meta_extension_t.
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 4 | magic | 0x334D5454 ('TTM3') |
| 4 | 4 | epoch | The epoch this slot describes |
| 8 | 4 | log_start_page | First page of the block the epoch began in |
| 12 | 4 | created_timestamp | Always 0, since the log reads no clock |
| 16 | 2 | details_length | Bytes of caller-defined details |
| 18 | 2 | format_version | NANDLOG_FORMAT_VERSION: 2 |
| 20 | 4 | details_crc | CRC-32 over the details |
| 24 | 4 | header_crc | CRC-32 over bytes 0–23 |
| 28 | 4 | reserved | 0xFFFFFFFF, not covered by header_crc |
| 32 | 4 | sequence | One more than the slot written before it, anywhere in the ring |
| 36 | 4 | head_failed_page | 0xFFFFFFFF, or a write-head page whose program failed or did not read back |
| 40 | 4 | retired_blocks | Retired blocks in the ring and log region when the slot was written |
| 44 | 4 | span_retired | Fingerprint of which of the epoch's blocks are retired |
| 48 | 2 | span_blocks | Blocks from the epoch's first through the one holding its newest page, or 0 |
| 50 | 1 | zero | 0 |
| 51 | 1 | sealed | 0xFF, or 0 once the epoch is sealed |
| 52 | 2 | passed_over_count | Runs in the passed-over list |
| 54 | 2 | reserved | 0xFFFF |
| 56 | 4 | passed_over_crc | CRC-32 over the passed-over list |
| 60 | 4 | extension_crc | CRC-32 over bytes 0–59 |
| 64 | details_length | details | The caller's blob |
| 64 + details | 4 per run | passed-over list | Runs of positions, below |
The rest of the page reads FFh.
Validity. A copy is valid when its magic, header CRC, and extension CRC
hold, its log_start_page begins a block of the log region, and its details leave room for at least
64 runs of the list. It is whole when its details CRC and list CRC hold too. The details are
limited by what the page holds, not by the reading build's NANDLOG_MAX_EPOCH_DETAILS_BYTES, so a
slot written under a larger limit is still found.
Passed-over list. A passed-over position is one the log will never program,
because a boot found that its page would not read whole. A torn page, one a power cut
interrupted, is the usual case. The list holds ascending runs, one 32-bit word each: the run's first position in
bits 0–23 and its length less one in bits 24–31. A listed position counts as written, whatever its
page reads later. The list has room for (page size − 64 − NANDLOG_MAX_EPOCH_DETAILS_BYTES)
/ 4 runs, at most 1,024: 880 on a 4 KB page and 368 on a 2 KB page, with the default 512 bytes of
details.
Failed head. head_failed_page names a write-head page whose program failed or
did not read back. The log records it before it does anything else about the failure, and carries it into every
later slot of the epoch. Such a page may hold charge that no read can see, so a boot whose head is still in that
block, unretired, moves the block's pages before it programs anything.
Layout record. Positions are laid out over the blocks the driver calls good, so
retired_blocks, span_blocks, and span_retired record the layout the slot
was written under. span_retired is the 32-bit sum, over each retired block among the epoch's first
span_blocks blocks, of the CRC-32 of that block's 32-bit offset from the epoch's first block. A boot
whose table names fewer retired blocks, or other ones under the epoch, would lay the pages out differently, so it
seals the epoch and keeps the slot's original record. The one exception is the block of a recorded failed head,
whose retirement completes a relocation the slot recorded, once the head stands at or past the failed page.
Seal. A sealed epoch takes no more pages. Every later boot reads the seal,
refuses records with NANDLOG_ERR_SEALED, and calls nandlog_port_unwritable(), until a
new epoch begins, but the epoch's pages can still be read. A boot seals the epoch, in its slot, in four
cases:
- The passed-over list is within four runs of what the slot can hold.
- The newest slot the epoch acted on has lost its list in both copies (see Newest epoch).
- The table lays the epoch out differently from the slot's record, or the head search finds a page of the epoch below its own sequence number, which means a block under committed pages was retired without the log.
- The slot's details are longer than the reading build's
NANDLOG_MAX_EPOCH_DETAILS_BYTES.
Bad-block table
Which blocks are retired, and so which pages have positions, is the chip driver's business rather than part of this format. A parser of a raw dump still needs it, to tell the live copy of a relocated page from the stale original. This section describes the Alliance driver's table. The Winbond part remaps a retired block in a lookup table inside the chip, so a Winbond dump carries no table (see Durability).
Each version of the Alliance table is one page:
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 4 | magic | The ASCII bytes BBT3 |
| 4 | 4 | crc | CRC-32 over byte 8 through the last entry |
| 8 | 4 | version | One more than the version it replaces |
| 12 | 4 | count | Entries that follow, at most 256 |
| 16 | 4 per entry | entries | The first page of each retired block |
The rest of the page reads FFh. The rules a reader needs:
- Where. The table rotates over the first eight blocks of the reserve. Each version goes to both pages of the next pair, and a full block hands on to the next, which is erased first. Each copy is judged from one read, header and entries together, because a torn page can read differently from one read to the next.
- Newest. A boot dates each table block by the first version in it that reads, and loads the newest block's last pair that has a readable copy, falling back to older blocks if it has none.
- Marks. Every block the table names also carries a mark:
00hin the first byte of its first page's spare area, where the factory marks bad blocks. Marks are read with ECC off. A mark counts only when it reads exactly00h, so every boot programs again any entry's mark that does not. Because a power cut can leave a mark part-programmed, any byte butFFhmay be one: the driver never erases such a block or takes it for a table block, and passes over any version in it. - A stray bit. Read disturb can program one bit of a mark. A reserve block whose mark reads a single programmed bit is therefore read as unmarked if it holds a version newer than the one loaded that does not name it, and the boot writes that version again into a fresh block.
- Settling. The newest version is settled when both its copies read with margin and nothing was written after it. Otherwise the boot writes the same entries again, as a new version in a fresh block, before the log lays out any position.
- Rebuild. If no version loads, the driver rebuilds the table from the marks, taking any byte
but
FFhas a mark, and writes it.nandlog_reset_bad_block_table()forces this, after programming every entry's mark again and checking that each reads00h. The driver writesBBT2to page 4 of the part's OTP area once a table exists, so a later rebuild is reported as a lost table. - When the reserve cannot hold it. The log gives the driver an aligned pair of blocks from the top of the log region, outside the current epoch and holding no valid page. Every version written there names both blocks as retired, and they are the only entries without a mark, because a mark would hide their versions. A boot looks for them only when no reserve block holds a version, with one or two header reads a block, down to 48 blocks below the reserve.
- Degraded mode. With no pair to be had, the driver makes every block that holds a version yield none, and the marks alone record retired blocks. Every boot then rebuilds the table from the marks, until a boot can give the table a pair.
A reader of a raw dump that has no table recognizes the stale copies a relocation leaves in a retired block by keeping one copy of each (epoch, sequence number).
Wire format
The offload stream is how a device sends an epoch to a host. nandlog.h defines its two
structures, nandlog_stream_header_t and nandlog_wire_page_t, and the device's firmware
writes them from what nandlog_read_span() and nandlog_retrieve_next_page() report. A
stream is a 16-byte header, the caller's details, then a 20-byte frame and its payload for each page.
| Offset | Size | Stream header field | Meaning |
|---|---|---|---|
| 0 | 4 | magic | 0x31535454 ('TTS1') |
| 4 | 2 | record_format | 1 opaque, 2 framed |
| 6 | 2 | details_length | Bytes of details that follow the header |
| 8 | 4 | total_pages | Pages that will be sent, gaps included |
| 12 | 4 | total_payload_bytes | Sum of their payload lengths |
| Offset | Size | Page frame field | Meaning |
|---|---|---|---|
| 0 | 4 | seq | The page's sequence number |
| 4 | 4 | first_timestamp | As in the page header |
| 8 | 4 | last_timestamp | As in the page header |
| 12 | 2 | payload_length | Payload bytes that follow, or 0 if the device could not read this page |
| 14 | 2 | record_count | As in the page header |
| 16 | 4 | payload_crc | CRC-32 over the payload that follows |
A device sends a page it cannot read, and a tombstone, as a frame with zero payload, so the host sees an
explicit gap at a known sequence number rather than silently missing data. The host checks
payload_crc itself, which also catches corruption in transit.
A frame carries no magic, so the header's record_format applies to every page of the stream. An
epoch's pages share one format unless NANDLOG_RECORD_FRAMING changed while it was being written, so
begin a new epoch along with a firmware update that changes it. Alternatively, a device can send each page's
magic, which nandlog_retrieve_next_page() returns in the header it fills in, alongside the
frame.
Sequence numbers are contiguous within an epoch. A host can therefore identify exactly which pages are missing, including pages lost to a truncated transfer, which have no frame at all, and ask for them again (see Retransmission).
Reading an image or a stream
tools/nandlog_parse.py is a second implementation of this page, written independently of the
library, so a disagreement between the two shows that one of them is wrong. It reads a raw dump of the part,
main and spare area page by page, or an offload stream.
./tools/nandlog_parse.py image dump.bin --page-size 4096 --spare-size 256
./tools/nandlog_parse.py image dump.bin --json
./tools/nandlog_parse.py image dump.bin --expect library_view.txt
./tools/nandlog_parse.py stream offload.bin
imagetakes--page-size(default 4096),--spare-size(default 256, or 0 for a dump of the main array only), and--pages-per-block(default 64). It finds pages and slots by their magic, verifies every CRC, and reports each epoch's verified pages, missing sequence numbers, and tombstones, and every slot with its state.- Stale copies. When the dump holds the Alliance driver's table, the parser reads its newest version wherever it is kept, passing over marked blocks as the driver does, and with no version left it takes the marks themselves. Pages in the blocks they name are stale. In every case it keeps one copy of each (epoch, sequence number), preferring one that verifies.
streamchecks each frame's payload CRC, lists the gaps to request again, and walks framed records.--jsonprints either result as JSON.--expectcompares the parser's verdict on every page with the library's own view of the same image, one line per position (epoch seq payload_length record_count), as the simulator suite writes it.
The parser exits with status 1 if any live page fails verification or, with --expect, if any page
disagrees. make in sim/ runs the --expect comparison on every image the
suite dumps, a Winbond image among them.
Format versions
| Macro | Meaning |
|---|---|
NANDLOG_FORMAT_VERSION | The on-flash format a build writes: 2. Every metadata slot records it, but a reader goes by the magics, which each format has its own of. |
NANDLOG_RECORD_FORMAT_THIS_BUILD | The record format a build writes: 1 opaque, 2 framed. It follows NANDLOG_RECORD_FRAMING. A page states it in its magic, a stream in its header. |
NANDLOG_VERSION_MAJOR / _MINOR | The library API: 1.1. It is independent of the formats. |
The digits in the magics (TTP3, TTP4, TTM3, TTS1,
BBT3, and the OTP marker BBT2) are part of the tags, not version numbers. Each
on-flash format has its own page and slot magics, and the stream, table, and OTP tags change only when their
own layouts do.
Parts written in format 1. Format 1, which every release up to 1.0 wrote, tagged its pages
TTP1 and TTP2, and its slots TTM1 or TTM2. This library
does not read those slots, so it finds no epoch on such a part. It does recognize those pages, whose header
is this format's, and treats each as belonging to no epoch: a boot settles it with one header read, as it
would another epoch's page, and never adopts it or counts it as the current epoch's. Format 1 pages stay on the
part until the log erases their blocks, and are not readable through the API.
The first epoch on a part with no slot. With nothing in the ring to number from, as on a
fresh part or one whose whole ring was lost, nandlog_begin_epoch() reads a header from each block
of the log region and numbers the epoch above every epoch this format's pages name. Without that, a part whose
ring was lost would begin again at epoch 1 among its own earlier pages.
Finding the newest epoch
A boot first finds the newest slot it may trust, because that slot names the current epoch, where it began, and what the log knows about it. The boot only reads at this stage, and judges each copy from a single read.
How the ring is written. The ring's eight blocks are used in turn. The log enters a block by erasing it, fills it strictly in order, and leaves it at the first pair that is not blank or will not take a program, so each block's written pages are a prefix of it. The second copy of a pair is programmed only after the first has read back with margin and its CRC agrees. If no pair in the ring takes both copies, a single verified copy stands as the slot.
What a boot reads.
- The first readable slot of each ring block, usually its first page: 8 reads of 64 bytes. The block whose
first slot has the highest
sequenceis the newest. - A binary search of that block for the end of what was written: 6 header reads on a 64-page block.
- Both copies of the last pair, each read once, as a whole page, into RAM. Each image is judged by every checksum it carries: whole, valid with its list but not its details, valid without its list, or not a slot. That image, never a second read, is what the boot goes by and what every slot it writes is built from.
- A header read of the page after the pair and of the first page of the next ring block, each followed by a raw read (the whole page and spare, ECC off) if its header reads erased, to check that nothing was written after the slot.
That is 18 to 20 reads, at most 2 of them raw, and ten of them in the newest ring block. If that block has no usable pair, the boot repeats steps 1 to 3 for the block entered before it, at most once per ring block.
Choosing the slot. The last pair counts only if a copy is whole, because a power cut may have torn it before anything acted on it. An earlier pair counts if either copy is valid with its list, since it was verified twice when it was written, and acted on. If neither copy of that pair still holds its list, going back to an older slot would undo what it recorded, so the boot keeps the slot's header and seals the epoch. If only the details are lost, the epoch goes on without them. As a result, one unreadable page never costs a slot.
Settling. A slot is settled when both its copies are whole and read with margin, and nothing was written after it, in its block or in the first page of the next. Otherwise a power cut may have torn it, and a torn page can read valid on one boot and not the next. So before the boot erases or programs anything for the write head, it writes the slot again from its image, as the first pair of the next ring block, numbered past anything the torn pages could claim. Every later boot then goes by the same slot.
Worn copies. A copy that the part corrects only at the limit of its ECC
(NANDLOG_READ_AT_ECC_LIMIT) still counts as whole, but it leaves the slot unsettled, so the boot
writes the slot again into a fresh block. A copy is never written to a page that reads back at the limit, so a
worn page costs one erase and two programs once, not at every boot. Both copies share a block, and every boot
reads ten of its pages. Durability covers that wear.
A newer epoch the ring lost. An epoch begins only once its slot is on the part twice, so pages
of an epoch newer than the ring names mean that every copy of its slot became unreadable. After finding the
write head of the epoch the slot names, and before acting on that slot, the boot reads the first page header of
the head's block (or of the next good block, if the head is part-way into one) and of the blocks after it,
NANDLOG_ERASE_AHEAD_BLOCKS + 2 good blocks in all. A block whose first header neither
checks nor reads erased is read on, page by page. A page of a newer epoch with sequence number s at
offset o in its block shows that the epoch began (s − o) / P
good blocks earlier, where P is the pages per block. The boot carries on with that epoch, finds its
write head, and writes it a new slot without the caller's details. If
s − o is not a whole number of blocks, the log stops writing. The check
repeats after each epoch it adopts, at most once per page of the ring.
Finding the write head
The boot finds the write head by binary search over the epoch's positions, reading only. The search is correct because the write paths keep three rules true at every instant a power cut can land. With h the write head:
- Every position below h is passed over or not blank, and any valid header there is this epoch's, carrying the position as its sequence number.
- Position h is blank and not passed over, unless it begins a block the epoch has not entered yet.
- No position at or above h is passed over, or holds this epoch's valid header for that position.
Classes. The search sorts each position it probes into one of three classes:
- Inside: passed over, or holding this epoch's valid header for that position.
- Outside: blank, meaning every bit of the page and its spare area reads erased with ECC off, or holding any other valid header.
- Unknown: anything else, such as an unreadable or torn page. It takes the class of the nearest classifiable position below it.
The rules make "inside" exactly "below the head". Only a blank page that is not passed over counts as evidence
of being past the head, so retired blocks, unreadable pages, and torn pages below the head do not mislead the
search. A torn page that reads whole cannot be told from a committed one, and is taken as committed. The comment
that opens the Write-Head Recovery section of nandlog.c states the rules.
What the search reads.
- ⌈log2(N + 1)⌉ probes over the epoch's N good
positions, and at most three more, because the first four probes are rotated within the middle half of the
range from boot to boot, by the ring's sequence number and
NANDLOG_BOOT_SALT, to spread read disturb. On the Alliance part that is 18 to 21 probes. - Each probe is a header read, plus a raw read when the header reads erased. An unknown probe adds a header read for each position of the run of unknown positions directly below it, never below the search's lower bound.
- A look past the answer, one header read a position for at most a block's worth, for a page of the epoch at its own position. Finding one means a committed page came to read blank, a retention failure outside the design's model, so the search runs again above it and leaves that page a gap. The look stops at the first header that reads erased, unless the epoch's list was lost.
Below the head. The boot then checks the answer from below. It reads each position below the head once, as a whole page, until one reads whole: this epoch's header for that position, a payload whose CRC holds, and ECC that corrects. Every position on the way is passed over, whatever the search made of it, because a page below the answer that reads blank or as another epoch's contradicts the search, as the remains of an interrupted erase can. The boot lists those positions in the slot before it commits anything after them. Usually this costs one whole-page read, of the page just below the head.
When that run covers everything below the head in its block, the block cannot be trusted as it stands:
- If none of those positions is passed over or carries the epoch's header, and a page at or past the head in the block is not blank, the epoch never entered the block. What is there is left from an interrupted erase, so the head goes back to the block's start, and the block is erased before it is programmed. Telling the two cases apart costs up to a block's worth of raw reads.
- Otherwise the positions may be pages the epoch tore. The boot passes them over, erases the block again, and writes a tombstone at each. A boot that finds such a block again, because a power cut stopped that erase, does the same again.
The head's own page. A build with NANDLOG_PASS_OVER_HEAD_AT_BOOT also passes over
the head's own page whenever the head is part-way into a block in which no program has failed and which the boot
is not rewriting, and moves the head past it. A power cut during a commit can leave that page partly programmed,
and this keeps the log from programming it a second time.
Getting Started covers when to choose it.
Then. If the slot is unsettled, or the boot passed over new positions, adopted an epoch, or
counts a different number of retired blocks, it writes the slot. Only then does it prepare the head: it relocates
the head's block if a program failed there before the reboot or the head's page is not blank, rewrites a
distrusted block, and erases the head's block, if the epoch has not entered it, and the
NANDLOG_ERASE_AHEAD_BLOCKS blocks after it. Those blocks are erased again at every boot because an
interrupted erase can leave a block that reads erased but programs unreliably.