最近在做STM32F407的開發板實驗的時候,在開發板移植了uCosII和LWIP,按照正點原子的開發板例程,做到第八個實驗(NETCONN TCP Client)的時候,出現瞭如下的錯誤。
Assertion "OSQCreate" failed at line 71 in ..\LWIP\arch\sys_arch.c
Assertion "netconn_connect: invalid conn" failed at line 197 in ..\LWIP\lwip-1.4.1\src\api\api_lib.c
Assertion "netconn_accept: invalid recvmbox" failed at line 464 in ..\LWIP\lwip-1.4.1\src\api\api_lib.c
原因:
在移植LWIP的時候,配置文件lwipopt.h的時候,寫錯了兩個宏的名字。宏定義TCPIP_MBOX_SIZE和DEFALT_TCP_RECVMBOX_SIZE的名字,由於在opt.h中已經定義過了,默認值都是0,所有即時是在lwipopt.h寫錯,在編譯的時候也沒報錯,正是由於這個原因,導致lwip內核無法分配發送和接收數據的郵箱隊列。