如何修复 ESP32 lwIP:assert failed: tcpip_inpkt (Invalid mbox)
问题
你的微控制器因断言失败而崩溃,如
lwip_assert_failed.txt
assert failed: tcpip_inpkt /IDF/components/lwip/lwip/src/api/tcpip.c:252 (Invalid mbox)解决方案
此错误发生是因为 TCP/IP 堆栈在使用前尚未初始化。
注意,esp_netif_init() 内部调用 tcpip_init(),因此如果你使用 esp_netif_init(),则不需要调用 tcpip_init():
esp32_tcpip_init.cpp
#include <lwip/tcpip.h>
#include <esp_netif.h>
void setup() {
// Call this early in your setup function!
esp_netif_init();
}如果你不使用 ESP 高级堆栈,确保在使用任何 lwIP 函数之前调用 tcpip_init(nullptr, nullptr)。
esp32_tcpip_init_only.cpp
#include <lwip/tcpip.h>
void setup() {
// Call this early in your setup function!
tcpip_init(nullptr, nullptr);
}If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow