Decode Protected GD32F305RET6 Binary: Post-Extract Recovery
The GD32F305RET6 holds 512 KB of flash in an LQFP64 body, which is enough room for a real application plus a USB stack and a boot stub without the author having to squeeze. Once that image is read past the lock the harder half of the job begins: you have a blob of bytes and you have to decode the protected GD32F305RET6 binary into something a person can read and a toolchain can rebuild. The decode step is where a raw capture turns into engineering information.

Starting at the vector table
Every Cortex-M4 image begins with a vector table: two words at 0x08000000, then the reset handler and the fault and interrupt entries. The first word is the stack top, the second is the reset vector, and reading those two alone tells you the image is whole and where execution starts. From the reset vector the disassembly walks the code, and the peripheral registers it touches — the FMC, the RCU clock controller, the USB OTG block — begin to name the hardware the firmware expects. A binary that decodes cleanly from the vector table forward is a binary that will run.
Mapping the peripherals
The F305 is the connectivity member of the line, so a decoded RET6 image usually shows accesses to the USB OTG FS and HS controllers and, on parts that use it, the digital camera interface. That peripheral signature is what separates an F305 decode from an F303 one, where only the FS controller is present. Picking those register ranges out of the disassembly and labelling them is what turns “some code” into “this is the USB enumeration path” or “this is the camera capture loop,” and it is the work that makes the image reusable rather than merely readable.

Recovering the USB descriptors
Because the RET6 carries USB OTG, the image almost always contains a USB descriptor table — the device, configuration, interface and endpoint structures the part presents to a host. Those tables survive the read intact and decode into plain structures: vendor and product ids, endpoint sizes, string indices. Recovering them from the binary is often faster than guessing them, and it is what lets a rebuilt clone enumerate on the same bus as the original. The companion notes on retrieving the locked flash cover how the image is captured before any of this decoding starts.
From disassembly to a buildable project
Decode does not stop at a listing. The next step is recognising library code — the vendor USB driver, a CRC routine, a fixed-point math block — and setting it aside so the application logic stands clear. Where the goal is a clone, the labelled image becomes the basis for a project that builds and runs on a blank RET6, option bytes carried over so it boots identically. The source-level clone of the 1 MB RGT6 part takes this same decode and pushes it one level further, and where the goal is a working copy rather than a rebuild by hand the decoded image is handed to the firmware cloning process.
What the 512 KB size changes
Twice the flash of the RCT6 means more room for a second stage, an updater or a stored data region, and a decoder has to account for that. A region that is pure data rather than code — a font, a lookup table, a calibration set — decodes differently and must not be forced through the disassembler. Telling code from data is the discipline that keeps a 512 KB decode honest, and it is why the table below lists what each pass is for. On the F305 specifically the larger array also tends to hold the USB OTG HS driver intact alongside the FS one, which is a useful cross-check: if both driver copies decode to the same peripheral map, the image is almost certainly whole.
| Decode pass | Input | Output |
|---|---|---|
| Vector resolve | first 1 KB | entry points, stack top |
| Peripheral label | register access | FMC, RCU, USB OTG, DCI |
| Descriptor pull | data scans | USB ids, endpoint map |
| Library split | code patterns | vendor driver vs application |

How the decoded result is returned
The deliverable is the binary plus a disassembly, plus a peripheral and descriptor map where those are present. The smaller flash parts decode the same way with less to wade through, so the RET6 is the middle of the LQFP64 range in both size and effort.