From 9446775a76ffdbe712ecfaf99faaec49c053198d Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Sun, 15 May 2022 21:05:21 +0800 Subject: [PATCH 1/3] [BSP] Update smart.json for ART-Pi smart --- bsp/imx6ull-artpi-smart/.vscode/smart.json | 13 ++++--------- bsp/imx6ull-artpi-smart/drivers/SConscript | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/bsp/imx6ull-artpi-smart/.vscode/smart.json b/bsp/imx6ull-artpi-smart/.vscode/smart.json index c483be5cb1..a23f53fda1 100644 --- a/bsp/imx6ull-artpi-smart/.vscode/smart.json +++ b/bsp/imx6ull-artpi-smart/.vscode/smart.json @@ -2,15 +2,10 @@ "env": { "windows": { "VENV_MODE": true, - "RTT_CC": "gcc", - "RTT_CC_PREFIX": "arm-linux-musleabi-", - "RTT_EXEC_PATH": "${SDK_ROOT}/tools/gnu_gcc/arm-linux-musleabi_for_i686-w64-mingw32/bin", - "PATH": "%RTT_EXEC_PATH%;%ENV_ROOT%/tools/gnu_gcc/arm_gcc/mingw/bin;%PATH%" + "UDB_PATH": "${SDK_ROOT}/tools/udb-tools/windows", + "PATH": "%RTT_EXEC_PATH%;%PATH%;%UDB_PATH%" }, "linux": { - "RTT_CC": "gcc", - "RTT_CC_PREFIX": "arm-linux-musleabi-", - "RTT_EXEC_PATH": "${SDK_ROOT}/tools/gnu_gcc/arm-linux-musleabi_for_x86_64-pc-linux-gnu/bin", "UDB_PATH": "${SDK_ROOT}/tools/udb-tools/linux", "PATH": "$PATH:$RTT_EXEC_PATH:$UDB_PATH" } @@ -40,7 +35,7 @@ "commands": [ "udb tcp ${SERVER_IP} 5555", "udb devices", - "udb push ${EXECUTABLE_PROGRAM} /kernel/kernel.bin" + "udb push rtthread.bin /kernel/kernel.bin" ], "label": "下载", "tooltip": "下载 RT-Thread Smart 工程" @@ -55,4 +50,4 @@ "tooltip": "刷新工程" } } -} +} \ No newline at end of file diff --git a/bsp/imx6ull-artpi-smart/drivers/SConscript b/bsp/imx6ull-artpi-smart/drivers/SConscript index b4b63c8cd1..cbb68865ee 100644 --- a/bsp/imx6ull-artpi-smart/drivers/SConscript +++ b/bsp/imx6ull-artpi-smart/drivers/SConscript @@ -8,7 +8,7 @@ if GetDepend(['BSP_USING_USB_DEVICE']): src += Glob('usb/phy/*.c') list = os.listdir(cwd) -CPPPATH = [cwd, cwd + '/iomux'] +CPPPATH = [cwd] objs = [] group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH) -- Gitee From abef0af159112a6f5241a75fd87a46785ed288f1 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Sun, 15 May 2022 21:05:55 +0800 Subject: [PATCH 2/3] [lwP] place ld.so to /lib/ld.so --- components/lwp/lwp_syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index 9581fe7a04..ac489eef63 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -2082,7 +2082,7 @@ int load_ldso(struct rt_lwp *lwp, char *exec_name, char *const argv[], char *con goto quit; } - ret = lwp_load("/bin/ld.so", lwp, RT_NULL, 0, aux); + ret = lwp_load("/lib/ld.so", lwp, RT_NULL, 0, aux); rt_strncpy(lwp->cmd, exec_name, RT_NAME_MAX); quit: -- Gitee From c3f50ad9466b41eedd492ad1607b79db0418d307 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Sun, 15 May 2022 21:07:05 +0800 Subject: [PATCH 3/3] [lwIP] apply AF_UNIX feature on lwIP 2.1.2 --- .../net/lwip-2.1.2/src/include/lwip/sockets.h | 2 + .../net/lwip-2.1.2/src/netif/ethernetif.c | 155 ++++++++++++++++++ 2 files changed, 157 insertions(+) diff --git a/components/net/lwip-2.1.2/src/include/lwip/sockets.h b/components/net/lwip-2.1.2/src/include/lwip/sockets.h index 12ffbddccc..1154145270 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/sockets.h +++ b/components/net/lwip-2.1.2/src/include/lwip/sockets.h @@ -235,12 +235,14 @@ struct linger { #define AF_UNSPEC 0 +#define AF_UNIX 1 #define AF_INET 2 #if LWIP_IPV6 #define AF_INET6 10 #else /* LWIP_IPV6 */ #define AF_INET6 AF_UNSPEC #endif /* LWIP_IPV6 */ +#define PF_UNIX AF_UNIX #define PF_INET AF_INET #define PF_INET6 AF_INET6 #define PF_UNSPEC AF_UNSPEC diff --git a/components/net/lwip-2.1.2/src/netif/ethernetif.c b/components/net/lwip-2.1.2/src/netif/ethernetif.c index 8b581c3e04..54237e141a 100644 --- a/components/net/lwip-2.1.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.1.2/src/netif/ethernetif.c @@ -595,6 +595,161 @@ void eth_device_deinit(struct eth_device *dev) rt_free(netif); } +#ifdef SAL_USING_AF_UNIX /* create loopback netdev */ +static err_t af_unix_eth_netif_device_init(struct netif *netif) +{ + struct eth_device *ethif; + + ethif = (struct eth_device*)netif->state; + if (ethif != RT_NULL) + { + rt_device_t device; + +#ifdef RT_USING_NETDEV + /* network interface device register */ + netdev_add(netif); +#endif /* RT_USING_NETDEV */ + + /* get device object */ + device = (rt_device_t) ethif; + if (rt_device_init(device) != RT_EOK) + { + return ERR_IF; + } + + /* copy device flags to netif flags */ + netif->flags = (ethif->flags & 0xff); + netif->mtu = ETHERNET_MTU; + + /* set output */ + netif->output = etharp_output; + +#if LWIP_IPV6 + netif->output_ip6 = ethip6_output; + netif->ip6_autoconfig_enabled = 1; + netif_create_ip6_linklocal_address(netif, 1); + +#if LWIP_IPV6_MLD + netif->flags |= NETIF_FLAG_MLD6; + + /* + * For hardware/netifs that implement MAC filtering. + * All-nodes link-local is handled by default, so we must let the hardware know + * to allow multicast packets in. + * Should set mld_mac_filter previously. */ + if (netif->mld_mac_filter != NULL) + { + ip6_addr_t ip6_allnodes_ll; + ip6_addr_set_allnodes_linklocal(&ip6_allnodes_ll); + netif->mld_mac_filter(netif, &ip6_allnodes_ll, NETIF_ADD_MAC_FILTER); + } +#endif /* LWIP_IPV6_MLD */ + +#endif /* LWIP_IPV6 */ + + /* set default netif */ + if (netif_default == RT_NULL) + netif_set_default(ethif->netif); + + /* set interface up */ + netif_set_up(ethif->netif); + + + if (ethif->flags & ETHIF_LINK_PHYUP) + { + /* set link_up for this netif */ + netif_set_link_up(ethif->netif); + } + + return ERR_OK; + } + + return ERR_IF; +} + +/* Keep old drivers compatible in RT-Thread */ +rt_err_t af_unix_eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flags) +{ + struct netif* netif; +#if LWIP_NETIF_HOSTNAME +#define LWIP_HOSTNAME_LEN 16 + char *hostname = RT_NULL; + netif = (struct netif*) rt_calloc (1, sizeof(struct netif) + LWIP_HOSTNAME_LEN); +#else + netif = (struct netif*) rt_calloc (1, sizeof(struct netif)); +#endif + if (netif == RT_NULL) + { + rt_kprintf("malloc netif failed\n"); + return -RT_ERROR; + } + + /* set netif */ + dev->netif = netif; + /* device flags, which will be set to netif flags when initializing */ + dev->flags = flags; + /* link changed status of device */ + dev->link_changed = 0x00; + dev->parent.type = RT_Device_Class_NetIf; + /* register to RT-Thread device manager */ + rt_device_register(&(dev->parent), name, RT_DEVICE_FLAG_RDWR); + rt_sem_init(&(dev->tx_ack), name, 0, RT_IPC_FLAG_FIFO); + + /* set name */ + netif->name[0] = name[0]; + netif->name[1] = name[1]; + + /* set hw address to 6 */ + netif->hwaddr_len = 6; + /* maximum transfer unit */ + netif->mtu = ETHERNET_MTU; + + /* set linkoutput */ + netif->linkoutput = ethernetif_linkoutput; + + /* get hardware MAC address */ + rt_device_control(&(dev->parent), NIOCTL_GADDR, netif->hwaddr); + +#if LWIP_NETIF_HOSTNAME + /* Initialize interface hostname */ + hostname = (char *)netif + sizeof(struct netif); + rt_sprintf(hostname, "rtthread_%02x%02x", name[0], name[1]); + netif->hostname = hostname; +#endif /* LWIP_NETIF_HOSTNAME */ + + /* if tcp thread has been started up, we add this netif to the system */ + if (rt_thread_find("tcpip") != RT_NULL) + { + ip4_addr_t ipaddr, netmask, gw; +// set loopback ip + ipaddr.addr = inet_addr("127.0.0.1"); + gw.addr = inet_addr("255.0.0.0"); + netmask.addr = inet_addr("127.0.0.1"); + + netifapi_netif_add(netif, &ipaddr, &netmask, &gw, dev, af_unix_eth_netif_device_init, tcpip_input); + } + +#ifdef RT_USING_NETDEV + /* network interface device flags synchronize */ + netdev_flags_sync(netif); +#endif /* RT_USING_NETDEV */ + + return RT_EOK; +} + +rt_err_t af_unix_eth_device_init(struct eth_device * dev, const char *name) +{ + rt_uint16_t flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP; + +#if LWIP_IGMP + /* IGMP support */ + flags |= NETIF_FLAG_IGMP; +#endif + + return af_unix_eth_device_init_with_flag(dev, name, flags); +} +#endif /* SAL_USING_AF_UNIX */ + #ifndef LWIP_NO_RX_THREAD rt_err_t eth_device_ready(struct eth_device* dev) { -- Gitee