Problem Description
A redundant pair of SIMATIC S7-315-2DP CPUs configured with the Siemens Software Redundancy (SWR) blocks transitions unexpectedly into STOP mode shortly after FC100 "SWR_START" initializes the redundancy link. The diagnostic buffer reports an "Area length writing error" (German: Bereichslängenfehler beim Schreiben) tied to a data block operation inside the SWR runtime. The fault appears only when the engineer changes DB_NO_LEN (the number of redundant user data blocks) from 1 to any larger value such as 2, 4, or higher.
When DB_NO_LEN = 1 the system runs for hours or days without incident. The instant a second redundant DB is referenced (or when the project is downloaded with DB_NO_LEN > 1), the standby CPU goes into STOP within one or two redundancy cycles and the active CPU follows on the next link update.
16#2522 (OB not loaded) or 16#35xx (area length error) and a starting event of SWR_START / FB 101 "SWR_DIAG". MW2 (RETURN_VAL) and MW4 (EXT_INFO) hold the encoded SWR error.Affected Hardware and Software
| Item | Value / Catalog |
|---|---|
| Active CPU | 6ES7 315-2AG10-0AB0 (or 6ES7 315-2EH13-0AB0) |
| Standby CPU | Identical to active, same firmware major |
| SWR package | S7-300 Software Redundancy V1.x / V2.x (FB 100–105, FC 100) |
| STEP 7 | SIMATIC Manager V5.5 SPx or compatible |
| CP (MPI/DP coupling) | CP 342-5 (LADDR = 256 in the example) or integrated DP port of 315-2DP |
| ET 200M slaves | IM 153-3 (6ES7 153-3BA00-0XB0 or later) |
| Profibus address range | SLAVE_NO = 3, SLAVE_LEN = 2, SLAVE_DISTANCE = 1 |
The fault is independent of the CP type and reproduces on both the integrated DP interface of the 315-2DP and on external CP 342-5 modules. It is also independent of the VERB_ID used for S7 connection number 1.
FC100 SWR_START Parameter Reference
The following parameter assignment corresponds to the field program that triggered the STOP:
| Parameter | Value in Example | Engineering Meaning | Constraint |
|---|---|---|---|
AG_KENNUNG |
'A' |
PLC classification: A for Station A, B for the partner | One CPU per redundancy pair must be 'A', the other 'B' |
DB_WORK_NO |
DB1 |
Working DB for SWR runtime | Reserved — SWR writes internal state |
DB_SEND_NO |
DB2 |
Send DB for redundancy coupling | Must be deleted in CPU before re-init |
DB_RCV_NO |
DB3 |
Receive DB for redundancy coupling | Must be deleted in CPU before re-init |
MPI_ADR |
4 |
MPI address of the partner station | Must match partner's MPI/DP port |
LADDR |
256 |
Logical base address of the CP | From HW Config > CP properties |
VERB_ID |
1 |
S7 connection number for redundancy coupling | NetPro must contain this connection |
DP_MASTER_SYS_ID |
1 |
DP master system identification (HW Config) | Must match the DP master system number |
DB_COM_NO |
DB5 |
Instance DB of FB 101 "SWR_DIAG"
|
Auto-generated by STEP 7 |
DP_KOMMUN |
1 |
DP master system used for SWR diagnostics | Same as DP_MASTER_SYS_ID in standard configurations |
ADR_MODUS |
1 |
CPU I/Q addressing interval (every cycle vs. every other cycle) | 1 = address every call (faster response) |
PAA_FIRST / PAA_LAST |
0 / 5 |
Byte range of redundant process outputs (PA) | QB0..QB5 are mirrored to partner |
MB_NO / MB_LEN |
40 / 70 |
First flag byte / length used as scratch by SWR | Range MB40..MB109 must be free of user code writes |
IEC_NO / IEC_LEN |
111 / 0 |
First instance DB / count for IEC counters/timers | 0 = no IEC blocks to mirror |
DB_NO / DB_NO_LEN |
10 / 1 (failure point) |
First DB / count of redundant user DBs | DBs must be contiguous, long enough, and pre-deleted online |
SLAVE_NO / SLAVE_LEN |
3 / 2 |
First DP slave address / number of redundant slaves | Slaves must be active in HW Config of both stations |
SLAVE_DISTANCE |
1 |
Configuration of IM 153-3 interface | 1 = SWR compatible mode |
DB_A_B_NO / DB_A_B_NO_LEN |
DB112 / W#16#0 |
Non-redundant send DB / byte length | 0 = disabled |
DB_B_A_NO / DB_B_A_NO_LEN |
DB112 / W#16#0 |
Non-redundant receive DB / byte length | 0 = disabled |
RETURN_VAL |
MW2 |
SWR_START return code | W#16#0000 = OK |
EXT_INFO |
MW4 |
Extended diagnostic word | See error matrix below |
Root Cause Analysis
The "area length writing error" is raised by the SWR library while copying redundant user DBs from the active CPU to the standby. There are three independent root causes that can trigger it; in this incident two of them were present simultaneously.
Cause 1 — DB length below minimum
Siemens documentation states that every DB declared redundant via DB_NO and DB_NO_LEN must have a length of more than 2 words (i.e. > 4 bytes). A DB containing only a single BOOL or a few bytes under that threshold causes FC100 to perform an out-of-range SFC write. With DB_NO_LEN = 1 the engineer happened to assign a DB that just exceeded the threshold; the moment the second redundant DB was added it was sized below 4 bytes and triggered the fault.
Cause 2 — Stale DBs in the CPU image
FC100 "SWR_START" re-initializes DB_WORK_NO, DB_SEND_NO and DB_RCV_NO at each call. If the actual on-line image of those DBs was created in a previous program version with a different structure (e.g. older SWR library revision), the residual length on the CPU does not match the offline project. SWR's copy routine then writes past the runtime DB and the area-length check fires. The standard fix is to delete DB1, DB2 and DB3 on the CPU before downloading the new FC100 instance, then download the blocks in this order: FC100 → DB1 → DB2 → DB3 → DB5 (instance of FB 101) → FB 101 → remaining user DBs.
Cause 3 — Non-contiguous DB numbering
When DB_NO = 10 and DB_NO_LEN = 2, the SWR library expects DB10 and DB11 to both exist on both CPUs. If only DB10 is present in HW Config or in the offline program, the copy step writes to DB11 which is not allocated, and the CPU enters STOP. Verify in STEP 7 via PLC > Accessible Nodes that DBs DB_NO through DB_NO + DB_NO_LEN - 1 are present and identical on station A and station B.
_SWR_COPY or block FC 100) and EXT_INFO = W#16#8001, suspect Cause 1. If EXT_INFO = W#16#8002 or W#16#8003, suspect Cause 2. If EXT_INFO = W#16#8004 or W#16#8005, suspect Cause 3. Always confirm with the diagnostic buffer before replacing memory cards.Step-by-Step Resolution
- Back up both projects. Archive the active project via File > Archive and read the on-line program from station A and station B to a separate project. Note the current SWR library version under PLC > Module Information > Blocks.
-
Install OB 121 (Programming Error OB). On each CPU, download
OB 121,OB 122(I/O access error),OB 80(time error),OB 82(diagnostic interrupt), andOB 85(program cycle error). With these OBs in the CPU, transient access errors no longer drop the PLC intoSTOP; the user program is given a chance to log the error viaSFC 36-39instead. -
Verify each redundant DB length > 4 bytes. In SIMATIC Manager, right-click each DB in the block folder, choose Properties and confirm the length shown in the Length in the work memory field is greater than
W#16#0004. Recommended safe size: 16 bytes or more, even if most of it is unused. -
Delete the three SWR system DBs in the CPU. In Accessible Nodes, mark DB1, DB2, DB3 (the values of
DB_WORK_NO,DB_SEND_NO,DB_RCV_NO) and choose Delete. Do not deleteDB5(the instance of FB 101) — it will be re-written by the next download. -
Re-download blocks in correct order. From the offline project, download to station A first, then station B:
FC 100 "SWR_START"-
DB1,DB2,DB3(system DBs, freshly created) -
FB 101 "SWR_DIAG"and its instanceDB5 - User DBs in the range
DB_NO…DB_NO + DB_NO_LEN - 1 - OB 100, OB 1, OB 35 (or whatever cycle OB triggers
FC100)
-
Confirm DB contiguity. In Accessible Nodes > station A > Block folder, sort by number and verify that no DB number is missing between
DB_NOandDB_NO + DB_NO_LEN - 1. Repeat for station B. -
Cold restart (MRES). Perform a full restart on both stations so that
OB 100rebuilds the SWR working DB from scratch. Power down the standby first, MRES the active, restart, wait for standby to be promoted, then power up the standby and let it resynchronize.
Memory Layout and DB Numbering Rules
The SWR library claims three ranges of DB numbers on each CPU. They must not overlap with each other or with user DBs:
| Range | Configured via | Example | Notes |
|---|---|---|---|
| SWR system DBs |
DB_WORK_NO, DB_SEND_NO, DB_RCV_NO
|
1, 2, 3 | Reserved for SWR runtime. Each > 4 bytes. |
| IEC instance DBs |
IEC_NO, IEC_LEN
|
111, 0 | Holds SFB 0..7 instances for IEC timer/counter sync. |
| Redundant user DBs |
DB_NO, DB_NO_LEN
|
10, 1 | Mirrored on every SWR cycle. Must be contiguous. |
| Non-redundant A→B / B→A |
DB_A_B_NO, DB_B_A_NO
|
112, 0 | Optional. 0 length disables the channel. |
Flag bytes MB_NO through MB_NO + MB_LEN - 1 (in this case MB40..MB109) are also reserved. Any user write into this range will be silently overwritten by the SWR runtime; if the program reads flags that should have been written, the value will appear stuck. Avoid using MB40..MB109 for HMI handshakes or interlocking logic.
Error Code Reference (RETURN_VAL / EXT_INFO)
| RETURN_VAL (MW2) | EXT_INFO (MW4) | Meaning | Corrective action |
|---|---|---|---|
W#16#0000 |
W#16#0000 |
Startup successful | — |
W#16#7000 |
— | Initial call, no error | Continue execution |
W#16#8001 |
DB number | Redundant DB length < 4 bytes | Resize the affected DB; EXT_INFO contains the DB number |
W#16#8002 |
DB number | SWR system DB missing or wrong size | Re-create DB_WORK_NO, DB_SEND_NO, DB_RCV_NO
|
W#16#8003 |
DB number | DB not contiguous in numbering | Insert the missing DB or reduce DB_NO_LEN
|
W#16#8004 |
DP master sys ID | DP master system not found | Check DP_MASTER_SYS_ID against HW Config |
W#16#8005 |
Slave address | DP slave outside configured range | Verify SLAVE_NO and SLAVE_LEN
|
W#16#8080 |
— | Internal timeout on link check | Inspect MPI/DP cable, check partner CPU |
W#16#80A1 |
— | Partner CPU not in RUN
|
Bring standby CPU into RUN
|
Diagnostic and Error OBs
Loading the full set of error OBs is best practice for any SWR system and is the single most effective way to keep a transient STOP from becoming a production outage:
- OB 80 – Time error. Triggered when OB 1 is overrun or by SWR's internal watchdog.
- OB 82 – Diagnostic interrupt. Captures IM 153-3 hot-swap events.
- OB 85 – Program cycle error. Reports a missing or wrong-length DB, including the SWR area-length fault.
-
OB 121 – Programming error. Catches the access error at the instruction level (e.g.
SFC 20 BLKMOVwith a mismatched length). - OB 122 – I/O access error. Triggered if SWR reads from a slave that is currently being swapped.
Each OB can call SFC 6 RD_SINFO to read the start event information and SFC 17 ALARM_SQ or SFC 107 ALARM_DQ to push a message to the HMI / WinCC. Logging the offending DB number, block number, and SW:OB85 fault code on every entry makes future root cause analysis far faster.
Verification and Commissioning Checks
- Diagnostic buffer clean – On both CPUs, PLC > Module Information > Diagnostic Buffer should show no entries newer than the most recent MRES, apart from expected partner-link events.
-
FB 101
SWR_DIAGstatus – CallFB 101in a low-priority OB (e.g. OB 82) and read theSTATE,MASTER,STBYandLINKUPoutputs.LINKUP= TRUE within 1 second ofFC 100completing on both stations. -
Forced failover – Stop the active CPU. Within one redundancy cycle the standby must take over. Verify all
PAA_FIRST..PAA_LASToutputs (QB0..QB5 in the example) hold their last value throughout the failover. -
DB mirroring loop test – Write a known pattern (e.g.
W#16#1234) into DB10 on the active CPU. Within one SWR cycle the same pattern must appear in DB10 on the standby. Monitor/Modify is the easiest tool for this. -
Non-redundant channel – If
DB_A_B_NO_LENis non-zero, write toDB_A_B_NOon station A and confirm readback on station B. Ensure the two DBs are different numbers (here both are 112 — the example shows this as disabled with length 0, which is correct).
Common Pitfalls and Edge Cases
- Mixing SWR library revisions – Station A and B must run the same major SWR library version. A V1.x block on one and V2.x on the other causes a size mismatch in the system DBs and the same area-length error. Check PLC > Module Information > Block list for the timestamp on FC 100.
- Optimized DB access (S7-300 does not support this anyway) – On S7-300 the access mode is fixed to "standard"; however, when migrating blocks from an S7-400 project, an "optimized" attribute left in the S7-300 DB can corrupt the length. Always re-create the DBs in the S7-300 project.
-
Reusing
DB112for both directions – The example usesDB_A_B_NO = DB_B_A_NO = DB112withDB_A_B_NO_LEN = 0. That is allowed and effectively disables the non-redundant channel. SettingDB_A_B_NO_LEN > 0with the same number on both directions is illegal and triggers the sameSTOP. -
DP master sys ID mismatch –
DP_MASTER_SYS_ID = 1must match the index in HW Config (not the Profibus address of the master itself). On the integrated 315-2DP this is usually 1; on a CP 342-5 it can be 2 or higher. -
Slot for
SWR_START– CallFC 100once in OB 100 (startup) and again in OB 1 (cycle). Calling it more than once per cycle causes the library to re-initialize and may trigger the area-length error on already-written DBs. -
MPI vs Profibus for the link – If
MPI_ADRis used for the partner's MPI/DP port address, verify it physically matches the partner's port being used. Using 4 for a CP 342-5 port that is actually 5 will keep the link up intermittently and confuse the diagnostic.
Extended Sizing Reference
For planners who need to size the on-line memory of an SWR CPU, the rough formula is:
Total SWR DB memory (bytes) =
sizeof(DB_WORK_NO) +
sizeof(DB_SEND_NO) +
sizeof(DB_RCV_NO) +
sum(sizeof(DB_i) for i in [DB_NO .. DB_NO + DB_NO_LEN - 1]) +
sum(sizeof(DB_i) for i in [IEC_NO .. IEC_NO + IEC_LEN - 1]) +
sizeof(DB_A_B_NO) + sizeof(DB_B_A_NO)
The 315-2DP has 128 KB of work memory and 256 KB of load memory (for 6ES7 315-2AG10). Reserve at least 20% of work memory for SWR overhead — typically 24 KB is enough for the configuration in the example. A 315-2DP can mirror up to approximately 8,000 bytes of DBs per redundancy cycle; if your application is close to that, consider splitting across multiple DB_NO/DB_NO_LEN windows or upgrading to S7-300 SWR V2.x, which supports a longer per-cycle payload.
Related Siemens Documentation
- SIMATIC S7-300 Software Redundancy – Function Manual (entry ID 1137086)
- S7-300 CPU 31x-2 DP Operating Instructions (entry ID 12416006)
- S7-300/400 Standard and System Functions reference (entry ID 22254723)
- Software Redundancy for S7-300 and S7-400 – Library download and release notes (entry ID 30805151)
- ET 200M IM 153-3 manual (entry ID 10806878)
Why does S7-300 software redundancy only fail when DB_NO_LEN is greater than 1?
The first redundant user DB happens to exceed the 4-byte (2-word) minimum length required by FC 100. The second DB added when DB_NO_LEN > 1 is typically sized below that minimum, which makes the area-length check inside SWR's copy routine fire and the CPU enters STOP. Increase the length of every DB in the DB_NO…DB_NO+DB_NO_LEN-1 range to at least 4 bytes (16 bytes is recommended) and reload.
Do I have to delete DB1, DB2, DB3 in the CPU before downloading FC 100 again?
Yes. DB_WORK_NO, DB_SEND_NO and DB_RCV_NO are re-initialized by FC 100 on every call. If a residual image of those DBs from an older program revision remains in the CPU, the size mismatch causes an area-length error. Delete them in Accessible Nodes, then download the FC 100 instance followed by freshly created DB1/DB2/DB3 in that order.
Which error OBs should I load to keep a single access error from stopping the CPU?
At minimum load OB 80 (time error), OB 85 (program cycle error), OB 121 (programming error) and OB 122 (I/O access error). Add OB 82 for IM 153-3 hot-swap diagnostics. Inside each OB call SFC 6 RD_SINFO to log the start event and push an alarm via SFC 17 or SFC 107 so the fault becomes visible in WinCC without taking the system down.
What does RETURN_VAL W#16#8001 with EXT_INFO containing a DB number mean?
It means FC 100 has detected that a redundant user DB is shorter than the 4-byte minimum. EXT_INFO contains the offending DB number. Open the DB, resize it in its Properties dialog so the work-memory length is greater than W#16#0004, recompile and re-download only that DB; the next redundancy cycle clears the error.
Can I use the same DB number for DB_A_B_NO and DB_B_A_NO?
Only if both DB_A_B_NO_LEN and DB_B_A_NO_LEN are zero (channel disabled). As soon as either length is non-zero, the two DBs must have different numbers and be present on both stations. The example in this article sets both to DB112 with length W#16#0, which is a legal way to disable the non-redundant channel without freeing DB112.