工具/软件:
您好、
我们目前正在为项目实现软件更新功能、希望利用引导加载程序身份验证来验证在 SBL 之外接收到的映像。
简明背景 :在带有 AM243x MCU+ SDK 11.01.00 和 SYSCFG 1.22 的 AM243X-LP 上、我们有一个在 R5F0-0 内核 上运行的应用程序、它使用 ICSS 上的 lwIP 协议栈托管 REST API 服务器(我们自己的实施)。 我们在一个 FreeRTOS 任务中将图像作为 TCP 分段接收、并使用 FreeRTOS 队列将其发送到另一个将图像写入闪存的任务。 到目前为止一切顺利。 我们目前是 GP、但最终将以 HS-SE 为目标。 我们的 SBL 在很大程度上 sbl_ospi_multi_partition以示例为基础。
一旦我们收到映像、但在“提交“ 更新之前、我们希望可以使用Bootloader_socAuthImage来验证映像 x.509 证书。 “承诺“更新是指以某种方式告诉 我们的自定义 SBL 新映像的位置(此机制仍在进行中)并重新启动器件。 我们 此步骤的原因有两个方面:a) 映像完整性 — 确保映像通过线路完好无损(这里需要一些校验和机制)、更重要的是 b) 验证证书、以确保在器件重新启动时、映像不会被 SBL 拒绝、从而“冻结“器件、或者至少会立即引入一些备用引导机制。
代码如下所示:
// Once I receive the first update chunk in my FreeRTOS task that stores the image in Flash memory,
// I can find out the x509 certificate length and store it
// Chunk data is: char chunkData[1460]
mFlashOffset = 0x200000u; // Hardcoded destination for now
mX509CertificateLength = Bootloader_getX509CertLen(reinterpret_cast<uint8_t*>(mpChunk->chunkData)); // 1654
if(mX509CertificateLength <= 0x100 || mX509CertificateLength > 0x800)
{
// Abort update. We use the same magic numbers as TI SDK
}
// ...
// Once we have received the entire image
Flash_enableDacMode(mFlashHandle); // SystemP_SUCCESS
uint32_t certificateLoadAddress = mFlashOffset + SOC_getFlashDataBaseAddr(); // 0x60200000
uint32_t imageLength = Bootloader_getMsgLen(mX509Certificate.data(), mX509CertificateLength); // 439520
uint32_t cacheAlignedLength = (mX509CertificateLength + imageLength + 128) & ~(127); // 441216
CacheP_wbInv(reinterpret_cast<void*>(certificateLoadAddress), cacheAlignedLength, CacheP_TYPE_ALL);
const int32_t cVerifyStatus = Bootloader_socAuthImage(certificateLoadAddress); // SystemP_FAILURE
CacheP_inv((void*)certificateLoadAddress, cacheAlignedLength, CacheP_TYPE_ALL);
Flash_disableDacMode(mFlashHandle); // SystemP_SUCCESS
如果我逐步Bootloader_socAuthImage达到之后 Sciclient_procBootAuthAndStart、我会得到:
retVal int 0 0x701A79CC (respParam).flags unsigned int 0 0x701A7998 (respParam).respPayloadSize unsigned int 20 0x701A79A0 (respParam).pRespPayload unsigned char * (see below) 0x701A799C pRespPayload as 8-bit Hex - TI style: 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 02 01 0A 70
sw.release.appimage.hs_fs 已成功签名、并已通过我们启用了身份验证的 SBL 成功加载(在 SYSCFG 中取消选中“Disable Auth for Application Image“)。 我已经检查了 sysfw 日志的更多信息基于这里的评论 downloads.ti.com/.../PROC_BOOT.html 但没有任何相关. 提前感谢、
Vaclav