Archive for the ‘Break IC’ Category
PIC18F26K22: Sixty-Four Kilobytes and the Address That Crosses a Line
Up to 32K of program memory, an address fits in sixteen bits and almost every instruction can carry one. At 64K that stops being true, and the architecture deals with it the way architectures do: by making the common case nearly free and the general case visible.
That visibility is the useful part. A 64K image contains structural evidence of its own layout — branch sequences that only appear when code crosses a boundary, and table accesses that reveal which half of the array they address. Reading those correctly is the difference between understanding an image and misreading it.
What changes at this size
The program counter is wider than the address fields in most instructions. A two-word call or goto can carry a full address; a single-word branch cannot. So the compiler emits different code depending on where the target is.
| Target | Encoding | Size |
|---|---|---|
| Within reach of a short branch | Relative or page-relative | One word |
| Anywhere in the array | Full address | Two words |
| Computed | Via a table or a register pair | Several instructions |
Consequently, code that was written once and compiled at two memory sizes produces different instruction sequences — and code compiled for 64K contains long-form branches in places where a 32K build would have short ones. Neither is wrong, and they disassemble differently.
The boundary’s visible effects
Three artifacts appear in 64K images and rarely in smaller ones:
Two-word branches clustered at module boundaries. Functions that live far from their callers are called with long forms. A cluster of them marks the edge of a compilation unit.
Address high-byte manipulations. Loading a twenty-bit address requires setting an upper byte before the call. Those instructions are a signature, and they tell you the target’s location without following it.
Jump tables with widened entries. A switch statement compiled at 64K stores entries that carry more than a word each, so the table’s stride changes. A reader who assumes a word stride reads the table wrong.
Reading the image in the right order
- Find the reset vector. It is a long-form branch, since it jumps from the bottom of the array to wherever reset code lives.
- Follow it and identify initialisation. Clock, ports, peripherals — the sequence is regular.
- Map the interrupt vector table. Its entries identify handlers, and their targets are within the first half on most builds.
- Decode outward from each entry point rather than linearly.
- Treat everything unreferenced as data and test it for regular structure.
Step four matters more at this size than at 8K. In a small image, a linear disassembly is wrong but short; in a 64K image it is wrong and enormous, and the errors accumulate into a listing that appears to describe code and does not.
Constant tables at this size
With 64K available, firmware for this part tends to carry more tables and fewer computed values. That is good news for a reader: tables are structure, and structure is legible.
The common forms:
- Lookup tables indexed by a measurement. Regular stride, monotonic values, ends that correspond to the measurement’s range.
- Text strings. ASCII in word form, and recognisable immediately.
- Transition tables for a state machine. Small integers with regular repetition.
The first is the most informative. A monotonic table with a regular stride is a calibration curve, and its endpoints tell you the range of the quantity being measured — which is often the most commercially specific fact in the firmware and the one least protected by any bit.
The 64K configuration, and the protection that comes with it
At this size the array divides into four blocks, each with its own protection bits. That granularity is a practical advantage during analysis: a partially protected device can yield three quarters of an image, with the boundary at a block edge rather than an arbitrary address.
The same granularity applies to write protection, and the two are independent — a device with all four blocks read-protected and none write-protected is a device that can be erased but not read, which is a specific and recoverable situation.
Expectations worth setting
- A 64K image is not five times the work of a 13K image; it is perhaps twice, because structure dominates.
- The most informative content is usually in the tables, not the code.
- Protection at this size is per block, so partial outcomes are normal.
- A full read of a protected device yields nothing, and no reading strategy changes that.
Related reading
- PIC18F25K22 and what a restoration must reproduce — the configuration and data that a 64K image does not carry.
- PIC18F23K22 and the two protection gates — the bits that decide whether a read is possible.
- PIC18F67K22 and 128K of program memory — where the same boundary problem appears twice.
FAQ
Does the instruction set change at 64K? No, but the encodings do. Long-form branches appear where short forms sufficed on smaller parts.
Why do switch tables look different? Entries widen, so the stride changes. Assuming a word stride misreads the table.
How many protection blocks does this part have? Four, each with independent read and write protection bits.
Is a linear disassembly ever correct at this size? Rarely. Entry points and references are the reliable anchors.
Are tables more informative than code? Frequently, because they encode the application’s domain knowledge in a legible form.
Conclusion
Sixty-four kilobytes changes the instruction encodings before it changes anything else, and those changes are visible in the image as long branches, widened tables and high-byte manipulations. Reading from entry points outward, and treating unreferenced regions as data, turns a large image into a structured one — and in this size class the structure is where the information lives.
PIC18F46K80: The Verification Step Is a Map of the Design
A device that can be updated in the field needs a way to decide whether the application it holds is complete. The usual answer is a checksum over a defined range, computed at start-up and compared against a stored value. That is a robustness feature, and it is also the most informative few dozen instructions in the whole image.
The reason is simple: to verify the application, the loader must know where the application begins, where it ends, and what the result should be. Those are exactly the facts a reader wants, and they are stated by code that has to work.
What the verification defines
Four quantities, all of them structural:
- the start address of the application;
- the length, or the end address;
- the algorithm — a simple sum, a CRC, or something more specific;
- where the expected value is stored, and how it is protected against being wrong.
| Quantity | What it tells you | Why it matters |
|---|---|---|
| Start address | Where the application lives | Fixes the memory map |
| Length | Where the application ends | Distinguishes code from trailing constants |
| Algorithm | CRC width and polynomial | Constrains the image, and detects tampering |
| Stored value location | Where the loader keeps its reference | A second place the image is described |
A CRC rather than a checksum is a meaningful detail: it implies the vendor cared about detecting corruption in transit, which in turn implies the update path is used in conditions where corruption is possible.
Why the loader is often readable
The loader must function for updates to work, so it is frequently left writable, and on some products it is left readable as well — particularly where the vendor’s own service tooling reads it back to confirm a version.
Even when it is protected, the loader’s behaviour is observable through the update interface: an identification exchange gives a version, an erase command gives the granularity, and a verification failure gives the range indirectly, because the loader will report a mismatch after a known number of bytes.
That last technique is worth knowing: send an image that is deliberately short and observe where the loader stops or what it reports. The boundary it complains about is the boundary it checks.
Configuring the destination
For replication, the verification step adds a requirement that is easy to miss: the destination image must produce the expected checksum. If the original’s expected value is stored in the loader’s region, and the rebuilt application differs by one byte, the loader will refuse to start it.
Three ways to handle that:
- Rebuild to match, which is impractical for anything but a trivial difference.
- Update the stored expected value, which requires writing to the loader’s region.
- Disable verification, which requires modifying the loader.
On a device where the loader is in a write-protected boot region, none of the three is available without erasing and rewriting the whole device — which is a decision, not a step.
What this tells you about the protection design
A vendor who verifies the application but leaves the loader readable has made a specific trade: reliability over secrecy. A vendor who protects both has chosen secrecy and accepted that field diagnosis is harder.
The pattern of which region is protected, and which is not, is a fairly reliable indicator of how the product was maintained. Products with readable loaders were usually built with a service organisation in mind; products with everything closed were usually built to be replaced.
Reading the application through the loader’s expectations
Once the start address and the length are known, the application’s extent is bounded. That is a small but real advantage during analysis: a disassembly can be limited to the region the loader considers the application, and everything outside it can be treated as loader, configuration or unused.
It also resolves an ambiguity that arises on 64K parts: whether a block of content near the top of the array is application data or an artefact. The loader’s range answers it.
Practical sequence
- Determine whether a loader exists — update interface behaviour, or a boot region in the image.
- Extract the verification parameters: start, length, algorithm.
- Record the expected value and where it lives.
- Bound the application region using those parameters.
- Read the application region if permitted; treat the loader as a separate program.
- For replication, decide how to handle verification before writing anything.
Step six prevents the most common replication failure on these devices: a correctly copied application that will not start because the loader’s stored checksum refers to the original.
Limits
- The verification tells you the application’s extent, not its content.
- A loader that verifies only a portion of the application leaves the remainder unbounded.
- If the expected value is stored in a protected region, it cannot be read, and the checksum can only be inferred by experiment.
Related reading
- PIC18F25K80 and the CAN interface the loader serves — the transport the verification protects.
- PIC18F45K80 and reconstruction from behaviour — where the loader’s bounds become useful constraints.
- PIC18F65K80 and recording the result as a file — how the bounded region is represented.
FAQ
Why do loaders verify the application? Because an interrupted update leaves an incomplete image, and jumping into it is worse than not starting.
Does verification protect the code? No. It detects corruption. Confidentiality comes from the configuration bits.
Can the expected value be read? If it is in an open region, yes. Otherwise it has to be inferred by experiment.
What happens if a copied application fails verification? The loader refuses to transfer control, and the device appears dead while being intact.
Is a CRC always used? No. Simple sums are common, and a sum detects less — which is itself information about how much the vendor worried about corruption.
Conclusion
Verification code is a specification of the memory map written by someone who needed it to be exactly right. Start address, length, algorithm and stored value together bound the application, tell you how the vendor thought about reliability, and predict the failure mode of a copy that ignores them.
PIC18F26K80: Getting Past “Secured Flash” as a Description
“Secured flash” is a conclusion, not an observation. It is what someone writes after a programmer returned zeros, and it collapses a set of quite different device states into one word. On a 64K part with four application blocks, a boot region and separate table-read protection, that collapse loses almost everything useful.
The useful version of the statement names which region is closed. That is obtainable, and it changes what the next step should be.
The layout that the word hides
The array is organised as a boot region at the bottom and application blocks above it, with protection applied per block. The boot region holds the reset vector and, usually, a loader.
| Region | Holds | Protectable separately |
|---|---|---|
| Boot region | Reset vector, loader | Yes |
| Application block 0 | Application entry, interrupt vectors | Yes |
| Application block 1 | Application code | Yes |
| Application block 2 | Application code | Yes |
| Application block 3 | Application code, constants | Yes |
Six independent decisions, in other words, each of which can be open or closed, readable or write-protected. A device described as “secured” is a device where all of them happen to be closed — or a device where one is closed and the read attempt hit it first.
The reading that distinguishes them
Protection state is held in configuration, and configuration is readable through the programmer. So the first operation on an unknown device is not a read of the array; it is a read of the configuration, followed by interpretation.
From it you learn, per block, whether reads are gated and whether writes are gated. Four combinations per block, six blocks, and the pattern tells you what the vendor intended:
- Boot region closed, application open — the vendor’s loader is secret, the customer’s code is not.
- Boot region open, application closed — the loader is documented and the application is the asset.
- Everything closed — the device shipped locked, and the only question is whether the password-equivalent exists (on this family there is none; the bits are the mechanism).
- Nothing closed — the device is readable and the word “secured” was a mistake.
The fourth case is more common than it should be, and it is worth eliminating before any technique is considered.
Behavioural evidence when blocks are closed
A device with a closed application block still runs, and its behaviour is measurable. Three measurements give a good deal:
Start-up timing. Measured from reset release to first output activity, it bounds the initialisation work — and a device with a loader spends longer at start-up than one without.
Bus traffic. A K80 in a CAN product emits frames from the first moments after reset if its loader announces itself. Silence at start-up then traffic later is a different architecture from traffic throughout.
Response to the loader entry condition. If the device accepts an update, the loader is present and functional, and the update format describes the application’s layout.
The third is the most valuable and the least used. A device that can be updated over CAN is a device whose application begins at a known address, whose image has a known format, and whose verification is defined — all stated by the loader’s behaviour.
What cannot be recovered and why
On this family there is no password to supply. Protection is a set of configuration bits; a device with the read bits set will not produce its array for any sequence of operations that does not first erase it.
That makes the honest boundary sharp:
- Configuration is recoverable.
- Behaviour is recoverable.
- The array is not, once read protection is set, unless it is erased first.
Any technique that claims otherwise is either erasing the device and calling the result a recovery, or reading a device that was not protected as believed.
A procedure that avoids waste
- Read and interpret the configuration.
- Identify which blocks, if any, are open, and read those.
- If the boot region is open, read the loader and extract the application’s expected layout.
- If a field-update path exists, exercise it and record the protocol.
- Decide, with the evidence, whether the remaining unknown justifies further work.
Step five is a decision, not a formality. On a device whose function is understood from behaviour and whose update path is functional, the value of further work is often zero — and saying so is more useful than continuing.
Related reading
- PIC18F26K80 and the protection settings in detail — the same silicon analysed from the bits rather than the regions.
- PIC18F25K80 and the CAN update path — the interface that usually decides the outcome.
- PIC18F23K22 and why erasing is not unprotecting — the mistake that turns a diagnosis into a loss.
FAQ
Is there a password on this family? No. Protection is configuration bits, and there is no value to guess.
Can a partially protected device be read? Yes, block by block, subject to the bits for each block.
Does a closed block still execute? Yes. Protection gates reads, not execution.
What does a working CAN update imply? That a loader exists at a known location, with a known image format and a defined entry point.
When is further work not worth it? When behaviour and update path together describe everything the project actually needs.
Conclusion
“Secured flash” describes a conclusion rather than a device. On the K80 family the device has six independent protection decisions, a readable configuration that states them, and behaviour that continues regardless. Naming which region is closed — and accepting that the array itself is not available once it is — turns a vague problem into a short, decidable list.
PIC18F25K80: CAN Is a Second Door Into the Same Room
When a device is chosen for its CAN controller, the product usually speaks CAN for more than control. Field updates over the vehicle or machine bus are common, and where they exist there is a bootloader in the device listening for them. That loader is a documented, functional, write-capable interface — and it is present whether or not the array is protected.
Starting from that interface rather than from the programmer changes the shape of the work. It answers different questions, and on many projects it answers the only questions that mattered.
What the CAN path provides
A bootloader reached over CAN typically implements:
- an entry condition, triggered by a specific frame or a pin state at reset;
- an identification exchange, so the host knows which device and which version answered;
- an erase command;
- a data transfer with addressing;
- a verification step, and a jump to the application.
Each of those is a fact about the design. The identification exchange especially: a loader that reports a version and a part identifier is telling you what the vendor considered sufficient to distinguish builds.
| Loader feature | What it reveals |
|---|---|
| Entry trigger | How production and service enter the loader |
| Identification | Part, version, sometimes a variant code |
| Erase granularity | How the vendor thinks about the memory map |
| Address scheme in transfers | Where the application is expected to live |
| Verification | Whether the loader checksums, and over what range |
The message objects are in RAM
The CAN controller holds its filter and message objects in RAM, configured by firmware at start-up. That matters for two reasons.
First, the configuration is a fingerprint. The set of identifiers a device accepts, the masks it applies, and the number of objects it uses describe the protocol it implements, and all of it is observable on the bus without any access to memory.
Second, because the objects are in RAM, they are not part of the flash image. A recovered image does not contain the device’s CAN configuration — it contains the code that writes it. Reproducing the configuration means running the code, not copying a table.
Reading the bus instead of the array
For a device on a working machine, the bus is a richer source than the array in one specific respect: it is live. Behaviour under real load is available, and the firmware’s decisions are visible as messages.
A capture gives:
- the identifier set, and therefore the message structure;
- the cycle times, and therefore the scheduler’s period;
- the payload layouts, and therefore the signals, scaling and units;
- the fault handling, when something is disconnected.
The fourth item is the one people forget to provoke. Disconnecting a sensor and capturing what the device does reveals its fault policy, which is usually a distinctive part of the firmware and not derivable from normal operation.
What the loader gives up
A CAN bootloader designed for field updates cannot be protected against being used. If it were, updates would not work. So on a device with a loader, there is always an interface that will accept a program.
That has a consequence worth stating: a locked K80 device with a working CAN loader is not a lost device. It is a device that can be restored to a known image at any time — and if the goal is a working unit, the loader is the whole solution.
The distinction between restoring and reading remains the same as everywhere else in this family. The loader writes. It does not read. A device restored through CAN is a device running a known program, not a device recovered.
When both are needed
Some projects need both: the unit restored, and the original’s behaviour understood. In that case the order is:
- Capture CAN traffic from the working device, including fault conditions.
- Exercise the loader and record its protocol.
- Restore a replacement unit with a known image and confirm it behaves like the original.
- If the original’s program is still required, treat that as a separate problem with separate techniques.
Step three is often the end of the project. Organisations frequently commission a “firmware recovery” when what they need is a supply of working units and a documented protocol — both of which are obtainable without reading a protected array.
Practical notes
- CAN bit timing depends on the device clock; a capture at the wrong rate produces error frames rather than data.
- Loader entry conditions vary; some require a specific frame within a short window after reset, others a pin held low.
- The loader may preserve the data array during updates, which means calibration survives a reflash — useful when restoring, and a source of surprise when it does not.
- A device that answers on CAN is running code; a failure to read its array says nothing about whether it is alive.
Related reading
- PIC18F26K80 and the protection settings on the same silicon — the gates that the loader operates behind.
- PIC18F26K80 and boot block mechanics — where the loader lives in the array.
- PIC18F45K80 and the 44-pin variant — the same family in a different package.
FAQ
Can the CAN loader read the existing program? No. It writes and verifies; it has no read command.
Does code protection stop the loader working? No. The loader writes, and protection gates reads.
Are CAN settings part of the flash image? The code that configures them is; the registers themselves are RAM and are rebuilt at start-up.
Why capture during faults? Because fault handling is firmware behaviour that normal operation does not exercise.
Is restoring through CAN the same as recovery? It produces a working unit running a known image. It does not recover what was there.
Conclusion
On a part built for CAN, the bus is a second door: a write channel with a protocol that must remain functional, and a live view of the firmware’s decisions. For most projects that door is enough, and the harder question — what was in the array — turns out not to be the one that needed answering.
PIC18F45K20: Two Kinds of “Blocked”, and Telling Them Apart
A device that will not give up its program has failed in one of two quite different ways. Either the read completed and returned a substitute value, or the read never completed at all. The first is protection working as designed. The second is an interface problem, and treating it as protection destroys devices.
The distinction is not subtle once stated, and it is constantly lost in practice, because both outcomes look like “the programmer could not read it”.
The two events
Substituted read. The device responds, in the expected number of cycles, with a value that is not the content. On this family the substitute is a fixed pattern, and it is stable: reading the same address ten times returns the same value ten times.
Failed read. The device does not respond, responds with an error, times out, or returns a value that changes between attempts.
| Symptom | Meaning | Next step |
|---|---|---|
| Stable uniform values | Protection, or genuinely erased | Read configuration |
| Values change between reads | Interface, voltage, or sampling | Fix the connection |
| No response at all | Entry sequence failed | Check programming mode |
| Response, wrong length | Wrong part selected in the tool | Correct the device selection |
The third row is the one that wastes the most bench time and is the easiest to fix: the device never entered programming mode, so nothing was ever attempted.
Entry, and why it fails quietly
Programming mode is entered by a specific sequence on specific pins, sometimes with a raised voltage. If the sequence is not applied correctly — a pin held by a circuit on the board, a capacitor slowing an edge, a supply that does not reach the required level — the device simply carries on executing its program.
Nothing reports this. The programmer’s tool may report a failure, or may report success with implausible data, depending on how it handles the absence of a response.
On this family the low-voltage programming option changes which entry methods are accepted, and a device configured without it requires the higher-voltage sequence. That is a configuration fact with a hardware consequence, and it is invisible until someone tries to connect.
Why stable values suggest protection
A protected read goes through the same path as a normal one: the address is presented, the array is accessed, and the substitution happens at the output. The timing is identical and the result is deterministic.
That determinism is the diagnostic. Protection produces the same answer every time; a marginal connection does not.
The caveat is erasure: an erased block also returns a stable value. So stability separates “device or interface” but not “protected or blank”. The configuration word separates those, and it is why every article in this series begins with it.
Protection as a set of blocks
Four blocks, each with a read bit and a write bit. The state that matters is the pattern, not the aggregate:
- all open — a development device or an oversight;
- first open, rest closed — a loader is visible;
- first closed, rest open — the vectors are gone;
- all closed — a shipped, locked product.
Each pattern leads to a different next step. The second suggests exercising the update path. The third suggests decoding without anchors. The fourth suggests behavioural work or stopping.
What is worth trying, in order
- Confirm entry: does the device respond at all, with the expected device identifier?
- Read the configuration; it states the pattern.
- Read a known-populated address; the reset vector if the first block is open.
- Read each block in turn; record the boundary.
- Only then consider the device’s behaviour.
Steps one to four take minutes and eliminate the majority of misdiagnoses. Everything expensive comes after, and most of the time it is not needed.
The cost of getting it wrong
The specific cost on this family is that the remedy for a failed entry looks like the remedy for protection: erase the device and start again.
On a device whose content was expendable, that works. On one whose content was the point of the exercise, it converts a solvable problem into an unsolvable one — and it does so at the moment when the diagnosis was least certain.
That is the argument for the sequence above, and it is why the sequence appears in every article about this family.
Related reading
- PIC18F44K20 and the order of operations — what to do once a read has succeeded.
- PIC18F43K20 and the two-block array — the same analysis with fewer boundaries.
- PIC18F23K20 and configuration as the first read — the read that distinguishes protection from erasure.
FAQ
How do I tell protection from a bad connection? Repeat the read. Protection is deterministic; a marginal connection is not.
Why does the device not enter programming mode? Usually a pin held by the circuit, an edge slowed by capacitance, or a configuration that disables the low-voltage entry.
Does an erased device read like a protected one? Yes at a single address. The configuration distinguishes them.
Which block holds the vectors? The first, along with start-up code.
What erases the protection? A full erase, which also erases the content. That is why the diagnosis comes first.
Conclusion
Two kinds of blocked read, distinguishable by repetition and by whether the device responds at all. Separating them costs minutes and prevents the one irreversible mistake available on this part — erasing a device whose contents were the reason for the exercise.
PIC18F43K20: Eight Kilobytes, Two Vectors, and No Room to Hide
There is a relationship between array size and how much a firmware can conceal. Eight kilobytes is roughly four thousand instructions, and after start-up code, a serial stack and a couple of tables, the application-specific part is small — small enough that the code’s structure is largely determined by what the device does.
The 40-pin package sharpens this. More pins means more I/O, which means the firmware’s job is visible at the edges. A device with eight pins could be doing almost anything; a device with thirty-two I/O pins is doing something specific, and the specific thing is measurable.
Where the vectors sit, and why it matters
On this family the reset vector and the interrupt vectors occupy the bottom of the array, in the same protection block as the start of the application. That has a consequence for partial reads: if the first block is protected, the vectors are gone.
Losing the vectors costs more than losing the same number of bytes elsewhere, because the vectors are the primary anchor for disassembly. Without them, entry points have to be found by scanning for branch-shaped words and testing candidates — a slower and less certain method.
| Block | Typical contents | What is lost if closed |
|---|---|---|
| First | Vectors, start-up, small functions | Every entry point |
| Second | Application body | Control flow details |
| Third, fourth (if present) | Tables, remaining code | Domain constants |
On an 8K part there are two blocks, so the loss is coarser: half the application, including the anchors.
Reading with a missing lower block
If the first block is closed and the second is not, the image begins with code whose entry points are unknown. Three techniques recover the structure:
- Scan for call targets. A call instruction encodes its destination. Collect every destination in the readable region and the frequently-called addresses will emerge as functions.
- Look for the interrupt handlers by shape. A handler saves context, does a little work, restores and returns. The shape is recognisable even without the vector that points at it.
- Use the tables. On a small part, tables are indexed by measured quantities; the instructions that read them identify the routines that use them.
None of these is as good as the vector table. All of them are enough to produce a call graph for a four-thousand-instruction image.
The pin map as a specification
With 40 pins, the pin assignment is most of the specification. What can be measured without any access to memory:
- which pins are outputs, and their idle states;
- which toggle at a fixed rate, and therefore which timers are configured;
- which carry a serial protocol, and at what rate;
- which are analog inputs, from the presence of a reference and the shape of the readings.
Add the response of each output to a change in each input and the interaction structure appears. On a device this size that is often enough to describe the application completely, with the code contributing confirmation rather than discovery.
Protection on this part
Two protection concepts, as on the rest of the family: code protection per block, and write protection per block, plus table-read protection for reads from code.
For an 8K device the practical effect is stark. A protected part loses half its array at minimum, and a fully protected part loses all of it. There is no partial outcome that leaves a useful fraction, which is why the behavioural route matters more here than on a 64K part.
What an 8K image tells you about its compiler
Small images have a distinctive texture. A compiler optimising for size emits denser code, reuses registers more aggressively, and inlines short functions. The result is a listing where function boundaries are less obvious and where a routine may be entered at more than one point.
That texture is worth recognising, because applying a 64K-part reading method to an 8K image produces confusion: the code does not look like well-separated functions, because it was not written that way.
Expectations
- Half the array is the smallest useful unit of loss on this part.
- The vectors are worth more than their size.
- The pin map is a specification in its own right.
- A fully protected 8K device is a behavioural problem, and a short one.
Related reading
- PIC18F44K20 and the 16K version — what one more block buys.
- PIC18F23K20 and reading configuration first — the step that decides whether the lower block is available.
- PIC18F45K20 and four protection blocks — where granularity starts to help.
FAQ
How many protection blocks does an 8K member have? Two. On a device this size that is a coarse division.
Where are the interrupt vectors? At the bottom of the array, in the first block. If that block is closed, they are unavailable.
Can entry points be found without vectors? Yes, from call targets and handler shapes, at some cost in certainty.
Is the pin map really a specification? For a device with this many I/O pins, largely yes — it defines the interfaces the firmware serves.
Why does the code look unsmooth? Small-image compilers optimise for size, which merges and inlines functions.
Conclusion
An eight-kilobyte part in a forty-pin package is legible because it cannot afford to be otherwise. The vectors are the expensive loss, the pin map is the specification, and the analysis is short enough to complete. Where the array is closed, that brevity is the compensating advantage.
PIC18F13K50: Two Gates, Not One, on a USB Bootloader Design
Most discussion of protection treats it as one thing: a bit that stops a programmer reading the array. On a part with a USB bootloader that framing breaks down, because there are two audiences for the same memory — a programmer outside the device, and code inside it.
The two are gated separately. Code protection stops reads from outside. Table-read protection stops reads from code, whichever block that code happens to live in. A device can be protected against one and open to the other, and on parts designed for field updates that combination is not an accident.
Why a bootloader needs the application readable
A USB bootloader’s job is to receive a new application and write it into the array. Before writing, it typically verifies what is already there: a checksum, a version, a signature. That requires reading the application block.
If the application were protected against table reads from the boot block, verification would return zeros and the bootloader could not do its job. So the application is usually left readable from code, and protected — or not — against external reads.
The reverse applies to the bootloader. It is the vendor’s intellectual property and the customer’s application has no reason to read it. Table-read protection on the boot block makes the bootloader invisible to the application while leaving it executable.
| Setting | External read | Read from code | Typical use |
|---|---|---|---|
| No protection | Allowed | Allowed | Development |
| Code protect only | Zeros | Allowed | Application, verifiable by bootloader |
| Table-read protect on boot block | Allowed or gated | Zeros in boot block | Vendor bootloader |
| Both | Zeros | Zeros where protected | Shipped, fully closed |
What this means for an outside reader
The first practical consequence: a device that is readable from code is not therefore readable from a programmer, and the reverse. Establishing which gate is closed requires two different tests.
The second: table-read protection is enforced while code runs, so a debugger that halts the core and reads memory through the programmer interface is subject to the external gate, not the internal one. A device that returns zeros through the programmer and behaves normally in operation is consistent with several configurations, and the config word is the only reliable discriminator.
The USB interface as an observation point
A USB device announces itself. Enumeration transfers a device descriptor, a configuration descriptor, and string descriptors, and these are generated by firmware that lives in the array.
That makes enumeration a read of sorts — not of the code, but of strings and constants that the code emits. On a locked device, this is often the first concrete information obtained:
- Vendor and product identifiers identify the product family, and often the vendor’s design house.
- String descriptors frequently carry a product name and a firmware version.
- The device class narrows what the firmware does: HID, CDC, vendor-specific.
- Endpoint configuration describes the communication shape, which constrains the protocol.
None of that is the program. All of it is metadata the firmware must produce to work, and none of it is protected by a code-protection bit.
Recovering the protocol from the host side
Given a working device, the host-side driver or application is often available, and it documents the protocol by construction. Capturing the bus during normal operation gives the exchange formats, and the timing gives the frame rate.
For a device whose firmware cannot be read, the protocol plus the descriptor set plus the behaviour is a specification, and a specification is what a rebuild needs. This is the standard route for USB peripherals, and it is more reliable than it sounds because USB leaves so little room for variation in the lower layers.
What the protection actually costs
On an 8K part, protection has an unusually high price because there is so little array. The upper block, or the whole array depending on configuration, is a meaningful fraction of the device’s code.
That has an implication for what the protection was for. A vendor protecting an 8K USB part is usually protecting a small, valuable piece of logic — an authentication routine, a proprietary protocol handler, a calibration algorithm. Those are exactly the pieces where behavioural reconstruction is most difficult, because the behaviour is designed not to be observable.
The honest assessment: on this part, a fully protected device with a well-designed protocol is a hard target, and the realistic output is a device that speaks the protocol rather than a device that contains the same code.
Checks before drawing conclusions
- Confirm the part number from the descriptor string and the device marking; they do not always agree.
- Read the config word where possible; it settles which gate is closed.
- Test whether the bootloader still functions. A device whose bootloader responds can still be updated, which may be all that is needed.
- Distinguish “cannot read” from “cannot run”. A device that enumerates on USB is running code, whatever a programmer reports.
The fourth item eliminates the most common false conclusion in this family: a device reported as dead because a programmer could not read it, when in fact it boots and waits for a USB connection that was not present.
Related reading
- PIC18F14K50 and what USB descriptors leak — the same interface on the larger sibling.
- PIC18F14K22 and block-granular protection — the non-USB part with a comparable array.
- PIC18F23K22 and the difference between read and write gates — a third, independent restriction on the same array.
FAQ
Can a bootloader read a protected application? Normally yes, because code protection gates external reads while table-read protection gates reads from code, and the two are configured separately.
Does code protection stop USB enumeration? No. Enumeration is normal operation and does not require reading protected memory.
Is table-read protection defeated by a debugger? A debugger reading through the programmer interface is subject to the external gate. The internal gate applies to code that runs.
What can be learned from a locked USB device? Descriptors, strings, endpoint layout, protocol behaviour and timing — all without reading the array.
Does the bootloader remain usable on a locked part? Usually. Field update is the reason it exists, and blocking it would defeat the design.
Conclusion
The K50 family shows why “protected” needs a subject. Two gates, two audiences, four configurations, and a USB interface that leaks metadata regardless. Recognising the split turns a single opaque question into a short list of specific ones, most of which can be answered without touching the array.
PIC18F14K22: The Block Boundary That Decides What You Can See
Sixteen kilobytes of program memory on a 20-pin device, split into two halves. The split exists so that a bootloader written into the lower half can stay readable — or stay writable — independently of the application above it. It is a small feature with a large effect on what a read produces.
The effect is easiest to see as a table of outcomes, because on this part a read either works completely, fails completely, or produces exactly one visible half.
| CP1 | CP0 | Lower half | Upper half |
|---|---|---|---|
| 0 | 0 | Readable | Readable |
| 0 | 1 | Readable | Zeros |
| 1 | 0 | Zeros | Readable |
| 1 | 1 | Zeros | Zeros |
The third row is the one that matters in practice. It describes a device whose bootloader is protected and whose application is not — a configuration that appears in products where the vendor’s code sits below and the customer’s above.
Where the boundary falls
The two blocks divide the array at its midpoint: the lower block occupies the first half of the program memory, the upper block the second. On a 16K part that places the division at the eight-kilobyte address.
Everything about interpreting a partial read depends on that address being known exactly. A read that stops producing valid data at the midpoint is a read of a protected upper block. A read with a gap somewhere else is not.
This distinction is worth stating because it is routinely missed. A tool that reports “reads zeros after address X” invites the conclusion that X is a protection boundary, and on this part X must be the midpoint. If it is not, the cause is elsewhere: a transport failure, a device held in a state where the array is not accessible, or a reader configured for the wrong part.
Why a partially readable device is easier and harder
Easier, because half the code is available and half a program is a substantial amount of evidence. The visible block usually contains the vector table — reset and interrupts sit at the bottom of the array — so the reading starts with entry points.
Harder, because the two halves were written at different times by different people, and the interface between them is exactly the thing that is missing. A bootloader’s calls into an application are not in the application, and an application’s expectations of its bootloader are not in the bootloader.
The practical approach is to read the visible half completely, then use it to characterise the invisible half: what it is called, what it is passed, and when.
Reading a visible block properly
Half an image is not half a job. Three things need to be established before the visible half is useful:
- Where it ends. Confirm the last valid word and the first zero. The boundary should be the block edge; anything else means the read is not simply gated.
- What it contains. Vector table, initialisation, and — often — a version string, which identifies the build.
- What it expects. Calls into the missing region leave traces: arguments loaded before the call, return values consumed after it.
The third item is where a partial image earns its keep. A bootloader that calls an application entry point with a structure pointer reveals the structure’s layout from the bootloader’s side, even though the application’s own definition is invisible.
Configuration words, and the trap in reading them
The configuration words sit outside the protected region and are readable on this family. They confirm which of the four states in the table above applies.
The trap is that configuration is often rewritten by a bootloader at runtime. A device whose bootloader clears CP0 before jumping to the application, or restores it afterwards, presents different configuration depending on when it was read. Reading the configuration twice — once after reset, once after the application has started — resolves the ambiguity, and the difference between the two readings is itself informative.
Writing protection is a separate gate
This family also provides write-protect bits, one per block, and they are independent of the read-protect bits. A device can be read-protected and writable, or readable and write-protected, and the two states lead to different recovery options.
| Writable | Readable | What you can do |
|---|---|---|
| Yes | Yes | Read and rewrite freely |
| Yes | No | Erase and rewrite; original lost |
| No | Yes | Read, and treat the source as a reference |
| No | No | Neither; analysis is behavioural |
The second row is the common production configuration: readable protection removed by erasing. It is also where most accidental losses happen, because an erase looks like the first step of a recovery and is in fact a destruction.
Limits
- Two bits, two halves. There is no finer granularity to work with.
- A fully protected device yields nothing by reading, and the configuration word is the only confirmation available.
- Erasing to remove protection removes the contents with it, on this part more than on any larger one because there is so little to lose.
Related reading
- PIC18F13K22 and the single-bit case — the same silicon without the block split.
- PIC18F13K50 and bootloaders that cannot read their application — why a readable boot block does not imply a readable application.
- PIC18F23K22 and write protection as a separate gate — the second bit that changes what is possible.
FAQ
How many protection bits does this part have? Two, one per half of the array.
Where is the block boundary? At the midpoint of the program memory — for a 16K device, the eight-kilobyte address.
Can a partial read be produced deliberately? Yes, by protecting one block and leaving the other open. That is the bootloader configuration.
Is the configuration word readable when protected? Yes on this family, which is how the protection state is confirmed.
Does write protection hide contents? No. It prevents modification, not reading.
Conclusion
Two bits and one address define everything about what a read of this part can produce. The boundary’s position is the diagnostic: a transition at the midpoint is protection, a transition anywhere else is a different problem. And the sharpest practical warning on the family applies here most of all — erasing to unprotect destroys the very thing the exercise was for.
PIC18F13K22: One Protection Bit Over Eight Kilobytes
Protection on larger parts is a partition: several blocks, each with its own bit, arranged so that a bootloader can be readable while the application is not. On the 13K22 there is no partition. A single configuration bit covers the array, and the array is small enough that the vendor had no reason to offer more.
The simplicity is useful. It removes a whole category of questions — which block is which, which boundary matters, whether a sibling block is exposed — and replaces them with one: is the bit set or not. What it does not do is make the part easier to read. A single bit over eight kilobytes is still a closed door.
The array, and its shape
Eight kilobytes of program memory in a 20-pin package. The core addresses it in words, with instructions two bytes wide, which means four thousand instruction slots. Code plus constants have to fit, and on a part this size they usually consume most of it.
That density matters for recovery. On a device using 6K of its 8K, an erased flash looks quite different from a programmed one in aggregate statistics — not in any single word, since protected reads return zeros uniformly, but in the distribution of what a full read produces when protection is off.
| Configuration | Reads return | Interpretation |
|---|---|---|
| Unprotected, programmed | Actual contents | Direct read |
| Unprotected, blank | FF words |
Genuinely empty |
| Protected, programmed | Zeros | Gate active |
| Protected, blank | Zeros | Indistinguishable from above |
The last two rows are the same result, and no amount of reading separates them.
What the single bit actually gates
The protection bit affects data reads from the array. It does not stop the core from executing, which is why a protected device is a perfectly functional product.
On this family the gate is enforced at the point where the array is read as data: table reads through the program memory access mechanism, and reads from an external programmer. Both return zero. The instruction fetch path is unaffected, because a device that could not fetch its own instructions would not run.
This produces the standard consequence: code can execute, so the device’s behaviour is available; code cannot be read, so the instructions are not.
Why there is no partial image
On parts with block protection, a common outcome is a partial read: some blocks visible, others not, and a resulting image with holes whose edges correspond to block boundaries. On the 13K22 that outcome cannot occur from protection — the whole array is one unit.
Where a partial read does occur, it means something else:
- A read interrupted at the interface. The transport stopped, so the image is short.
- A device that has been partly erased. Sector-level erase exists even where read protection does not.
- A read taken at marginal conditions. Some words returned, others did not, and the pattern is noise rather than structure.
Distinguishing these from each other is easier than distinguishing them from protection, because each has a signature: a short read is contiguous, a partly erased device has FF regions, and a marginal read disagrees with itself on repetition.
Configuration recovery
Even when the array is closed, the configuration word can sometimes be obtained. On many parts the config word is readable through the programming interface even when code protection is enabled, because the programmer needs it to know how to proceed.
Where that holds, the config tells you:
- whether the code-protect bit is set (confirming the diagnosis rather than inferring it);
- whether the watchdog is enabled, which affects timing measurements;
- the oscillator selection, which tells you what the board must provide;
- the brown-out level, which constrains supply behaviour.
On a device where only eight kilobytes exist, knowing the oscillator and watchdog settings is a substantial part of reconstructing the environment the firmware ran in — often more useful than a few hundred bytes of recovered code would be.
Reading a part this small by other means
The productive approach on a locked 13K22 is behavioural, and the size helps:
The job is small. An application that fits in 8K does a bounded set of things. Enumerate the pins, and the set of possible functions is short.
The interfaces are few. Twenty pins, most of them shared with analog functions. Measuring which are digital, which are analog, and at what rates defines the application’s shape.
Timing is measurable. A control loop in an 8K part runs at a period you can observe on a pin. That period constrains the instruction count per iteration, which constrains the algorithm.
Assembling those three gives a specification that a rebuild can satisfy, and a rebuild is a legitimate outcome when the original cannot be read.
What to check before concluding a device is locked
Three things produce a false “locked” diagnosis:
- Reading through an interface that does not support reading that region.
- A programmer configured for a different part in the same family, which reads at the wrong addresses.
- An erased device, which returns the same value as a protected one.
The first two are configuration errors and cost nothing to exclude. The third is excluded by the config word, which is why reading it first is worth the effort.
Related reading
- PIC18F14K22 and protection with two blocks — what changes when the array can be partitioned.
- PIC18F14K50 and USB descriptors — information that leaks without reading the array.
- PIC18F23K22 and the difference between read and write protection — the second gate that is often confused with the first.
FAQ
Can a single block be read on this part? No. There is one protection bit for the whole array.
Does protection stop the device running? No. It affects data reads, not instruction fetches.
Is a zero read proof of protection? No. An erased array read through the same path can return similar values; the config word distinguishes them.
Is the config word readable when code is protected? On this family, usually yes — the programmer needs it. That is enough to confirm the diagnosis.
Can an 8K device be reconstructed from behaviour? More readily than a large one: fewer pins, fewer interfaces, a shorter list of possible functions.
Conclusion
The 13K22 reduces code protection to a single bit over a single array. That removes the block-boundary questions entirely and leaves one binary fact, which the configuration word usually settles. From there the work is behavioural, and eight kilobytes of application is a small enough space for that to be realistic.
Attack R5F51306BDFL MCU Flash Memory
Attack Renesas R5F51306BDFL MCU Flash Memory, and extract MCU IC Chip code out from microcontroller flash and eeprom memory, to make the MCU cloning which will provide the same functions;
Below are features of this Flash 32 BIT microcontroller:
Features
- 32-bit RX CPU coreMax. operating frequency: 32 MHz
Capable of 50 DMIPS in operation at 32 MHz
- Accumulator handles 64-bit results (for a single instruction) from 32-bit × 32-bit operations
- Multiplication and division unit handles 32-bit × 32-bit operations (multiplication instructions take one CPU clock cycle)
- Fast interrupt which is also important feature when clone R5F21276 microcontroller firmware
- CISC Harvard architecture with 5-stage pipeline
- Variable-length instructions, ultra-compact code
- On-chip debugging circuit
- Low power design and architecture
- Operation from a single 1.8-V to 5.5-V supply
- Three low power consumption modes
- Low power timer (LPT) that operates during the software standby state
- Supply current
High-speed operating mode: 96 mA/MHz

RENESAS R5F51306BDFL संरक्षित MCU फ्यूज बिट पर हमला करके सुरक्षित माइक्रोकंट्रोलर R5F51306BDFL स्रोत कोड को प्रोग्राम फ्लैश मेमोरी और डेटा eeprom मेमोरी से पुनर्स्थापित करें, बाइनरी फ़ाइल या हेक्सिमल सॉफ़्टवेयर के प्रारूप में स्रोत कोड को नए माइक्रोप्रोसेसर R5F51306BDFL में कॉपी करें;
Supply current in software standby mode: 0.37 mA
- Recovery time from software standby mode: 4.8 ms
- On-chip flash memory for code, no wait states
- Operation at 32 MHz, read cycle of 31.25 ns
- No wait states for reading at full CPU speed
- Programmable at 1.8 V
- For instructions and operands
- On-chip data flash memory
- 8 Kbytes (1,000,000 program/erase cycles (typ.))
- BGO (Background Operation)
- On-chip SRAM, no wait states
- 10- to 16-Kbyte size capacities
- DTC
- Four transfer modes
- Transfer can be set for each interrupt source.
-

atacar el bit de fusible de MCU protegido RENESAS R5F51306BDFL para restaurar el código fuente seguro del microcontrolador R5F51306BDFL desde la memoria flash del programa y la memoria eeprom de datos, copiar el código fuente en formato de archivo binario o software heximal al nuevo microprocesador R5F51306BDFL;
- ELC
- Module operation can be initiated by event signals without using interrupts.
- Linked operation between modules is possible while the CPU is sleeping.
- Reset and supply management
- Eight types of reset, including the power-on reset (POR)
- Low voltage detection (LVD) with voltage settings
- Clock functions
- External clock input frequency: Up to 20 MHz
- Main clock oscillator frequency: 1 to 20 MHz
- Sub clock oscillator frequency: 32.768 kHz
- PLL circuit input: 4 MHz to 8 MHz
- Low-speed on-chip oscillator: 4 MHz
- High-speed on-chip oscillator: 32 MHz ± 1 %
- IWDT-dedicated on-chip oscillator: 15 kHz
- Generate a 32.768 kHz clock for the real-time clock
- On-chip flash memory for code, no wait states

attaccare il bit del fusibile MCU protetto RENESAS R5F51306BDFL per ripristinare il codice sorgente protetto del microcontrollore R5F51306BDFL dalla memoria flash del programma e dalla memoria eeprom dei dati, copiare il codice sorgente nel formato di file binario o software esimale sul nuovo microprocessore R5F51306BDFL;
On-chip clock frequency accuracy measurement circuit (CAC)