Skip to content

Commit 41e442c

Browse files
Copilotsofthack007
andcommitted
Enable serial monitor in diagram.json and add firmware verification
Critical fix for missing serial output: - Add serialMonitor configuration to diagram.json with display:"always" - Required for capturing serial output in headless/CI mode - Without this, firmware output is not recorded - Add firmware hexdump verification in boot check workflow - Displays first 64 bytes to verify valid ESP32 header (0xe9 magic byte) - Helps diagnose corrupt or invalid firmware files - Update README with comprehensive Serial Monitor Configuration section - Explains why serialMonitor config is required - Documents configuration options - Adds troubleshooting steps for missing serial output - Includes firmware verification commands This should resolve the issue where boot check runs but shows no firmware serial output Co-authored-by: softhack007 <[email protected]>
1 parent 9fceaf0 commit 41e442c

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

.github/workflows/wokwi-test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ jobs:
105105
echo "⚠️ firmware.elf not found (optional for simulation)"
106106
fi
107107
108+
# Verify firmware can be read and has valid ESP32 header
109+
echo ""
110+
echo "Firmware file details:"
111+
ls -lh firmware.bin firmware.elf 2>/dev/null || true
112+
echo ""
113+
echo "Firmware.bin first 64 bytes (hex):"
114+
hexdump -C firmware.bin | head -4 || echo "Cannot read firmware.bin"
115+
echo "Note: ESP32 firmware should start with magic byte 0xe9"
116+
108117
echo ""
109118
echo "Running quick boot check scenario (15 seconds)..."
110119
echo "Wokwi CLI location: $(which wokwi-cli || echo 'NOT FOUND')"

test/wokwi/README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,39 @@ The Wokwi testing workflow:
1212

1313
## Files
1414

15-
- `diagram.json` - Wokwi hardware configuration (ESP32 DevKit)
15+
- `diagram.json` - Wokwi hardware configuration (ESP32 DevKit) with serial monitor settings
1616
- `wokwi.toml` - Wokwi CLI configuration and port forwarding
1717
- `prepare-firmware.sh` - Script to copy built firmware to test directory
1818
- `run-simulator.sh` - Script to start the Wokwi simulator
1919

20+
## Serial Monitor Configuration
21+
22+
The `diagram.json` file includes critical serial monitor configuration required for capturing firmware output in CI environments:
23+
24+
```json
25+
"serialMonitor": {
26+
"display": "always",
27+
"newline": "lf"
28+
}
29+
```
30+
31+
**Why this is needed:**
32+
- Without `display: "always"`, serial output is not captured in headless/CI mode
33+
- The Wokwi simulator only records serial output when explicitly configured
34+
- This is **required** for debugging boot issues and verifying firmware execution
35+
36+
**Configuration options:**
37+
- `display: "always"` - Ensures serial output is captured even in headless mode (CI)
38+
- `display: "auto"` - Only shows serial monitor when running interactively (not suitable for CI)
39+
- `newline: "lf"` - Line ending format (LF for Unix-style, CRLF for Windows)
40+
41+
**Troubleshooting missing serial output:**
42+
If you see empty serial logs (`boot-check-serial.log` or `serial.log`):
43+
1. Verify `serialMonitor` section exists in `diagram.json`
44+
2. Check firmware.bin has valid ESP32 header (starts with `0xe9` magic byte)
45+
3. Ensure firmware was built successfully and copied to test directory
46+
4. Review firmware build logs for compilation errors
47+
2048
## Running Tests Locally
2149

2250
### Prerequisites
@@ -150,6 +178,16 @@ To add more tests:
150178
- Verify Wokwi CLI is installed: `wokwi-cli --version`
151179
- Check Wokwi CLI logs for errors
152180

181+
### No serial output from firmware
182+
- Verify `serialMonitor` configuration in diagram.json
183+
- Check firmware.bin is valid:
184+
```bash
185+
hexdump -C firmware.bin | head -4
186+
# Should show ESP32 magic byte 0xe9 at start
187+
```
188+
- Ensure firmware was copied: `ls -lh test/wokwi/firmware.bin`
189+
- Check firmware build logs for errors
190+
153191
### Web server not accessible
154192
- Wait 30-60 seconds for the ESP32 to boot and start WiFi
155193
- Check that port 8080 is not already in use

test/wokwi/diagram.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@
1212
}
1313
],
1414
"connections": [],
15-
"dependencies": {}
15+
"dependencies": {},
16+
"serialMonitor": {
17+
"display": "always",
18+
"newline": "lf"
19+
}
1620
}

0 commit comments

Comments
 (0)