启动:二级引导加载程序在加载 TEE 分区之前,将其安全版本与 eFuse 计数器进行比较。安全版本更低的新镜像(NEW 状态)不会被选中进行试启动,而是启动先前的镜像;如果当前已激活镜像的版本更低,引导加载程序会记录错误并复位设备。
TEE OTA:esp_tee_ota_end() 会拒绝安全版本低于 eFuse 计数器或正在运行的 TEE 镜像的新 TEE 镜像,返回 ESP_ERR_INVALID_VERSION,并擦除非活动 TEE 分区。
确认:正在运行的 TEE 镜像被确认为有效后(见上文的启动流程),TEE 会把 eFuse 计数器更新为自己的安全版本。与应用程序一样,计数器只在成功启动之后才会提高,因此失败的更新不会抬高这一下限。如果 eFuse 写入失败(例如因为 SECURE_VERSION 字段已被写保护),TEE 会记录错误并继续运行;每次启动都会重试该写入,在此期间,针对正在运行镜像的 TEE OTA 检查可以防止降级。
Write TEE OTA update data to the partition. This function can be called multiple times as data is received during the OTA operation and can write data in non-contiguous manner.
参数:
rel_offset -- Address offset at which the given data should be written at - relative to the start address of the passive TEE partition
data -- Data buffer to write
size -- Size of data buffer in bytes
返回:
ESP_OK on success
ESP_ERR_INVALID_ARG in case the tee_otadata or the passive TEE partition is not found
ESP_ERR_INVALID_STATE in case the TEE OTA state machine is in an invalid state
ESP_ERR_FLASH_OP_FAIL in case writing the new TEE image fails