PostHeaderIcon R5F212DASNFP: Program Flash and Data Flash Are Two Transactions

A R5F212DASNFP flash data copy is often requested as a single word: “the flash”. On this device that word covers two areas that were designed for different jobs, written by different code paths, and worn at different rates. They sit close enough in the map that a careless read treats them as one contiguous range, and the resulting file is a plausible-looking binary with a segment in the middle that means nothing in the context of the code around it.

The separation matters most at the moment a customer says the copy is incomplete. Nine times out of ten the code is there and the calibration is not, or the calibration is there and the manufacturing record is not, and the reason is that only one of the two transactions was ever performed.

Two arrays, two jobs

The program area holds code that is written once at production and changed only at firmware update. The data area holds parameters that change during the life of the product: calibration constants, counters, user settings, the last-known state of something that must survive a power cycle. Each area inherited a different design assumption from that difference.

property program area data area
typical write frequency once, plus rare updates continuously, at runtime
typical write size a full block or a full image a few bytes
who writes it a programmer, in a dedicated session the application itself, while running
dominant failure mode interrupted update leaves a half-written block wear-out from accumulated writes
what a copy must preserve exact code bytes and their addresses exact bytes and, critically, their position

The last row is where the two diverge most sharply. A code image is meaningful anywhere it lands, because the customer reloads it at a known base address. A data image is meaningful only at its exact offset, because the application addresses it by fixed pointers. Losing the offset loses the data, even if every byte was read correctly.

Why the two wear differently

Wear is a function of erase count per block, and the two areas have completely different erase profiles. Code is erased when it is replaced, which is rare. Data is erased whenever a parameter changes, and a device that logs a value every few minutes will cycle a data block many thousands of times over a product lifetime.

This produces a recognisable signature in a recovered image. Data blocks near the end of their endurance show cells that no longer reach a clean erased state on every bit, or that program to a marginal level. When such a block is read, the result is not obviously corrupt: most bits are right, a few are wrong, and the wrong ones are in the low-order bits of stored numbers. A checksum over the block catches it; a visual inspection of the hex does not.

The signature is useful in the other direction too. A data block that is entirely erased, all FF, on a device that has clearly been running for years is not a worn block. It is a block that the application never used, and that tells you the product was configured with default parameters held somewhere else, or that the data area was cleared by a service procedure.

Block granularity and the interruption problem

Both areas are erased in blocks, and the block is the unit that a power loss damages. On a device performing an update, the vulnerable moment is between the erase of a block and the completion of its reprogramming. If power fails in that window, the block contains a mix of erased bytes and new bytes, and nothing in the device records that this happened.

That is the state a recovery most often encounters in the field: a unit that stopped booting after an interrupted update, sent in as “dead”. The code is not lost; it is half-replaced. The recovery is therefore not only a read but a decision about which blocks are trustworthy and which need to be reconstructed from a sibling unit or from the customer’s own archive.

block state how it reads trustworthy what to do
uniformly erased all FF no reconstruct from another unit or the update package
uniformly programmed, checksum matches clean data yes keep as is
programmed, checksum fails plausible but wrong no compare against a sibling, repair the differing bytes
mixed erased and programmed within one block partial no treat as interrupted update, rebuild the block
programmed, but zero everywhere suspicious no likely a failed erase that decoded as data

Why two units never compare equal

A technician who is used to comparing code images will try the same trick on the data area and conclude that the read is bad, because two units from the same production batch differ in dozens of bytes. They are supposed to. Counters differ, calibration drifts, the last-known state differs. The code region of the same two units should be identical apart from a serial number, and if it is not, that is a real finding.

The comparison that is meaningful for the data area is structural, not byte-wise: same record layout, same field widths, values inside plausible ranges, checksum over the block valid. Applying a byte-wise comparison to a region that is designed to diverge produces false alarms and, worse, teaches the team to ignore data-area mismatches that might matter.

When only one area is reachable

There are configurations in which the program area can be read and the data area cannot, and the reverse. This usually comes from option byte settings that apply per region, or from a session that was terminated partway through a multi-region read. The mistake to avoid is presenting a partial result as complete. A binary that contains code and a blank data region is not a backup; it is a backup of one of the two things the customer needs.

The practical rule is that the two areas are reported separately even when both are obtained in the same session. Two files, two checksums, two notes on how each was obtained. It costs nothing and it makes the incompleteness visible when it happens.

Where the neighbouring work sits

The map argument in R5F212A7SDFA flash program establishes where the top of the map is, which is what fixes the position of both regions relative to each other. The identity gate described in R5F212AASDFP memory data applies before either region is touched, so it determines whether this is a session problem or a two-transaction problem. For the block-level view of what a partial read looks like, R5F21292SDSP covers the failure signature in detail.

A checklist before the session starts

Four questions, answered in writing, before any tool is connected. Does this group have a data area at all, and where does it sit in the map? Which option bytes govern each region separately? Does the application write to the data area at runtime, and if so, is there a record of when it last did? And what does the customer actually intend to do with each of the two results: reload the code, read the calibration, or both?

The fourth question is the one that changes the plan. A customer who only needs the calibration does not need a perfect code image, and a customer who only needs the code does not care about worn data blocks. Asking first avoids delivering two files when one was wanted, and avoids delivering one when two were needed.

Comments are closed.