Skip to content

Commit 3c9a68f

Browse files
Copilotsofthack007
andcommitted
Document QEMU DHCP networking and add static IP option
QEMU provides a built-in DHCP server, but if there are issues, static IP can be enabled as a fallback. Documentation updates: - Explained QEMU user-mode networking (slirp) provides DHCP - Default network: 10.0.2.0/24, guest IP: 10.0.2.15 - Gateway: 10.0.2.2, DNS: 10.0.2.3 - Port forwarding: ESP32:80 → localhost:8080 Added static IP option in platformio.ini: - Commented out by default (DHCP is preferred) - Can be enabled if DHCP doesn't work - Static IP 10.0.2.15 matches QEMU's default assignment - Flags: WLED_STATIC_IP_DEFAULT_1 through _4 Updated documentation: - docs/QEMU-ISSUES.md: Network configuration section - e2e-tests/README.md: Troubleshooting ethernet/DHCP issues DHCP should work by default in QEMU, but the static IP option provides a fallback if connection issues occur. Co-authored-by: softhack007 <[email protected]>
1 parent 79a1d5c commit 3c9a68f

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

docs/QEMU-ISSUES.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,36 @@ The build uses ESP32-POE board configuration (index 2):
2424

2525
This configuration is compatible with QEMU's `open_eth` model, which emulates standard ESP32 RMII ethernet interface.
2626

27+
### Network Configuration in QEMU
28+
QEMU's user-mode networking (slirp) provides:
29+
- **DHCP Server**: Built-in DHCP server (default network 10.0.2.0/24)
30+
- Guest IP: 10.0.2.15 (assigned via DHCP)
31+
- Gateway: 10.0.2.2
32+
- DNS: 10.0.2.3
33+
- **Port Forwarding**: TCP port 80 on guest → port 8080 on host (localhost:8080)
34+
35+
**DHCP vs Static IP:**
36+
- WLED normally uses DHCP on ethernet
37+
- QEMU provides a DHCP server by default
38+
- If DHCP doesn't work (connection issues), enable static IP in platformio.ini:
39+
```
40+
-D WLED_STATIC_IP_DEFAULT_1=10
41+
-D WLED_STATIC_IP_DEFAULT_2=0
42+
-D WLED_STATIC_IP_DEFAULT_3=2
43+
-D WLED_STATIC_IP_DEFAULT_4=15
44+
```
45+
- Static IP 10.0.2.15 matches QEMU's default guest IP assignment
46+
2747
## QEMU Limitations
2848

2949
ESP32 QEMU emulation is not perfect and has several known limitations:
3050

51+
### Network Configuration
52+
- **DHCP**: QEMU provides a built-in DHCP server (10.0.2.0/24 network)
53+
- **Expected behavior**: ESP32 should receive IP 10.0.2.15 via DHCP
54+
- **If DHCP fails**: Enable static IP in platformio.ini (see Build Configuration above)
55+
- **Port forwarding**: HTTP port 80 on ESP32 → localhost:8080 on host
56+
3157
### Hardware Emulation
3258
- **WiFi**: Not emulated - **causes crashes if enabled**
3359
- **Bluetooth**: Not emulated

e2e-tests/README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,17 @@ npx playwright show-report
120120
- Check QEMU logs: `cat qemu-output.log`
121121
- Verify firmware was built successfully
122122

123+
**Ethernet/network connection issues:**
124+
- QEMU provides DHCP server (10.0.2.0/24 network, guest IP 10.0.2.15)
125+
- If DHCP fails, enable static IP in `platformio.ini` (see comments in file)
126+
- Check QEMU output for "ETH Connected" message
127+
- Port forwarding: ESP32 port 80 → localhost:8080
128+
123129
**Tests fail with connection errors:**
124130
- Wait longer for ESP32 to boot (30-45 seconds minimum)
125-
- Check if port 80 is accessible: `curl http://localhost/`
131+
- Check if HTTP server started: `curl http://localhost:8080/`
126132
- Verify QEMU is still running: `ps aux | grep qemu`
133+
- Check for ethernet connection errors in QEMU logs
127134

128135
**Tests timeout:**
129136
- QEMU emulation is slow - tests have 45 second timeouts
@@ -138,8 +145,10 @@ npx playwright show-report
138145
## QEMU Limitations
139146

140147
ESP32 QEMU emulation has limitations:
141-
- **Network**: User-mode networking only (no raw ethernet)
142-
- **WiFi**: Not emulated (returns mock data)
148+
- **Network**: User-mode networking with built-in DHCP (10.0.2.0/24)
149+
- Guest IP: 10.0.2.15 (via DHCP or static configuration)
150+
- Port forwarding: ESP32 port 80 → localhost:8080
151+
- **WiFi**: Not emulated (crashes if enabled - use ethernet build)
143152
- **Peripherals**: Many are stubbed (LEDs, I2C, etc.)
144153
- **Performance**: Slower than real hardware
145154

@@ -148,6 +157,7 @@ Despite these limitations, QEMU is sufficient for testing:
148157
- JavaScript executes without errors
149158
- API endpoints respond
150159
- Page navigation works
160+
- Ethernet networking works (via open_eth emulation)
151161

152162
## Adding New Tests
153163

platformio.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,12 @@ build_flags = ${esp32_4MB_V4_S_base.esp32_build_flags}
18281828
-D WLED_USE_ETHERNET
18291829
-D WLED_ETH_DEFAULT=2 ;; ESP32-POE board configuration (works with QEMU open_eth)
18301830
-D WLED_DISABLE_ESPNOW ;; ESP-NOW requires wifi, may crash with ethernet only
1831+
;; Static IP for QEMU testing - user-mode networking provides DHCP at 10.0.2.0/24
1832+
;; If DHCP fails, uncomment these lines to use static IP:
1833+
; -D WLED_STATIC_IP_DEFAULT_1=10
1834+
; -D WLED_STATIC_IP_DEFAULT_2=0
1835+
; -D WLED_STATIC_IP_DEFAULT_3=2
1836+
; -D WLED_STATIC_IP_DEFAULT_4=15
18311837
lib_deps = ${esp32_4MB_V4_S_base.esp32_lib_deps}
18321838
${common_mm.HUB75_lib_deps}
18331839
lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation

0 commit comments

Comments
 (0)