为了查这个问题我把加解密算法过了一遍,真的是,哎
报错:
E (47079) esp_encrypted_img: failed
! mbedtls_pk_decrypt returned -0x4100
直接说结果,实际原因是ESP32得BLE-OTA组件预加密OTA时候,给缓存区写入得数据量少了,导致最终报加密错误。
错误代码及位置如下:
if (SLIST_NEXT(om, om_next) != NULL) {
struct os_mbuf *temp2 = SLIST_NEXT(om, om_next);
pargs.data_in_len += temp2->om_len;
}
将以上代码块改为如下内容即可:
struct os_mbuf *last;
last = om;
while (SLIST_NEXT(last, om_next) != NULL) {
struct os_mbuf *temp2 = SLIST_NEXT(last, om_next);
pargs.data_in_len += temp2->om_len;
last = SLIST_NEXT(last, om_next);
temp2 = NULL;
}