PostHeaderIcon CPLD and MCU Firmware File: One Phrase, Two Incompatible Objects

A board with a microcontroller and a CPLD has two programmable devices and, in most people’s vocabulary, two pieces of firmware. The word suggests the files are similar. They are not, and the difference is structural rather than stylistic: one file describes what a device should compute, the other describes what a device should be.

This matters at quotation time more than at any other. A request that says “recover the firmware from both chips” is ambiguous in a way that changes the effort by an order of magnitude, and the ambiguity is invisible until somebody opens the files.

The two objects compared

Property MCU hex file CPLD fuse map
Basic unit Address and data pair Fuse coordinate
Total length Proportional to used code Fixed: the device’s programmable element count
Contains addresses Yes, explicitly No; position implies address
Contains checksum Per record, plus a file checksum One checksum over the fuse bits
Meaning of a byte An instruction or data An unordered set of connection bits
Can be disassembled Yes No; requires architecture decode

The second row is the one people find surprising. A hex file for a small microcontroller program can be a few kilobytes, because it only records the addresses that were written. A fuse map for a 64-macrocell CPLD is exactly the size of the device’s programmable array regardless of how much logic the design uses — an almost-empty design still produces a full-length file.

What each file is for

The intended use of the two files is different, and that difference explains their structure.

File Consumer Operation
Hex or binary Programmer writing flash Place bytes at addresses
Fuse map Programmer configuring logic Set or clear every element
Bitstream Configuration engine Load a serial frame
Object file Linker and debugger Combine sections, resolve symbols

A programmer that expects a fuse map will reject a hex file immediately, and vice versa. The failures are usually loud, which is the good case. The bad case is a tool that accepts either and guesses wrong, producing a device that is programmed with something.

Where the confusion causes damage

Three specific failures follow from treating the two as the same kind of thing.

Assumption Reality Consequence
Same effort to read both CPLD read is often physical; MCU read may be a session Schedule and price both wrong
Same file size means same work Fuse map is fixed size, hex is not Progress measured by bytes is meaningless
Same reconstruction path MCU to disassembly, CPLD to equations Wrong specialist assigned

The first row is the expensive one. On a board where the microcontroller can be read over its debug port and the CPLD cannot be read at all, a single quotation covering both devices will either overprice the first or underprice the second, and the direction of the error depends on which device the estimator thought about.

Reading the CPLD half

The fuse map’s fixed length is actually helpful once understood, because it makes truncation detectable. A read that returns fewer bits than the device has programmable elements is incomplete, and the device’s own checksum confirms whether the bits are self-consistent.

Check What it proves
Length equals device fuse count No truncation
Checksum matches device-reported value Bits are consistent
Device ID in the header matches marking The map is for this device
UES contents are plausible The read reached the signature row

Without these checks, a partial read produces a map that decodes into equations, and the equations produce a design that nearly works. Reading the JED format covers the container field by field, including the checksum definition that makes the second check possible.

Reading the MCU half

The microcontroller file’s variable length is helpful in a different way: it tells you where the code ends. Everything after the last recorded address is unused, and on many devices that region is erased. It also tells you nothing about the parts of the device that were never programmed, which matters when a configuration region is written separately.

Region In the hex file Often missed
Program flash Yes, by address No
EEPROM or data flash Sometimes, different address space Yes
Configuration or fuse bytes Sometimes, at a high address Yes
Calibration or serial Sometimes, at a fixed address Yes

The third and fourth rows are the recurring omissions, and they are the reason a device programmed with a perfect copy of the code sometimes does not run.

A comparison that makes the point

Consider two devices with the same part count and the same board. The microcontroller file, when recovered, is 14 kilobytes and disassembles into about three thousand instructions. The CPLD file is exactly 4,832 bits, contains no instructions, and decodes into 64 equations of three to twelve product terms each.

Both are complete. Both are correct. Neither can be substituted for the other, and no single tool reads both. A workflow that treats them as one class of artefact will produce one good deliverable and one that is nonsense.

Where the specialist boundary falls

The MCU side leads to disassembly and reconstruction, treated in attacking Microchip source code for one family and in cracking microcontroller source code generally. The CPLD side leads to equations and state machines, treated in attacking CPLD source code. The two skills overlap in the first week and diverge completely after it.

Services at this boundary

Work covers both device classes, with the scope written per device rather than per board, and with the file type stated in the quotation. It does not cover producing a single merged deliverable, because there is no such object, and it does not cover estimating a CPLD read from an MCU read, because the routes have nothing in common.

The sentence that prevents most of these problems is one line in the quotation: which device, which file, which deliverable.

Comments are closed.