CH32V307内置PHY,使用RT Thread 系统,其它全部采用默认配置,主任务只有一个以太网任务,不管是只接收、只发送、回传,数据量大了(接近满速)后,几秒或几十秒后就死机。
请帮忙分析是什么问题,谢谢。
代码: while(1) { rt_thread_delay(500); //* wait eth phy enable host = (struct hostent*)gethostbyname(url); serveraddr.sin_family = AF_INET; serveraddr.sin_port = htons(port); serveraddr.sin_addr = *((struct in_addr *)host->h_addr); rt_memset(&(serveraddr.sin_zero), 0, sizeof(serveraddr.sin_zero)); if((sock=socket(AF_INET,SOCK_STREAM,0)) == -1) { rt_kprintf("Socket error sock=%d\n",sock); break; } if (connect(sock, (struct sockaddr *)&serveraddr, sizeof(struct sockaddr)) == -1) { rt_kprintf("Connect fail!\n"); closesocket(sock); continue; } else { rt_kprintf("Connect sock_%d successful\n",sock); } while(1) { /*bytes_received = recv(sock, rx_buffer, sizeof(rx_buffer) - 1, 0); if (bytes_received < 0) { // receive timeout, continue the receiving of next socket break; } else { rx_buffer[bytes_received] = 0; }*/ //int err = send(sock, rx_buffer, strlen(rx_buffer), 0); int err = send(sock, rx_buffer, 100, 0); //rt_thread_mdelay(100); if (err < 0) { rt_kprintf("Error occurred during sending: errno % .\r\n", err); rt_kprintf("Shutting down socket and restarting..."); // shutdown(sock, 0); closesocket(sock); rt_thread_mdelay(1000); break; } } } 打印信息,但经常不完整。 \ | / - RT - Thread Operating System / | \ 4.0.4 build Mar 25 2022 2006 - 2021 Copyright by rt-thread team lwIP-2.1.2 initialized! MCU: CH32V307 SysClk: 144000000Hz msh >Connect fail! Connect fail! Connect sock_0 successful state! Assertion: 1836 in ../rt-thread/components/net/lwip-2.1.2/src/api/api_msg.c, thread etx hardfult mepc:0bd3fca8 mcause:00000001 mtval:0bd3fca8
LWIP 配置
测速速度