Posts Tagged ‘extract pld mcu binary’
Extract PLD and MCU Code: The Bus Decides the Order
On a board with a microcontroller, a PLD, and one or more memory devices, the physical order of the components is not the logical order of their relationships. The PLD frequently sits between the microcontroller and everything else, latching addresses, decoding chip selects, and gating the bus. That position makes it both a key to the board and an obstacle to reading it.
The practical consequence is that extraction has an order, and the order is determined by the bus topology rather than by preference. Reading the wrong device first is not merely inefficient; on some boards it is impossible.
The three common topologies
| Topology | PLD’s role | Consequence for extraction |
|---|---|---|
| PLD decodes only | Passive; chip selects from address lines | Any device can be read independently |
| PLD latches and decodes | Holds the low address byte | Reads require the latch to be driven correctly |
| PLD arbitrates | Grants the bus to one master at a time | Reads require a grant, or a halt |
| PLD holds the boot image select | Chooses which memory is mapped at boot | Which device is visible depends on boot state |
The second row is the most common on older designs, where a multiplexed address and data bus needs an external latch. The PLD is the latch, and the address it holds determines what the memory sees. A read that drives the bus without driving the latch reads whatever address happened to be latched, which is usually the last one the system used.
Why a latch changes the method
With a latch in the path, the microcontroller’s address is not the memory’s address. The mapping goes through a register inside the PLD, and the register’s value is part of the system state.
| Signal | Source | Needed for a read |
|---|---|---|
| High address byte | Microcontroller, direct | Driven by the reader |
| Low address byte | Latched inside the PLD | Must be written to the latch first |
| Chip select | Decoded from both bytes | Follows from the address |
| Read strobe | Microcontroller, or PLD | Must be asserted at the right time |
This is why a clip-on programmer sometimes fails on these boards while an in-system read succeeds: the programmer drives addresses directly at the memory, which works if the memory’s address pins are accessible, and fails if the low byte comes from the PLD’s output rather than the bus.
Establishing the topology before reading
The topology can be determined without a schematic, from a few observations.
| Observation | Inference |
|---|---|
| Memory address pins trace to the microcontroller directly | Direct bus, no latch |
| Memory address pins trace to the PLD | Latched or decoded |
| PLD output drives the memory’s chip enable | PLD gates access |
| Two memory devices with mutually exclusive enables | Banked; boot state matters |
| PLD input from the microcontroller’s read strobe | PLD may qualify the strobe |
The second row is the decisive one. Once the low address lines come from the PLD, the PLD has to be understood before the memory can be read reliably.
Order of extraction
| Order | Device | Why |
|---|---|---|
| 1 | PLD | Defines the map and the latch behaviour |
| 2 | Memory | Read using the map, with the latch driven |
| 3 | Microcontroller | Read last, because it is usually the easiest |
| Alternative | Memory first, with the PLD held in a known state | Works if the latch can be forced |
The alternative is worth knowing because it is sometimes much faster: if the PLD can be held in reset, its outputs go to a defined state, and some designs tri-state their latch outputs on reset, which restores direct access to the memory.
When the PLD cannot be read first
A protected PLD blocks the preferred order, and the fallback is behavioural.
| Situation | Approach |
|---|---|
| PLD unprotected | Read it; the map follows |
| PLD protected, board working | Capture the bus; infer the map from observed selects |
| PLD protected, board dead | Read the memory by forcing the latch, or desolder |
| PLD failed | Reconstruct the map from the memory’s contents and the MCU code |
The fourth row is a genuine and satisfying case: a failed decoder can often be reconstructed from the firmware, because the microcontroller’s code contains the addresses it expects. Those addresses define the map that the PLD must have implemented.
The firmware as a specification of the decoder
This is the most useful cross-check available on these boards, and it works in both directions: the firmware tells you what the decoder does, and the decoder tells you what the firmware assumes.
| Firmware evidence | Decoder property |
|---|---|
| Base addresses of peripheral accesses | Decode ranges |
| Access width | Bus width configuration |
| Wait states or delay loops | Timing requirements |
| Initialisation sequence | Enable and reset ordering |
| Aliased accesses | Mirrored decode windows |
The fifth row is subtle and valuable. If the firmware accesses the same peripheral at two different addresses, either the decode mirrors the window or the firmware has a latent bug. Reading the decoder settles which.
Reading the PLD itself
Once the topology is understood, the PLD read follows the usual path. Its array is small, its protocol is documented, and its position on the board usually makes in-system access straightforward if the device is unprotected.
| Device type | Read method | Note |
|---|---|---|
| EEPROM PLD, unprotected | In-system or socket | Charge-based, see the EEPROM page |
| EEPROM PLD, read inhibited | Physical | Array is small and accessible |
| Flash CPLD, unprotected | JTAG or ISP | Container is a fuse map |
| Flash CPLD, security bit set | Physical or policy analysis | Depends on architecture |
The first row’s caveat matters: the physical basis of an EEPROM array is treated in extracting PLD EEPROM, and the conversion of the array into logic is in reading PLD binary into equations. Where the PLD’s role is purely decoding, the map reconstruction is the whole deliverable and is covered in reading PLD code in an MCU system.
Services at this boundary
Work covers topology identification, latch behaviour characterisation, extraction ordering, in-system reads with the latch driven, behavioural map inference where the PLD is unreachable, and cross-checking against firmware constants. It does not cover reading a memory device through a latch that cannot be controlled, without either desoldering or forcing the latch through another path.
The practical rule is that on these boards the bus is the specification, and the PLD is usually the part of the bus that nobody wrote down.