Page 1 of 1

ESP32运行OTA例程报错

Posted: Wed Mar 17, 2021 6:34 am
by kernelz
I (4137) tcpip_adapter: sta ip: 10.0.2.88, mask: 255.255.255.0, gw: 10.0.2.254
I (4637) example_connect: Connected to Sandstar-OFFICE
I (4637) example_connect: IPv4 address: 10.0.2.88
I (4637) example_connect: IPv6 address: fe80:0000:0000:0000:eadb:84ff:fe19:8508
I (4647) wifi:Set ps type: 0

I (4647) simple_ota_example: Starting OTA example
http_parse_host return:1
E (4657) HTTP_CLIENT: Error parse url https://ssl_test.sandstar.com:2369/upgrate/hello-world.bin
E (4667) HTTP_CLIENT: parser_status= 4
E (4667) HTTP_CLIENT: Error while setting default configurations
E (4677) esp_https_ota: Failed to initialise HTTP connection
E (4677) simple_ota_example: Firmware upgrade failed




但是我的链接使用浏览器是可以打开的,附件里面是我打开链接的截图
1615962713(1).png
1615962713(1).png (65.88 KiB) Viewed 10454 times

Re: ESP32运行OTA例程报错

Posted: Thu Mar 18, 2021 8:22 am
by ESP_Gargamel
导致该问题的主要原因是 IDF 中的 http parser 采用 strict 的方式,详见:https://github.com/espressif/esp-idf/bl ... #L429-L439
当域名中有 `_` 时会导致解析错误。

有以下建议:
1、域名中不要采用 `_`,改用 `-`
2、修改 https://github.com/espressif/esp-idf/bl ... .h#L52-L54,define HTTP_PARSER_STRICT 为 0

推荐采用方式 1。

另外,你需要采用命令 openssl s_client -showcerts -connect ssl_test.sandstar.com:2369 来获取你服务器的 CA 根证书。证书为执行该命令后,最下面的一个。用该证书内容覆盖 simple_ota_example/server_certs/ca_cert.pem 中内容。

以下为你测试服务器的 CA 根证书:
-----BEGIN CERTIFICATE-----
MIIEqjCCA5KgAwIBAgIQAnmsRYvBskWr+YBTzSybsTANBgkqhkiG9w0BAQsFADBh
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWw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AECATANBgkqhkiG9w0BAQsFAAOCAQEAK3Gp6/aGq7aBZsxf/oQ+TD/B
SwW3AU4ETK+GQf2kFzYZkby5SFrHdPomunx2HBzViUchGoofGgg7gHW0W3MlQAXW
M0r5LUvStcr82QDWYNPaUy4taCQmyaJ+VB+6wxHstSigOlSNF2a6vg4rgexixeiV
4YSB03Yqp2t3TeZHM9ESfkus74nQyW7pRGezj+TC44xCagCQQOzzNmzEAP2SnCrJ
sNE2DpRVMnL8J6xBRdjmOsC3N6cQuKuRXbzByVBjCqAA8t1L0I+9wXJerLPyErjy
rMKWaBFLmfK/AHNF4ZihwPGOc7w6UHczBZXH5RFzJNnww+WnKuTPI0HfnVH8lg==
-----END CERTIFICATE-----

Re: ESP32运行OTA例程报错

Posted: Tue Mar 23, 2021 6:11 am
by kernelz
多谢,采用方法2解决了问题。

Re: ESP32运行OTA例程报错

Posted: Tue Mar 23, 2021 6:26 am
by kernelz
另外我想请问一下,esp32如果固件写入到flash后错误是否有处理呢?

Re: ESP32运行OTA例程报错

Posted: Tue Mar 23, 2021 6:30 am
by ESP_Gargamel
kernelz wrote:
Tue Mar 23, 2021 6:26 am
另外我想请问一下,esp32如果固件写入到flash后错误是否有处理呢?
你是说 OTA 过程中错误?OTA 过程结束后,会对下载的 bin 做 verify,有错误会导致 OTA 失败。

Re: ESP32运行OTA例程报错

Posted: Tue Mar 23, 2021 6:41 am
by kernelz
了解,也就是说会校验在RAM中的bin文件数据,文件烧入到flash后是不会校验的。

Re: ESP32运行OTA例程报错

Posted: Tue Mar 23, 2021 7:27 am
by ESP_Gargamel
kernelz wrote:
Tue Mar 23, 2021 6:41 am
了解,也就是说会校验在RAM中的bin文件数据,文件烧入到flash后是不会校验的。
不是。整个 OTA bin,在升级过程中,会全部写入到 flash,全部写入完后,会对写入后的 OTA bin 做一个整体的校验。

Re: ESP32运行OTA例程报错

Posted: Tue Mar 23, 2021 7:36 am
by kernelz
明白,多谢回复