Posts Tagged ‘reverse engineering IC protected file’
ATmega644A: What the A Revision Actually Changes
Part numbers that differ by one letter usually differ by more than one letter internally. An A suffix on a megaAVR marks a die revision: same pinout, same instruction set, same memory sizes, different silicon and a different errata list. For anyone examining a device, the interesting question is not what stayed the same but which of the differences can be observed from outside.
The answer is a short list, and every item on it is measurable without opening anything.
The signature byte is the observable difference
Tools identify a part by reading three signature bytes through the programming interface. The first two identify vendor and family and do not change across revisions. The third identifies the model, and it is where a revision can diverge.
When it does diverge, the consequence is procedural rather than technical. A programmer with a fixed device table refuses to talk to a part it does not recognise, and reports an error that sounds like a hardware fault. The part is fine; the table is stale.
The way around it is to stop using the tool’s identification step as a gate. Issue the signature read command directly, print the three bytes, and select the programming algorithm by family rather than by the tool’s model match. Every megaAVR in a given flash-size class uses the same algorithm, so the family-level selection is correct even when the model match fails.
Errata are where the revisions actually differ
Silicon revisions exist to fix things. A published errata sheet lists behaviours that deviate from the datasheet, and the list shrinks with each revision. Three categories recur across the megaAVR line:
- Analogue deviations. Brown-out thresholds that trip slightly outside the specified window, or an internal reference that drifts with temperature more than specified.
- Timing deviations. A peripheral that needs an extra cycle in a corner case, or a start-up delay that is longer than documented.
- Interface deviations. A programming command that behaves differently when issued at the edge of the specified clock range.
The third category is the one that lands on the bench. A revision that changed how the part responds to a fast programming clock will fail on a programmer tuned for the earlier die, and pass on a slower one. That is a testable hypothesis and worth testing before assuming a part is damaged.
What does not change, and why that is the useful part
The lock bit mechanism, the fuse map, and the page organisation of the flash are stable across revisions. That stability is what makes a family-level method work: the sequence signature, fuses, lock byte, then memory does not need to be rewritten for each revision.
| Item | Changes with revision | Same across revisions |
|---|---|---|
| Device signature, third byte | sometimes | — |
| Instruction set | — | yes |
| Lock bit state machine | — | yes |
| Fuse map | — | yes |
| Page size and buffer | — | yes |
| Errata behaviour | yes | — |
The practical reading of that table is: the procedure is portable, the timing and thresholds are not. Plan the method once; calibrate the electrical parameters per die.
Revision and the identity question
Devices get redesigned without a part number change far more often than with one. A revision suffix is a gift, because it tells you the vendor changed something and documented it. The absence of a suffix does not tell you the opposite.
When a customer supplies units that behave differently from each other, the first check is the signature byte, then the date code. Two units with the same signature and different date codes are the same design at different points in the production lifetime; two units with different signature bytes are different dies and may legitimately behave differently.
That distinction changes the answer to a common question — “is this a counterfeit?” A different revision is not a counterfeit. A different signature on a part sold as a specific revision is.
Reading a device whose revision you cannot confirm
The order of operations is unchanged: signature, fuses, lock byte, then memory. What changes is the interpretation of anomalies.
If a read fails at a fast clock and succeeds at a slow one, suspect revision-specific timing before suspecting damage. If a brown-out test trips earlier than the datasheet suggests, suspect the errata list before suspecting the supply. If an erase completes but the lock byte does not read back as expected, suspect the command sequence before suspecting the die.
Each of those is a hypothesis that costs one retest to falsify, and retesting is cheaper than the alternatives.
Related notes
- ATmega644 and page-level behaviour — the flash mechanics both revisions share.
- ATmega644PA and RSTDISBL — the fuse-level difference that removes ISP entry.
- ATmega32PA and the picoPower die — another revision family with its own electrical shifts.
FAQ
Is an A revision a different chip? It is a different die implementing the same specification, with corrections. Pinout, instruction set and memory map are unchanged.
Do I need a different socket? No. The package and pinout are the same, so the same adapter fits.
Can a revision change the lock bit behaviour? The state machine is stable across the family. What can differ is timing at the edges of the specified range.
Does a different signature byte mean the part is fake? Not by itself. It means the die is not the one the tool expected. Check the errata and the date code before drawing a conclusion about authenticity.
Conclusion
The A suffix is a documented die change, and its observable footprint is narrow: a signature byte that may differ, an errata list that shrinks, and analogue or timing behaviour that shifts slightly. The recovery procedure does not change with it. The electrical calibration does, which is why measuring beats assuming on every revision.
STM32F745: The Program in ROM That Decides How the Job Starts
Before any bench equipment is connected, a device of this family is already running a program that its owner did not write and cannot remove. It sits in a read-only region of the address space, it is entered by holding configuration pins at reset, and it implements a command set over a serial interface. It exists so that a blank device can be programmed at the factory, and it remains in every shipped product.
That program is the first thing worth talking to. Its responses classify the device in a way that no amount of documentation can, and its limits are precise enough to plan around.
What it is and how it is entered
The bootloader is selected at reset by sampling two configuration pins. One combination boots the application from flash, another enters the loader, and a third is reserved. Designs wire these pins to fixed levels or to a connector, and the choice is visible on the schematic in about thirty seconds.
| pin state | what the device does at reset |
|---|---|
| both low | boots the application from flash |
| one high | enters the factory bootloader, which then waits on a serial interface |
| the other high | reserved, behaviour not defined for application use |
| both high | enters the factory bootloader |
The loader negotiates a serial protocol: a synchronisation byte, an acknowledgement, then commands. It runs from an internal oscillator, so it works on a board with a dead crystal, a shorted peripheral or a program that never reaches its first instruction. That is the reason it is worth trying first on a device described as dead.
The command set
The set is small, and each command answers a different question.
| command | what it returns | what it establishes |
|---|---|---|
| initialise | the loader version and the list of supported commands | that the interface works and what else is available |
| identify | the device identification word and the flash size in kilobytes | which die is fitted and how large the array is |
| read | the contents of a memory range | the image, when permitted |
| write | acknowledgement, or an error | whether the target region is writable |
| erase | acknowledgement after a mass erase | that the array is now blank, irreversibly |
| read protection status | whether protection is set | the classification that decides the whole job |
| jump | none, the device restarts into the application | a clean exit without a power cycle |
The second row is useful even when nothing else works. A dead board that still answers identify has told you the die, the array size and, by implication, which memory map applies — the same information a debugger would give, obtained without a working clock.
The sixth row is the one to issue second, immediately after identify. It is a single transaction and it splits every incoming job into two categories.
How protection is enforced
Protection is not a single switch. It is applied per command, and the pattern is consistent.
| command | protection unset | protection level one | protection level two |
|---|---|---|---|
| identify | works | works | works, but the debug path is gone |
| read | works | refused | refused |
| write to unprotected region | works | works | works |
| mass erase | works | works, and clears the array | works, and clears the array |
| read protection status | reports unset | reports set | reports set |
| jump to application | works | works | works |
The asymmetry in the second and fourth rows is the whole story of this class of job. The loader will happily destroy the array on a protected device and will refuse to show it, which means the one command a protected device still accepts is the one that makes recovery impossible.
| what the loader says | what it means | what follows |
|---|---|---|
| read succeeds | protection is unset | read the array and finish |
| read refused, erase accepted | level one | the flash contents are not obtainable through this path |
| read refused, identify works | level one or two | distinguish by attempting a debug attach |
| no response at all | the loader is not being entered | check the pins, the interface and the supply before concluding the device is dead |
The one-word test
The most efficient habit in this work is to attempt a read of a single word immediately after identify, before anything else is discussed. It costs one transaction and it converts an open question into a decided one.
A successful single-word read establishes that the entire array is readable through the same path, because the protection check is per request rather than per region. A refusal establishes that no read command will work at any address, which removes an entire category of plan from consideration and points the work at the debug port and, if that is also closed, at physical access.
What it does not establish is whether the refusal was caused by protection or by a malformed request. The two produce the same negative acknowledgement on the wire, which is why the protection status command exists and why issuing it second is worth the extra transaction.
What the ROM path cannot do
Four things, each of which is proposed regularly as a workaround.
It cannot read a protected array, at any address, by any arrangement of commands. It cannot bypass the protection by starting a write and reading back the result, because a write to a protected region is refused before it reaches the array. It cannot be replaced with a modified loader, because the region is read-only by construction. And it cannot be made to run user code with the protection temporarily lifted, because there is no such state.
The one thing it can do that is sometimes overlooked is execute a jump to an address outside flash. A device whose application has been damaged can be given control of a small routine placed in RAM, and that routine can do what the loader will not — provided the protection permits reading the array at all. This is a narrow path and it depends entirely on the first classification; where protection is unset, the loader’s own read command is simpler and faster.
Where this fits in a job
The order is fixed. Enter the loader if the pins allow it, identify the device, read the protection status, attempt a one-word read, and only then plan the work. A job that starts at the debug port skips the cheapest diagnostic available, and a job that starts with physical work may be skipping two cheaper routes.
The member of the family with two USB controllers, where this loader is reachable over USB and where the descriptor tables provide the product’s own documentation, is in STM32F723 binary recovery. The protection levels described from the crypto side, including the case where a key is derived from the device identifier, are in STM32F756 code recovery, and the stripped member where the loader is often the only interface the product exposes is in STM32F722 code recovery.
FAQ
Does entering the loader erase anything? No. It runs from read-only memory and waits for commands; only the erase command changes the array.
Can the loader read a device protected at level one? No, and there is no sequence of commands that changes that. Level one also blocks the debug port.
Why does the loader still accept an erase on a protected device? Because erasing is how a protected device is returned to service, and the array is destroyed in the process. That is the intended behaviour and the opposite of a recovery.
Conclusion
The factory loader is the cheapest diagnostic instrument on the board: it runs without the application, it reports the die and the array size, and it classifies protection in two short transactions. Its refusal to read is not an obstacle to be worked around but a fact that redirects the job, and knowing that before quoting is worth more than any single piece of equipment.
R7FA2L1AB3CFM: The Sixty-Four-Pin Version Stops at the Number of Channels
Going from a hundred pins to eighty costs general-purpose I/O and some convenience. Going from eighty to sixty-four costs channels — and channels are different, because a design can absorb losing a spare port pin and cannot absorb losing the eighth sensor input it was built around.
That is what makes the sixty-four-pin body the interesting member of this group. It is the point at which the capacitive touch interface and the converter stop being described by the silicon and start being described by the package.
The same peripheral with fewer electrodes
The touch sensing unit is the second generation of Renesas’ capacitive block: self-capacitance and mutual-capacitance modes, automatic judgement, multi-frequency scanning to dodge noise, and the ability to run in a low-power state and wake the core.
None of that changes with the package. What changes is how many electrodes can be connected, because each electrode occupies a pin, and the pins that reach the touch multiplexer are a subset of the package’s pins.
The same is true of the converter. Nineteen channels exist in the design; how many of them are bonded out depends on how many pins the package has, and the higher-numbered channels are the ones that go first.
| resource | LQFP80 | LQFP64 | effect on a design |
|---|---|---|---|
| touch electrodes | more | fewer | key count, or a different sensing layout |
| converter channels | more | fewer | sensor count, or external multiplexing |
| serial flow control | often present | usually absent | software flow control |
| general-purpose I/O | more | fewer | serial peripherals instead of parallel |
The scan table is a data structure in flash
A touch design is not written as nineteen separate handlers. It is written as a table: which channels are enabled, what threshold applies to each, what baseline each channel settled on, and in what order the scan proceeds. That table lives in flash, is read at start-up, and is updated in RAM as the baselines drift.
For a reader this is the most informative structure in the whole image, because it states the design’s physical layout in numbers. The number of entries says how many electrodes the product has. The threshold column says how sensitive the design needed to be, which correlates with overlay thickness and electrode size. The baseline column says what the raw counts look like on a real board, which is the single most useful figure for anyone rebuilding the product.
A table with twelve entries read out of a firmware that was written for a hundred-pin board tells you either that only twelve electrodes were used, or that the build was retargeted. The distinction is usually visible from whether the unused entries are absent or present-and-disabled.
The converter sequence as a second fingerprint
The converter is configured with a channel sequence, and the sequence order is a design decision, not an accident. A design that reads a strain gauge, then a temperature sensor, then a battery voltage, will have those three channels in that order, because the sequence determines the settle time between conversions.
Reading the sequence gives the same information the touch table gives: how many analogue inputs the product actually uses, and in what priority. Combined with the touch table it produces a complete inventory of the product’s sensing surface, which for many customers is more valuable than the code.
| what the image states | where it lives | what it tells a customer |
|---|---|---|
| enabled touch channels | channel occupancy register image | number of keys or sliders |
| per-channel thresholds | constant table | sensitivity and overlay assumptions |
| baseline values | initialised table | raw counts on a real board |
| converter sequence | sequence registers set at start-up | which physical quantities are measured |
| averaging counts | loop bounds | resolution versus sample rate |
What happens when a larger build is restored smaller
Restoring a hundred-pin image onto a sixty-four-pin part produces a specific failure signature, and it is worth recognising because it looks like a firmware bug rather than a package mismatch.
Start-up completes. The touch scan runs and returns values. The converter runs and returns values. But the channels above the package’s limit return either the last value latched or a constant, because the input is not connected to anything. The firmware has no way to know: from its point of view the conversion completed successfully.
The result is a device that appears to work and reports a fixed reading for the inputs that do not exist. On a touch panel this shows up as a key that is always pressed or always released; on a sensor input it shows up as a channel stuck at full scale or at zero.
Reading order for this package
- Vector table: confirm base address, byte order, and that the image is complete.
- Clock configuration: establish the operating frequency, because every timing constant depends on it.
- Port configuration: collect the set of port bits and function selects written at start-up, which states the package the build expected.
- Touch table: count entries and read thresholds and baselines.
- Converter sequence: count channels and note the order.
- Everything else.
Steps three to five answer the package question from three independent directions, and they take less time than reading the main loop.
What the deliverable contains
The return set is the code flash image at 256 KB, the data flash separately, the configuration words, the identification words as read, a disassembly with the vector table resolved, and the extracted tables: touch channels with thresholds and baselines, and the converter sequence.
Those extracted tables are usually the part of the report a customer reads first, because they describe the product rather than the program.
The step down from eighty pins, and what it costs in general-purpose I/O rather than channels, is in R7FA2L1AB3CFN program recovery. The hundred-pin member and its field-by-field decoding are in R7FA2L1AB3CFP software extraction. A full treatment of the touch unit itself is at R7FA2L1A93CFM firmware recovery.
FAQ
Does the silicon have fewer touch channels on this package? The block is the same. What changes is how many of its inputs are bonded to pins.
Why does an unbonded converter channel not report an error? The conversion completes on whatever the input network presents. With no pin, that is not a signal, and the result is a constant rather than a fault.
Can a sixty-four-pin design be identified without the code? Sometimes, from the board. From the image it is straightforward, because the channel tables state it.
Conclusion
Sixty-four pins is where this group stops being a slightly smaller hundred-pin part and starts being a different product. The touch and converter front ends are limited by the package, and the firmware records those limits in tables that are easy to find and easy to read. Locating them answers the package question, the sensor-count question and, often, the customer’s actual question about what the device measured.