Files
OpenIris-ESPIDF/README.md

165 lines
7.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
| Supported Targets | ESP32-S3 |
| ----------------- | -------- |
## OpenIris-ESPIDF
Firmware and tools for OpenIris — WiFi, UVC streaming, and a Python setup CLI.
---
## Whats inside
- ESPIDF firmware (C/C++) with modules for Camera, WiFi, UVC, REST/Serial commands, and more
- Python tools for setup over USB serial:
- `tools/switchBoardType.py` — choose a board profile (builds the right sdkconfig)
- `tools/openiris_setup.py` — interactive CLI for WiFi, MDNS/Name, Mode, LED PWM, Logs, and a Settings Summary
---
## First-time setup on Windows (VS Code + ESPIDF extension)
If youre starting fresh on Windows, this workflow is smooth and reliable:
1) Install tooling
- Git: https://git-scm.com/downloads/win
- Visual Studio Code: https://code.visualstudio.com/
2) Get the source code
- Create a folder where you want the repo (e.g., `D:\OpenIris-ESPIDF\`). In File Explorer, rightclick the folder and choose “Open in Terminal”.
- Clone and open in VS Code:
```cmd
git clone https://github.com/lorow/OpenIris-ESPIDF.git
cd OpenIris-ESPIDF
code .
```
3) Install the ESPIDF VS Code extension
- In VS Code, open the Extensions tab and install: https://marketplace.visualstudio.com/items?itemName=espressif.esp-idf-extension
4) Set the default terminal profile to Command Prompt
- Press Ctrl+Shift+P → search “Terminal: Select Default Profile” → choose “Command Prompt”.
- Restart VS Code from its normal shortcut (not from Git Bash). This avoids running ESPIDF in the wrong shell.
5) Configure ESPIDF in the extension
- On first launch, the extension may prompt to install ESPIDF and tools — follow the steps. It can take a while.
- If you see the extensions home page instead, click “Configure extension”, pick “EXPRESS”, choose “GitHub” as the server and version “v5.4.2”.
- Then open the ESPIDF Explorer tab and click “Open ESPIDF Terminal”. Well use that for builds.
After this, youre ready for the Quick start below.
---
## Quick start
### 1) Pick your board (loads the default configuration)
Boards are autodiscovered from the `boards/` directory. First list them, then pick one:
Windows (cmd):
```cmd
python .\tools\switchBoardType.py --list
python .\tools\switchBoardType.py --board seed_studio_xiao_esp32s3 --diff
```
macOS/Linux (bash):
```bash
python3 ./tools/switchBoardType.py --list
python3 ./tools/switchBoardType.py --board seed_studio_xiao_esp32s3 --diff
```
Notes:
- Use `--list` to see all detected board keys.
- Board key = relative path under `boards/` with `/` replaced by `_` (and duplicate tail segments collapsed, e.g. `project_babble/project_babble` -> `project_babble`).
- `--diff` shows what will change vs the current `sdkconfig`.
- You can also pass partial or pathlike inputs (e.g. `facefocusvr/eye_L`), the tool normalizes them.
### 2) Build & flash
- Set the target (e.g., ESP32S3).
- Build, flash, and open the serial monitor.
### 3) Use the Python setup CLI (recommended)
Configure the device over USB serial.
Before you run it:
- If you still have the serial monitor open, close it (the port must be free).
- In VS Code, open the sidebar “ESPIDF: Explorer” and click “Open ESPIDF Terminal”. Well run the CLI there so Python and packages are in the right environment.
Then run:
```cmd
python .\tools\openiris_setup.py --port COMxx
```
Examples:
- Windows: `python .\tools\openiris_setup.py --port COM69`, …
- macOS: idk
- Linux: idk
What the CLI can do:
- WiFi menu: automatic (scan → pick → password → connect → wait for IP) or manual (scan, show, configure, connect, status)
- Set MDNS/Device name (also used for the UVC device name)
- Switch mode (WiFi / UVC / Setup)
- Adjust LED PWM
- Show a Settings Summary (MAC, WiFi status, mode, PWM, …)
- View logs
---
## Serial number & MAC
- Internally, the serial number is derived from the WiFi MAC address.
- The CLI displays the MAC by default (clearer); its the value used as the serial number.
- The UVC device name is based on the MDNS hostname.
---
## Common workflows
- Fast WiFi setup: in the CLI, go to “WiFi settings” → “Automatic setup”, then check “status”.
- Change name/MDNS: set the device name in the CLI, then replug USB — UVC will show the new name.
- Adjust brightness/LED: set LED PWM in the CLI.
---
## Project layout (short)
- `main/` — entry point
- `components/` — modules (Camera, WiFi, UVC, CommandManager, …)
- `tools/` — Python helper tools (board switch, setup CLI, scanner)
If you want to dig deeper: commands are mapped via the `CommandManager` under `components/CommandManager/...`.
---
## Troubleshooting
### LED Status / Error Patterns
The firmware uses a small set of LED patterns to indicate status and blocking errors. When `LED_DEBUG_ENABLE` is disabled and `LED_EXTERNAL_AS_DEBUG` is enabled the external IR LED mirrors ONLY error patterns (0%/50% duty). Nonerror patterns are not mirrored.
| State | Category | Repeat | Pattern (ON/OFF ms) | Meaning |
|-------|----------|--------|---------------------|---------|
| LedStateNone | idle | no | (off) | No activity / heartbeat window waiting |
| LedStateStreaming | active | yes | steady on | Streaming running (UVC or WiFi) |
| LedStateStoppedStreaming | inactive | yes | steady off | Streaming intentionally stopped |
| CameraError | error | yes | 300/300 300/700 | Camera init/runtime failure (check sensor, ribbon, power) |
| WiFiStateConnecting | transitional | yes | 400/400 | WiFi associating / DHCP pending |
| WiFiStateConnected | notification | no | 150/150 x3 then off | WiFi connected successfully |
| WiFiStateError | error | yes | 200/100 500/300 | WiFi failed (auth timeout or no AP) |
Guidelines for adding new patterns:
- Keep error patterns short, distinctive, and repeating.
- Reserve long holds (>600ms ON) for critical failures.
- Use non-repeating patterns to acknowledge one-shot events (e.g. successful connection).
Potential future additions (not implemented yet):
- StorageError: two long ON pulses (e.g. NVS/flash failure).
- ConfigError: triple short pulses repeating (invalid configuration / preferences corrupt).
- ThermalWarning: slow ramp or alternating duty (would require PWM pattern support).
- FirmwareUpdate: progressive heartbeat (increasing ON time) while updating OTA.
- UVC doesnt appear on the host?
- Switch mode to UVC via CLI tool, replug USB and wait 20s.
### Adding a new board configuration
1. Create a new config file under `boards/` (you can nest folders): for example `boards/my_family/my_variant`.
2. Populate it with only the `CONFIG_...` lines that differ from the shared defaults. Shared baseline lives in `boards/sdkconfig.base_defaults` and is always merged first.
3. The board key the script accepts will be the relative path with `/` turned into `_` (example: `boards/my_family/my_variant` -> `my_family_my_variant`).
4. Run `python tools/switchBoardType.py --list` to verify its detected, then switch using `-b my_family_my_variant`.
5. If you accidentally create two files that collapse to the same key the last one found wins—rename to keep keys unique.
Tips:
- Use `--diff` after adding a board to sanitycheck only the intended keys change.
- For WiFi overrides on first flash: add none—pass `--ssid` / `--password` when switching if needed.
---
Feedback, issues, and PRs are welcome.