【简介】
S32K3 系列芯片在设计时引入了Life Cycle 的概念,在不同的 Life Cycle 时芯片有不同的权限,JTAG 调试端口的开启关闭也是通过该配置来进行控制的,对应的 Life Cycle 类型说明如下:
针对不同的LC 芯片对DEBUG 端口的访问权限是不同的。
芯片的生命周期的推进需要谨慎,一旦向前推进后无法再向后恢复为之前的状态,LC 推进过程如下:
HSE lib 中对LC 的宏定义说明如下
/*================================================================================================== HSE Secure Lifecycle ==================================================================================================*/ /** @brief HSE secure lifecycle definition (OTP-ADVANCE-ATTR attribute; refer to #hseAttrId_t). * @details Represents HSE secure lifecycle. The lifecycle can be advanced only in forward direction. * Warnings: * - The lifecycle is read/scanned by hardware during the reset phase. Hence, a reset is recommended * after each LC write-advance operation. * - The lifecycle can be advanced to OEM_PROD/IN_FIELD only if the #HSE_APP_DEBUG_KEY_ATTR_ID attribute was set before. */ typedef uint8_t hseAttrSecureLifecycle_t; #define HSE_LC_CUST_DEL ((hseAttrSecureLifecycle_t)0x4U) /**< @brief Customer Delivery Lifecycle. \ - Read: The current LC is CUST_DEL. \ - Write: Advancement to this LC is not allowed (through HSE Firmware). */ #define HSE_LC_OEM_PROD ((hseAttrSecureLifecycle_t)0x8U) /**< @brief OEM Production Lifecycle. \ - Read: The current LC is OEM_PROD. \ - Write: Advancement to this LC is allowed only once (from CUST_DEL LC). \ The key catalogs MUST be configured before advancing to this lifecycle. */ #define HSE_LC_IN_FIELD ((hseAttrSecureLifecycle_t)0x10U) /**< @brief In-Field Lifecycle. \ - Read: The current LC is IN_FIELD. \ - Write: Advancement to this LC is allowed only once (from CUST_DEL, OEM_PROD LCs). \ The key catalogs MUST be configured before advancing to this lifecycle. */ #define HSE_LC_PRE_FA ((hseAttrSecureLifecycle_t)0x14U) /**< @brief Pre-Failure Analysis Lifecycle. \ - Read: The current LC is Pre-FA. \ - Write: Advancement from/to this LC is NOT allowed (through HSE Firmware).*/ #define HSE_LC_SIMULATED_OEM_PROD ((hseAttrSecureLifecycle_t)0xA6U) /**< @brief Simulated OEM_PROD to avoid writing in FUSE/UTEST. A system reset will revert LC to FUSE/UTEST value. \ - Read: The current LC is OEM_PROD. \ - Write: Advancement to this LC is allowed only once (from CUST_DEL LC). \ The key catalogs MUST be configured before advancing to this lifecycle. */ #define HSE_LC_SIMULATED_IN_FIELD ((hseAttrSecureLifecycle_t)0xA7U) /**< @brief Simulated IN_FIELD to avoid writing in FUSE/UTEST. A system reset will revert LC to FUSE/UTEST value. \ - Read: The current LC is IN_FIELD. \ - Write: Advancement to this LC is allowed only once (from CUST_DEL, SIMULATED_OEM_PROD LCs). \ The key catalogs MUST be configured before advancing to this lifecycle. */
从上述代码的注释中可知“The lifecycle can be advanced to OEM_PROD/IN_FIELD only if the #HSE_APP_DEBUG_KEY_ATTR_ID attribute was set before.” 在推进芯片的生命周期至OEM/IN_FIELD 前ADKP 必须先进性配置好方可推进生命周期。
secure debug 的配流说明如下
以下是HSE lib 也是按照上述的流程中推进LC 和 ADKP 的配置代码,使用HSE 固件的时候使用 HSE 的服务即可完成对应ADKP 和 LC的配置。
/********************************************************************************************** * Program ADKP (OTP) * **********************************************************************************************/ if(HSE_SRV_RSP_NOT_ALLOWED == HseMid_Admin_GetAttr(HSE_APP_DEBUG_KEY_ATTR_ID, sizeof(hseAttrApplDebugKey_t), (void *)&getAttrVal, NULL)) { srvResponse = HseMid_Admin_SetAttr(HSE_APP_DEBUG_KEY_ATTR_ID, sizeof(hseAttrApplDebugKey_t), (void *)&gsAdkp, NULL); ASSERT(HSE_SRV_RSP_OK == srvResponse); } /********************************************************************************************** * Advance LC (OTP) * **********************************************************************************************/ srvResponse = HseMid_Admin_GetAttr(HSE_SECURE_LIFECYCLE_ATTR_ID, sizeof(hseAttrSecureLifecycle_t), (void *)&getAttrVal, NULL); ASSERT(HSE_SRV_RSP_OK == srvResponse); if(HSE_LC_CUST_DEL == getAttrVal.lifecycle_OTP_ADVANCE) { setAttrVal.lifecycle_OTP_ADVANCE = HSE_LC_IN_FIELD; srvResponse = HseMid_Admin_SetAttr(HSE_SECURE_LIFECYCLE_ATTR_ID, sizeof(hseAttrSecureLifecycle_t), (void *)&setAttrVal, NULL); ASSERT(HSE_SRV_RSP_OK == srvResponse); /* The LC advancement takes effect after a functional reset */ Power_Ip_MC_ME_SocTriggerResetEvent(POWER_IP_FUNC_RESET_MODE); }