PostHeaderIcon Break IC PIC16F715 Firmware: What Makes a Delivery Rebuildable

Two jobs can be described with the same words and end with different artefacts. One produces a file that records what a device’s array contained. The other produces something that can be programmed into a blank device and will run. The first is a record. The second is firmware.

The difference sounds academic until a customer takes delivery of the first and expects the second. On a small mid-range device it is worth settling before the work starts, because the acceptance test is different and so is the amount of interpretation required.

The acceptance test defines the job

The cleanest way to separate the two is to name the test that will decide whether the work succeeded.

Deliverable Acceptance test What it requires
image record the file reproduces the read, word for word a faithful read and a stated convention
rebuildable firmware a blank device programmed from it runs correctly the image, the configuration, the calibration, and the peripheral assumptions resolved

The second test is much harder and it is the one most customers actually mean. It requires not only the bytes but an understanding of which of those bytes are device-specific — the same problem that produces wrong clocks and wrong calibration when it is ignored.

What has to be resolved to make an image programmable

Programming a blank device from a recovered image works on the first attempt only when four things are true.

The configuration word must be present and correct, because a blank device’s default configuration is rarely the one the product needs. The program image must include the top region where any factory calibration constant lives, because that region is part of the array and is not code. The data EEPROM, if the part has one, must be present even if it is blank, because the firmware’s first-run behaviour depends on distinguishing blank from populated. And the image must be complete through the last implemented address, because a truncated image programs a device that fails at a boundary.

On a device of this size all four fit in a few kilobytes, and all four are commonly missing from a delivery that was described as firmware.

The array is small enough to read in full

Around two thousand instruction words is small enough that the whole thing can be held in view. That has a practical benefit which is worth using: the entire image can be checked by hand, and a hand check catches classes of error that automated structural tests miss.

What to look for, in order.

The start of the array is initialisation. The order in which the oscillator, the port directions, the analogue modules and the timers are configured is a statement of the design’s dependencies — anything that depends on the clock must come after the clock is set, and a read that appears to configure a timer before the oscillator is a sign of a misread word.

The middle of the array is the main loop. On a device without interrupts, or with them disabled in this product, the loop is a fixed sequence of calls, and its shape tells you the product’s operating cycle.

The end of the code is followed by the erased pattern. The position of that boundary is a measurement, and it should agree with what the linker would have produced for a program of this size.

The very top is configuration. It is not code and should never appear in the disassembly.

Interrupts, when they exist, change the reading

This family sits above the baseline, so an interrupt vector may be present and the handler may be a real one. Where it is, the image acquires the structure that a linear program lacks: a jump at address zero past a fixed vector, and a handler whose ordering of flag tests reveals the product’s priorities.

Where the product disables interrupts entirely, the vector may still contain a jump to a handler that is never entered. That is a common pattern on simple products written by engineers who left the scaffolding in place, and its presence is not evidence that the product uses interrupts.

Making the delivery rebuildable in practice

Four artefacts turn an image into something a customer can act on.

  • the program image, with the configuration and calibration regions named separately rather than buried at the end
  • the data EEPROM image, included even when blank, with the blank state stated
  • the configuration word decoded field by field, so that a customer can see the oscillator choice and the protection state
  • a note stating which values belong to the donor device and must not be copied

The last item is what makes the difference between a device that programs and runs and a device that programs and runs slightly wrong. On this family the value in question is the oscillator calibration where one is present, and the same reasoning applies to any per-unit constant the firmware reads at startup.

Verification that the rebuild worked

The final step of a firmware job is not the delivery. It is programming a blank device and observing it.

Three observations establish success. The device must start, which proves the configuration and the vectors. Its clock-dependent behaviour must match, which proves the calibration was handled correctly — a serial link or a timed output is the easiest witness. And its analogue behaviour, where the product has any, must be within the tolerance the original showed, which proves the data array was handled correctly.

Where a working original is available, the two can be compared side by side on the same harness. That comparison is worth more than any amount of checksum agreement.

For a device where the array is small enough that the whole image fits in a single view and the verification strategy changes accordingly, PIC16F506 binary recovery covers the small-array case. Where the corresponding eight-pin parts force the programming interface to share pins with the application, PIC12F635 program recovery sets out the constraints. And for the 28-pin relatives where paging becomes a structural feature of the image, PIC16F71 binary recovery develops the address-structure side.

Asking the question early

The question to ask before any work begins is what will happen to the result. If the answer is that a technician will program a blank device and fit it to a machine, the job is firmware and the acceptance test above applies. If the answer is that an engineer will read the listing, the job is a record and the annotations matter more than the configuration word.

The two products overlap heavily and they are not the same. Naming which one is being bought, in the first conversation, prevents the most common disagreement in this line of work — a delivery that met its specification and disappointed its customer.

Comments are closed.