Restore Secured STM32F407ZG Embedded Firmware on a Locked 144-Pin Part
Restoring a locked STM32F407ZG is not a matter of copying one megabyte from one chip to another. To restore secured STM32F407ZG embedded firmware correctly, the order of operations matters more than the technique: capture the image before any option byte change, carry the option byte state with it, and verify the connectivity peripherals. The firmware driving Ethernet, USB and the camera sits in the same protected flash.
Why a plain flash copy breaks the connectivity peripherals
The STM32F407ZG adds a 10/100 Ethernet MAC with dedicated DMA and IEEE 1588 timestamping, USB OTG FS and HS controllers with ULPI, a DCMI camera interface, a true random number generator and a CRC unit, on a Cortex-M4 with FPU at 168 MHz.
None of that configuration is separately protected. The STM32F407ZG Ethernet MAC and camera interface firmware, PHY values and USB descriptors are ordinary data in the first sectors, so a copy skipping them never brings up a link.

How to restore secured STM32F407ZG embedded firmware: the order of operations
Read the option bytes first, in the delivered state: readout protection level, write protection bits, brown-out level, boot configuration. Then capture the flash image, and only then release the debug ports, as the STM32F407ZG secured microcontroller unlock requires.
The reason is hardware, not convention. With readout protection level 1 active, a debug port read makes the part mass erase itself before returning data, so unprotecting first leaves a blank part, as in cloning a secured STM32F469VGH6 file.

The option byte state that must travel with the image
Option bytes carry the read protection level, twelve write protection bits, a brown-out reset level, the hardware watchdog mode and the boot configuration. None are part of the flash image, and all change behaviour: a different brown-out threshold resets the target on a slow ramp.
Keep the record as a short option byte manifest taken from the source before it is modified. The watchdog mode interacts with the brown-out setting at cold start, and the boot configuration decides between embedded flash and the system bootloader, as in STM32F207IGT6 flash recovery.
Unique device ID and OTP: the data a copy cannot carry
One class of data is never carried by a plain flash copy, because it is not stored in flash. The part provides 512 bytes of OTP and a 96-bit unique device ID, exposed through the factory bootloader region. Applications deriving keys from that ID reject the image on a replacement.
Record the unique device ID and OTP contents separately, while the source is readable, then reproduce them on the target where the application allows it. Skipping this produces a system that fails only against a remote server.
What has to travel with the flash image on an STM32F407ZG
The items below must accompany a restored image for STM32F407ZG embedded firmware recovery. The first four are part of a normal restoration; the fifth is most often left behind.
| Item | Where it lives | Consequence if it is missed | How to capture it |
|---|---|---|---|
| Application image | Flash sectors 0 to 11 | No firmware to run | Read the protected flash |
| Option byte state | Option bytes | Write protection or lock behaviour differs | Read the option bytes before any change |
| Ethernet MAC configuration | Application sectors | Network interface does not come up | Recover with the flash image |
| Camera interface setup | Application sectors | Sensor never initialises | Recover with the flash image |
| Unique device ID and OTP | System memory and OTP | Derived keys no longer match | Record separately if the application uses them |
The option byte state is where a partial restoration fails, because the flash reads cleanly while the device still misbehaves. The unique device ID is most likely to be forgotten.

Physical access and verification on the 144-pin LQFP package
The STM32F407ZG is packaged in LQFP 144, 20x20x1.4 mm, with 114 I/O. A 20 mm body with 0.5 mm pitch gives more room for a fixture, but denser interleaving of ground and supply means a probe shorting two pads stops the port enumerating, so access moves to the package, as in decapsulating STM32F423VHT6.
STM32F407ZG LQFP144 firmware restoration ends with verification: byte totals, option byte equality, then peripheral behaviour. A complete image is 1 Mbyte, and a shortfall means a sector was skipped. The Ethernet MAC should enumerate, the PHY negotiate a link, DCMI initialise the sensor and USB OTG HS enumerate over ULPI. A booted image with no link points to the early sectors, as in restoring STM32F103C8 flash code.

To restore secured STM32F407ZG embedded firmware, treat the job as an ordering discipline rather than a technique: capture the protected image while the security state is intact, record the option bytes and device identities with it, then rebuild the target so Ethernet, camera and USB come up as on the source. ic-crack.com performs this MCU firmware recovery.