TI DSP MCU TMS320F28015 Program Recovering
The tms320f28015 is a specialized dsp device from texas instrument developed for demanding real-time digital control applications where fast calculation, deterministic response, and reliable embedded operation are essential. Devices in this class have been used in motor-control equipment, industrial automation, digital power supplies, renewable-energy systems, robotics, instrumentation, factory machinery, and other electronic platforms requiring precise control algorithms.

The combination of signal-processing capability and integrated peripherals makes the device particularly useful for executing complex control programs while maintaining efficient system operation. In many products, important firmware, calibration data, configuration parameters, and executable information are stored in internal flash and memory. After years of production, however, an engineering company may still have the original board while its development source code, binary, heximal, or project archive has disappeared. Our “ti dsp mcu tms320f28015 program recovering” service is designed for authorized customers facing this type of legacy-system challenge and seeking to preserve valuable embedded engineering information.

The TMS320F28015 devices include the four-pin serial peripheral interface (SPI) module. The SPI is a high-speed synchronous serial-I/O port that allows a serial bit stream of programmed length (one to eight bits) to be shifted into and out of the device at a programmable bit-transfer rate.
Our recovery work starts with a technical assessment of the target dsp, mcu, microcontroller, or microprocessor, including its physical condition, surrounding circuitry, storage architecture, and available documentation. Engineers determine what firmware, flash, eeprom, memory, and data resources may be available and how they relate to the original application. Depending on the condition of the texas instrument device and the scope of the project, advanced laboratory investigation may be considered, including carefully controlled decapsulate analysis where appropriate and authorized. Recovered information can be retrieved and decoded into useful binary, heximal, file, and archive resources for further engineering analysis.

Customers sometimes use terms such as attack, break, or hack when describing difficulties associated with protective, protected, locked, encrypted, or secured firmware. Our professional approach, however, is focused on authorized recovery and preservation rather than providing instructions for defeating security mechanisms. Where technically feasible, recovered program information can support controlled clone evaluation, duplicate development, compatibility verification, repair, and product modernization. The exact achievable result depends on the device architecture, physical condition, available evidence, and protection scheme, so every project is evaluated individually.

Normally, the SPI is used for communications between the DSP controller and external peripherals or another processor. Typical applications include external I/O or peripheral expansion through devices such as shift registers, display drivers, and ADCs. Multidevice communications are supported by the master/slave operation of the SPI.
The SPI module features include the following:
Four external pins:
- SPISOMI: SPI slave-output/master-input pin, or general-purpose bidirectional I/O pin
- SPISIMO: SPI slave-input/master-output pin, or general-purpose bidirectional I/O pin
- SPISTE: SPI slave-transmit-enable pin, or general-purpose bidirectional I/O pin
- SPICLK: SPI serial-clock pin, or general-purpose bidirectional I/O pin
Two operational modes: master and slave
Baud rate: 125 different programmable rates / 2.5 Mbps at 10-MHz SYSCLK
Data word format: one to eight data bits
Four clocking schemes controlled by clock polarity and clock-phase bits include:
Falling edge without phase delay: SPICLK active high. SPI transmits data on the falling edge of the SPICLK signal and receives data on the rising edge of the SPICLK, Falling edge with phase delay: SPICLK active high. SPI transmits data one half-cycle ahead of the falling edge of the SPICLK signal and receives data on the falling edge of the SPICLK

Rising edge without phase delay: SPICLK inactive SPI transmits data on the rising edge of the SPICLK signal and receives data on the falling edge of the SPICLK signal. Rising edge with phase delay: SPICLK inactive SPI transmits data one half-cycle ahead of the falling edge of the SPICLK signal and receives data on the rising edge of the SPICLK signal. Simultaneous receive and transmit operations to facilitate the progress (transmit function can be disabled in software)
Transmitter and receiver operations are accomplished through either interrupt-driven or polled algorithms. Ten SPI module control registers: Located in control register frame beginning at address 7040h. NOTE: All registers in this module are 8-bit registers that are connected to the 16-bit peripheral bus. When a register is accessed, the register data is in the lower byte (7 – 0), and the upper byte (15 – 8) is read as zeros. Writing to the upper byte has no effect.
A key part of program recovery is distinguishing usable engineering information from a simple raw memory image. Compiled firmware generally contains machine-level binary instructions rather than the developer’s original source code, comments, and project files. Engineers therefore combine firmware analysis with examination of the original circuit’s behavior. Communication interfaces, peripheral activity, timing, control signals, and system responses can help establish relationships between recovered data and the functions implemented by the dsp. Where suitable, semiconductor-level investigation and controlled decapsulate examination can complement conventional analysis and provide additional technical evidence. The resulting engineering package may include validated firmware information, organized heximal or binary file records, program documentation, memory observations, and reconstructed archive materials. This information can be especially valuable when an established industrial product must continue operating even though its original development environment, programming files, or documentation are no longer available.

For manufacturers, maintenance providers, and engineering organizations, recovering the tms320f28015 program can deliver substantial lifecycle benefits. Historical firmware, validated binary resources, organized data, and reconstructed technical records can reduce redevelopment effort and help teams maintain proven products. Recovered information may support troubleshooting, replacement-board development, hardware migration, discontinued-product maintenance, and future redesign. Instead of rebuilding a mature control system entirely from the beginning, engineers can use the recovered resources as a technical reference for understanding established functionality. By combining expertise in texas instrument dsp devices, embedded mcu systems, firmware analysis, and semiconductor investigation, our service provides a practical route for preserving valuable engineering knowledge and extending the useful life of complex electronic equipment.

PIC18F44K22: The Vector Table Is the Cheapest Thing to Protect
At the bottom of the program memory sit the reset vector and the interrupt vectors: a handful of instructions that point at every routine the hardware can enter. They occupy perhaps thirty bytes. They are also the single most useful thing in an image for anyone trying to understand it.
A vendor who protects only the block containing them has protected almost nothing of value to a copier and a great deal of value to a reader. That is not always deliberate — protection is applied per block, and the first block happens to contain the vectors — but the effect is the same.
What the vectors give a reader
Every decoded image starts somewhere. With the vectors available, it starts in a dozen places simultaneously, each of them a known entry point, each with a known trigger.
| Vector available | Consequence |
|---|---|
| Yes | Entry points known; decode outward from each |
| No | Entry points inferred from call targets and handler shapes |
The difference is not a matter of convenience. Decoding outward from known entry points produces regions that are correct where they exist, and honest gaps between them. Decoding by scanning produces a listing with no anchors, where every inference depends on the previous one.
What the vectors give a copyist
Almost nothing. An address points at a routine; it does not contain it. A copyist with the vectors and not the code has a table of addresses into memory they cannot read.
This is why the protection pattern appears: blocking the first block removes the diagnostic value without any cost to whoever is copying, because copying was never the threat the block was aimed at.
Reading without vectors
If the first block is closed and the rest is open, the image lacks anchors, and four techniques substitute:
- Collect call targets. Every call instruction carries a destination. Frequent destinations are functions; unique ones are often main or a dispatcher.
- Find handler shapes. Save context, do work, restore, return. Handlers are recognisable by their prologue even without a vector pointing at them.
- Follow the tables. A jump table’s targets are a set of nearby addresses, and the table itself identifies the dispatcher that reads it.
- Use entry-like sequences. Start-up code initialises the clock in a recognisable order; finding it identifies the reset path even if the reset vector is unavailable.
None of these is as clean as the vector table, and all of them together are usually enough for a 16K image.
The block arithmetic
On this part the array divides into four blocks. The vectors are in the first, along with start-up code and whatever small routines the compiler placed early.
So a device with the first block closed loses: the reset vector, the interrupt vectors, the clock initialisation, and the routines that happen to live nearby. That is a coherent loss, not a random one, and its consequence is that the image begins in the middle of the application with no way to know what came before.
The practical response is to decode the readable region first and treat the missing block as a hypothesis to be tested by behaviour — the clock is measurable, the interrupt map is inferable from which peripherals respond, and the entry point is findable from the loader if one exists.
Protection as an economic decision
Vendors choose protection settings under constraints: what the tooling supports, what the update path requires, what a distributor needs to be able to read for verification.
The result is often a compromise that looks arbitrary from outside and is entirely rational from inside. A first block protected and the rest open is a pattern that says: updates are supported, verification is done by the vendor, and nobody thought about disassembly.
That reading is more useful than a judgement about intent. It predicts what else exists — an update path, a service tool, a production record — and those are often where the answer actually lies.
Related reading
- PIC18F43K22 and duplicating a device — what the vectors are worth to a copy and why.
- PIC18F45K22 and the boot block pattern — the configuration that puts a loader below the vectors.
- PIC18F24K22 and locating the readable boundary — how to establish which blocks are open.
FAQ
How large is the vector table? A few dozen bytes — an insignificant fraction of the array and the most informative content in it.
Can entry points be recovered without it? Yes, from call targets and handler shapes, with less certainty.
Why would a vendor protect only the first block? Because protection is per block and the vectors happen to live there, or because the loader below them must be protected for other reasons.
Does protecting the vectors stop copying? No. Addresses are not code.
What else is in the first block? Start-up code, clock configuration and small routines the compiler placed early.
Conclusion
The vector table is a few dozen bytes that cost nothing to protect and remove the best anchor an image has. When it is missing, the work is inference rather than lookup, and the compensation is behavioural: the clock, the interrupt map and the entry point are all measurable. Recognising the pattern also predicts what else the device has — usually an update path worth more than the code.
PIC18F43K22: Duplication Is a Matching Problem, Not a Copying One
Copying is a transfer. Duplication is a correspondence, and the correspondence has four dimensions: the program, the configuration, the data array, and the physical device. A copy addresses one of them. Most duplication failures are the other three.
The 43K22, with eight kilobytes of program memory in a 40-pin package, is a good case to reason about because the array is small enough that everything else is proportionally larger.
The four dimensions
| Dimension | Reproduced by | Fails as |
|---|---|---|
| Program array | Programming the image | Code runs but behaves differently |
| Configuration | Writing config explicitly | Wrong clock, watchdog, or boot behaviour |
| Data array | Copying, or leaving blank deliberately | Measurement offset, wrong settings |
| Silicon | Nothing — it is a property of the part | Small consistent differences |
The fourth is the one that cannot be closed, and pretending otherwise wastes time. Analog trim and silicon revision belong to the die. A duplicate is therefore an approximation whose error is bounded by those two factors, and the practical question is whether the bound is acceptable for the application.
Configuration: the dimension that is usually skipped
Programmers treat configuration as a setting rather than as content, and tools reinforce this by offering it as a separate operation. A hex file exported from the array may or may not include it.
The result is a device that boots, runs the code, and differs in ways that are hard to attribute:
- Watchdog enabled on one and not the other, which shows up as a device that resets under load.
- Different oscillator source, which shifts every timing relationship.
- Different brown-out threshold, which changes behaviour at low supply.
- Different low-voltage programming setting, which changes how the device can be entered later.
Each of these is a field in the configuration word, each is comparable, and none is in the code.
Data array: decide, do not default
The small data array on this family holds whatever the application decided to keep: settings, offsets, counters, sometimes a copy of the serial number.
Three choices, and the honest one depends on purpose:
- Copy the original’s array. The duplicate behaves like the original, including its accumulated state.
- Leave it blank. The firmware writes defaults; whether that is correct depends on the design.
- Write a known set. Correct when the values are documented and reproducible.
Choosing by default — that is, leaving it blank because nothing was decided — is the most common of the three and the least defensible.
What a duplicate cannot fix
Two differences survive any amount of care:
Trim. Analog blocks carry per-die trim. A duplicate that measures a small offset from the original is showing trim, not a code error. The fix is recalibration, not reprogramming.
Revision. Errata differ between revisions, and firmware written to avoid a specific erratum may behave differently on a die where the erratum does not exist — or vice versa. On a device this size the effect is usually small and occasionally decisive.
Recording the revision at duplication time is cheap and answers the question later.
Verifying a duplicate
The verification that matters compares behaviour, not files:
- Program the image and the configuration; write or deliberately omit the data array.
- Read everything back and compare against the record.
- Run both devices on the same inputs and compare outputs at every accessible point.
- Compare timing, not just values — a duplicate that produces the right answer late is not a duplicate.
- Run the fault cases the original was known to handle.
Step four catches configuration differences that step three misses, because a wrong oscillator often changes timing before it changes logic.
When duplication is the wrong tool
If the firmware depends on a per-die value — a unique identifier used in a key, a trim value baked into a calculation — copying produces a device that runs and computes differently. In that case the work is to understand the dependence, which is a reconstruction problem rather than a duplication one.
Deciding this before starting requires reading the program. On a device where that is impossible, the dependence can often be detected from behaviour: a duplicate that works in every mode except one is usually hitting a per-die assumption in that mode.
Related reading
- PIC18F44K22 and the 16K variant — where the same procedure meets a larger array.
- PIC18F43K20 and the previous generation — the same package with the older core.
- PIC18F25K22 and restoring a single unit — the one-device version of the same matching problem.
FAQ
Does copying the array duplicate the device? It duplicates one of four dimensions. Configuration, data and silicon remain.
Why does a duplicate reset under load? Usually a watchdog setting that differs from the original’s.
Should the data array be copied? Only if the duplicate must reproduce the original’s accumulated state.
Can trim be transferred? It can be written, but it belongs to the die, so the result measures like the source silicon.
How is a duplicate verified? By comparing outputs and timing on identical inputs, and by exercising the fault cases.
Conclusion
Duplication on this part is a four-dimensional matching problem in which the easiest dimension is the one everyone does. Configuration, data array and silicon decide whether the second device is a duplicate or merely a device with the same program — and only behavioural verification distinguishes the two.
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.
PIC18F25K22: Restoring a Part Means Reproducing a State, Not Just Code
A hex file is a description of memory contents. A working device is a state: a program, a configuration, a data array, a calibration, and a physical part with a particular silicon revision. Programming the first into a replacement part reproduces one fifth of the second.
That gap is where restorations fail quietly. The unit boots, runs, responds on its bus, passes the test that was written against the old firmware — and then behaves differently under conditions the test did not cover, because something outside the array was never reproduced.
The five things that must match
| Item | Where it lives | In a hex file |
|---|---|---|
| Program code and tables | Program array | Yes |
| Configuration words | Config registers | Sometimes, as records |
| Data EEPROM contents | Data array | Usually not |
| Analog and oscillator trim | Factory area | No |
| Silicon revision | The die | No |
Items one and two are usually handled. Item three is forgotten often enough to be the most common cause of a restored instrument reading slightly wrong. Items four and five are properties of the replacement part and cannot be programmed at all.
Configuration: the part that changes behaviour silently
Configuration decides the oscillator, the watchdog, the brown-out threshold, the programming interface and the protection state. A restored part with the right code and the wrong watchdog setting runs until it does not.
The reason configuration is omitted is mechanical: many tools treat configuration as a separate operation from programming the array, and a hex file exported from the array may or may not include the configuration records depending on how the export was performed.
The check is simple: after programming, read the configuration back and compare it field by field against the source device’s recorded values. A comparison of the raw bytes is better than a comparison of the tool’s display, since the display merges fields and hides reserved bits that may differ.
Data EEPROM: the part that is different on every unit
Calibration values, settings and counters live in the data array. On a restored part there are three choices:
- Copy the source device’s data array. Reproduces the original’s calibration, including any drift it had accumulated.
- Leave it blank. The firmware writes defaults on first run, which may be correct and may not.
- Restore from a recorded value. Correct when the calibration is documented and reproducible.
The first choice is right when the replacement must behave exactly like the original, including its errors. The second is right when the calibration is a property of the hardware rather than the unit. Deciding between them requires knowing what the data array contains, which is why reading it during recovery matters even when the program array is the headline item.
Trim, and why the copy cannot be perfect
Every die carries analog trim written at test. A replacement part has its own. For most digital work the difference is irrelevant; for anything measuring an analog quantity it is not.
A restored instrument that reads a consistent offset from the original is showing trim difference, not a code error. If the offset is unacceptable, the correct fix is to recalibrate the restored unit against a reference — which is a procedure, not a firmware change.
Revision, and the compatibility question
Silicon revisions fix errata, and errata include peripheral behaviour that firmware may depend on. A replacement part of a different revision may behave differently in exactly the corner the original firmware was written to avoid.
Revision is visible in the device identification area and, sometimes, from behaviour. Recording it at recovery time is cheap; discovering it months later is not.
A restoration procedure that holds
- Record the source device: configuration bytes, data array, identification area, behaviour.
- Erase the replacement completely, including configuration.
- Program the code.
- Program the configuration explicitly, do not assume the file carried it.
- Write the data array, or leave it blank by decision rather than by omission.
- Read everything back and compare against the record.
- Run the functional test, then run the corner cases the original was known to handle.
Steps two and four are where most failures are introduced. An incomplete erase leaves configuration from a previous life, and a program that omits configuration inherits whatever was there.
When restoration is not the right goal
Two situations call for something else:
- The source device is unique and its behaviour is undocumented. Then restoration is a research project, and the output is a specification rather than an image.
- The replacement part is a different revision or a different variant. Then the code may run and the behaviour may differ, and the honest description of the result is “a compatible replacement”, not “a copy”.
Saying which of those applies, before the work starts, is worth more than a perfect procedure applied to the wrong problem.
Related reading
- PIC18F23K22 and the two protection gates — what has to be cleared before a restore is possible.
- PIC18F24K20 and the data array — why the second array is separate.
- PIC18F26K22 and the 64K image — where configuration handling becomes more error-prone.
FAQ
Does a hex file include the configuration words? Sometimes, depending on the export. Treat it as unknown and program configuration explicitly.
Will a restored part have the same calibration? Only if the data array was copied. Otherwise it has defaults or the replacement’s own.
Can trim be copied between devices? It can be written, but it belongs to the die. Copying it makes the replacement measure like the original’s silicon, which is not the same as measuring correctly.
Why does a restored unit pass tests and fail in the field? Because the test covered function and not the corner the original handled through configuration or calibration.
Is a different silicon revision a problem? It can be. Record the revision at recovery time so the difference is known rather than discovered.
Conclusion
Restoring a device is reproducing a state: code, configuration, data array, trim and revision. Only the first is reliably in the file, and the other four decide whether the restored unit behaves like the original. The procedure is not difficult; it is just longer than the part of it people usually do.
PIC18F24K22: Finding the Gate by Testing Addresses
On a 16K device with four protection blocks, a device can present a readable region that stops at one of four addresses. Which one it stops at is a fact about the configuration, and it is recoverable by experiment even when the configuration cannot be read.
The method is a binary search over addresses, and it takes fewer reads than most people expect: with four possible boundaries, two well-chosen probes distinguish most cases.
Why the boundary is informative
The position of the transition tells you which blocks are open, which tells you something about the product’s design:
| Transition at | Blocks open | Likely intent |
|---|---|---|
| Immediately | None | Fully locked |
| First boundary | Boot block only | Vendor loader visible |
| Second boundary | Lower half | Development build shipped locked above |
| Third boundary | Three quarters | Update path visible, application protected |
| Never | All | Unprotected, or read attempt failed |
The fourth row is the interesting one, and it is more common than the others on products that were updated in the field: the region containing the loader and the vector table is open, and the application above it is not.
The search
Each probe is a read of one word at a candidate address, compared against what a populated address should contain. The comparison is not against an expected value — you do not know the contents — but against the pattern of a protected read, which is uniform.
The procedure:
- Read a word at the lowest application address. If it is uniform (all zeros or all ones), the first block is closed and the search is over.
- Otherwise, read at each block boundary. The first address that returns uniform values is the transition.
- Refine within the block before the transition if more precision is needed — though on this family, blocks are the granularity, so it is not.
The number of reads is small, and each is cheap. The cost is in interpreting the results, which requires knowing that a uniform read can mean three different things.
Three explanations for a uniform read
The block is protected. The gate returns a fixed value.
The block is erased. There was never any content.
The read is failing. The programmer is configured for the wrong part, or the device is not entering programming mode reliably.
The first two are indistinguishable at a single address and distinguishable in aggregate: an erased block is uniform everywhere, and so is a protected one. Only the configuration word separates them — which is why the binary search is a supporting technique rather than a primary one.
The third is distinguishable by reading an address that must be populated on any working device. The reset vector is the standard choice, and on a device whose first block is open, it is the first thing the search reads.
What “code recovery” means at this point
Once the boundary is known, the readable portion is available and the unreadable portion is not. Recovery from that position means:
- reading the open blocks completely, twice, at different speeds;
- recording the block map alongside the image;
- treating the image as partial in every subsequent use.
The last item is where discipline is needed. A partial image written to a file and handed to someone else will, eventually, be programmed into a device, and the device will boot from a vector that points into a region the file does not cover. Recording the map prevents that; omitting it guarantees it.
The vectors question
If the first block is open, the vector table is available, and the readable region can be decoded from its entry points. If the first block is the closed one, the remainder of the image has no anchors and must be decoded by scanning.
That asymmetry means the boundary’s position determines not just how much is readable but how legible it is. Three quarters of an image including the vectors is more useful than three quarters excluding them.
Limits
- Protection is per block; there is nothing to find within a block.
- A uniform read has three explanations, and only configuration distinguishes them.
- A partial image is partial regardless of how carefully it is recorded.
Related reading
- PIC18F14K22 and the two-block version — the same search with fewer candidates.
- PIC18F25K22 and restoring what was read — what a partial image still cannot reproduce.
- PIC18F23K22 and the protection bits themselves — the configuration that the search is inferring.
FAQ
How many probes does the search need? A handful. With four blocks there are four candidate boundaries.
Can a uniform read be trusted as evidence of protection? No. Erasure and read failures produce the same result; only configuration separates them.
What if the first block is the closed one? The image has no vector table, and decoding has to proceed by scanning.
Is there any granularity finer than a block? No. The block is the unit of protection.
Why read twice at different speeds? To distinguish content from sampling error, which produces non-uniform values that look like data.
Conclusion
On a device with four blocks, the position of the readable region’s edge is a measurement rather than a guess, and it is obtained by probing a few addresses. What the boundary means depends on which blocks it exposes — and the most valuable configuration is the one where the vectors are inside the readable part.
PIC18F23K22: Write Protection Is Not Read Protection
Two bits sit next to each other in the configuration word, both named for protection, both applied per block. One stops you reading the array; the other stops you writing it. They are independent, and the independence is the source of an expensive mistake that happens on benches regularly: a device that could have been read is erased, on the assumption that removing write protection would expose it.
Getting these straight is a five-minute exercise that saves devices.
What each one does
Code protection gates reads. With it set, the array cannot be read from outside the device — through the programmer, or through table reads from unprotected code. The device still runs.
Write protection gates modification. With it set, the block cannot be erased or programmed. The array remains fully readable if code protection is clear.
| Read-protected | Write-protected | Read | Modify | What it implies |
|---|---|---|---|---|
| No | No | Yes | Yes | Development, or unlocked production |
| No | Yes | Yes | No | Fixed content, readable — the useful case |
| Yes | No | No | Yes | Locked but recoverable by erase |
| Yes | Yes | No | No | Fully closed |
The second row is the one people fail to look for. A device with write protection and no read protection is a device whose content is available right now, and it is also the configuration a vendor chooses for a boot block that must never change.
Why a vendor protects writes without protecting reads
Because it is the configuration that makes a fixed region safe without making it secret. A bootloader in the boot block should never be modified by field activity; it does not necessarily need to be hidden.
There is a second motive, less flattering: some production processes set write protection because the tooling offers it in the same dialog as code protection, and nobody separated the two. Those devices are readable, and the fact that they are readable is discovered only by trying.
The mistake, in full
The sequence that destroys images:
- A device will not respond to a read. The reader concludes “protected”.
- The reader decides to remove protection by erasing.
- The erase clears the array, and with it the program.
- The device is now readable and empty.
Step one is where the error occurs, and it usually comes from treating a failed read as evidence of code protection. A failed read has several causes: wrong part selected in the tool, wrong programming entry voltage, low-voltage programming disabled so the entry method is wrong, or a device whose configuration is genuinely protective.
Only the last of those justifies an erase, and it is distinguishable from the others by reading the configuration word — which is exactly the read that remains available when everything else is closed.
Order of tests that avoids the mistake
Before any modifying operation:
- Read the configuration word. It states both protection settings.
- Attempt to read a known-populated address. The vector table at the bottom of the array is the standard target, since every program has one.
- If that read returns zeros while the configuration says code protection is clear, the problem is the interface, not the device. Fix the interface.
- Only if the configuration states code protection is set, consider whether an erase is acceptable — which requires knowing that the content is expendable.
Step four is the point where a decision has to be made honestly. Erasing to unprotect is a valid technique for a device whose program exists elsewhere. It is a total loss for a device whose program does not.
Write protection’s own complications
A write-protected block is protected against the ordinary programming sequence, and removing the protection requires an erase — of the whole device on this family, since configuration is erased with the array.
There is a further wrinkle: some write-protect bits are applied by a bootloader at runtime, so a device can be writable when read immediately after reset and write-protected once the application is running. Reading the configuration twice catches this, and it is a useful signal that the device has a bootloader at all.
What survives a partial attempt
If an erase was performed and the program was expendable, the device is restored and the story ends well. If it was not expendable, what remains is:
- the behaviour recorded before the erase, if anyone recorded it;
- sibling units with the same build, if any exist;
- the vendor’s update package, if the product had one.
Nothing in the array. This is why the checklist above is worth more than the technique it protects: the technique recovers a device, and the checklist decides whether the device should be touched at all.
Related reading
- PIC18F24K20 and data EEPROM protection as a third setting — the bit that makes “program and data” two questions.
- PIC18F14K22 and block granularity — how the blocks these bits apply to are laid out.
- PIC18F26K22 and the larger array — where both protections are commonly set together.
FAQ
Does write protection stop a read? No. Write protection gates modification; read protection gates reads.
Can write protection be removed without an erase? Not on this family. Configuration is cleared by the erase that removes the protection.
Why would a device be writable but unreadable? That is a locked part. It can be erased and rewritten, which recovers the device and loses the program.
Is a failed read proof of code protection? No. Wrong part selection, wrong entry voltage and disabled low-voltage programming all produce a failed read.
Can a bootloader change these settings? Yes, which is why the configuration should be read both after reset and during operation.
Conclusion
Two adjacent bits, two different questions, and a habit of treating them as one. Code protection hides the array; write protection freezes it. Reading the configuration word before touching anything tells you which applies, and that single read is what stands between a recoverable device and an erased one.
PIC18F66K80: Restoring an Image Into a Machine, Not Into a Socket
An image that boots on a bench has satisfied one requirement. In the machine it came out of, the same device must also start within the time the system allows, present the right interface to the other participants, and behave correctly when they misbehave. Those requirements are not in the file, and a restoration that ignores them produces a unit that works until it is installed.
The distinction sounds obvious and is routinely lost, because the bench test is easy and the machine test is not.
What the machine expects at power-up
A controller in a machine is usually the first thing to start and the last to be ready. Between those two points, other participants wait for it — or do not, depending on the design.
| Expectation | Where it comes from | Consequence if missed |
|---|---|---|
| Start-up time | Other devices’ timeouts | A participant gives up and faults |
| Interface presence | Bus protocol | The controller is treated as absent |
| Initial state of outputs | Safe-state requirements | Actuators move on power-up |
| Handshake sequence | The system’s own protocol | Operation proceeds with stale state |
The third row is the one with consequences outside the equipment. A restored controller whose outputs default to the wrong state during the first milliseconds moves something it should not, and the failure is intermittent because it depends on how fast the rest of the system comes up.
That behaviour is set by configuration and by the first few instructions after reset — both of which are outside the code image in the sense that matters: configuration is a separate item, and the first instructions are the part most likely to differ in a rebuild.
Configuration as a machine requirement
The oscillator setting is not merely a preference. A device configured for an external crystal, installed on a board that provides one, starts in milliseconds. The same device configured for the internal oscillator starts immediately and runs at a different frequency, changing every timing relationship in the system.
Similarly, the watchdog: enabled with a particular period, it constrains how long any routine may take. A restored device with the watchdog disabled passes every bench test and loses its protection against a lock-up in the field.
The restoration checklist therefore includes configuration as a first-class item, compared field by field against the record taken from the original.
The data array and the machine’s calibration
In an embedded control application the data array frequently holds constants that belong to the machine rather than to the firmware: offsets measured at commissioning, limits set for this particular unit, counters recording its history.
Copying the original’s data array reproduces the original’s calibration, which is correct if the replacement is going into the same machine and wrong if it is going into another. Leaving it blank lets the firmware write defaults, which is correct if the design supports it and produces a unit that measures wrong if it does not.
Neither choice is universally right, and the decision has to be made with knowledge of what the array contains — which is why reading it during recovery is worth the effort even when the program array is the headline item.
Rebuilding versus restoring
For a device whose image is unavailable, the work is a rebuild, and a rebuild has an additional requirement: it must satisfy the machine, not just the bench.
The practical approach is to instrument the machine. Measure the timing of the start-up sequence, capture the bus traffic, record the states of the outputs at each stage, and provoke the fault conditions the system can produce. That gives a specification in machine terms, and a rebuild written to it will install successfully where one written to bench observations will not.
What tends to go wrong after installation
Four failures recur:
- Start-up too slow or too fast, because the oscillator configuration differs and the system’s timeouts are tight.
- Outputs in the wrong state during reset, because the port initialisation order differs from the original.
- A missing handshake, because the rebuild implements the protocol’s steady state and not its opening exchange.
- Watchdog behaviour, because the period differs and a routine that fitted no longer does.
All four are configuration and sequencing rather than logic, and all four are avoidable by recording the original’s behaviour at power-up before it is replaced.
The order that works
- Record the original in the machine: start-up timing, output states at each stage, bus traffic, response to each fault the system can produce.
- Record the configuration and the data array.
- Restore or rebuild.
- Compare at every point from the first, in the machine, with the rest of the system present.
- Only then treat the unit as serviceable.
Step four is the one that distinguishes a restoration from a programming operation, and it takes an afternoon rather than an hour. It is also the only step that finds the four failures above.
Related reading
- PIC18F65K80 and recording the image as a file — what the file does and does not carry.
- PIC18F46K80 and the loader’s verification — why a copied image may refuse to start.
- PIC18F45K80 and reconstruction from measurement — the direction to work in when no image exists.
FAQ
Is a bench-tested restore good enough? It is necessary and not sufficient. The machine imposes timing and sequencing requirements the bench does not.
Which configuration field matters most in a machine? The oscillator, because every timing relationship in the system depends on it.
Should the data array be copied? Only if the replacement is going into the same machine and the original’s calibration applies.
Why do outputs move on power-up after a restore? Because the port initialisation order or the initial values differ from the original’s.
How do I capture what the machine expects? Instrument it: record timing, bus traffic and output states across the full start-up and through each fault condition.
Conclusion
Restoring a controller into a machine is a system problem wearing a firmware costume. The image is the visible part; configuration, data array, sequencing and timing decide whether the unit is serviceable. Recording the original in the machine before removing it is the step that makes everything afterwards possible.
PIC18F65K80: Extended Addressing and the Three Ways a Hex File Goes Wrong
Intel HEX was designed when addresses were small. Each data record carries a two-byte offset, which was ample for the memories of the time and is not ample for a part with 64K of program memory plus configuration and identification areas. The format’s answer is the extended address record: a special record that sets the upper bits for the records that follow.
That mechanism works, and because it works silently, it produces files that pass every validity check and describe the wrong memory. Three failure modes account for most of them, and all three are visible in a file that is otherwise well-formed.
The record types that matter
| Type | Purpose | Consequence if mishandled |
|---|---|---|
| 00 | Data | The payload itself |
| 01 | End of file | Anything after it is ignored |
| 02 | Extended segment address | Upper bits, segment-scaled |
| 04 | Extended linear address | Upper bits, linear |
Types 02 and 04 both set upper bits, and they scale differently. A tool that mixes them, or a reader that assumes one while the file uses the other, places data at addresses offset by a multiple of the segment size — which on this part usually lands writes outside the intended region, or wraps within it.
Failure one: the address that resets
An extended address record applies to the records after it, until another extended record appears. A file that changes the upper bits for the configuration area and never restores them will place subsequent data at the wrong address.
The visible symptom is a file whose data records are all valid and whose total length is correct, but whose contents, when loaded, put code where constants belong. The audit is straightforward: track the current upper bits while reading, and print the effective address of each record. Any jump in effective address that does not correspond to a region boundary is a bug.
Failure two: word addresses recorded as byte addresses
The core addresses words, and the programmer’s notion of an address may be in words while the file’s offsets are in bytes. A file produced with the wrong convention has every record at twice or half its correct address.
This one is more insidious than it sounds, because for the first few kilobytes the two conventions produce addresses that are both plausible. The divergence shows at the first region boundary — the point at which the two mappings disagree by more than the region’s size.
The test: load the file into a reader that shows the effective address map, and compare the boundaries against the part’s documented regions. A boundary that sits at an odd multiple of a documented value is a convention error.
Failure three: the regions that are not program memory
A complete file for this device contains more than program memory: configuration registers at their own address range, and an identification area. Some tools export them, some do not, and some export them at addresses that differ between tool versions.
A recovered file that omits configuration is a file that restores a device which boots into whatever configuration the destination part happened to carry. That is the single most common cause of a restored unit behaving differently from the original.
| Region | Contents | Usually in an export |
|---|---|---|
| Program memory | Code and tables | Yes |
| Configuration | Protection, oscillator, watchdog | Sometimes |
| Data EEPROM | Settings, calibration | Rarely |
| Identification | Part number, revision, unique ID | No |
The last row cannot be written at all, and it is the reason a recovered file can never fully describe a device.
Validating a recovered file
Four checks, in order, none of which take long:
- Record audit. Walk every record, track the effective address, and print the map. Region boundaries should match the documentation.
- Reset vector check. The word at the reset address should be a branch, and its target should be inside the program region.
- Fill check. Erased regions read as a uniform value. A region that is neither code nor uniform fill is either data or an error.
- Round trip. Program a blank device, read it back, and compare record for record. Discrepancies indicate address handling, not content.
Step four catches everything the first three miss, and it is the only one that tests the whole chain.
What “heximal” leaves out
A hex file is a memory image. It carries no information about:
- which regions were readable and which were gated;
- whether the source device was locked;
- what the data array contained;
- which silicon revision produced it.
Those four facts decide whether the file is a faithful record or a partial one, and none of them can be recovered from the file itself. They belong in the documentation that accompanies it, and their absence is why recovered files are so often misread years later.
Practical note on this part
Sixty-four pins and 64K of program memory mean a complete image is a substantial file, and a partial one is easy to mistake for a complete one. The regions beyond program memory are small, and their absence changes a file’s size by a few hundred bytes — an amount no one notices.
That is the argument for the record audit: it reports boundaries, and boundaries are where the truth is.
Related reading
- PIC18F46K80 and the range a loader verifies — how the application’s extent is defined, which the audit should confirm.
- PIC18F25K20 and what a hex of a protected part can contain — the limits that apply before formatting.
- PIC18F66K80 and restoring a file into a part — what the file must include for a restore to work.
FAQ
What is an extended linear address record? A record that sets the upper bits of the address for subsequent data records.
Can a hex file be valid and wrong? Yes. Checksums verify the record, not the address it lands at.
Why does a restored device boot differently? Usually because the file omitted configuration, and the destination’s own configuration applied.
Is the identification area in the file? No. It is factory-written and cannot be programmed.
How do I detect an address convention error? Compare the file’s region boundaries against the documented ones; an odd multiple indicates a word/byte mismatch.
Conclusion
Extended addressing is a small mechanism with three specific failure modes, all of which produce files that validate and mislead. A record audit, a reset-vector check, a fill check and a round trip resolve them in minutes — and the four facts a hex file cannot carry are the ones worth writing down before the file is filed away.
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.