Clone Encrypted GD32F305RGT6 Source Code: 1 MB Rebuild
The GD32F305RGT6 is the 1 MB flash member of the line in an LQFP64 package, and the parts we are asked to clone encrypted GD32F305RGT6 source code from are usually finished products: an RTOS, a USB stack, an application and a data region all sharing the same array. “Encrypted” is the word the trade uses, but on the die the data is gated rather than ciphered — the real work is reading the locked image, then rebuilding it into something a toolchain will accept. The clone is only finished when a blank RGT6 runs the customer’s behaviour.

Reading the locked image first
Nothing can be cloned that has not first been read. The RGT6 at level 1 is opened by the same fault-injection route used across the family, and because the array is 1 MB the capture is broken into many checksummed blocks so a single dropped word is caught and re-read rather than accepted. The companion notes on retrieving the locked flash describe the block discipline; at 1 MB it is simply applied more often. The image that comes off the bench is whole or it is not shipped.
Splitting code from the RTOS and USB stack
A 1 MB image almost never is one program. It is an RTOS, a vendor USB OTG driver, middleware and the application, layered together. Cloning source means recognising those blocks rather than disassembling blindly: the RTOS scheduler, the USB enumeration and the CRC and math libraries are identified and set aside, leaving the application logic clear. Separating the F305 USB OTG HS driver from the application is the single most useful step, because that driver is reused unchanged while the application is what the customer actually wrote. The HS driver in particular is large and self-contained, and confirming it decodes to a coherent set of endpoint and DMA registers is often the first sign the surrounding application region is also intact.

Reconstructing source, not just a listing
A raw disassembly is not source. The rebuild recovers function boundaries, data structures, the descriptor tables and the build configuration that make the image compile again. Where the goal is a working clone the recovered project is compiled, loaded onto a blank RGT6 with the option bytes carried over, and confirmed to boot and enumerate on the same bus as the original. Enumeration on the original bus matters because the F305 presents as a USB OTG device; a clone that compiles but fails to enumerate has a descriptor or endpoint mismatch the decode missed. A clone that builds but will not run has not been cloned; it has only been read.
Checking the rebuild before it ships
A rebuilt project is not trusted until it is compiled and run. The recovered code is built with the same toolchain the original used where that can be identified, loaded onto a blank RGT6 with the option bytes carried over, and compared against the original capture block by block. Where the rebuilt image diverges the difference is traced to a misrecovered structure, not assumed away. This verification is the difference between a clone that is claimed and a clone that is proven, and it is a step the memory attack that opens the part never sees — by the time the silicon is read the decoding work is only beginning.
Why the 1 MB size matters for the clone
Room for an RTOS and a full USB stack means the application leans on both, and a clone that drops either will fail in ways that are hard to trace. The larger array also hides a data region — calibration, fonts, a parameter set — that must be carried verbatim. Telling that region from code is the discipline that keeps the rebuild honest, and it is why the table below lists what each pass contributes to the clone.
| Clone pass | What it recovers | Why the clone needs it |
|---|---|---|
| Image read | whole 1 MB array | the source of everything |
| Library split | RTOS, USB OTG, CRC | reused unchanged |
| Structure recover | functions, descriptors | compiles again |
| Verify on blank | boot + enumerate | proves the clone runs |
How the clone is delivered
The deliverable is a buildable project plus the binary and the option bytes, with the lock left off so the clone is useful. The 512 KB RET6 part decode is the same work with less to separate, and the program duplication of the VGT6 takes the finished image and copies it rather than rebuilding it.