Copyright 2021 P&E Microcomputer Systems, Inc. All rights reserved.
See www.pemicro.com/securedebug/s32k3 for more information.

Setup:
PEmicro's helper scripts must be run using Python 3.5 or later. Before running any of the scripts, the target must be powered and the PEmicro interface (e.g. Multilink or Cyclone) must be connected to the target's debug header. It is recommended that S32K312 devices are power cycled before the scripts are run.

Authenticating a Device in Password Mode:
PEmicro's authenticate_password_mode.py script authenticates a device that has been secured in Password mode so that it can be securely debugged.
The inputs for authenticate_password_mode.py are:
    hardwareid: the debug hardware IP address, name, serial number, or port name (e.g. -hardwareid=10.0.4.17)
    password: the 16 byte hexadecimal preconfigured password needed to authenticate the device (e.g. -password=0123456789ABCDEF0123456789ABCDEF)

Registering a Key:
PEmicro's register_adkp.py script registers an existing wrapped Application Debug Key/Password (ADKP) onto the smart card for use with a device secured in Challenge/Response mode. Contact NXP for more information on how to create a ADKP.
The inputs for register_adkp.py are:
    hardwareid: the debug hardware IP address, name, serial number, or port name (e.g. -hardwareid=10.0.4.17) 
    wrapped_adkp: the 256 byte hexadecimal wrapped ADKP value (e.g. -wrapped_adkp=0123456789ABCDEF...)
    user_pwd: if a smart card is being used and is password protected, the password must be provided (e.g. -user_pwd=pwd123)

Authenticating a Device in Challenge/Response Mode:
PEmicro's authenticate_challenge_reponse_mode.py script authenticates a device that has been secured in Challenge/Response mode so that it can be securely debugged. The Register ADKP step must be completed before authenticating a device in Challenge/Response mode.
The inputs for authenticate_challenge_reponse_mode.py are:
    hardwareid: the debug hardware IP address, name, serial number, or port name (e.g. -hardwareid=10.0.4.17)
    user_pwd: if a smart card is being used and is password protected, the password must be provided (e.g. -user_pwd=pwd123)

After Authenticating a Device:
After a device has been authenticated, the developer can securely debug the device in PROGACMP, Cyclone standalone mode, or third-party IDEs with PEmicro plug-ins. Note: the device will remain accessible in secure debug only until the next hard reset or power cycle. By default, a hard reset is toggled during debug entry which would clear the authentication. To prevent this, specify the "SECUREDEBUG" device in the software (eg. "S32K344-SECUREDEBUG" instead of "S32K344").