Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY

 

UnlockProtectionSSeries (FB)

Description

Function block is used to unlock software download protection in S / E Series units.

 

Following sequence is performed:

  1. Request GFC. Note CANopen GFC message is sent by application (see code example below).

  2. Wait for control unit safe state

  3. Read SW protection status (OD index 2032:01h). If protection is already unlocked, then sequence is ended and o_State is Unlocked.

  4. Write password to control unit’s OD (index 2031:01h).

  5. Read SW protection status

 

Limitations

SW protection needs to be unlocked before loading binaries with LoadApplicationSSeries (FB) or LoadFirmwareSSeries (FB).

 

Output o_State should change to Processing when i_Enable is set TRUE. If protection is unlocked successfully, the o_State changes to Unlocked.

 

CANopen GFC protocol is required in HMI to activate GFC message.

 

After SW protection is unlocked, reboot is required to resume operational state.

Inputs

Input variable name

Data type

Range

Description

i_Enable

BOOL

 

Action trigger

i_pDevice

POINTER TO EPEC_CANopen.Device

 

Used CANopen device

(e.g. ADR(G_CANopen_CAN1.Device))

i_NodeID

BYTE

1..127

CODESYS (Runtime) Node ID of target unit

i_Password

STRING(20)

 

SW protection password which is used to unlock control unit

i_Timeout

TIME

 

SDO protocol transfer timeout

Outputs

Output variable name

Data type

Range

Description

o_State

ProtectionState

 

State is Unlocked when SW download is possible, see ProtectionState enumeration.

o_AbortCode

DWORD

 

CANopen abort code

o_GFCRequest

BOOL

 

Application is requested to send GFC CANopen message

Errors

ProtectionState

 

Example code

 

Definitions:

 

VAR

unlockSSeries: EPEC_SWD.UnlockProtectionSSeries;

unlockTrigger: BOOL;

codesysNodeID: BYTE := BYTE#127;

timeout: TIME := T#1s;

protectionState: EPEC_SWD.ProtectionState;

password: STRING(20) := '1234';

abortCode: DWORD;

gfcRequest:BOOL;

gfcRequestOld: BOOL;

END_VAR

 

 

Code:

 

unlockSSeries(

i_Enable := unlockTrigger,

i_pDevice := ADR(G_CANopen_CAN1.Device), // From code template

i_NodeID := codesysNodeID,

i_Password := password,

i_Timeout := timeout,

o_State => protectionState,

o_AbortCode => abortCode,

o_GFCRequest => gfcRequest

);

 

IF gfcRequest AND NOT gfcRequestOld THEN

G_CANopen_CAN1.GFC_Handler.Activate(); // GFC protocol from code template

END_IF

gfcRequestOld := gfcRequest;

 

IF protectionState = EPEC_SWD.ProtectionState.Unlocked THEN

; // SW download enabled

END_IF

 

See also

 

 

Source file topic100504.htm

Last updated 21-Feb-2025