Closed bluestar714 closed 1 year ago
Can you post the console output of idf.py monitor?
Below is the console output of the wifi router. 192.168.5.1 is assigned as the USB IP, but on the Windows side However, on the Windows side, the IP address is not assigned as shown in the attached image.
I (24) boot: ESP-IDF v4.4.4-292-g7894f032f6-dirty 2nd stage bootloader
I (25) boot: compile time 00:47:20
I (25) boot: chip revision: v0.1
I (28) boot.esp32s3: Boot SPI Speed : 80MHz
I (33) boot.esp32s3: SPI Mode : DIO
I (38) boot.esp32s3: SPI Flash Size : 4MB
I (43) boot: Enabling RNG early entropy source...
I (48) boot: Partition Table:
I (52) boot: ## Label Usage Type ST Offset Length
I (59) boot: 0 nvs WiFi data 01 02 0000d000 00008000
I (66) boot: 1 phy_init RF data 01 01 00015000 0000b000
I (74) boot: 2 ota_0 OTA app 00 10 00020000 001d0000
I (81) boot: 3 ota_1 OTA app 00 11 001f0000 001d0000
I (89) boot: End of partition table
I (93) esp_image: segment 0: paddr=00020020 vaddr=3c090020 size=241b0h (147888) map
I (128) esp_image: segment 1: paddr=000441d8 vaddr=3fc99060 size=03a2ch ( 14892) load
I (131) esp_image: segment 2: paddr=00047c0c vaddr=40374000 size=0840ch ( 33804) load
I (141) esp_image: segment 3: paddr=00050020 vaddr=42000020 size=8b0ech (569580) map
I (249) esp_image: segment 4: paddr=000db114 vaddr=4037c40c size=0cc50h ( 52304) load
I (274) boot: Loaded app from partition at offset 0x20000
I (274) boot: Disabling RNG early entropy source...
I (285) cpu_start: Pro cpu up.
I (285) cpu_start: Single core mode
I (294) cpu_start: Pro cpu start user code
I (294) cpu_start: cpu freq: 240000000
I (294) cpu_start: Application information:
I (297) cpu_start: Project name: wifi_router
I (302) cpu_start: App version: v1.0.0-205-gca96007-dirty
I (309) cpu_start: Compile time: Apr 4 2023 00:01:16
I (315) cpu_start: ELF file SHA256: 3c75c2ac330baf03...
I (321) cpu_start: ESP-IDF: v4.4.4-292-g7894f032f6-dirty
I (328) cpu_start: Min chip rev: v0.0
I (332) cpu_start: Max chip rev: v0.99
I (337) cpu_start: Chip rev: v0.1
I (342) heap_init: Initializing. RAM available for dynamic allocation:
I (349) heap_init: At 3FCA17F0 len 00047F20 (287 KiB): D/IRAM
I (355) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DIRAM
I (362) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (368) heap_init: At 600FE000 len 00002000 (8 KiB): RTCRAM
I (375) spi_flash: detected chip: gd
I (379) spi_flash: flash io: dio
W (383) spi_flash: Detected size(16384k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (396) sleep: Configure to isolate all GPIO pins in sleep state
I (403) sleep: Enable automatic switching of GPIO sleep configuration
I (410) coexist: coexist rom version e7ae62f
I (415) cpu_start: Starting scheduler on PRO CPU.
I (428) bridge_common: esp-iot-bridge version: 0.4.0
I (429) pp: pp rom version: e7ae62f
I (433) net80211: net80211 rom version: e7ae62f
I (440) wifi:wifi driver task: 3fced9f4, prio:23, stack:6656, core=0
I (445) system_api: Base MAC address is not set
I (450) system_api: read default base MAC address from EFUSE
I (457) wifi:wifi firmware version: bd1de02
I (460) wifi:wifi certification version: v7.0
I (464) wifi:config NVS flash: enabled
I (467) wifi:config nano formating: disabled
I (472) wifi:Init data frame dynamic rx buffer num: 32
I (476) wifi:Init management frame dynamic rx buffer num: 32
I (482) wifi:Init management short buffer num: 32
I (486) wifi:Init dynamic tx buffer num: 32
I (490) wifi:Init static tx FG buffer num: 2
I (494) wifi:Init static rx buffer size: 1600
I (498) wifi:Init static rx buffer num: 10
I (502) wifi:Init dynamic rx buffer num: 32
I (506) wifi_init: rx ba win: 6
I (510) wifi_init: tcpip mbox: 32
I (514) wifi_init: udp mbox: 6
I (517) wifi_init: tcp mbox: 6
I (521) wifi_init: tcp tx win: 5744
I (525) wifi_init: tcp rx win: 5744
I (529) wifi_init: tcp mss: 1460
I (533) wifi_init: WiFi IRAM OP enabled
I (538) wifi_init: WiFi RX IRAM OP enabled
I (543) wifi_init: LWIP IRAM OP enabled
I (548) phy_init: phy_version 540,a5d905b,Oct 20 2022,19:36:11
I (585) wifi:mode : null
I (586) bridge_common: COMMON
I (586) ip select: IP Address:192.168.4.1
I (586) ip select: GW Address:192.168.4.1
I (590) ip select: NM Address:255.255.255.0
I (594) bridge_wifi: WiFI
I (598) bridge_wifi: IP Address:192.168.4.1
Add netif ap with ca96007(commit id)
I (606) bridge_common: netif list add success
I (611) wifi:mode : softAP (f4:12:fa:84:78:25)
I (616) wifi:Total power save buffer number: 16
I (619) wifi:Init max length of beacon: 752/752
I (624) wifi:Init max length of beacon: 752/752
I (629) bridge_wifi: Wifi Wifi Wifi Wifi Wifi Wifi Wifi Wifi Wifi Wifi Wifi
I (636) bridge_common: COMMON
I (639) ip select: IP Address:192.168.5.1
I (644) ip select: GW Address:192.168.5.1
I (649) ip select: NM Address:255.255.255.0
I (654) mac select: MAC f4:12:fa:84:78:24
I (659) bridge_usb: USB initialization
I (663) tusb_desc: using default config desc
I (668) tusb_desc: config desc size=75
I (672) tusb_desc:
┌─────────────────────────────────┐
│ USB Device Descriptor Summary │
├───────────────────┬─────────────┤
│bDeviceClass │ 0 │
├───────────────────┼─────────────┤
│bDeviceSubClass │ 0 │
├───────────────────┼─────────────┤
│bDeviceProtocol │ 0 │
├───────────────────┼─────────────┤
│bMaxPacketSize0 │ 64 │
├───────────────────┼─────────────┤
│idVendor │ 0x303a │
├───────────────────┼─────────────┤
│idProduct │ 0x4012 │
├───────────────────┼─────────────┤
│bcdDevice │ 0x100 │
├───────────────────┼─────────────┤
│iManufacturer │ 0x1 │
├───────────────────┼─────────────┤
│iProduct │ 0x2 │
├───────────────────┼─────────────┤
│iSerialNumber │ 0x3 │
├───────────────────┼─────────────┤
│bNumConfigurations │ 0x1 │
└───────────────────┴─────────────┘
I (840) TinyUSB: TinyUSB Driver installed
I (845) bridge_usb: USB initialization DONE
Add netif USB_Netif with ca96007(commit id)
I (854) bridge_common: netif list add success
I (859) bridge_usb: USB IP Address:192.168.5.1
Add netif sta with ca96007(commit id)
I (867) bridge_common: netif list add success
I (873) wifi:mode : sta (f4:12:fa:84:78:24) + softAP (f4:12:fa:84:78:25)
I (879) wifi:enable tsf
I (1482) wifi:Total power save buffer number: 16
I (1485) bridge_wifi: Wifi Wifi Wifi Wifi Wifi Wifi Wifi Wifi Wifi Wifi Wifi
I (1486) bridge_wifi: softap ssid: ESP_Bridge_847825 password: 12345678
I (1491) gpio: GPIO[38]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
start web server
Snipet of ipconfig /all
I have added the following to sdkconfig to support RNDIS.
CONFIG_TINYUSB_NET_ENABLED=y
CONFIG_TINYUSB_RNDIS_VENDOR="Espressif Incorporated"
CONFIG_TINYUSB_NET_ECM=y
I am guessing that we probably need to add a process like rndis_connect().
There are my suggestions:
Use wireshark to see if there is dhcp packet on the RNDIS interface. Also, check if there is any response from ESP to the computer at all
try add these two line where applicable
esp_netif_action_start(usb_netif, NULL, 0, NULL);
esp_netif_action_connected(usb_netif, NULL, 0, NULL);
Add these lines after the netif has been created
esp_netif_ip_info_t ip_info{};
esp_netif_str_to_ip4("192.168.5.1", &ip_info.ip);
esp_netif_str_to_ip4("192.168.5.1", &ip_info.gw);
esp_netif_str_to_ip4("255.255.255.0", &ip_info.netmask);
esp_netif_dhcps_stop(usb_netif);
esp_netif_set_ip_info(usb_netif, &ip_info);
esp_netif_dhcps_start(usb_netif);
See if any or the combination of these can help.
Thank you for pointing this out.
I was looking at WireShark and found DHCP Discovery (source is Windows) but. Also, there seems to be no ESP source packets other than ARP. So I am wondering if there is a problem here.
By the way, I am not sure how to do "Also, check if there is any response from ESP to the computer at all". I tried to check from the terminal connected to the SoftAP side, but it was still unreachable.
I also tried some of steps 2 and 3. Using esp_netif_action_start seems to crash on "netif already added."
Can you manually configure the IP address of the interface on windows to 192.168.5.2 and see if 192.168.5.1 is ping-able?
I had disappointed in a very rudimentary point. Thank you very much. I was able to manually assign an IP address to RNDIS and ping it between Windows (192.168.5.2) and ESP (192.168.5.1). Thank you very much!
Do you know what implementation or configuration is required to communicate between a Windows PC and a terminal connected to SoftAP, for example, 192.168.5.2 and 192.168.4.2?
If manually assigned IP works, it means the DHCP did not work properly on your ESP.
You can add the route to 192.168.4.0/24 through 192.168.5.1 on Windows to access the devices
I'm trying, but I can't get an IP address assigned to RNDIS from ESP32's DHCP.
I have the following steps 2 and 3 in bridge_common.c right after esp_bridge_create_usb_netif, does this seem to work? https://github.com/espressif/esp-iot-bridge/issues/42#issuecomment-1497120082
@bluestar714 You just need to upgrade your esp-idf version to 5.0, as version 4.4 does not support multiple DHCPS.
Whether to support the selection of multiple network data forwarding interfaces to provide network functions to different devices?
IDF Version | | Note -- | -- | -- ESP-IDF Release/v4.4 | Not Support | Only one network data forwarding interface can be selected ESP-IDF Release/v5.0 | Support | Currently, SDIO and SPI interfaces cannot be selected at the same time +-- USB <-+-> Computer
|
RasPi + ethsta0 +-- SPI -- ESP32 --> External WiFi(Router)
|
+-- SoftAP <-+-> Phone
@tswen
After changing to v5.0 of ESP-IDF, the IP address is assigned to the RNDIS device. Thank you very much.
We are currently having the following two issues
route add 192.168.4.0 mask 255.255.255.0 192.168.5.1 if 57
I'm sorry to keep repeating myself, but could you please give me a configuration or advice that would solve these problems
The update for this part has not been synced to the lwip component yet. Please apply the following patch in the esp-idf/components/lwip/lwip
submodule.
diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c
index a5c3dd55..a6106c90 100644
--- a/src/core/ipv4/ip4.c
+++ b/src/core/ipv4/ip4.c
@@ -332,8 +332,10 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
#if ESP_LWIP
#if IP_NAPT
- if (ip_napt_forward(p, iphdr, inp, netif) != ERR_OK)
- return;
+ if (!netif->napt) {
+ if (ip_napt_forward(p, iphdr, inp, netif) != ERR_OK)
+ return;
+ }
#endif
#endif /* ESP_LWIP */
Thank you for the patch info. After applying the patch, I see the following message in WireShark: "no response found" for ping, but it seems to be possible to communicate directly. Is it possible to check the communication by ICMP?
42 23.359778 192.168.4.2 192.168.5.2 ICMP 74 Echo (ping) request id=0x0001, seq=236/60416, ttl=127 (no response found!)
Yes, it is possible to check communication using ICMP. I didn't find any "no response found" situation during my testing. Could it be an accidental phenomenon?
Thanks for the reply. No, it happens every time so it is reproducible. It's not accidental, maybe the route add command is wrong?
I have tried to reflect the latest master commit, but the event continues.
If possible, could you please tell me the value of the sdkconfig you are using?
Also, below is my sdkconfig and sdkconfig.defaults.esp32s3, are there any suspicious settings? Could you please check them?
CONFIG_FREERTOS_UNICORE=y
CONFIG_TINYUSB=y CONFIG_TINYUSB_DEBUG_LEVEL=0
#
# CONFIG_TINYUSB_NET_ENABLED=y CONFIG_TINYUSB_RNDIS_VENDOR="Espressif Incorporated" CONFIG_TINYUSB_NET_ECM=y
#
# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ=240
CONFIG_USB_TASK_CORE_ID=1
#
# CONFIG_CDC_SEND_DTE_ACTIVE=n CONFIG_CDC_BULK_OUT_URB_BUFFER_SIZE=1536 CONFIG_CDC_BULK_IN_URB_BUFFER_SIZE=1536 CONFIG_CDC_BULK_IN_URB_NUM=4 CONFIG_CDC_BULK_OUT_URB_NUM=4
- sdkconfig
[sdkconfig.txt](https://github.com/espressif/esp-iot-bridge/files/11280531/sdkconfig.txt)
Have you tried using a Linux computer? TINYUSB_NET_ECM
I created a linux (ubuntu 22.04) environment with a VM and tried it. Ping from the USB side to the PC connected to SoftAP is "no respond found!", but the ping returned on the other side(the PC connected to SoftAP to the USB-ECM).
The environment is as follows.
$ uname -a
Linux virtual-machine 5.19.0-38-generic #39~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 17 21:16:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
I used the following command to configure static route on the linux side.
sudo route add -net 192.168.4.0 gw 192.168.5.1 netmask 255.255.255.0 enxf412fa84782c
Linux-side ip address infomation
6: enxf412fa84782c: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
link/ether f4:12:fa:84:78:2c brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 0 maxmtu 65535 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 parentbus usb parentdev 2-2.4:1.0
inet 192.168.5.2/24 brd 192.168.5.255 scope global dynamic noprefixroute enxf412fa84782c
valid_lft 5336sec preferred_lft 5336sec
inet6 fe80::d452:796d:8e41:6f6a/64 scope link noprefixroute
valid_lft forever preferred_lft forever
wireshark information on linux side
798 660.195187058 192.168.5.2 192.168.4.2 ICMP 98 Echo (ping) request id=0x000a, seq=27/6912, ttl=64 (no response found!)
idf.py monitor (Partial cut out)
I (898) TinyUSB: TinyUSB Driver installed
I (903) bridge_usb: USB initialization DONE
Add netif USB_Netif with dceb403(commit id)
I (911) bridge_common: netif list add success
I (917) bridge_usb: USB IP Address:192.168.5.1
Add netif sta with dceb403(commit id)
I (925) bridge_common: netif list add success
I (931) wifi:mode : sta (f4:12:fa:84:78:24) + softAP (f4:12:fa:84:78:25)
I (937) wifi:enable tsf
I (1544) wifi:Total power save buffer number: 16
I (1546) bridge_wifi: softap ssid: ESP_Bridge_847825 password: 12345678
I (1547) gpio: GPIO[38]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
start web server
I (5964) esp_netif_lwip: DHCP server assigned IP to a client, IP is: 192.168.5.2
I (9033) wifi:new:<1,1>, old:<1,1>, ap:<1,1>, sta:<0,0>, prof:1
I (9034) wifi:station: 9c:fc:e8:d0:f8:4a join, AID=1, bgn, 40U
I (9052) bridge_wifi: STA Connecting to the AP again...
I (9062) esp_netif_lwip: DHCP server assigned IP to a client, IP is: 192.168.4.2
Without modifying any code in the bridge, the test works as follows
27 17.935125342 192.168.5.2 192.168.6.2 ICMP 98 Echo (ping) reply id=0x0007, seq=11/2816, ttl=63 (request in 26) 28 18.609012242 192.168.6.2 192.168.5.2 ICMP 98 Echo (ping) request id=0x0007, seq=12/3072, ttl=64 (reply in 29) 29 18.635965777 192.168.5.2 192.168.6.2 ICMP 98 Echo (ping) reply id=0x0007, seq=12/3072, ttl=63 (request in 28)
Can 192.168.5.2 and 192.168.6.2 be successfully pinged in both directions?
By the way, I am using esp-idf version release/v5.0, is it another version?
Yes, you can add the following patch. release/v5.0 is OK. https://github.com/espressif/esp-iot-bridge/issues/42#issuecomment-1498611006
I have confirmed that the latest master has the patch! Do you need to configure Static Routing? (route add command etc.)
Not required, all dynamically assigned.
Hmmm, I've tried a clean environment and tweaking sdkconfig, but it doesn't seem to return pings across subnets (both from 192.168.4.2 to 192.168.5.2 and from 192.168.5.2 to 192.168.4.2).
I have a softap network that seems to be 192.168.4.x/24, and I am thinking of assigning an RNDIS netif to this, but is there any ESP-IDF spec issue?
@bluestar714 Do you have multiple network interface on your host PC? i.e. multiple default gateways. If so, you have to either 1. route add the static route entry or 2. use DHCP option to pass the route to the host PC automatically.
@wuyuanyi135 Thank you for your reply.
My Windows PC had multiple Network Adapters and multiple default gateways. Therefore, once I disabled the other NICs and looked at the communication situation. I tried setting up individual static routes as shown in the route table below, but so far I am unable to communicate from RNDIS (192.168.5.2) to 192.168.4.1 and 192.168.4.2 (SoftAP's clients). Strangely enough, I can communicate from 192.168.4.2 (SoftAP client) to 192.168.5.1. However, I am having trouble seeing any noticeable difference in route print.
IPv4 route table
===========================================================================
Active route:
network destination netmask gateway interface metric
0.0.0.0 0.0.0.0 192.168.5.1 192.168.5.2 55
127.0.0.0 255.0.0.0 On-Link 127.0.0.1 331
127.0.0.1 255.255.255.255 On-Link 127.0.0.1 331
127.255.255.255 255.255.255.255 On-Link 127.0.0.1 331
192.168.4.0 255.255.255.0 On-Link 192.168.5.2 56
192.168.4.0 255.255.255.0 192.168.5.1 192.168.5.2 56
192.168.4.0 255.255.255.255 On-Link 192.168.5.2 56
192.168.4.1 255.255.255.255 On-Link 192.168.5.2 56
192.168.4.2 255.255.255.255 On-Link 192.168.5.2 56
192.168.4.255 255.255.255.255 On-Link 192.168.5.2 311
192.168.5.0 255.255.255.0 On-Link 192.168.5.2 311
192.168.5.2 255.255.255.255 On-Link 192.168.5.2 311
192.168.5.255 255.255.255.255 On-Link 192.168.5.2 311
224.0.0.0 240.0.0.0 On-Link 127.0.0.1 331
224.0.0.0 240.0.0.0 On-Link 192.168.5.2 311
255.255.255.255 255.255.255.255 On-Link 127.0.0.1 331
255.255.255.255 255.255.255.255 On-Link 192.168.5.2 311
IIRC it is normal behavior if you couldn't access the gateway of the softAP. Does it work if you connect to the RNDIS gateway? i.e. 192.168.5.1.
It is possible to connect (ping) to 192.168.5.1 from the RNDIS NIC (192.168.5.2). It is also possible to connect to 192.168.5.1 from a client (192.168.4.2) connected to SoftAP.
The route should work if it was configured like this. Do you think the firewall is to blame? try disable it. Also, if memory serves, the PING didn't work for me when I was writing this library. try connect a phone or something else to the AP and run a http server, see if it connects. ICMP didnt work for me.
Thank you very much. Your earlier reply contained very suggestive information.
if memory serves, the PING didn't work for me when I was writing this library. try connect a phone or something else to the AP and run a http server, see if it connects. ICMP didnt work for me.
I have concluded that for RNDIS connections, the ping does not go through (even if the firewall setting is turned off).
I am planning to use OSC on a WiFi dongle and for this it seems to connect without any problem. (I could also do HTTP Request).
Here is a summary of what I have done
Set esp-idf version to 5.0
rewrite ipv4.cpp in esp-idf https://github.com/espressif/esp-iot-bridge/issues/42#issuecomment-1498611006
Enable RNDIS
Configure static route
route ADD 192.168.4.0 MASK 255.255.255.0 192.168.5.1
Hello, I am trying to create a bridge between USB-SoftAP and RNDIS. As far as I understand, the current iot-bridge does not support RNDIS. Can you provide some guidance or hints on how to achieve this?
So far, I have added RNDIS settings to the sdkconfig, and my Windows PC is able to recognize the ESP32S3 as an RNDIS device. However, an IP address is not being assigned.
I have heard that iot-bridge is already in a state where it can support RNDIS, as mentioned in the following issues. When can we expect these to be merged?
https://github.com/espressif/esp-iot-bridge/issues/29 https://github.com/espressif/esp-iot-solution/issues/240