# airflash
Flash and monitor ESP32-S3 apps over Wi-Fi with `idf.py`. Plug in USB once per board; after that, flashing,
`idf.py monitor` (with crash decoding) and crash dumps all work over Wi-Fi.
**Needs:** ESP32-S3 · ESP-IDF 5.4.x · the laptop and the board on the same 2.4 GHz Wi-Fi.
## Quick start
**1. Add the component**
```bash
idf.py add-dependency "hexcore/airflash==0.1.0"
```
**2. Start it** in `app_main()`, after your network is up:
```c
#include "airflash.h"
void app_main(void)
{
// ... your Wi-Fi setup, e.g. example_connect() ...
airflash_start(); // never fails your app: problems are logged
}
```
No Wi-Fi code in your app? Turn on menuconfig → airflash → **Connect to Wi-Fi inside airflash_start()**.
**3. Enable the `idf.py airflash-*` commands** (once per project; the build prints this line until it's done)
```bash
idf.py build
# macOS / Linux
ln -s managed_components/hexcore__airflash/tool/idf_ext.py idf_ext.py
# Windows (copy it again after updating the component)
copy managed_components\hexcore__airflash\tool\idf_ext.py idf_ext.py
```
**4. Configure** with `idf.py menuconfig`:
- **Wi-Fi:** taken from your app's own settings (`CONFIG_EXAMPLE_WIFI_SSID`, `CONFIG_ESP_WIFI_SSID`,
`CONFIG_WIFI_SSID`). Your app has none? Set **airflash → Wi-Fi name and password**.
- **Component config → Core dump → Data destination → Flash**, so crashes can be decoded over Wi-Fi.
**5. Find the board's port**
```bash
python -m serial.tools.list_ports # any OS, in an ESP-IDF terminal
ls /dev/cu.usb* # macOS
ls /dev/ttyACM* /dev/ttyUSB* # Linux
```
Windows: Device Manager → Ports (COM & LPT), e.g. `COM5`.
**6. Install over USB, once per board**
```bash
idf.py -p PORT airflash-install
```
It builds a small updater for your board, makes the flash layout from your partition table, installs it with your
Wi-Fi and a pairing token (saved in `~/.airflash/token`), then uploads your app over Wi-Fi.
**7. Use it over Wi-Fi**
```bash
idf.py airflash-flash # build and flash
idf.py airflash-monitor # idf.py monitor over Wi-Fi (Ctrl+] to quit)
```
## Commands
| Command | What it does |
|---|---|
| `idf.py -p PORT airflash-install` | one-time USB install (updater, layout, Wi-Fi, token), then your app |
| `idf.py airflash-flash` | build, check, flash over Wi-Fi |
| `idf.py airflash-monitor` | `idf.py monitor` over Wi-Fi, from the first boot line, through crashes and reboots |
| `idf.py airflash-coredump` | download and decode the last crash dump |
| `idf.py airflash-info` | what's running, last reset, pairing |
| `idf.py airflash-find` | list the airflash boards on this network |
| `idf.py airflash-logs` | plain log stream |
| `idf.py airflash-run` | boot the installed app again (when the updater is running) |
Pick a board: `--airflash-host <ip>` (or `AIRFLASH_HOST`). Otherwise the board remembered in `build/airflash.json` is
used, or the only one on the network.
## Run `airflash-install` again when
- your app's data partitions change, or the app outgrows the board's app slot;
- your Wi-Fi name or password changes;
- a newer airflash needs a newer updater.
The tool tells you when. Don't `idf.py flash` an airflash board over USB: it removes the updater
(`airflash-install` brings it back).
## Example
```bash
idf.py create-project-from-example "hexcore/airflash^0.1.0:demo"
```
A small web page with buttons that crash the board in different ways: watch the crash in `airflash-monitor`, decode
it with `airflash-coredump`, fix it and reflash over Wi-Fi.
## Limits
- ESP32-S3 and ESP-IDF 5.4.x only, so far.
- The laptop must be on the board's network. A new network means `airflash-install` again.
- Pairing locks the board to your token, but traffic is not encrypted: use trusted networks.
## More
[User guide](https://github.com/karan90687/airflash/blob/main/docs/user-guide.md): all options, partition layout,
pairing, troubleshooting, resource cost. Source: [github.com/karan90687/airflash](https://github.com/karan90687/airflash).
## Contributing
airflash is updated from time to time. Suggestions and bug reports are welcome: open an
[issue](https://github.com/karan90687/airflash/issues), or send a pull request with the fix.
## License
[MIT](https://github.com/karan90687/airflash/blob/main/components/airflash/LICENSE)
idf.py add-dependency "hexcore/airflash^0.1.0"