Posts Tagged ‘reverse engineering chip heximal’
Duplicate Locked GD32F305VGT6 Program: 1 MB Copy
The GD32F305VGT6 is the 1 MB flash member of the line in the LQFP100 body, and the parts we are asked to duplicate locked GD32F305VGT6 program from are typically end products that must be copied exactly — same behaviour, same lock state, no interest in the source. Duplication is the simplest of the recovery family: read the whole array, write it to a fresh part, confirm it runs. The difficulty is only in doing the read on a locked 1 MB device without loss.

Reading the full 1 MB image
A duplication begins with the same fault-injection opening used across the family, applied to the largest array in the range. The capture is broken into many checksummed blocks so a single dropped word is caught and re-read; at 1 MB the discipline is identical to the smaller parts, only applied more often. The image that comes off the bench is whole or it is not shipped, because a duplicate with a corrupted block is a duplicate that fails in the field. Because the VGT6 is the top of the flash range, the capture also exercises the addressing past the 512 KB boundary that the smaller parts never reach, which is one more reason the block checksums matter more, not less, at this size. The memory attack that opens the VET6 is the same opening scaled to this array.
Carrying the option bytes
The most overlooked part of a faithful duplicate is the option bytes, which hold the SPC level and the boot settings. If those are captured with the array, the image written to a blank VGT6 boots and locks exactly as the original did. If they are dropped, the copy may run but will not carry the original protection, which defeats a duplication that was supposed to be exact. We return the option bytes explicitly and write them with the array so the clone is bit-for-bit the same device.
Writing to a blank part
A blank VGT6 takes the captured array through the same programming path any firmware uses, with the option bytes written last so the lock engages only after the code is in place. Writing the option bytes last is not a detail: if the SPC level were set before the array was complete the part would lock with a partial image and the duplicate would be useless, so the sequence is that the lock engages only on a whole, verified array. The 1 MB write is long but routine; what is not routine is the verification that follows. The copy is read back and compared block by block against the original capture, and only when they agree is the duplicate accepted. A clone rebuilt from source is judged by whether it runs; a duplicate is judged by whether it matches.
Why a duplicate is not a clone
A duplicate and a clone are often confused, and the difference decides the method. A clone rebuilds the source and recompiles, which is the route when the goal is to understand or modify the firmware; a duplicate copies the image bit for bit, which is the route when the goal is simply to have another part that behaves identically. The VGT6 duplicate asks for neither understanding nor modification, only fidelity, and that is why its verification is a comparison rather than a build. The rebuilt clone of the 1 MB RGT6 is the other end of that choice.
Why the VGT6 size matters
Room for an RTOS, a USB stack, an application and a data region means the duplicate must carry all of them verbatim, and a data region — calibration, fonts, a parameter set — must not be mistaken for code and altered. The larger array also means the verification pass is longer, but it is the same pass that proves the smaller parts. The 256 KB VCT6 decapsulation is the route when this part will not open electrically; once it does, duplication is the easy half.
| Duplicate step | Action | Proof |
|---|---|---|
| Read | block-checksummed 1 MB | whole capture |
| Write | array then option bytes | lock engages last |
| Verify | read back vs original | bit-for-bit match |
| Boot | run on blank part | same behaviour |
How the duplicate is returned
The deliverable is the working duplicate part plus the original binary and option bytes, so you hold both the copy and the record of what it contains. The image itself, if you prefer to program the copies yourself, is the same file used for the flash retrieval of the smaller parts — only the array is larger.