Overview: Know-How Protection in SIMATIC S7-300 / S7-400
Siemens know-how protection is a built-in block-level access control feature in STEP 7 V5.x and TIA Portal. It allows a programmer to compile a Function (FC), Function Block (FB), Organization Block (OB), or Data Block (DB) in a form that is callable from the user program but whose internal logic, variable declarations, and comments are not readable. The protection mechanism is implemented at compile time and is stored as a marker inside the compiled block's S7 file, paired with a SHA-1 password hash that the engineering software validates before revealing content.
On the SIMATIC S7-300 platform, the S7-313C (6ES7313-5BF03-0AB0), S7-314C, S7-315-2 DP, S7-317, and S7-319 CPUs all support know-how protection identically. The same protection grammar applies to the S7-400, ET 200S, and ET 200SP CPUs. The user's original question concerned a protected FC 1 on an S7-313C — the procedures below apply to that CPU and its family.
KNOW_HOW_PROTECT active and the source file discarded, the only supported recovery path is the password. Always archive a non-protected source copy before activating know-how protection in production projects.How Know-How Protection Works Internally
When you compile a block in STEP 7 (or TIA Portal) with the know-how protection checkbox enabled, two things happen:
- A
KNOW_HOW_PROTECTdirective is written into the block header of the generated.awl/ STL source representation, marking the block as protected. - The compiled
S7-Program/Filesversion of the block (FC1as a binarySFC-type container) has its symbol/information area sealed. The CPU executes the machine code identically to an unprotected FC; only the offline editor in STEP 7 enforces the read lock.
The protection is enforced by the engineering software (STEP 7 / TIA Portal), not by the CPU firmware. The PLC itself does not contain the protection logic — once a protected FC is downloaded, the CPU runs the compiled STL/MC7 code without any access check. This is why protected blocks can still be called, monitored online (limited), and overwritten by another compiled block, even though the editor refuses to display the contents.
| Block Type | Know-How Protection Supported | Protection Marker | Recovery Method |
|---|---|---|---|
| OB (Organization Block) | Yes | KNOW_HOW_PROTECT |
Password only |
| FC (Function) | Yes | KNOW_HOW_PROTECT |
Password only |
| FB (Function Block) | Yes | KNOW_HOW_PROTECT |
Password only |
| DB (Data Block) | Yes (separate checkbox) | KNOW_HOW_PROTECT |
Password only |
| UDT (User-Defined Type) | No | — | — |
| FB multi-instance / Instance DB | Inherits from FB | Inherited | FB password unlocks |
STEP 7 V5.x: Legitimate Access Procedure
The standard, Siemens-supported method to view the contents of a protected FC on a S7-313C is to enter the password in the editor. The procedure is identical in STEP 7 V5.5, V5.6, and V5.7:
- Open SIMATIC Manager and load the project containing the S7-313C station.
- Expand
S7-Program > Blocksin the project tree. - Double-click the protected
FC 1. STEP 7 displays the Access Protection dialog. - Enter the case-sensitive password in the Password field. The password is up to 24 characters; any ASCII character is allowed.
- Click OK. The block opens in LAD/FBD/STL editor with the
KNOW_HOW_PROTECTheader stripped from the working copy. - Optionally:
File > Save Asexports a new non-protected STL source by unchecking the Know-how protection option in the block properties dialog.
STEP 7 V5.x: Source Code Folder Approach
The Source folder in STEP 7 V5.x is a parallel, text-based representation of the offline project. It contains .awl (Anweisungsliste / STL) files for each block. If the source files were generated before know-how protection was applied, they are unprotected and can be opened with any text editor (Notepad++, vim, etc.) or recompiled via Options > Compile.
However, if the source was exported after protection was activated, STEP 7 writes only a stub to the .awl file:
FUNCTION FC 1 : VOID
TITLE =
VERSION : 0.1
KNOW_HOW_PROTECT
VAR_INPUT
// (no input parameters declared)
END_VAR
VAR_OUTPUT
// (no output parameters declared)
END_VAR
VAR_TEMP
// (no temporary variables declared)
END_VAR
BEGIN
// (block body is protected)
END_FUNCTION
This is exactly the state the user observed — an empty Source container with a KNOW_HOW_PROTECT directive. Removing the directive line and recompiling does not regenerate the logic; it only produces an empty FC because the body is gone from the source. The compiled block on the PLC, however, still contains the full machine code. To extract the body, you must open the compiled block and enter the password.
STEP 7 V5.x: Generating STL Source from the Compiled Block
The legitimate path to recover source from a compiled (online or offline) protected block is:
- Open the project offline in SIMATIC Manager.
- Right-click the protected
FC 1in the Blocks container and select Generate Source (orFile > Generate Sourcefrom the menu). - Choose an empty source file or create a new one (e.g.,
FC_Sources.awl). - STEP 7 prompts for the know-how password. Enter it.
- The unprotected STL source is written to the Sources folder and can be opened in LAD/FBD/STL editor.
TIA Portal Procedure (V13 SP1 to V18 / V19)
For S7-300 stations that have been migrated to a TIA Portal project, the procedure is documented in the official Siemens TIA Portal Help under Protection of know-how. The portal implementation matches the ET 200SP documentation referenced by Siemens.
Per the official TIA Portal documentation (TIA Portal: Know-How Protection):
- Open the TIA Portal project and navigate to the Program blocks folder.
- Double-click the protected block (e.g.,
FC1). The editor opens the Access protection dialog. - Enter the password in the Password field and click OK. The block contents are decrypted and displayed.
- To remove protection permanently, right-click the block → Properties → Protection tab → uncheck Know-how protection → enter the password → confirm with OK.
- Compile the project (Compile > Software (rebuild all)) and download to the S7-313C.
§ $ % & are allowed but should be avoided if the project must remain compatible with older STEP 7 V5.x versions. The TIA Portal SHA-256 hash format is not directly compatible with STEP 7 V5.x's SHA-1 representation; cross-version projects must re-enter the password when first opened in the new tool.Removing the KNOW_HOW_PROTECT Marker After Password Recovery
After entering the password, the block opens with all logic visible. To permanently remove the protection on the offline block:
- STEP 7 V5.x: Right-click the block → Object Properties → Protection tab → clear the Know-how protection checkbox → confirm.
- TIA Portal: Project tree → right-click block → Properties → Protection → clear the Enable know-how protection checkbox → enter password → OK.
- Recompile the project and download the new block to the CPU. The PLC will replace the protected compiled block with the unprotected one. The old protection metadata is purged at this point.
Source Code Folder State in TIA Portal
TIA Portal's Program blocks > Sources folder uses .scl, .db, and .udt source files. When a block is compiled with know-how protection, TIA Portal does not export the body to the source file — only the interface section and a {S7_Optimized_Access := 'TRUE'} attribute block. The KNOW_HOW_PROTECT keyword from STEP 7 V5.x is not written; instead, the editor uses a separate binary metadata field in the project file (.apXX).
Attempting to open a protected .scl source in an external editor (VS Code, Notepad++) will show only the interface, since the body is stored separately in the compiled representation within the TIA Portal project database. The only supported way to recover the source is the password dialog in the editor.
Password Recovery When the Password Is Lost
If the original password is lost, Siemens does not provide a backdoor or recovery tool for know-how-protected blocks. This is by design — the protection exists precisely to prevent unauthorized access to proprietary logic. The supported paths are:
- Check the project archive, version control system (SVN, TIA Project Server), or backup tapes for an older non-protected source.
- Contact the original programmer or system integrator for the password.
- Reconstruct the logic from functional specifications, I/O lists, and online monitoring data.
Online monitoring (Monitor & Force in STEP 7, Online & diagnostics → Monitor in TIA Portal) reveals the running variable states but does not expose the program code. For an FC, monitoring shows only the I/O tag values during the call; the network-by-network STL is not accessible.
S7_PROG folder, are encrypted by the CPU and cannot be read on a PC without the engineering software.Why the Source Folder Appears Empty
The user's screenshot showed an empty Source folder. This is a common situation when:
- The original programmer never generated STL source files; only the compiled blocks were saved.
- The source was generated after know-how protection was applied, leaving the
KNOW_HOW_PROTECTstub. - The project was opened in a different STEP 7 version that did not import the source files (e.g., a STEP 7 V5.4 project opened in V5.5 with a partial migration).
- The MMC card was deleted, and the offline project contains only the compiled blocks from the last online download.
The fix is not to manually edit the KNOW_HOW_PROTECT line in the source — that approach leaves the FC with an empty body. The fix is to use Generate Source on the compiled block and enter the password when prompted.
Best Practices for Protecting Your Own Blocks
| Practice | Rationale |
|---|---|
| Archive STL source in version control (SVN, Git, TIA Project Server) before enabling protection. | Recovery path if the password is lost or the MMC fails. |
| Document the password in a password manager (e.g., KeePass, HashiCorp Vault) tied to the project metadata. | Avoids the empty-source situation when the original author leaves the company. |
| Use CPU-level write protection (mode selector in RUN-P / RUN / STOP) as an additional layer. | Prevents unauthorized online block edits even if the password leaks. |
| Enable Access protection on the CPU itself (password for the S7-313C's online connection). | Blocks the Read from PLC action that would otherwise copy the protected compiled block. |
Export the project as a .zip with the With dependency option after each major change. |
Creates a self-contained archive that includes sources, symbols, and hardware configuration. |
Troubleshooting Matrix
| Symptom | Likely Cause | Solution |
|---|---|---|
| Source folder is empty after opening the project. | Sources were never generated, or the project was migrated from a stripped archive. | Right-click the compiled block → Generate Source → enter password. |
Source contains only KNOW_HOW_PROTECT line. |
Source was generated after protection was activated. | Delete the source stub, regenerate from the compiled block with the password. |
| Block opens in STEP 7 but the body is blank. | Wrong password entered, or the block was corrupted during download. | Re-enter the password. If still empty, re-download from the MMC card. |
| Password field is greyed out in TIA Portal. | Block was imported from STEP 7 V5.x and the metadata did not migrate. | Re-enable protection manually in the block properties to set a new TIA Portal password. |
| Online monitoring shows only I/O tags, not code. | Know-how protection strips code from the online view. | This is expected; enter the password to view code offline. |
| Cannot delete the protected block from the project. | The block is referenced by another FC/FB or is used as a multi-instance. | Remove all call references, then delete or replace the block. |
| Error: Protection violation: the block is know-how protected during compilation. | The compiler cannot reconcile the protected compiled block with changes to its interface. | Recompile the project (Project → Compile All in STEP 7) to regenerate interface metadata. |
CPU-Specific Notes: SIMATIC S7-313C
The S7-313C referenced in the original question is a compact CPU with integrated digital and analog I/O. The two most common part numbers in service today are:
- 6ES7313-5BF03-0AB0 — CPU 313C, 32 DI / 32 DO onboard, MPI, firmware V3.3 (replacement: 6ES7313-5BG04-0AB0, firmware V3.3).
- 6ES7313-5BG04-0AB0 — Successor with extended diagnostics.
Both CPUs run the same STEP 7 V5.x programming environment. The firmware revision is irrelevant to know-how protection enforcement — the protection is entirely a STEP 7 / TIA Portal feature. However, the firmware revision determines which TIA Portal versions can download to the CPU. TIA Portal V18 SP1 and later support S7-313C with firmware V3.3 via the legacy S7-300/400 target support package. Earlier TIA Portal versions (V13 SP1 through V17) also support it, but V18 and later require the legacy CPU support add-on.
S7_PROG blocks; the know-how protection metadata is preserved in the encrypted container.Verification Steps After Recovery
After successfully entering the password and viewing the FC body, perform these checks to confirm full project integrity:
- Compile the project (Project → Compile All). The build should complete with zero errors and zero warnings.
- Compare the online and offline block versions (Online → Compare). Both sides should match exactly.
- Generate STL source from the unprotected block to confirm the source export works. Save the source under a versioned name (e.g.,
FC1_v2.1.awl). - Re-archive the project to capture the new source files in the backup.
- If the FC will be reused in a new S7-300 station, copy the block via Options → Manage Multilingual Texts or via the project library to preserve the protection settings if desired.
FAQ
What is the KNOW_HOW_PROTECT directive in STEP 7 source files?
It is a marker inserted by the STEP 7 V5.x compiler at the top of an STL .awl file when a block is compiled with the Know-how protection checkbox enabled. It indicates the block's compiled S7 file is sealed against offline reading without a password; deleting the line from the source does not regenerate the lost code body.
Can I open a protected FC on an S7-313C without the password?
No. Siemens does not provide a recovery tool. The supported paths are entering the original password, restoring an unprotected source from version control, or contacting the original programmer. Online monitoring shows runtime I/O but not program code.
Does know-how protection prevent the protected FC from being called?
No. The CPU executes the protected FC exactly as it would an unprotected one. The protection is enforced only by the engineering software (STEP 7 / TIA Portal editor) when you attempt to read, edit, or generate source from the offline block.
Is the TIA Portal know-how protection compatible with STEP 7 V5.x?
The block-level protection concept is identical, but the password hash format differs (TIA Portal uses SHA-256; STEP 7 V5.x uses SHA-1). Migrating a protected project from STEP 7 V5.x to TIA Portal requires re-entering or re-setting the password in the new tool.
How do I prevent my own team from being locked out of a protected FC?
Always export the STL source to the Sources folder (or version control) before activating the protection, store the password in a managed vault, enable CPU-level access protection, and back up the project to an external archive after each significant change. These steps ensure a recovery path exists even if the password is lost.