1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
Multicast packets (mDNS) are not sent out of VM
Description of problem:
The app is sending multicast packets (mDNS), but they are not sent out of VM.
Here is the configuration of the network: `-netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::50051-:50051,hostfwd=tcp::50050-:50050`
Steps to reproduce:
1. Install arduino-cli from https://github.com/arduino/arduino-cli/releases (eg. 0.20.2)
2. `arduino-cli config init`
3. `vi ~/.arduino15/arduino-cli.yaml`
4. edit it to have it as follows:
```
board_manager:
additional_urls: ["http://arduino.esp8266.com/stable/package_esp8266com_index.json"]
daemon:
port: "50051"
directories:
data: /root/app/data
downloads: /root/app/downloads
user: /root/app/user
library:
enable_unsafe_install: false
logging:
file: ""
format: text
level: info
metrics:
addr: :9090
enabled: false
output:
no_color: false
sketch:
always_export_binaries: false
updater:
enable_notification: true
```
5. `arduino-cli core update-index`
6. `arduino-cli core install esp8266:esp8266`
7. `arduino-cli board list -v`
This will give an output similar to:
```
INFO[0000] Using config file: /root/.arduino15/arduino-cli.yaml
INFO[0000] arduino-cli.x86_64 version git-snapshot
INFO[0000] Checking if CLI is Bundled into the IDE
INFO[0000] Adding libraries dir dir=/root/app/user/libraries location=user
INFO[0000] Checking signature index=/root/app/data/package_index.json signatureFile=/root/app/data/package_index.json.sig =
INFO[0000] Checking signature error="opening signature file: open /root/app/data/package_esp8266com_index.json.sig: no such file or d=
INFO[0000] Loading hardware from: /root/app/data/packages
INFO[0000] Loading package builtin from: /root/app/data/packages/builtin
INFO[0000] Checking existence of 'tools' path: /root/app/data/packages/builtin/tools
INFO[0000] Loading tools from dir: /root/app/data/packages/builtin/tools
INFO[0000] Loaded tool tool="builtin:ctags@5.8-arduino11"
INFO[0000] Loaded tool tool="builtin:mdns-discovery@1.0.2"
INFO[0000] Loaded tool tool="builtin:serial-discovery@1.3.1"
INFO[0000] Loaded tool tool="builtin:serial-monitor@0.9.1"
INFO[0000] Loading package esp8266 from: /root/app/data/packages/esp8266/hardware
INFO[0000] Checking signature error="opening signature file: open /root/app/data/packages/esp8266/hardware/esp8266/3.0.2/installed.js=
INFO[0000] Adding monitor tool protocol=serial tool="builtin:serial-monitor"
INFO[0000] Loaded platform platform="esp8266:esp8266@3.0.2"
INFO[0000] Checking existence of 'tools' path: /root/app/data/packages/esp8266/tools
INFO[0000] Loading tools from dir: /root/app/data/packages/esp8266/tools
INFO[0000] Loaded tool tool="esp8266:mklittlefs@3.0.4-gcc10.3-1757bed"
INFO[0000] Loaded tool tool="esp8266:mkspiffs@3.0.4-gcc10.3-1757bed"
INFO[0000] Loaded tool tool="esp8266:python3@3.7.2-post1"
INFO[0000] Loaded tool tool="esp8266:xtensa-lx106-elf-gcc@3.0.4-gcc10.3-1757bed"
INFO[0000] Adding libraries dir dir=/root/app/data/packages/esp8266/hardware/esp8266/3.0.2/libraries location=platform
INFO[0007] Executing `arduino-cli board list`
INFO[0007] starting discovery builtin:serial-discovery process
INFO[0007] started discovery builtin:serial-discovery process
INFO[0007] sending command HELLO 1 "arduino-cli git-snapshot" to discovery builtin:serial-discovery
INFO[0007] starting discovery builtin:mdns-discovery process
INFO[0007] started discovery builtin:mdns-discovery process
INFO[0007] sending command HELLO 1 "arduino-cli git-snapshot" to discovery builtin:mdns-discovery
INFO[0007] from discovery builtin:serial-discovery received message type: hello, message: OK, protocol version: 1
INFO[0007] from discovery builtin:mdns-discovery received message type: hello, message: OK, protocol version: 1
INFO[0007] sending command START to discovery builtin:serial-discovery
INFO[0007] sending command START to discovery builtin:mdns-discovery
INFO[0007] from discovery builtin:mdns-discovery received message type: start, message: OK
INFO[0007] from discovery builtin:serial-discovery received message type: start, message: OK
INFO[0008] sending command LIST to discovery builtin:serial-discovery
INFO[0008] sending command LIST to discovery builtin:mdns-discovery
INFO[0008] from discovery builtin:mdns-discovery received message type: list
INFO[0008] from discovery builtin:serial-discovery received message type: list, ports: [/dev/ttyS0]
INFO[0008] sending command STOP to discovery builtin:serial-discovery
INFO[0008] sending command STOP to discovery builtin:mdns-discovery
INFO[0008] from discovery builtin:mdns-discovery received message type: stop, message: OK
INFO[0008] from discovery builtin:serial-discovery received message type: stop, message: OK
Port Protocol Type Board Name FQBN Core
/dev/ttyS0 serial Unknown
```
Note `builtin:mdns-discovery` discovery started. It is expected to send the packets as follows (the screenshot from the host with Wireshark):

The screenshot is taken if running the same app (but for macOS) from the host and **i can't see the packets sent if executed from the QEMU guest os**.
I believe i either configured it the wrong way (`-netdev user,id=net0,...`) or it's a QEMU bug.
Additional information:
I've tested on macOS host with qemu 6.0.0 and on Linux (Android) host with qemu 6.1.0 and both were not working.
the network interface seems to be configured for multicasting:
```
# ifconfig
eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:57
inet addr:10.0.2.15 Bcast:0.0.0.0 Mask:255.255.255.0
inet6 addr: fec0::5054:ff:fe12:3457/64 Scope:Site
inet6 addr: fe80::5054:ff:fe12:3457/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:91955 errors:0 dropped:0 overruns:0 frame:0
TX packets:25203 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:119904373 (114.3 MiB) TX bytes:1868274 (1.7 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
```
It might be easier to skip using arduino-cli and just use any mdns discovery app.
|