Uploading CFC Blocks from S7-400H Flash Memory: Recovery Steps

David Krause20 min read
S7-400SiemensTechnical Reference
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Uploading CFC Blocks from Simatic S7-400H Flash Memory: Recovery Steps

When the only artifact of a SIMATIC S7-400H (or standard S7-400) controller project is the flash memory card in the CPU's slot, recovering the controller's runtime program is possible, but the operation is not a single "upload CFCs" command. The CFC (Continuous Function Chart) editor in SIMATIC PCS 7 stores its charts as source files inside the STEP 7 project on the engineering station; what the CPU executes is the compiled machine code packed inside standard STEP 7 blocks (FB, DB, OB, SFB, SFC, SDB). Those compiled blocks are what physically reside on the flash card, so the recovery procedure copies blocks, not charts, and recreates the chart view from the compiled artifacts.

This reference walks through the complete recovery workflow for an S7-400H CPU whose flash card is intact but whose original STEP 7/PCS 7 project archive has been lost. The procedure covers block extraction, hardware configuration reconstruction, password/know-how protection handling, CFC source re-creation, and H-system (fault-tolerant) considerations such as the requirement that both CPUs carry the same program image.

Critical warning: Always back up the flash card contents to a separate PC folder before any read or write operation. On S7-400H, both CPUs' flash cards must be backed up. On a synchronized pair, only the active (master) CPU's flash card is the authoritative program source at the moment of switchover. Loss of a single card does not lose the program; loss of the engineering archive does.

1. CFC Compilation Model and Why Direct Upload Is Impossible

CFC is a graphical configuration language in the SIMATIC PCS 7 toolbox that sits on top of STEP 7. A CFC chart is, in concept, a network of function block instances wired together with signal flows. From the engineer's perspective the chart is the source of truth; from the CPU's perspective, the chart never exists. When you compile a CFC chart, the compiler generates:

  • One or more Function Blocks (FB) that contain the run sequence and instance references.
  • Instance Data Blocks (DB) that hold the runtime data of each block instance (CTRL_PID instance, MOT_SPEED instance, VLV instance, etc.).
  • Modifications to OB1 (and OB35 / OB100 / OB121 for cyclic tasks and error handling).
  • Possibly System Blocks (SFB/SFC) when standard PCS 7 libraries call them.

These blocks are then downloaded to the CPU along with the rest of the STEP 7 program. The compiled blocks are also the only thing written to the flash card. The CFC source representation lives in the offline project only; the CPU has no knowledge of "CFC" as a concept, it only knows the resulting FBs and DBs. This is why the recovery operation extracts blocks, not charts.

Object Location Recoverable from Flash? Notes
CFC chart source (*.fct) STEP 7 project on ES No Source is not on CPU
SFC chart source (*.sfc) STEP 7 project on ES No Source is not on CPU
Compiled FBs CPU load memory (flash) Yes Run sequence + block calls
Instance DBs CPU load memory (flash) Yes Runtime parameters + initial values
OB1 / OB35 / OB100 CPU load memory (flash) Yes Includes CFC-generated calls
System data (SDB) CPU load memory (flash) Yes HW config + net config
Hardware configuration SDB container Partially Recovered as a unit; can be edited
Comments / symbols STEP 7 project on ES No Lost unless project backup exists
WinCC tags and faceplates WinCC project on ES No AS-OS connection lost

The implication is that even a perfect block recovery yields a CFC program whose chart names, comments, and signal names are stripped down to whatever is in the block headers and instance DB comments. Names like FC1001_PID_TIC_101 often survive because the CFC compiler writes them into the FB/DB name fields, but descriptive text, signal comments, and operator text from WinCC are unrecoverable without the original ES project.

2. Prerequisites: Hardware, Software, and Authorization

To extract blocks from an S7-400H flash card you need the following hardware and software on the engineering station:

  1. A PG/PC with STEP 7 V5.5 SPx or SIMATIC PCS 7 V8.x/V9.x installed. Use the same major version that originally compiled the project when possible. A project compiled with PCS 7 V8.0 cannot be cleanly re-opened in PCS 7 V7.1 because the CFC runtime version field and the chart DB layout have changed across major versions. STEP 7 "TIA Portal" cannot read classic S7-400 blocks; this procedure applies to the classic STEP 7 / PCS 7 toolchain only.
  2. The CPU's external flash card reader/programmer (S7-400 FEPROM card in a Field PG, or a Prommer with a 5 V slot). The card is 5 V FEPROM and is not readable by a generic USB card reader; the Siemens SIMATIC Field PG has a built-in 5 V slot. Alternatively, the card can be read while seated in the CPU via an online connection (TCP/IP or MPI).
  3. The original passwords for any know-how-protected blocks (see Section 6). Without the password, the CPU refuses to read the protected FBs/DBs and the operation aborts with a protection violation event in the diagnostic buffer.
  4. An empty STEP 7 project created with the same station template (S7-400H station), with the rack and slot count matching the original H-station (UR2-H, two CPUs, sync modules, sync cables).
  5. Authorization for CFC/SFC if the project is to be edited in the CFC editor (license required, not just for read).
Authorization note: Reading blocks from the CPU does not require a CFC license on the ES. Compiling, chart editing, and downloading the regenerated CFC project back to the CPU do require a valid CFC/SFC authorization. If you only need to extract blocks for documentation or for transferring them to a new controller, no license is required.

3. S7-400H Memory Architecture and Flash Card Layout

The S7-400H is a fault-tolerant station with two CPUs running in synchronous mode. Each CPU has its own load memory (FEPROM flash card) and its own work memory (RAM). The program is identical on both cards. The flash card contains:

  • Block container with all S7 blocks (OB, FB, FC, DB, SFB, SFC, SDB).
  • System data blocks (SDB) that encode the hardware configuration, network configuration, and the H-station link parameters.
  • The diagnostic buffer content is not on the flash; it is in RAM, so it is lost on a hard power-down if RAM is not buffered by a backup battery.
  • Optionally, recipe data or user data if the application stores them in the load memory (rare for PCS 7).

STEP 7's "Memory Card" icon in the SIMATIC Manager opens a window that shows the block list and the SDB list side by side. Cards are formatted with the Siemens proprietary filesystem; a Windows PC cannot read them. Note: a 5 V FEPROM card is different from a SIMATIC MMC (MultiMediaCard) used on S7-300/S7-1500. The S7-400H series does not accept MMC.

CPU Card Type Card Size Range Filesystem
CPU 412-3H 5 V FEPROM 2 / 4 / 8 / 16 MB Siemens S7
CPU 414-3H 5 V FEPROM 2 / 4 / 8 / 16 MB Siemens S7
CPU 416-3H / 416-5H 5 V FEPROM 4 / 8 / 16 / 32 MB Siemens S7
CPU 417-4H 5 V FEPROM 8 / 16 / 32 / 64 MB Siemens S7
H-station caveat: Always read the flash card from the currently active CPU (the master). On switchover, the standby CPU's RAM is updated from the master but the flash card on the standby is written only if the program is explicitly downloaded to that CPU. If the two cards diverge, sync errors will appear and the standby will not go online. The role of each CPU is visible in the diagnostic buffer (event IDs 0x4Exx range) and in HW Config under CPU > H-Parameters.

4. Hardware Configuration Recovery

Recovering blocks without recovering the hardware configuration is futile, because the CPU will reject blocks whose SDB references point to non-existent slot addresses. The HW Config is stored in the SDB container on the flash card. To recover it:

  1. Open the empty S7-400H station project in SIMATIC Manager.
  2. Right-click the S7-400H station and select Station > Open with HW Config.
  3. In HW Config, select Station > Save and Compile with a placeholder configuration (a UR2-H rack with two CPU slots). This creates a baseline SDB that the CPU can compare against.
  4. Connect the PG to the active CPU via Ethernet (or MPI as fallback) using TCP/IP at the CPU's IP address (default 192.168.0.1 for the first H-CPU, 192.168.0.2 for the second, on subnet 255.255.255.0).
  5. Right-click the S7-400H station and select Target System > Download to Target System for the SDB part. STEP 7 will offer to "Upload Station to PG"; choose this if offered. The upload reads the SDBs from the CPU and replaces the placeholder HW Config in your project.
Alternative path: If the S7-400H station has never been online to the CPU and you have no SDBs, open SIMATIC Manager and select PLC > Upload Station to PG. This uploads the entire station (HW Config + blocks) to the connected PG, provided the CPU password (if any) is known. This is the cleanest recovery path and should be the first attempt.

After HW Config is recovered, verify the following elements match the original plant:

  • Central rack type (UR2-H, UR2-H with I/O, or a remote ET200M ring),
  • CPU order numbers, firmware versions, and slot positions,
  • Sync module types and link addresses,
  • PROFIBUS DP master and slave addresses,
  • PROFINET IO device names and IP addresses,
  • CP443-1 / CP443-5 / CP1623 modules and their slot locations,
  • HMI/WinCC connection points.
SDB Type Content Edit After Upload
SDB 0 CPU parameters (priority, watchdog, OB selection) Yes, in HW Config > CPU properties
SDB 1xx DI/DO signal module parameters Yes, in HW Config > module properties
SDB 2xx AI/AO signal module parameters Yes, in HW Config > module properties
SDB 5xx CP module parameters (PROFIBUS, PROFINET, Industrial Ethernet) Yes, in NetPro
SDB 1xxx H-station redundancy parameters (sync, master/standby role) Yes, in HW Config > CPU > H-Parameters

5. Block Recovery Procedure (Step-by-Step)

The canonical procedure is "Upload Station to PG", but if that fails (e.g., password locked, CP failure, network unreachable) the manual block-by-block fallback applies. The fallback is also useful when the goal is to read individual blocks rather than the whole station.

S7-400H CFC Recovery Flowchart Start: Flash card present Establish online connection (TCP/IP / MPI) PLC > Upload Station to PG Recover HW Config from SDB container Generate CFCs from S7 Program (PCS 7 V8+) Verify & download to both CPUs
  1. Establish online connection. Set the PG/PC interface to TCP/IP > Network card with the CPU on the same subnet, or use MPI for a CPU that is still in factory state. Open the project in SIMATIC Manager, expand the S7-400H station, then right-click the station and choose Accessible Nodes. The CPU should appear with its IP and MAC.
  2. Open the online view. Right-click the connected CPU and choose Online & Diagnostics, or select PLC > Online & Diagnostics from the menu. Switch to the Block Folder tab. The online view will list all blocks on the flash card with their S7 timestamps and CRC.
  3. Upload all blocks. Use PLC > Upload Station to PG. This creates a new S7-400H station in the current project with the recovered HW Config and blocks. If the project has an existing station, STEP 7 may prompt to overwrite; choose Yes only if the existing station is a placeholder.
  4. Verify block integrity. After upload, open the block folder and check the columns Author, Family, Name (header). For each FB, open it offline and confirm the code is present. For each DB, confirm the structure is non-empty (initial values appear in the declaration view).
  5. Resolve compile-time references. If the project was compiled with CFC, the FBs will reference standard PCS 7 library blocks (CTRL_PID, MOT_SPEED, VLV, and similar function blocks from the PCS 7 Master Data Library). These libraries must be installed in your STEP 7/PCS 7 installation or the project will not recompile. Install the matching PCS 7 library DVD or the version-matched Master Data Library for the PCS 7 version used originally.
  6. Re-open the project in CFC editor. From SIMATIC Manager, double-click the Charts folder. The CFC editor will attempt to reverse-engineer the run sequence and chart structure from the FBs. In PCS 7 V8.x and later, a "Create CFCs from S7 Program" function is available under Options > Charts > Import that uses the FBs' compile-time metadata to recreate the chart topology.
  7. Save the project to a permanent archive. Use File > Archive and save the *.s7p or *.pcx file to a network share. The S7-400H CPU's flash card is not a long-term backup; it is a working copy.
If the CPU is not reachable online: The flash card can be read in a Siemens Prommer or a Field PG with the SIMATIC FEPROM adapter. STEP 7's File > Memory Card File > Open opens the raw card image. The block list is then read from the card image directly. The block signatures (timestamps, checksums) are preserved.

6. Password Protection and Know-How Protection Handling

STEP 7 supports two layers of protection that block recovery:

  • CPU password (also called "Password for the CPU" or "Connection password"): set in HW Config under CPU > Protection. This password is required to read or write any data to the CPU. Without it, the online connection is denied and the diagnostic buffer logs an authorization failure event.
  • Know-How-Protect (KHP) on individual blocks: set in the LAD/FBD/STL editor under File > Know-How-Protect. The block's code section is replaced with a stub; the interface and comments remain visible but the code cannot be viewed or modified. KHP-protected blocks can still be executed by the CPU and can still be downloaded, but they cannot be read back to a PG without the password.

Recovering KHP-protected blocks requires the password that was set on the original PG. If the password is lost, there is no Siemens-supported mechanism to recover the protected code. The CPU will run the program, but the engineering station cannot display, recompile, or modify it. Attempts to bypass the KHP password by editing the S7-400 firmware are not supported and will void any service contract.

Protection Layer Set In Recovery Path Siemens-Supported
CPU password (read/write) HW Config > CPU > Protection Password reset via "Forgot password" only on the S7-1500; S7-400H requires the original password to be entered to change it Partial
CPU password (write only) HW Config > CPU > Protection Read-only operations allowed without password; full read/write requires it Yes
KHP on FB/FC LAD/FBD editor > File > KHP Original password Yes (password only)
KHP on DB DB editor > File > KHP Original password Yes (password only)
Encrypted project file (*.s7p) SIMATIC Manager > File > Archive > Encryption Original password Yes (password only)
Engineering recommendation: Whenever a CFC program is released for production, store the STEP 7 project archive (including the password list) in the plant's documentation system. The flash card on the CPU is not a substitute for an archive; it loses symbol tables, comments, source charts, SFC source, and the operator interface (WinCC) project.

7. Restoring the CFC Source View (Reverse Engineering)

Once the blocks are on the ES, recreating the CFC source is the next step. The exact path depends on the PCS 7 version:

7.1 PCS 7 V8.0 and later — "Generate CFCs from S7 Program"

The CFC editor's Options > Charts > Generate CFCs from S7 Program function reads the run sequence FB and the instance DBs, then reconstructs chart pages with one block per page. The function is available with the CFC license activated. The recovered charts are not identical to the original: instance block names and signal names are recovered from the FB/DB headers, but layout, page breaks, and comments are not. The charts are immediately editable and compilable.

7.2 PCS 7 V7.1 and earlier — manual chart reconstruction

Older PCS 7 versions did not have the auto-generate function. The recovery was manual:

  1. Open the run sequence FB (typically in the 1000-1999 range in the CFC naming scheme) and identify the run groups and run sequence.
  2. For each instance DB, open it in the DB editor and read the block type and the parameter values.
  3. Create a new CFC chart manually, place a block of the matching type, and copy the parameter values from the instance DB into the block I/Os.
  4. Reconnect the signal flow using the interconnections visible in the instance DBs and in the run sequence FB.

This is labor-intensive but can be partially automated with the CFC COM interface (CFC API) or with custom STEP 7 scripts. There is no off-the-shelf tool that recovers the original chart layout.

7.3 Recovering SFC Source

Sequential Function Charts (SFC) compile to FB 200 and the transitions compile to FB 300 to FB 500 series in standard PCS 7 practice. The same auto-generate path as CFC applies, with the source view regenerated from the FBs. The SFC transition logic (Boolean expressions) is recovered but the graphical layout is lost.

8. Commissioning and Verification

After the project is on the ES, the recovered program must be verified before it is downloaded to the CPU. The verification checklist is:

Check Method Pass Criteria
Block count match Compare online & offline block list Same OB, FB, FC, DB, SDB numbers
Block timestamp match Right-click block > Object Properties > Time Stamp Codes match (interface/compilation timestamp)
Block consistency Right-click block > Check Block Consistency No "Interface time stamp newer" warnings
Cross-reference Tools > Cross-References All used blocks resolved; no red entries
Compile (CFC) Charts > Compile > Charts as Program 0 errors, 0 warnings (warnings may be acceptable for unused signals)
Compile (SFC) Charts > Compile > SFCs 0 errors
H-station consistency HW Config > Station > Consistency Check Both CPUs pass
NetPro consistency NetPro > Network > Consistency Check All connections valid; no orphan connection
Download test Target System > Download to Target System (with H-CPUs stopped) Both CPUs accept the download; no SDB errors
Sync test Switch master/standby via "Stop -> Run" on the standby Standby goes RUN; no OB 70/72 calls; H-sync intact

For S7-400H, the download procedure is critical:

  1. Stop both CPUs (or stop only the standby; PCS 7 H-system allows download of program changes during a hot sync, but only for non-HW-Config changes).
  2. Download the program to the standby first.
  3. Run the standby; verify it synchronizes and goes into redundant standby.
  4. Switch the master/standby roles (via PLC > H-Operations > Switch Master).
  5. Download the same program to the new standby.
  6. Switch back if desired, or leave the role as is.
H-system rule: The two CPUs must have the same program image. If the flash cards diverge (one updated, the other not), the standby will not synchronize and the diagnostic buffer will log a master/standby mismatch (event IDs in the 0x4E0x range). Always download to both CPUs in the same maintenance window. Reference: S7-400H Fault-Tolerant Systems manual.

9. Troubleshooting Matrix

The most common recovery failure modes and their fixes are summarized below.

Symptom Diagnostic Buffer / Compile Output Likely Cause Resolution
Online connection refused Connection abort / authorization failure CPU password set, password missing Enter the correct CPU password; if lost, S7-400 does not allow reset; service the CPU
Block listed but read denied Block read protection KHP-protected block Provide the KHP password; without it the block cannot be uploaded
Compile error "Block FB unknown" Compile-time PCS 7 master library not installed Install the matching PCS 7 library for the version used originally
Cross-reference shows red entries Compile-time Symbol table lost or mismatched Recreate the symbol table; or accept that the project will compile with absolute addresses
"Interface time stamp newer" Online/Offline mismatch Block edited after the matching instance was generated Recompile the entire CFC program to realign timestamps
H-station sync failure after download 0x4E0x master/standby mismatch Only one CPU was updated Download the same program to both CPUs in sequence
Charts folder empty after upload n/a "Upload Station to PG" uploads blocks, not CFC source Use "Generate CFCs from S7 Program" to reconstruct the chart source
WinCC variables show "???" HMI runtime Tag connections lost because the symbol table is missing Reconnect the WinCC tags using the S7 tags; re-run "AS-OS Compilation"
Block "Author" field shows "***" n/a KHP-protected block; code section stripped Provide KHP password; the "***" indicates code is hidden but block executes normally
Card reader returns "unknown filesystem" PG/PC message Wrong card type (MMC in a FEPROM reader, or vice versa) Use the correct 5 V FEPROM programmer for S7-400 cards

For deeper fault diagnosis, the diagnostic buffer text can be looked up against the Siemens S7-400H Diagnostic Functions manual. The relevant event IDs for H-station operation are in the 0x4Exx range; the relevant event IDs for memory card errors are in the 0x02xx and 0x03xx range. For the full list of diagnostic events, refer to the S7-400H Fault-Tolerant Systems manual on Siemens Industry Online Support.

10. Preventive Practice for Future Recovery

A flash card is not a backup. The recommended procedure for any PCS 7 / S7-400H project is:

  1. Maintain a versioned archive of the STEP 7 / PCS 7 project (*.s7p or *.pcx) on a network share with read-only access for the engineering team.
  2. Store the project password list (CPU password, KHP passwords, archive encryption password) in a controlled password vault separate from the project archive.
  3. Document the H-station configuration (rack, slot, CPU order number, firmware version) in a separate inventory document.
  4. Run "Upload Station to PG" periodically (e.g., once per year) to capture a fresh offline copy of the live program.
  5. After any change, re-archive the project; do not rely on "the program is on the flash card" as a long-term record.

With this practice, the recovery procedure described in this reference is a fallback, not the primary path. The primary path is to load the latest project archive into STEP 7 and download it to the CPU. The fallback only activates when the archive itself is lost. The cost of the fallback is hours to days of engineering time; the cost of prevention is a few minutes per project release.

11. Frequently Asked Questions

Can I "upload" a CFC chart directly from an S7-400H CPU to the CFC editor?

No. The CFC source is not on the CPU; only the compiled FBs and DBs are. You must first upload the blocks to the PG, then use "Generate CFCs from S7 Program" (PCS 7 V8.0+) or reconstruct the chart manually. The chart's original layout, page breaks, and comments are not recoverable.

What is the minimum information I need to read blocks from the flash card?

A working STEP 7 V5.5 / PCS 7 installation, a TCP/IP or MPI connection to the active CPU (or a Prommer with the card), and the CPU password. If the CPU password is unknown, online read is denied. KHP passwords are only required to view the code section of protected FBs/DBs; unprotected blocks can be read without KHP passwords.

Do I need to read both CPUs' flash cards on an S7-400H?

No. Only the active (master) CPU's flash card is the authoritative program source at any moment. However, both cards should be backed up periodically because the standby's card may diverge after a partial download and become a confusing reference during recovery.

Will the recovered project compile in a different PCS 7 version?

Only if the major version matches or if a STEP 7 / PCS 7 upgrade is performed with the matching Service Pack. A project compiled with PCS 7 V8.1 will not open in PCS 7 V7.4 because the CFC runtime version field and several standard library FBs changed. Verify the original version in HW Config > CPU > Identification before installing the ES software.

What happens to WinCC tags and HMI faceplates when only the AS program is recovered?

WinCC tags are not on the AS flash card. They live in the WinCC project on the engineering station. If the WinCC project archive is also lost, the AS-OS connection must be rebuilt by hand: re-create the WinCC tags, re-bind the faceplate instances, and re-run the "AS-OS Compilation" function to align the tag names. This is the most time-consuming part of any recovery and is best avoided by archiving the WinCC project alongside the STEP 7 project.

Back to blog