Archive for the ‘Break IC’ Category
ATmega164 Boot Section: SPM and the Bits That Guard It
An AVR that can update its own firmware must be able to write to its own flash. The instruction that does it is SPM, store program memory, and its existence changes the shape of the protection problem: there are now two containers — the application section and the boot section — and the boot section is the one that holds the update logic.
Most discussions of AVR protection treat the lock bits as a single wall. On a part with a bootloader there are two walls, and they are built from different bit fields with different rules. Which wall is up determines what a read can see, and it is common to find one up and the other down.
Two sections, two jobs
The flash on this family is divided into a read-while-write section and a no-read-while-write section. The boot section sits at the top of the address space and is intended to hold code that must not be overwritten by the code it is updating.
The boot section has three properties that matter:
- It can be entered automatically on reset if the boot reset fuse is programmed.
- Its size is selected by a fuse pair, in fixed steps.
- It is the only place from which
SPMmay write, on parts where the SPM instruction is restricted to the boot section.
That last point is the crux. The application code cannot rewrite flash by itself; it has to hand control to the boot section, which performs the write and returns. The boot section is therefore privileged code, and the hardware gives it its own protection bits.
The boot lock bits are not the lock bits
| Field | Guards | Typical effect when set |
|---|---|---|
| General lock bits | Whole flash, both sections | Blocks programming, then verification |
| Boot lock bits, mode 1 | Application writing into boot section | Application cannot modify the bootloader |
| Boot lock bits, mode 2 | Boot section writing into itself | Bootloader cannot self-modify |
| Boot lock bits, mode 3 | Both of the above | Bootloader is read-only to software |
Two facts follow, and both are useful on the bench.
First, a part can have its general lock bits clear — flash readable — and still have boot lock mode 2 set, which blocks the boot section from rewriting itself. That combination is common in products that want a field-updatable application but an immutable bootloader.
Second, the boot lock bits do not block external reads. They govern what software running on the chip may write. External read permission comes from the general lock bits alone.
Why a bootloader is a second door
If the boot section is present and its lock bits allow it, the device can program itself. That means a device in the field with a working bootloader accepts new code over whatever transport the bootloader implements — UART, USB, CAN, radio.
For anyone examining a product, that is a completely different situation from a device with no bootloader. There is an existing, vendor-supported path to change the contents. The question stops being “how do I get in” and becomes “what does the bootloader accept, and what does it check”. Signature verification in the bootloader turns an open door into a locked one, and the presence or absence of a verification step is often the single most important thing to determine about the product.
The erase question again
SPM can write flash, and it can also perform a page erase. It cannot erase the whole chip, and it cannot change the lock bits. That asymmetry is deliberate: a bootloader must be able to update a page, and must not be able to remove its own protection.
So on a part whose protection is the general lock bits in mode 2 or 3, the bootloader is not an escape route. It can rewrite the application section; it cannot unlock anything. The only operation that clears the lock bits remains the external chip erase, which returns the flash to blank.
That is worth stating clearly because the intuition runs the other way — “there’s a bootloader, so there’s a way in”. There is a way to write, not a way to read.
Reading the boot section specifically
If the general lock bits permit verification, both sections read normally, and the boot section is just the top slice of the address space. Its contents are frequently the most informative part of the image, because bootloaders tend to contain readable strings: protocol names, version numbers, error messages, sometimes vendor URLs.
If the general lock bits do not permit verification, neither section reads. The distinction between the two containers only becomes decisive when the general bits are open and the boot bits are not — in which case the application reads, the boot section reads, but the on-chip software cannot touch the bootloader.
What a fuse read tells you before any of this
Before assuming anything about sections, read the fuses. Three of them set the shape of the problem:
- Boot reset fuse: whether reset vectors into the boot section at all.
- Boot size fuse pair: how large the boot section is, in fixed steps.
- Boot lock bits: which of the three modes applies.
A part with the boot reset fuse unprogrammed still has a boot section defined, but never enters it. A part with the boot size fuse at its smallest setting has a boot section that can hold a jump table and very little else. Both are useful facts and both come from a read that does not touch the flash.
Related notes
- ATmega644 and read-while-write behaviour — what the other half of the split does under load.
- ATmega324PA and brown-out reads — why a marginal read looks like corruption.
- ATmega644PA and RSTDISBL — the fuse that removes ISP entry entirely.
FAQ
Can a bootloader remove the lock bits? No. SPM cannot modify the lock bits. Only an external chip erase resets them, and it erases the flash as well.
Does a locked part still boot through its bootloader? Yes. Lock bits are enforced by the programming interface, not by the CPU. The device runs exactly as designed.
Are the boot lock bits readable? Yes, the lock byte includes them and can be read back through the programming interface.
If the boot section is locked, is the application section still readable? That depends on the general lock bits, not the boot bits. The two fields are independent.
Conclusion
On an ATmega164 with a bootloader, protection is two containers with two bit fields. The boot lock bits govern what on-chip software may write; the general lock bits govern what an external programmer may read. Confusing the two leads to wrong conclusions in both directions — assuming a bootloader means access, and assuming a locked boot section means a locked device.
ATtiny48A: Workarounds Are a Record of What Changed
Silicon revisions are documented unevenly. Some arrive with a change list and a revised errata; others arrive with a new suffix and nothing else. In both cases the firmware often documents the change better than the vendor did, because whoever wrote it had to work around the problem.
Reading an image for workarounds is therefore a way of reading the die’s history. Three patterns recur, and each points at a different kind of defect.
Pattern one: the redundant write
A register is written twice with the same value, with nothing in between that could have changed it. On a modern compiler that is not an optimisation failure — it is an instruction to the hardware, usually because the first write did not take effect reliably.
The distance between the two writes is informative. A few cycles apart suggests a synchroniser that needed time. A separate function suggests the workaround was applied at a call site rather than at the driver.
Pattern two: the delay that does nothing useful
A loop with no side effects, sitting between two register operations. Delay loops exist for legitimate reasons — start-up time, analogue settling, protocol spacing — and they also exist because a peripheral needed longer than the datasheet said.
Distinguishing the two requires context. A delay after enabling an oscillator is legitimate. A delay after writing a control register that has no start-up requirement is a workaround, and it names the peripheral that misbehaved.
Pattern three: reading a status bit twice
The code polls a flag, sees it set, and polls again before acting. That pattern appears in firmware written against a part where the flag was known to glitch, and it is close to conclusive evidence of a silicon defect in that path.
| Pattern | Likely cause | What it names |
|---|---|---|
| Duplicate register write | Write did not take | That peripheral |
| Unexplained delay loop | Operation slower than specified | Whatever the delay precedes |
| Double status poll | Flag unreliable | Whatever the flag reports |
| Value written then masked | Register reserved bits behave unexpectedly | Register-level behaviour |
The fourth row is subtler and shows up in code that writes a value, then immediately rewrites it with a mask applied. That is a response to reserved bits that do not read back as written.
Why this matters for a reproduction
A reconstruction that strips the workarounds produces code that is cleaner and, on the original die, wrong. It will fail intermittently, and the failure will appear in exactly the place the workaround was protecting.
Keeping them has the opposite cost: on a newer die they are harmless but they obscure the logic. The right answer is to keep them and annotate them, so that a later reader knows which parts of the code are the design and which are the design’s response to a defect.
Annotation is the part that gets skipped. An image with comments like “this delay is for the errata” is worth considerably more than the same image without them, and the cost of adding them is minutes.
What the revision changes at the observable level
Three things are visible without any errata:
The signature byte may differ. The fuse map does not. The lock bit state machine does not.
That combination means the recovery procedure is identical and only the interpretation changes, which is the useful split: method is portable across revisions, timing and thresholds are not.
Reading order for a revision-aware reconstruction
- Read signature and record it with the date code from the package.
- Read fuses and lock byte.
- Read the array, verified.
- Locate the three workaround patterns in the code.
- For each, record what it protects and which peripheral it names.
Step 5 produces something unusual and valuable: a per-peripheral list of suspected silicon quirks, derived from the firmware rather than from documentation. For anyone maintaining a product across a revision change, that list is the practical answer to “what do we have to be careful about”.
Related notes
- ATtiny48 and the wide package — the same die in its base revision.
- ATtiny88A and the program layout — the larger array with the same revision question.
- ATmega644A and revision footprints — the same analysis on a larger die.
FAQ
Can workarounds be identified without symbols? Yes. They are structural patterns, and they do not depend on names.
Should workarounds be removed from a reconstruction? No. Annotate them instead. Removing one that is still needed creates an intermittent fault.
Does the A revision change the lock bits? No. The state machine is stable across the family.
Is a duplicated register write always a workaround? Not always. It can be a compiler artefact from a volatile access. Context decides.
Conclusion
A revision leaves two records: the vendor’s, which may be terse, and the firmware’s, which is detailed and specific. Reading the second is a matter of recognising three patterns and asking what each one protects. Doing so turns an image into a change log for the silicon it was written against.
ATmega128A: EEPROM Endurance and the Pages That Wear Out
Flash and EEPROM are both non-volatile and both wear out. They differ in how fast, and the difference matters when a device arrives with data that looks damaged: it may not be damaged, it may be worn.
An EEPROM byte tolerates a large but finite number of write cycles. A product that updates a counter every few seconds will exhaust that budget within its service life, and a product that updates the same byte every second will exhaust it quickly.
The mechanism
Writing an EEPROM cell moves charge through a thin oxide. Each write degrades the oxide slightly. Enough writes and the cell no longer holds its state reliably: it reads as the erased value, or reads inconsistently between passes.
Two properties make this different from random corruption:
It is localised. Wear happens where writes happen. A log record at a fixed address wears that address out while the rest of the array is untouched.
It is predictable. Given the write rate and the endurance figure, the failure point is arithmetic, not chance.
That combination is useful diagnostically: a device whose damage is concentrated in a small, repeatedly-written region is showing wear, not damage.
Where wear appears
| Pattern in the EEPROM | Likely cause |
|---|---|
| One byte stuck at the erased value | That byte exhausted |
| A fixed-width record blank at one offset | Fixed-address logging |
| Damage spread evenly across a region | Rotating log, uneven rotation |
| Whole array blank | Erased, or never written |
The second and third rows are the interesting pair. They distinguish a naive design from a considered one: a firmware that writes a record at the same offset every time has no rotation, and a firmware that rotates has spread the wear.
Reading the image tells you which, and that is a statement about the design’s quality as well as its history.
How firmware mitigates it
Wear levelling, in its simplest form, is a cursor: the firmware keeps a write index in a header and appends records cyclically, so consecutive writes land in different cells. More elaborate schemes track per-block counters.
Both leave traces in the code:
- An index variable that wraps at a limit.
- A header structure with a generation counter.
- Code that scans for the most recent valid record at start-up.
The third is the clearest signal. A start-up scan through records looking for the newest valid one is a ring buffer in EEPROM, and it means the design anticipated wear.
Why this matters for reading a worn device
A worn byte does not announce itself. It reads as a value, and if that value is plausible the reader accepts it. The check that reveals wear is reading the array twice and comparing, plus looking for a region whose values are systematically at one extreme.
Isolated bytes that read as FF in an otherwise populated record are the classic signature. They are not erased — the page was written — they are exhausted.
Distinguishing that from an intentional blank requires knowing what the firmware expects to write there, which comes from reading the code rather than the data.
The reading order, with wear in mind
- Signature, fuses, lock byte.
- EEPROM read, before any operation that could erase it. Record EESAVE.
- EEPROM read again, comparing byte for byte.
- Identify repeated-write regions by structure: fixed width, cyclical content.
- Correlate with the firmware’s logging code.
Step 5 is where a data anomaly becomes an explanation. A record blank at one offset, in a firmware that writes to that offset every cycle, is wear — and that is a conclusion no amount of staring at the bytes will produce.
Related notes
- ATmega128P and binary layout — the other array on the same die.
- ATmega1280P and EESAVE — surviving through an erase.
- ATmega32PA and EEPROM survival — the fuse that decides it.
FAQ
How many writes can an EEPROM byte take? A large but finite number, given in the datasheet. Frequent logging can exhaust it within a product’s life.
Can worn cells be recovered? The value is gone. What can be recovered is the pattern and the design that produced it.
Is wear visible in a single read? Partly. A second read exposes cells whose state is no longer stable.
Does reading wear the array? No. Only writes do.
Conclusion
Wear is localised, predictable, and often mistaken for corruption. Concentrated damage in a repeatedly-written region, isolated bytes at one extreme, and a firmware that logs to a fixed offset together describe an exhausted page rather than a broken device — and the code, not the data, is what makes that attribution possible.
ATtiny48V: What the V Suffix Costs You, and What the Lock Bits Actually Do
The ATtiny48V is a 28-pin tinyAVR with 4 KB of flash, 256 bytes of SRAM, 64 bytes of EEPROM, 24 general-purpose I/O pins, an 8-bit and a 16-bit timer, SPI, TWI and a six-channel 10-bit ADC. It shares its pinout with the ATmega48 family, which is the reason it appears in designs that were laid out for a larger part and then cost-reduced.
The V suffix is the part that usually gets skipped over in discussion. It is not a package or temperature variant. It is a lower voltage range — 1.8 V to 5.5 V instead of 2.7 V to 5.5 V — and it comes with a lower maximum clock frequency. That single trade has more effect on whether a recovered binary behaves identically than the lock bits do.
What the ATtiny48V actually contains
| Item | ATtiny48V |
|---|---|
| Core | 8-bit AVR |
| Flash | 4 KB (2048 × 16) |
| SRAM | 256 bytes |
| EEPROM | 64 bytes |
| I/O pins | 24 (PORTA, PORTB, PORTC, PORTD) |
| Timers | 1 × 8-bit, 1 × 16-bit |
| Serial | SPI, TWI (I²C) |
| A/D converter | 6 channels, 10-bit |
| Operating voltage | 1.8–5.5 V |
| Max clock at 1.8 V | 4 MHz |
| Max clock at 4.5 V | 12 MHz |
| Packages | 28-pin PDIP, 32-pin TQFP, 32-pin MLF |
| Programming | ISP over SPI, high-voltage parallel |
The frequency table is the part to read twice. Speed grade is a function of supply voltage on these parts, not a fixed number: at 1.8 V the core is limited to 4 MHz, at 2.7 V to 8 MHz, at 4.5 V to 12 MHz. A design using the ATtiny48V at 3.3 V is a design running at 8 MHz or below, whatever the crystal says.
Why the clock ceiling is a recovery constraint
Flash contents describe what the firmware does. They do not describe how fast it does it. On an AVR, the relationship between the two is fixed by a small number of values that live outside flash:
- The clock source, set by the low fuse byte: internal 8 MHz RC, internal 128 kHz RC, external crystal, or external clock.
- The CKDIV8 bit, which divides whatever that source produces by eight.
- The timer prescaler registers, written at runtime.
A binary recovered from an ATtiny48V that ran at 8 MHz and reflashed into a device configured for the internal 128 kHz oscillator will execute the same instructions and produce completely different timing. Delay loops become 62 times longer, software PWM frequencies collapse, and any protocol with a bit-time budget stops working. This is not a subtle failure — it is total — and it is caused by a fuse byte, not by the flash.
The 64-byte EEPROM raises the same point in a different form. It is small enough that many designs skip it entirely and put configuration in flash, but where it is used it typically holds exactly the values that are easiest to lose: an offset correction, a node address, a run-hour counter. Sixty-four bytes that are absent from a recovered image produce a device that boots, runs, and reports the wrong numbers.
Lock bits and the erase that clears them
The ATtiny48 uses the standard AVR two-bit lock field with inverted polarity.
| Mode | LB1 | LB0 | Effect |
|---|---|---|---|
| 1 | 1 | 1 | No memory lock |
| 2 | 0 | 1 | Further programming of flash and EEPROM disabled; verification allowed |
| 3 | 0 | 0 | Further programming and verification disabled |
The distinction that matters in the field is between modes 2 and 3. Mode 2 leaves the verify path open, which is what a manufacturer wants when the device has to be tested after programming but must not be changed. Mode 3 closes both.
Both modes are subject to the same rule:
The chip erase operation erases the flash and EEPROM arrays and resets the lock bits.
On AVR parts the lock bits are stored in the same non-volatile array as the data they protect, so there is no sequence in which they are cleared independently. The erase clears the bits and the memory at once. This is a structural property of the family, and it means that the state of the lock bits in a device taken off a board is informative about how the part was manufactured and uninformative about how to read it.
The self-programming path
The ATtiny48 supports self-programming: the application can write to its own flash through the SPM instruction, using the RWW and SPM control registers. On a 4 KB part with no separate boot section, that means the application itself contains any routine that modifies flash.
Two practical notes follow. First, flash-write routines are the easiest thing in a recovered image to identify, because SPM requires a fixed four-instruction sequence that cannot be rearranged: write the address low byte, the address high byte, the data low byte, the data high byte, in that order, before executing SPM. Nothing else in a tinyAVR program looks like that.
Second, if a design uses self-programming for calibration storage, some of the constants in a recovered image may be written during operation rather than present at manufacture. A dump taken from a device that has been running for years is a dump of a device that has modified itself, and a fresh device programmed with that image is not necessarily a device in its original state. This is worth knowing before treating a recovered image as the factory firmware.
What a complete image contains
- 0000h–07FFh — 2048 × 16 bits of flash
- lock bits — LB1:LB0, in the non-volatile array
- fuse bytes — low fuse (clock source, start-up, CKDIV8), high fuse, extended fuse
- 64 bytes of EEPROM, separate address space
- calibration byte — read from the signature area at manufacture, sometimes written into flash by the application
The fuse bytes are the part that a flash-only image omits, and on a part whose speed grade is a function of supply voltage they determine more of the observable behaviour than anything in the first 4 KB.
Related notes
The non-V ATtiny48 has the same die at a 2.7 V minimum, and the ATtiny48A is the later revision of the same part number. The smaller 20-pin ATtiny45 uses the same lock bit field, and the ATtiny4313 extends the same architecture downward in pin count.
FAQ
What does the V suffix mean on an ATTINY48V? It marks the lower-voltage variant: 1.8–5.5 V rather than 2.7–5.5 V. The maximum clock frequency at low supply is correspondingly lower.
Do the lock bits survive a chip erase? No. The chip erase clears the lock bits together with the flash and EEPROM arrays, in one operation.
Is lock bit mode 2 unreadable? No. Mode 2 blocks further programming but still permits verification. Mode 3 blocks both.
Can the ATtiny48V write its own flash? Yes, through the SPM instruction. The four-instruction write sequence is distinctive and easy to locate in a recovered listing.
Does a flash dump reproduce the device’s behaviour? Only alongside the fuse bytes. Clock source and CKDIV8 set the timing base that every delay and bit-time in the firmware depends on.
Conclusion
The ATtiny48V is not a difficult part to characterise. Four kilobytes of flash, two lock bits, a small EEPROM and a fuse byte that sets the clock. The difficulty is in the last item, because it is the one that a flash-only view leaves out, and on a V-suffixed part the clock ceiling is low enough that getting it wrong changes the behaviour of every timed operation in the program.
Break IC ATmega2561 Program
Break IC ATmega2561 and copy mcu atmega2561 Program from its flash memory, the security fuse bit of the microcontroller atmega2561 will be unlocked after the process;

The device is manufactured using Atmel’s high-density nonvolatile memory technology. The On-chip ISP Flash allows the program memory to be reprogrammed in-system through an SPI serial interface, by a conventional nonvolatile memory programmer, or by an On-chip Boot program running on the AVR core.
The boot program can use any interface to download the application program in the application Flash memory. Software in the Boot Flash section will continue to run while the Application Flash section is updated, providing true Read-While-Write operation if Break microcontroller pic16c65b eeprom.
By combining an 8-bit RISC CPU with In-System Self-Program mable Flash on a monolithic ch ip, the Atmel ATmega2561 is a powerful microcontroller that provides a highly flexible and cost effective solution to many embedded control applications.
The ATmega2561 AVR is supported with a full suite of program and system development tools including: C compilers, macro assemblers, program debugger/simulators, in-circuit emulators, and evaluation kits after recover mcu pic16f687 software.
Each device in the ATmeg2561 family differs only in memory size and number of pins. Table 1 summarizes the different configurations for the six devices.
Port A is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port A output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port A pins that are externally pulled low will source current if the pull-up resistors are activated when copy microcontroller pic16f677 code.
The Port A pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated.
The Port B pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port C output buffers have symmetrical drive characteristics with both high sink and source capability.
As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if the clock is not running.
STM32F746: Why Two Reads of the Same Address Disagree
Every recovery job rests on a simple assumption: an address has a value. On this part that assumption needs a qualifier, because the processor does not read memory. It reads a 4 KB data cache, which reads memory when it has to. Between the two there is a window in which the cache holds a newer value than the memory does, and during that window the answer to “what is at this address” depends entirely on who is asking.
That is not a fault and not a rare condition. It is the normal state of a running device with a write-back cache, and it is the reason a live acquisition can produce an image that is neither the flash contents nor the RAM contents but a mix of both, frozen at slightly different moments.
A core that does not always read memory
The core in this device is a Cortex-M7 with a 4 KB instruction cache and a 4 KB data cache. The two caches are not symmetric in their consequences. The instruction cache matters for performance measurement and almost never for extraction, because code is not being modified while it runs. The data cache matters for extraction, because application state lives in RAM and application state is exactly what a recovery is trying to capture.
The data cache is write-back. When the core stores a word, the store lands in the cache line and the line is marked dirty. The write to the memory behind it is deferred until the line is evicted, either because the cache needs the space or because software explicitly cleans it. On a device running an interrupt-driven loop, evictions happen constantly and the window is short. On a device sitting in a tight polling loop with a small working set, the same lines can stay dirty for a very long time.
| who reads the address | what it sees | why |
|---|---|---|
| the core, through a normal load | the newest value | it reads the cache first |
| the core, after a cache invalidate | whatever memory holds | the invalidate discarded the dirty line |
| a debug probe over the AHB access port | whatever memory holds | the probe bypasses the cache entirely |
| a DMA engine | whatever memory holds | DMA is not cache-coherent on this part |
| a second bus master reading through the same path | the memory value | there is no snooping hardware |
The third row is the one that decides how a live read has to be done. A debug probe connected over the access port sees memory, not cache. That is usually described as an advantage, because it gives a stable and repeatable view. It is only an advantage if the value being captured is one that has already been written back.
Three ways this shows up in a recovery
The first is a torn parameter block. A device that stores calibration values in RAM and writes them back to flash on a timer will have the newest values in the cache. A probe reading the RAM copy gets the previous set. If the recovery reports the RAM copy, the customer compares it against the values the device displays on its own screen and finds a mismatch that looks like a reading error.
The second is a program that appears to branch into uninitialised memory. The stack holds return addresses and local variables. When the stack region is dirty, the memory image of it is older than what the core is actually using. A disassembly built from stack contents then produces a call chain that does not correspond to anything.
The third is the most expensive: a state machine captured one step behind. A device that keeps its current mode in a static variable, written on every transition, will show the previous mode in a probe read. The customer’s complaint is that the extracted logic is wrong, and the extracted logic is a faithful copy of a value that was true a few hundred microseconds earlier.
| observation | plausible wrong conclusion | what is actually happening |
|---|---|---|
| RAM copy differs from the value shown on the device’s display | the read is unreliable | the display reads the cache, the probe reads memory |
| a variable changes on every read of the same address | the device is still running | the cache is being evicted between reads |
| the stack looks like it belongs to an older call | the image is corrupted | the newest stack frames were never written back |
| a watchdog counter reads as a stale value | the watchdog is not running | its update sits dirty in a cache line |
Reading around it
Three approaches work, and they differ in how much they disturb the device.
| approach | how it works | trade-off |
|---|---|---|
| halt the core, then clean and invalidate the cache | after the halt, force a write-back of all dirty lines, then read | the halt changes timing; a device with a watchdog may reset unless the watchdog is frozen |
| read the cache contents as well as memory | extract both and reconcile | requires knowing the cache geometry and the mapping, which is where errors enter |
| capture under a repeated read, then take the modal value | read the same range many times and keep the most frequent value per address | slow, and wrong for genuinely changing data |
The first is what a careful bench does, and it has a side effect worth stating in the report: freezing the watchdog is a change to the device’s configuration. On a part where the watchdog runs from an independent oscillator and cannot be frozen while the core is halted for more than a short window, the halt has to be short enough to fit inside one timeout period. Sequencing the work — read the flash first, which does not need a halt, then halt briefly for the RAM — is the usual way to keep the window inside the budget.
The same problem in reverse: DMA
The cache problem has a mirror image that shows up during validation rather than acquisition. Code that writes a buffer and then hands it to a DMA engine must clean the cache first, or the DMA transfers the old contents. Firmware written for this family therefore contains cache maintenance calls scattered around every peripheral transfer, and their absence is itself informative.
A program that never touches the cache maintenance registers either runs with the cache disabled, which is common in bootloaders and in code that has been ported from an older part, or it does not use DMA at all. Both are visible in the image: the first from writes to the cache control block early in startup, the second from the absence of DMA stream configuration. When neither is present and the program clearly drives a peripheral at speed, the image is probably not the one that was running.
What belongs in the report
The deliverable should say which regions were captured with the core halted and which while running, whether cache maintenance was performed, and what the watchdog configuration was during the halt. It should also state the freshness caveat for any RAM region whose contents are used as evidence, because a customer who builds a behavioural specification from a stale state machine will not discover the discrepancy until the specification is already written.
For the memory layout that makes the same point from the other direction — a RAM map where the region bases do not follow the obvious pattern — STM32F765 heximal recovery covers the trap in detail. The path a device takes when it boots from its factory ROM rather than its own flash is in STM32F745 heximal extraction, and the external memory side of the same family, where the timing registers describe the attached part, is in STM32F769 program recovery. A worked case on a smaller member of the family with firmware encryption in play is at STM32F722RET6 firmware restoration.
FAQ
Does the cache affect a flash read? No. Flash is not cached in the data cache; the accelerator in front of it is a prefetch path, not a cache that can hold uncommitted writes.
Is halting the core enough to get a consistent view? Only if the cache is cleaned afterwards. Halting without cleaning leaves the dirty lines where they were, and the memory image stays old.
Can the cache be disabled to avoid the problem? It can, and some benches do, but disabling it changes execution timing enough to break devices with tight real-time loops, which defeats the purpose of reading a live system.
Conclusion
The single assumption underneath every extraction — that an address has a value — is true only once the writes have landed. On a part with a write-back data cache, the interval before they land is where inconsistent images come from, and the fix is procedural rather than technical: halt, clean, read, and state what was done. A recovery that reports a stable number without saying how it was obtained has reported a value, not a fact.
Break Chip PIC12CE518 Binary: Sixteen Bytes That Decide the Job
Sixteen bytes is not much. It fits in a single line of a hex file, it disappears in any discussion of array sizes, and it is the reason a job on this device is worth doing carefully.
This part is the variant of the eight-pin family that carries a small data memory alongside its program array. Five hundred instruction words of one-time-programmable program memory, forty-one bytes of RAM, sixteen bytes of data memory that survive power-off, and one configuration word. The total content of the device is smaller than a single page of text, and every part of it has a different claim on the word copy.
The complete inventory
| Region | Size | Written by | Recoverable when protected |
|---|---|---|---|
| program array | about 512 instruction words | the engineer, once | no |
| data memory | 16 bytes | production line or field firmware | separately protected |
| configuration word | one word | the engineer, once | sometimes |
| RAM | 41 bytes, volatile | the running program | not applicable |
The table is short and it is complete. There is no hidden region, no factory information area worth chasing, no second array. What makes the device interesting is not its size but the ratio: the data memory is three percent of the content and the majority of the value in a repair job.
Why sixteen bytes matter
A product built around an eight-pin part is a product with severe constraints. The pin count forces the programming interface to share pins with the application, the RAM is too small for anything elaborate, and the code is measured in hundreds of instructions. In that environment, anything that must persist across power cycles has exactly one place to go.
What lands in sixteen bytes, in practice:
- a serial number or a short identity code, because the product cannot afford a label
- one or two trim values measured at production, because the analogue function needs them
- a state flag or a usage counter, because the product needs to know something about its history
- nothing at all, on the many products that never write to it
That last case is common and it is not a disappointment. A data memory reading as uniformly blank is an answer: it says the product’s per-unit variation is in the code, not the data, and it redirects attention to comparing two units’ program arrays instead.
The reading channel is the engineering problem
Eight pins, and the programming interface needs several of them. On this family the programming pins are shared with general-purpose I/O, which means the tool has to hold the device in programming mode while the application circuit is trying to drive the same lines.
Three consequences follow, and they are the practical content of this job.
The load matters. A pin that drives an LED through a resistor, or an input with a pull-up, presents an impedance the programmer was not designed for. The symptom is an intermittent failure to enter programming mode that depends on the board and not on the device.
The supply matters. The programmer supplies the target during programming, and a board with its own regulator will fight it. Where the board cannot be powered down, the regulator has to be isolated or the device lifted.
The clock matters. Entry into programming mode is a timing sequence relative to the supply rising, and a board with a large decoupling network rises slowly. Devices that program perfectly on a socket and refuse on the board are almost always a supply-rise timing issue.
None of these are device faults, and all of them present as device faults. A bench with a socket for the package and a known-good reference device distinguishes them in minutes.
One-time programmable means the read is a one-shot
The program array cannot be erased. Nothing in the read path writes, so a read is safe by construction — unless the programmer performs a blank check with an erase cycle, which some production tools do as a matter of routine. On this device that destroys both the array and the job.
Two habits protect against it. Configure the tool explicitly for a read-only operation rather than relying on its default. And read the data memory first, because it is the region with no backup anywhere and the region a wrong tool setting would take with it.
Reading the data memory is a separate operation
The sixteen bytes are addressed through the same register interface as the rest of the small register file, and they are read by a sequence that is not the same as reading the program array.
That separation has a practical benefit: the data memory can be read on a device whose program array is not readable through the interface, because the protection bits are separate. On a device where the code is lost, the sixteen bytes may still come out, and on a product with a per-unit trim value that is a usable outcome.
The reverse is also true and worth stating: a device whose data memory is protected may still yield its program array. The two protections are independent, and the order of a read should be chosen with that independence in mind rather than fixed in advance.
What a delivery contains when the total is under a kilobyte
A short list, and it should not be padded.
- the program image, with the word-width convention stated
- the sixteen data bytes, in address order, with blank bytes marked
- the configuration word decoded
- the package type and whether the device is in a socket or on a board
- a statement of which regions were read through the interface and which were unavailable
The fourth item looks like paperwork and is not: a device read in a socket and the same device read in circuit can produce different results, and recording which was done makes a later discrepancy explicable.
Comparing two units is often the fastest route
Where two units of the same product are available, compare their sixteen bytes before attempting anything clever. If they differ, the differing bytes are the identity and the trim, and their positions are known immediately. If they are identical and blank, the product stores nothing per unit and the copy question reduces to the program array alone.
That comparison takes less time than reading either device and it answers the most important question in the job: whether the data memory is worth pursuing at all.
For the smallest flash members of the same pin-count family, where the array can be rewritten but the reading channel constraints are identical, PIC12F635 program recovery covers the physical side. The device without any data memory, where the whole question of the sixteen bytes disappears, is treated in PIC12C671 image copying. And for the same relationship between program and data arrays expressed on an 18-pin part with far more room, PIC16C72 software copying shows how the proportions change.
ATmega1280: 4 KB of EEPROM Is Not a Small Flash
A hundred-pin microcontroller with 128 KB of flash, 8 KB of SRAM and 4 KB of EEPROM invites a comparison that is intuitively appealing and wrong: that the EEPROM is a small flash array, so the two can be treated as one memory of 132 KB. They cannot, and the reason is not the capacity. It is that they are addressed by different mechanisms, written by different mechanisms, and destroyed by different mechanisms.
Getting that distinction wrong in a recovery produces a file that looks complete and is not, and it usually happens at the exact moment when the data matters most.
Two spaces, two access paths
The flash array is read through the program counter during execution and through a pointer pair for constant data. The EEPROM is read through three registers: an address register pair, a data register, and a control register whose bits start an operation and report when it has finished.
| property | flash | EEPROM |
|---|---|---|
| size on this part | 128 KB | 4 KB |
| address space | program, word-addressed | data, byte-addressed |
| write unit | page | byte, with an internal erase-write cycle |
| write time | milliseconds per page | milliseconds per byte |
| endurance | tens of thousands of cycles | hundreds of thousands of cycles |
| erase as the unit | yes | no, the write includes the erase |
The last row explains why the EEPROM is the better place for a serial number. A flash page rewrite destroys the whole page; an EEPROM write touches one byte. A design that stores a counter and increments it once per hour would destroy a flash page in weeks and never wear out the EEPROM.
The write cycle is slow, and the code knows it
An EEPROM write takes milliseconds, which is an eternity for a 16 MHz core — tens of thousands of instruction cycles. Firmware cannot proceed to the next write until the current one completes, so every design contains a polling loop waiting on the busy flag, or an interrupt driven from the ready condition.
That polling loop is one of the more reliable landmarks in an unfamiliar image. It is tight, it reads the control register, it branches back to itself, and it appears wherever persistent data is written. Finding it locates the data-writing routines, and those routines are the ones that define the data layout.
The interrupt-driven variant is worth distinguishing. A design that enables the ready interrupt and writes from the service routine is one that decided the main loop could not afford the wait, which usually means the EEPROM is written from a state machine that also does something time-sensitive. That in turn suggests the data is being logged rather than configured.
Three reasons a byte reads as 0xFF
Erased is 0xFF. That single fact produces a class of misreading that is expensive because it looks like an answer.
A byte of 0xFF can mean the location has never been written since the part was manufactured, because the factory state is the erased state. It can mean the location was erased as part of a whole-device operation. And it can mean a write was interrupted, or a write failed, leaving the location in the erased state rather than holding either the old or the new value.
| reading | most likely cause | how to confirm |
|---|---|---|
| a block of 0xFF in an otherwise populated region | deliberate erase, or a write that never happened | check the surrounding record structure for a sequence gap |
| 0xFF at the very end of the array | never used | nothing to confirm; it is the expected state |
| scattered 0xFF inside a record | failed write | the record’s own checksum will disagree |
| the whole array 0xFF | erased device, or a read that returned nothing | read a known-non-blank location, or read the fuse bytes |
Distinguishing these requires structure, not more reading. If the data has records with sequence numbers or checksums, a gap and a checksum failure separate the cases immediately. If the data is a bare parameter block with no structure, the distinction may be unresolvable from the contents alone, and saying so is better than guessing.
What 4 KB actually holds
The size is large enough that the contents are not a handful of settings. On a part with this much EEPROM the array usually contains one of three things, and they read very differently:
- A parameter set with a header, a version byte and a checksum. Compact, often under a hundred bytes, and the rest of the array is erased.
- A rolling log. Records of fixed length walking through the array, each with an increasing sequence number or a timestamp, overwriting the oldest when the end is reached. The newest record is the answer a customer usually wants, and finding it means ordering by sequence rather than by address.
- A calibration table indexed by sensor or channel. Nearly full, with regularity across the array and values that vary smoothly between neighbouring entries.
The three are distinguishable at a glance in a hex dump, and telling the customer which one they have is often more useful than the dump itself, because it tells them what the device was doing.
Delivering it without merging it
The EEPROM contents belong in their own file. Merging them into the flash image destroys the address-space distinction and produces a file that no programmer can use correctly, since the two regions would be written to the same device through different mechanisms at different addresses.
The deliverable is therefore the flash image, a separate EEPROM image with its base address stated, the fuse and lock state as read, and a note describing the structure found in the EEPROM: header, record length, sequence field, checksum.
Where the design also keeps data in the flash array as constants, ATmega1280V program recovery covers the addressing that makes those reachable. The same three-way 0xFF ambiguity applied to a smaller data page is in ATtiny85V software recovery, and the erase interaction with protection in ATmega1280 flash recovery.
FAQ
Can the EEPROM be read while the flash is locked? Often yes, because the lock bits govern the flash array. The EEPROM has its own protection bit and it is frequently left unset.
Is the EEPROM erased by a chip erase? It depends on a fuse bit that decides whether the EEPROM is preserved through the erase. Read that bit before running one.
Why is the write so slow? The internal cycle performs an erase and a write per byte. The time is the physics of the floating gate, not a firmware inefficiency.
Conclusion
Treating a 4 KB EEPROM as a tail of the flash array produces a merged file that is useless and a data structure that is misread. Separated, it is the part of the device most likely to hold something irreplaceable: a serial number, a calibration, a log of what the unit did before it failed. Read it through its own registers, deliver it as its own file, and describe its structure in words.
ATmega640V: Wait States and the Voltage Squeeze on an External Bus
An external memory bus is a timing contract. The processor asserts an address, the external device takes some number of nanoseconds to drive data, and the processor samples it at a defined point. Everything about that contract is expressed in nanoseconds, and nanoseconds do not care what the supply voltage is — but the drivers do.
The V grade lowers the operating voltage. That makes the chip’s output drivers weaker and its input thresholds move, while the external device’s access time stays exactly the same. The margin that was comfortable at five volts becomes thin at three, and the part of the system that fails first is the one with the longest wire.
Why this matters for an examination
On a device with an external bus, a read that returns wrong data is ambiguous. It can be:
- The flash array, read incorrectly.
- The bus, sampled incorrectly.
- The external device, genuinely holding different data.
- The firmware, having configured the bus wrongly for its own voltage.
The last one is the interesting case, because it is a design decision preserved in the image. If the start-up code sets zero wait states on a bus that needed one, the product may have worked on the engineering bench at five volts and failed in the field at three. Recovering such a device means recovering a design that never fully worked.
The three knobs
| Setting | What it controls | Failure when too small |
|---|---|---|
| Wait states, low region | Extra cycles added before sampling | Data sampled while the bus is still settling |
| Wait states, high region | Same, for the upper window | Same, but only on external code fetches |
| Chip-select setup | How early the select asserts | The device sees a select and an address in the wrong order |
All three are register fields written in the first few dozen instructions of the start-up path. All three are invisible from outside the chip. All three are recoverable from a good image — which means an image read incorrectly can be misread as a firmware bug.
The order of diagnosis
Because a bus fault and a memory fault produce the same symptom, the diagnosis has to proceed from the outside inward:
- Supply measured at the die. Not at the bench supply. A part at the bottom of its range with a long ground return is already marginal before any bus activity begins.
- Signature read. If this fails, the interface is the problem, not the bus.
- Internal array read twice. If two reads agree, the internal path is trustworthy and any later anomaly belongs to interpretation, not transmission.
- Start-up block disassembly. Read the wait-state fields. A zero where the external part’s access time demands a one is an explanation, not a guess.
Step 3 is the one that separates the two halves of the problem, and it costs one extra pass.
What a marginal bus looks like in data
The characteristic signature is not random noise. It is a small number of bits that resolve differently depending on which access preceded them — the classic pattern of a bus that is sampled just before it settles. Address bit patterns follow data patterns, because the slowest transition is the one that changed most recently.
In a dump of internal flash this never appears, because the internal array is not on the external bus. It appears when the firmware’s own behaviour is being observed, or when external memory is being read through the part.
That is why an internal read can be perfect while the product misbehaves. The defect is in the board, not in the array.
Voltage and the erase threshold
One more interaction belongs here. The charge pump that performs chip erase draws current in bursts, and at the low end of the V range that current causes a supply dip. A dip during an erase can leave a page partially erased, which reads as a mixture of FF and residual values.
The check is trivial: after erasing, read the whole array and confirm it is uniformly FF before writing anything. On a V part this check is not optional — it is the only way to know that the erase, the supply, and the socket were all adequate at the same moment.
Why the grade exists at all
A battery product needs to keep running as the cell drains. The V grade makes that possible by extending the operating range downward, and the cost is paid in timing margin on every peripheral that has to meet a fixed external specification.
The external bus is the worst case for that trade, because the other end of the contract does not know or care about the supply. That is a design fact, not a defect — and on the bench it means the electrical envelope deserves more attention than the protection bits, at least until the data is trustworthy.
Related notes
- ATmega640 and the external memory interface — why part of the program may not be on the die.
- ATmega640PV and the low-voltage bus — the same trade in a different revision.
- ATmega324V and read margins — the same voltage logic without a bus.
FAQ
Do wait states affect internal flash reads? No. They apply to the external bus only. Internal array access is unaffected.
Can wait states be changed without recompiling? Only by changing the register value, which is written by code. There is no fuse for it.
Is a bus fault detectable from the image alone? No. The image tells you what was configured, not whether the configuration worked in the physical board.
Does the V grade reduce maximum clock frequency? Yes, at the low end of the supply range. That interaction is exactly why the timing margin shrinks.
Conclusion
On a part with an external bus, voltage and timing are one subject. The V grade widens the supply range and narrows the timing margin at the bottom of it, and the registers that compensate are inside the image. Reading the internal array correctly is the easy half; recognising a bus configuration that cannot work at its own supply is the half that explains the symptom.
ATtiny261: The Calibration Constants Are the Product
Most small microcontrollers are chosen for their pins or their price. This one is usually chosen for its converter: a ten-bit successive-approximation unit with a differential input stage and a selectable gain ahead of it, which lets a part that costs very little measure a bridge, a thermocouple or a shunt without any external amplifier.
That has a direct consequence for a recovery. The code in such a device is mostly plumbing — timer, serial port, a state machine — and the part that a competitor or a repair engineer actually wants is a small set of constants that convert raw counts into physical units. Those constants are not a secret algorithm. They are the product.
What the converter offers
The array is 2 KB, the SRAM and EEPROM are 128 bytes each, and the package has twenty pins. Within that budget the analogue side is unusually complete: eleven single-ended channels, differential pairs selected by the input multiplexer, two gain settings ahead of the converter, and an internal reference selectable in software.
| feature | setting | where it shows in the image |
|---|---|---|
| input selection | single-ended or differential pair | channel bits written to the multiplexer register |
| gain | unity or a high fixed gain | the same register, adjacent bits |
| reference | internal or an external pin | reference bits written during initialisation |
| conversion mode | single shot or free running | the enable and start bits in the control register |
The differential gain setting is the one worth understanding. A bridge output is a few millivolts sitting on a common-mode level of half the excitation, and unity gain would spend most of the converter’s range on the offset. The gain stage multiplies the difference before conversion, which is why a design can resolve microvolts with a ten-bit converter and why the same converter is useless for that job without it.
How a conversion sequence reads in assembly
The register-level pattern is short and repetitive: select the channel, start a conversion, wait for the completion flag, read the result register pair, and either use the value or accumulate it.
Two details distinguish a careful design from a rushed one, and both are visible after the fact. The first is whether the code discards the first conversion after a channel change. The sample-and-hold circuit needs time to settle when the multiplexer moves, and the first result after a switch is systematically wrong by an amount that depends on the source impedance. Designs that discard it read cleanly; designs that do not have a fixed offset on every channel change.
The second is whether the reference is allowed to settle. Switching the reference and converting immediately produces a first reading that is low, and on a device that samples once per second that error is invisible in testing and present in every unit.
The constants that carry the model
After the raw counts come the arithmetic. A conversion is turned into a physical value by an expression of the form offset plus gain times the count, sometimes with a second-order correction term, and on a part this small the arithmetic is fixed point because there is no floating-point unit and no room for a library.
That makes the constants readable. A sixteen-bit gain term, a signed offset, a shift count that implements the division — those three values state the sensor’s sensitivity, its zero point and the scaling the designer chose. For a bridge sensor the gain term is proportional to the excitation voltage and the gauge factor; for a thermocouple it corresponds to the Seebeck coefficient over the reference junction range; for a current shunt it is the reciprocal of the shunt resistance.
A disassembly that labels those constants is therefore more useful than one that labels the control flow, because the control flow is generic and the constants are specific to the product.
Averaging, and what it says about the noise budget
A single conversion on this converter has a noise floor set by the reference and the sample time. Designs that need better resolution do not change hardware; they average. The number of samples averaged appears in the image as a loop count, and the loop count states the designer’s noise budget directly.
Four samples buys one bit. Sixteen buys two. A design averaging sixty-four conversions per reading is telling you that it needed three more bits than the converter could give and was willing to spend the time. That number also predicts the sample rate, which is often the specification the customer cares about and never has documentation for.
| samples averaged | resolution gained | typical use |
|---|---|---|
| 1 | none | monitoring a supply rail |
| 4 | 1 bit | a slow temperature reading |
| 16 | 2 bits | a bridge with moderate precision |
| 64 or more | 3 bits or more | a scale or a precision instrument |
What the deliverable contains
For a code-level recovery the return set is the flash image, the EEPROM as a separate file, the fuse and lock state as read, a disassembly with the converter configuration annotated, and — the part customers use — a table of the calibration constants with the arithmetic they feed, written out as an equation that reproduces the device’s output from a raw count.
That last item is often the whole engagement. A customer with a failed unit and no source code does not need the state machine; they need to know what the number on the display means.
The wider vector table of this part’s larger sibling is covered in ATtiny261 vector table notes, and the marginal-array read problem in ATtiny261V code recovery. For a device where the analogue front end is external and the constants therefore live in a separate part, see ATtiny4313 code recovery.
FAQ
Is the gain stage internal? Yes, it sits ahead of the converter and is selected through the same register that chooses the input pair.
Why discard the first conversion after a channel change? The sample-and-hold needs to settle. The first result after a multiplexer change carries an error proportional to the source impedance.
Can the calibration constants be recovered without the code? They can be measured from the device by applying known inputs, but reading them from the image is faster and exact.
Conclusion
On a converter-centric part the firmware is mostly scaffolding and the value is in a handful of numbers. Reading the multiplexer configuration says what is measured; reading the averaging count says how precisely; reading the gain and offset constants says what the numbers mean. Those three together reconstruct the product’s measurement model without needing a single line of the original source.