stm32h7/linum-stm32h753bi: Add support to rndis(etherver over usb)
Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
This commit is contained in:
parent
62c2b3e1ec
commit
4b3ef4d1fc
@ -589,4 +589,105 @@ This example use the flash memory W25Q128JV via qspi with the littlefs file syst
|
||||
/w25/folder1:
|
||||
.
|
||||
..
|
||||
message.txt
|
||||
message.txt
|
||||
|
||||
rndis
|
||||
-----
|
||||
This exemple use ethernet over usb and show how configure ip and download file with wget command from server.
|
||||
|
||||
After flash the board check if the linux found and recognized the new network driver::
|
||||
|
||||
$ sudo dmesg | tail
|
||||
[30260.873245] rndis_host 3-1.3:1.0 enxa0e0deadbeef: unregister 'rndis_host' usb-0000:00:14.0-1.3, RNDIS device
|
||||
[30265.461419] usb 3-1.3: new full-speed USB device number 34 using xhci_hcd
|
||||
[30265.563354] usb 3-1.3: New USB device found, idVendor=584e, idProduct=5342, bcdDevice= 0.01
|
||||
[30265.563359] usb 3-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
|
||||
[30265.563361] usb 3-1.3: Product: RNDIS gadget
|
||||
[30265.563362] usb 3-1.3: Manufacturer: NuttX
|
||||
[30265.563363] usb 3-1.3: SerialNumber: 1234
|
||||
[30265.572179] rndis_host 3-1.3:1.0: dev can't take 1558 byte packets (max 660), adjusting MTU to 602
|
||||
[30265.573517] rndis_host 3-1.3:1.0 eth0: register 'rndis_host' at usb-0000:00:14.0-1.3, RNDIS device, a0:e0:de:ad:be:ef
|
||||
[30265.584924] rndis_host 3-1.3:1.0 enxa0e0deadbeef: renamed from eth0
|
||||
|
||||
$ ifconfig
|
||||
enxa0e0deadbeef: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 602
|
||||
inet 10.42.0.1 netmask 255.255.255.0 broadcast 10.42.0.255
|
||||
ether a0:e0:de:ad:be:ef txqueuelen 1000 (Ethernet)
|
||||
RX packets 87 bytes 10569 (10.5 KB)
|
||||
RX errors 0 dropped 0 overruns 0 frame 0
|
||||
TX packets 99 bytes 22896 (22.8 KB)
|
||||
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
||||
|
||||
obs: In network settings of PC enable "Shared to other computers"
|
||||
|
||||
Configure the IP of target::
|
||||
|
||||
nsh> ifconfig eth0 10.42.0.2
|
||||
nsh> ifconfig
|
||||
lo Link encap:Local Loopback at RUNNING mtu 1518
|
||||
inet addr:127.0.0.1 DRaddr:127.0.0.1 Mask:255.0.0.0
|
||||
|
||||
eth0 Link encap:Ethernet HWaddr 00:e0:de:ad:be:ef at UP mtu 576
|
||||
inet addr:10.42.0.2 DRaddr:10.42.0.1 Mask:255.255.255.0
|
||||
|
||||
IPv4 TCP UDP ICMP
|
||||
Received 012a 0000 0126 0000
|
||||
Dropped 0004 0000 0000 0000
|
||||
IPv4 VHL: 0000 Frg: 0001
|
||||
Checksum 0000 0000 0000 ----
|
||||
TCP ACK: 0000 SYN: 0000
|
||||
RST: 0000 0000
|
||||
Type 0000 ---- ---- 0000
|
||||
Sent 0000 0000 0000 0000
|
||||
Rexmit ---- 0000 ---- ----
|
||||
nsh>
|
||||
|
||||
Testing communication with PC using ping command::
|
||||
|
||||
nsh> ping 10.42.0.1
|
||||
PING 10.42.0.1 56 bytes of data
|
||||
56 bytes from 10.42.0.1: icmp_seq=0 time=0.0 ms
|
||||
56 bytes from 10.42.0.1: icmp_seq=1 time=0.0 ms
|
||||
56 bytes from 10.42.0.1: icmp_seq=2 time=0.0 ms
|
||||
56 bytes from 10.42.0.1: icmp_seq=3 time=0.0 ms
|
||||
56 bytes from 10.42.0.1: icmp_seq=4 time=0.0 ms
|
||||
56 bytes from 10.42.0.1: icmp_seq=5 time=0.0 ms
|
||||
56 bytes from 10.42.0.1: icmp_seq=6 time=0.0 ms
|
||||
56 bytes from 10.42.0.1: icmp_seq=7 time=0.0 ms
|
||||
56 bytes from 10.42.0.1: icmp_seq=8 time=0.0 ms
|
||||
56 bytes from 10.42.0.1: icmp_seq=9 time=0.0 ms
|
||||
10 packets transmitted, 10 received, 0% packet loss, time 10100 ms
|
||||
rtt min/avg/max/mdev = 0.000/0.000/0.000/0.000 ms
|
||||
|
||||
In your pc you will be able connect to target using telnet and access their shell nsh::
|
||||
|
||||
$ telnet 10.42.0.2
|
||||
Trying 10.42.0.2...
|
||||
Connected to 10.42.0.2.
|
||||
Escape character is '^]'.
|
||||
|
||||
NuttShell (NSH) NuttX-12.5.1
|
||||
nsh> uname -a
|
||||
NuttX 12.5.1 c148e8f2af-dirty Apr 28 2024 10:27:50 arm linum-stm32h753bi
|
||||
nsh> exit
|
||||
Connection closed by foreign host.
|
||||
$
|
||||
|
||||
Testing wget to download file from server::
|
||||
|
||||
# PC: Creating a http server and sharing local folder.
|
||||
$ sudo python3 -m http.server 80 -d ./
|
||||
|
||||
# log of server
|
||||
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
|
||||
10.42.0.2 - - [28/Apr/2024 16:14:39] "GET /nuttx_logo.txt HTTP/1.0" 200 -
|
||||
|
||||
# Using wget on target
|
||||
nsh> mount -t tmpfs /tmp
|
||||
nsh> cd /tmp
|
||||
nsh> pwd
|
||||
/tmp
|
||||
nsh> wget http://10.42.0.1/nuttx_logo.txt
|
||||
nsh> ls
|
||||
/tmp:
|
||||
nuttx_logo.txt
|
||||
|
84
boards/arm/stm32h7/linum-stm32h753bi/configs/rndis/defconfig
Normal file
84
boards/arm/stm32h7/linum-stm32h753bi/configs/rndis/defconfig
Normal file
@ -0,0 +1,84 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_STANDARD_SERIAL is not set
|
||||
# CONFIG_STM32H7_USE_LEGACY_PINMAP is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="linum-stm32h753bi"
|
||||
CONFIG_ARCH_BOARD_LINUM_STM32H753BI=y
|
||||
CONFIG_ARCH_CHIP="stm32h7"
|
||||
CONFIG_ARCH_CHIP_STM32H753BI=y
|
||||
CONFIG_ARCH_CHIP_STM32H7=y
|
||||
CONFIG_ARCH_CHIP_STM32H7_CORTEXM7=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARMV7M_DCACHE=y
|
||||
CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
|
||||
CONFIG_ARMV7M_DTCM=y
|
||||
CONFIG_ARMV7M_ICACHE=y
|
||||
CONFIG_BOARDCTL_USBDEVCTRL=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=43103
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_FEATURES=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_EXAMPLES_ALARM=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_TMPFS=y
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=4096
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_MEMFD_ERROR=y
|
||||
CONFIG_LIBM=y
|
||||
CONFIG_MM_REGIONS=4
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x0
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NETINIT_NOMAC=y
|
||||
CONFIG_NETINIT_THREAD=y
|
||||
CONFIG_NETUTILS_DHCPC=y
|
||||
CONFIG_NETUTILS_NETCAT=y
|
||||
CONFIG_NETUTILS_TELNETD=y
|
||||
CONFIG_NETUTILS_WEBCLIENT=y
|
||||
CONFIG_NET_ARP_SEND=y
|
||||
CONFIG_NET_BROADCAST=y
|
||||
CONFIG_NET_ICMP=y
|
||||
CONFIG_NET_ICMP_SOCKET=y
|
||||
CONFIG_NET_LOOPBACK=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_TCP_WRITE_BUFFERS=y
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_OTG_ID_GPIO_DISABLE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=245760
|
||||
CONFIG_RAM_START=0x20010000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RNDIS=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_RTC_ALARM=y
|
||||
CONFIG_RTC_DATETIME=y
|
||||
CONFIG_RTC_DRIVER=y
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_STM32H7_HSI48=y
|
||||
CONFIG_STM32H7_OTGFS=y
|
||||
CONFIG_STM32H7_PWR=y
|
||||
CONFIG_STM32H7_RTC=y
|
||||
CONFIG_STM32H7_USART1=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_USART1_SERIAL_CONSOLE=y
|
||||
CONFIG_USBDEV=y
|
@ -49,6 +49,10 @@
|
||||
#include "stm32_fdcan_sock.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RNDIS
|
||||
#include <nuttx/usb/rndis.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
@ -242,5 +246,16 @@ int stm32_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RNDIS) && !defined(CONFIG_RNDIS_COMPOSITE)
|
||||
uint8_t mac[6];
|
||||
mac[0] = 0xa0;
|
||||
mac[1] = (CONFIG_NETINIT_MACADDR_2 >> (8 * 0)) & 0xff;
|
||||
mac[2] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 3)) & 0xff;
|
||||
mac[3] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 2)) & 0xff;
|
||||
mac[4] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 1)) & 0xff;
|
||||
mac[5] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 0)) & 0xff;
|
||||
usbdev_rndis_initialize(mac);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user