Posts Tagged ‘copy lattice cpld flash program’

PostHeaderIcon Copy Lattice CPLD Encrypted File: Encryption Stops Reads, Not Writes

A security mechanism that refuses reads but permits writes sounds like an oversight. It is not. The write path has to stay open, because the legitimate use of the device is to program it, and the legitimate user typically programs it in volume on a production line where the design file is present anyway. Reads are different: reading a programmed device extracts the design, and that is exactly what the protection is meant to prevent.

The consequence is a clean asymmetry. A protected device is a closed book that can be rewritten but not read. Copying it therefore requires getting the contents once, by whatever route works, and then using the ordinary programming path to place those contents into blank parts. The programming step is not the hard part; it is the one part of the process the vendor fully supports.

The asymmetry in detail

Operation Unprotected device Protected device
Program with a design Allowed Allowed
Verify after programming Allowed, reads back Refused, or returns a fixed pattern
Read back a programmed device Allowed Refused
Erase and reprogram Allowed Allowed
Read the security state Allowed Sometimes allowed

The second row is the one that breaks naive workflows. Production programmers verify after writing, by reading back and comparing. On a protected part that verification either fails or compares against the fixed pattern, and a line that treats verification failure as a programming failure will reject every good part. The fix is to verify before setting the security bit, and to treat the subsequent read as expected to fail.

What “encrypted file” means here

The phrase in the URL is worth unpacking, because a CPLD fuse map is not encrypted in any cryptographic sense. Three different things get called an encrypted file in this context.

Claim Actual situation
The file is encrypted The fuse map is plain; the device read is refused
The design is encrypted A security bit blocks readback; the array is plaintext
The file is unreadable Wrong format, wrong device ordering, or a protected-part dump
Genuine encryption Rare on CPLDs; appears on some flash-based families with encrypted bitstreams

The fourth row is real but uncommon, and it belongs to specific newer families rather than to the classic EEPROM parts. A genuinely encrypted configuration requires the key to be available to the device at boot, which on a standalone CPLD means the key is either in the device or derived from something in the device. That is a different problem from a read inhibit, with a different solution.

Why cloning works at all

Cloning works because the fuse map is a complete description of the configured device. There is no hidden state, no per-device calibration, no serial number that the logic depends on. Program the same map into an identical blank part and it behaves identically, because the part’s behaviour is entirely determined by the map.

Requirement Consequence if not met
Same device family and density Map does not fit; programming rejects it
Same revision letter Mapping may differ; the part programs but misbehaves
Same package and speed grade Timing may not close at the system’s operating point
Same programming algorithm Vendor tool refuses, or writes an incomplete map

The second row is the one that causes silent failures, and it is covered in more detail in copying CPLD IC code. The device revision affects the internal ordering of the fuse map, so a map from a revision A part written into a revision C part can be accepted by the programmer and still produce wrong logic.

Getting the contents in the first place

Since the read path is closed, the routes are the ones that do not use it: physical readout of the array, or a side channel that leaks the configuration. On EEPROM-based CPLDs the array is a regular structure and the die is fabricated on relaxed geometry, which makes imaging practical for modest densities.

Route Invasiveness Applicability
Session read, security bit absent None Only unprotected or unlocked parts
Session read after security bit removal Low, but destroys contents Not useful for copying
Optical readout of the array Destructive to the package General, density-limited
Electrical probing of internal nodes Destructive, expert Small arrays, targeted questions

The second row is a trap that catches people who confuse unlocking with recovering. Clearing the security bit on these devices is typically done by erasing the device, which removes the design along with the protection. There is no sequence that opens the read path while leaving the array intact, and a supplier who claims otherwise is describing a different device or a different decade.

Verifying a clone before volume

A single working clone is not evidence that a production run will work. The distribution of behaviour across parts depends on timing margins that a single sample does not reveal.

Test What it catches
Functional test at nominal supply and temperature Gross mapping errors
Test at supply extremes Timing margin that was already thin
Test across temperature range Speed-grade mismatch
Power-up sequencing test Logic that depends on initial register state
In-system test with the real host Interface timing assumptions

The fourth row matters more on CPLDs than on microcontrollers, because a CPLD has no boot code to initialise anything. Registers come up in whatever state the fabric defines, and a design that relied on a particular power-up order will behave differently in a system that powers up differently.

Where copying sits relative to the rest

Copying is the last step, not the first, and it depends on a validated design. Reading Lattice CPLD embedded firmware covers what the read produces, and copying CPLD and MCU software data extends the problem to systems where the CPLD and the microcontroller interact.

Services at this boundary

Work covers fuse map acquisition, device revision and speed grade confirmation, blank-part programming, clone validation across supply and temperature, and documentation of what was matched and what was not. It does not cover removing a security bit while preserving the array, and it does not cover copying a design into a different device family, because the mapping does not transfer.

The expectation worth setting is that a clone is a manufacturing exercise with a validation protocol, not a single successful programming run.