应用层代码从RT-thread studio 平台移植过来的,在使用socket 方式,aic 这个平台有点奇怪,又单独弄了个packages\third-party\lwip
这里面没有相关使用sal的配置,跑到原rt-thread components 下 打开
select RT_USING_POSIX_SOCKET
select RT_USING_POSIX_SELECT
select RT_USING_SAL
select RT_USING_POSIX_POLL
编译能够通过,有比较多的警告,运行时候错误
01-01 09:34:05 E/sal.skt: not find network interface device by protocol family(2).
01-01 09:34:05 E/sal.skt: SAL socket protocol family input failed, return error -3.
socket() failed: Not supported
离线
在函数 struct netdev *netdev_get_by_family(int family)中
if (netdev_list == RT_NULL)
{
LOG_E("NULL netdev_list"); // 新增添
return RT_NULL;
}
然后
01-01 17:12:03 E/netdev: NULL netdev_list
01-01 17:12:03 E/sal.skt: not find network interface device by protocol family(2).
01-01 17:12:03 E/sal.skt: SAL socket protocol family input failed, return error -3.
网络是正常的,可以ping通。
离线
Rt-Thread options → RT-Thread Components → Network
LwIP: light weight TCP/IP stack ---- 这个是没有选中,
选中的是 Local packages options → Third-party packages options 里面的
LwIP: light weight TCP/IP stack --->
网络相关配置是参考sdk 文档里面 rtos 相关的配置方式,是可以ping通的
离线
static err_t eth_netif_device_init(struct netif *netif) 函数里面会调用 netdev_add(netif);将netif 插入到netdev_list 中,于是在里面插入了一条打印信息
static err_t eth_netif_device_init(struct netif *netif)
{
struct eth_device *ethif;
ethif = (struct eth_device*)netif->state;
LOG_I("eth_netif_device_init:netif=0x%08x", netif);//插入打印信息
if (ethif != RT_NULL)
{
rt_device_t device;
#ifdef RT_USING_NETDEV
/* network interface device register */
netdev_add(netif);
#endif /* RT_USING_NETDEV */
程序更新后发现并没有打印出来,说明这个函数没有被调用。
发现这个依赖于RT_USING_LWIP,查找kconfig 发现要选中Rt-Thread options → RT-Thread Components → Network
LwIP: light weight TCP/IP stack ---- 这里的配置。
现在要重新配置了,感觉太乱了,自己非得要再加一个另外的lwip 功能还支持不全!
离线
启用rt-thread 那个lwip 后直接ping不通了
pri status sp stack size max used left tick error
---------------- --- ------- ---------- ---------- ------ ---------- ---
touch 25 suspend 0x0000029c 0x00001000 26% 0x00000004 OK
tx_serial 25 suspend 0x000002a4 0x00000800 49% 0x00000008 OK
rx_serial 25 suspend 0x00000334 0x00000800 40% 0x0000000a OK
LVGL 20 ready 0x00000250 0x00008000 10% 0xfffffec8 ETIMOUT
tshell 20 running 0x000005a8 0x00001000 35% 0x00000008 OK
usbh_hub0 0 suspend 0x00000360 0x00001000 22% 0x00000009 OK
mmcsd_detect 22 suspend 0x000002e0 0x00002000 37% 0x00000011 OK
alarmsvc 10 suspend 0x00000284 0x00000800 31% 0x00000005 OK
sys workq 23 suspend 0x00000234 0x00000800 27% 0x0000000a OK
tcpip 10 suspend 0x000002f4 0x00000800 36% 0x00000014 OK
etx 12 suspend 0x00000290 0x00000800 32% 0x00000010 OK
erx 12 suspend 0x000002c8 0x00000800 34% 0x00000010 OK
tidle0 31 ready 0x00000248 0x00000400 61% 0x00000018 OK
aic /> ifconfig
ifconfig: network interface device list error.
aic />
最近编辑记录 pineyer (2025-01-24 18:29:56)
离线
最新的V1.1.2 的SDK,在此环境下,
使用 Rt-Thread options → RT-Thread Components → Network LwIP: light weight TCP/IP stack
的时候能够编译成功,但是盒v1.1.1的一样网口灯不亮,ping不通。
使用 Local packages options → Third-party packages options 里面的
LwIP: light weight TCP/IP stack
的时候,编译错误,
kernel\rt-thread\components\net\sal\impl\af_inet_lwip.c:168:31: error: 'struct lwip_sock' has no member named 'wait_head'
168 | rt_wqueue_wakeup(&sock->wait_head, (void*) event);
kernel\rt-thread\components\net\sal\impl\af_inet_lwip.c:310:5: error: 'lwip_gethostbyname' undeclared here (not in a function); did you mean 'lwip_getsockname'?
310 | lwip_gethostbyname,
我打开了rtt 的 sal 功能,因为我要用这个。
sal 相关功能关闭的时候能够编译过去,但是也还没有ping通,网口灯不亮。
最近编辑记录 pineyer (2025-02-17 15:35:26)
离线
发现 sdk v1.1.1 使用 Local packages options → Third-party packages options 里面的
LwIP: light weight TCP/IP stack
能够ping通时 需要选中 LwIP Examples
否则就ping不通了。
发现这个关联到 LPKG_LWIP_EXAMPLES这个宏定义,奇怪的是全局搜索时候
Kconfig (packages\third-party\lwip) line 45 : config LPKG_LWIP_EXAMPLES
Kconfig (packages\third-party\lwip) line 52 : # if LPKG_LWIP_EXAMPLES
main in main.c (application\baremetal\helloworld) : #ifdef LPKG_LWIP_EXAMPLES
main in main.c (application\freertos\helloworld) : #ifdef LPKG_LWIP_EXAMPLES
main in main.c (application\ucos-ii\helloworld) : #ifdef LPKG_LWIP_EXAMPLES
rtconfig.h line 710 : #define LPKG_LWIP_EXAMPLES
SConscript (packages\third-party\lwip) line 327 : if GetDepend(['LPKG_LWIP_EXAMPLES']):
并没有在rt-thread的相关代码片段(比如main.c)找到有引用这个LPKG_LWIP_EXAMPLES的开关切换的地方。
他到底是怎么起作用的(打开才能ping通),进一步分析发现是在。
#if defined(KERNEL_RTTHREAD)
#include <rtthread.h>
#include <rtdevice.h>
#include <aic_core.h>
int lwip_test_example_init(void)
{
aicos_thread_create("lwip_test_example", 4096,
20, lwip_test_example_main_loop, NULL);
return 0;
}
INIT_DEVICE_EXPORT(lwip_test_example_init);
#endif
这里被初始化进系统的(奇怪的是ps命令列出的线程列表里面没有这个name 为 lwip_test_example 的线程,查看代码分析后应该是执行完毕被释放了)。
但是我安照此方法,在v1.1.2 sdk中选中 LwIP Examples 后 ifconfig 可以正常使用,但是没有ping通。
最后又返回认真对照“MAC 应用指南”,发现是没有配
Enable CLK_OUT2
(25000000) Clk CLK_OUT2 frequence
配完后v1.1.2 在不开启sal时候也是可以ping得通了。
最近编辑记录 pineyer (2025-02-18 10:55:16)
离线
sdk v1.1.2, 使用rtt的lwip 打开sal 相关功能,可以了,但是连接不是很稳定,用空的(刚刚git 下载的新的),无论是使用rtt的lwip 还是aic的third package里面的lwip都是一样的,ping 的时候
[I aicmac_rt_phy_poll_thread()95 Port 0 link UP! autoneg mode: speed 100M, full duplex, flow control on.
[I aicmac_rt_phy_poll_thread()115 Port 0 link DOWN!
[I aicmac_rt_phy_poll_thread()95 Port 0 link UP! autoneg mode: speed 100M, full duplex, flow control on.
[I aicmac_rt_phy_poll_thread()115 Port 0 link DOWN!
[I aicmac_rt_phy_poll_thread()95 Port 0 link UP! autoneg mode: speed 100M, full duplex, flow control on.
[I aicmac_rt_phy_poll_thread()115 Port 0 link DOWN!
[I aicmac_rt_phy_poll_thread()95 Port 0 link UP! autoneg mode: speed 100M, full duplex, flow control on.
[I aicmac_rt_phy_poll_thread()115 Port 0 link DOWN!
来自 10.10.0.34 的回复: 字节=32 时间<1ms TTL=255
来自 10.10.0.34 的回复: 字节=32 时间<1ms TTL=255
来自 10.10.0.34 的回复: 字节=32 时间<1ms TTL=255
来自 10.10.0.34 的回复: 字节=32 时间<1ms TTL=255
请求超时。
请求超时。
请求超时。
来自 10.10.0.33 的回复: 无法访问目标主机。
来自 10.10.0.34 的回复: 字节=32 时间=918ms TTL=255
来自 10.10.0.34 的回复: 字节=32 时间<1ms TTL=255
来自 10.10.0.34 的回复: 字节=32 时间<1ms TTL=255
感觉这个可能跟环境有关,后面会试下电脑直连开发板
最近编辑记录 pineyer (2025-02-18 16:15:09)
离线