An industrial-gateway builder needed a secured flash firmware replication for a controller based on the STM32F413VGT6: 100 MHz Cortex-M4F, 1 MB of flash, 320 KB of SRAM, 100-pin LQFP. The F413 generation stretches the F4 line toward instrumentation: ten UARTs, three CAN buses, digital filters for sigma-delta modulators, an LCD parallel interface and a quad-SPI controller. Replication here means more than copying bytes, because the commercially valuable content of this die is spread across the main array, the backup domain and a set of external SPI flash calibration tables.
The option-byte read placed the part at RDP level 1: debug, SRAM boot and the system bootloader refuse the main array with bus errors, while code running from flash keeps full access, and the backup SRAM and registers are protected alongside the flash. No PCROP was configured. On gateway-class firmware the flash image is the smaller half of the story. The customer’s units carried factory calibration for an analog front end, written to external SPI flash during production, and line-protocol tables in the backup domain that survived power cycles on the battery-backed rail. A replication that ignores those two stores produces a board that boots but does not behave like its sibling, a failure mode we also dissect in the boot-cluster recovery on an RL78 note, where a boot cluster and its flag block had to be treated as a unit.
The firmware’s CAN diagnostic service was the productive channel. Gateway builders expose CAN diagnostics for field service, and this implementation returned framed memory-region digests as part of a maintenance command set. Combined with the vendor’s signed-update path, which legitimately executes inside the chip, the digest oracle plus the update path together covered the whole 1 MB array sector by sector. The reconstruction side of that work, turning a stream of digests and page blocks into one verified image, is the same craft shown in the an RX62N network part case and in the the security byte on a GD32F303VC write-up on security-byte state machines.
The backup domain required its own phase, because the diagnostic channel addressed flash only. A short accessor, exercised through the same update path, walked the 4 KB of backup SRAM and the backup registers, which RDP protects together with the code array. The external SPI flash needed no protection work at all; it simply needed its table format reverse-engineered, and our rebuilding source from a dump engagement model covers exactly that translation from binary tables to documented structures. Teams replicating older designs will meet the same division of stores in the microcontroller recovery service description.
The F413 generation’s instrument-grade periphery turned out to matter to the recovery in an unexpected way: the sigma-delta filter block’s configuration registers were readable through the diagnostic channel, and their values encoded the front-end gain plan, which gave us an independent check on the calibration tables recovered from SPI flash. Cross-checking recovered data against a second, differently protected store is one of the strongest verification tools available, and this design offered it by accident.
The lesson we would hand to anyone quoting a replication on this family is to audit all three stores before committing a timeline. The flash was the predictable part: 1 MB, level 1, a known sector map. The backup domain cost a second phase because the diagnostic channel had never been given a command for it. The SPI tables cost the most calendar time, not because they were protected but because their format had drifted across three firmware generations, and the parsing work only converged once the customer located an old tuning-tool manual. A quote that treats the flash as the whole job will mislead both sides.
Acceptance was functional: two gateways, one replicated and one original, ran the customer’s full protocol conformance suite side by side and produced matching behaviour across the CAN buses and the analog front end. The delivered package held the 1 MB image, the backup-domain dump with annotations, the parsed calibration tables and a buildable project skeleton, the combination our program data recovered from a GD32F303RI reports and the a 512 KB RX24T motor-drive part case treat as the standard for a true replication. If your STM32F413VGT6 design carries the same split of stores, audit all three before quoting any timeline, because the flash is rarely the part that takes longest.