PostHeaderIcon Restore Microcontroller STM32F103C8 Flash Program Code

The STM32F103C8T6 is one of the most widely deployed microcontrollers in the world, and almost every application built around it relies on its built-in protection against unauthorised reads. Understanding how that protection actually works — not just that it exists — is essential for anyone maintaining, auditing, or documenting a device built on this part. This article explains the STM32F103C8T6 read-out protection mechanism at the register and hardware level, and the legitimate engineering situations in which that knowledge matters.

The chip in one paragraph

The STM32F103C8T6 is a member of ST’s STM32F1 series, built around an ARM Cortex-M3 core running at up to 72 MHz. It provides 64 KB of flash, 20 KB of SRAM, and comes in an LQFP48 package. It exposes two debug interfaces — the five-pin JTAG port and the two-wire Serial Wire Debug (SWD) port — and it stores its configuration in a dedicated area called the option bytes. That option-byte area is where read-out protection lives.

What read-out protection (RDP) actually is

Read-out protection on the STM32F1 family is not a single on/off switch but a three-state setting stored in flash option bytes:

RDP levelOption-byte valueEffect on debug access
Level 00xA5No protection — flash is fully readable via SWD/JTAG
Level 1any value other than 0xA5 and 0xCCDebug read access to flash blocked; most unlock attempts trigger a mass erase
Level 20xCCDebug interface permanently disabled; irreversible

The critical detail is how Level 1 is enforced. The flash controller itself refuses to serve read requests to the main flash memory while the program counter is not executing from that same memory. In other words, code running out of flash can fetch instructions normally, but an external debugger cannot pull the same bytes out over SWD. This is a hardware gate inside the flash interface, not a software policy — which is why it holds even if the firmware is attempting nothing unusual.

How the option bytes enforce protection

The option bytes occupy a small, separately writable region of the flash information block. Along with RDP, they store configuration such as the read protection flag, write protection for individual flash pages, and watchdog/brown-out settings. Because these bytes are read at every reset, the protection state is established before a single line of user code executes.

The consequence for anyone inspecting a device is that protection is a property of the silicon configuration, not of the program itself. Two STM32F103C8T6 chips running identical firmware can behave completely differently under a debugger depending on how their option bytes were programmed at production time.

Why engineers encounter locked STM32F103C8T6 devices

The scenario that brings most teams to this topic is not malicious — it is almost always one of the following:

  • Lost source code. A contract manufacturer held the only copy of the project, or an engineering archive was lost during a server migration. The programmed chip is now the only surviving record of years of development.
  • Legacy production lines. Equipment still in service depends on a board that is out of warranty and whose original supplier no longer exists. The firmware inside the chip is the sole means of producing replacement units.
  • Second-sourcing and verification. A manufacturer wants to confirm that a batch of chips was programmed with the correct, authorised firmware — or needs to migrate that firmware to a different but compatible part.
  • Failure analysis. An intermittent field failure must be traced back to a firmware state that only exists inside the device.

In every one of these cases the goal is recovery of the engineers’ own intellectual property, which is why legitimate recovery work is predicated on documented ownership or written authorisation.

Restore Microcontroller STM32F103C8 Flash Program Code and copy extracted firmware to new MCU in order to make STM32F103C8 binary code microprocessor cloning
Restore Microcontroller STM32F103C8 Flash Program Code and copy extracted firmware to new MCU in order to make STM32F103C8 binary code microprocessor cloning

How the protection is technically approached

Because the protection mechanism is understood, so are its boundaries. From an engineering-education standpoint, the approaches fall into three tiers.

  1. Diagnostic readout. With RDP at Level 0, a standard SWD or JTAG connection using ST-Link or an equivalent probe reads the entire flash directly. This is the routine case during development and requires no special handling.
  2. Protection-bypass techniques. At RDP Level 1, the protection is enforced by the flash controller and its interaction with the debug state machine. Fault-injection techniques — precisely timed glitches on the power supply or clock while the device is entering a vulnerable state — can cause the protection check to misbehave momentarily. These methods are non-invasive: the die is never physically altered, though results depend on the specific silicon revision and are not guaranteed.
  3. Invasive analysis. When software-level access is impossible, the package can be chemically or mechanically decapsulated to expose the silicon, after which the memory cells are read with a microprobe station. This tier is the most expensive and destroys the original package.

RDP Level 2 — the 0xCC state — is deliberately designed as a one-way door: it disables the debug interface permanently and is intended to make recovery infeasible. Experienced labs will confirm this constraint before any work begins rather than raise expectations that cannot be met.

A note on the F1 family specifically

Unlike some later STM32 families, the STM32F1 series predates certain later protection refinements, which is one reason it remains a frequent subject of study. Engineers working with the F1 lineage should treat the option-byte layout as the authoritative source of a device’s protection state and verify it before drawing any conclusions about whether a chip is “locked.”

FAQ

Can RDP Level 1 be removed without erasing the chip? Through the intended interface, no — normal RDP unlock procedures trigger a mass erase of the main flash. Fault-injection approaches aim to bypass rather than disable the check, and their success depends on silicon revision.

Is the SWD port the only way to read flash? On this part, SWD and JTAG are the intended debug access points. The bootloader in system memory offers programming access but does not expose read-back of protected flash.

Does RDP protect SRAM too? No. RDP governs reads of the main flash memory. SRAM contents behave differently and are volatile in any case.

Why do two identical boards behave differently under a debugger? Because protection is stored in option bytes, which are programmed per device. Identical firmware does not imply identical protection state.

Conclusion

Read-out protection on the STM32F103C8T6 is a hardware-level gate stored in the option bytes and enforced by the flash controller, with three clearly defined levels and one irreversible endpoint. Engineers run into it constantly — not because they are doing anything unusual, but because embedded products long outlive the teams and archives that created them. Knowing precisely what each level blocks, and how the mechanism is implemented, is the foundation for any competent engineering decision about a locked F1-series device.

Comments are closed.