# esparc

Rust on ESP32 with zero setup. One binary installs the esp-rs tools,
scaffolds a bare-metal esp-hal project, then builds, flashes and monitors
your board. It does not reimplement the toolchain, it drives espflash,
esp-generate and cargo.

## Install

```sh
curl -fsSL https://esparc.arc1.io/install.sh | sh
```

The script picks the build for your platform, verifies its SHA-256 against the
release manifest, and installs to `/usr/local/bin`, or `~/.local/bin` when that
is not writable. Set `ESPARC_INSTALL_DIR` to choose, or `ESPARC_VERSION` to pin a
release. You need rustup with a stable toolchain; esparc installs the rest.

## Quick start

```sh
esparc setup
esparc new blinky
cd blinky
esparc run
```

`esparc setup` puts espflash, cargo-espflash and esp-generate in `~/.esparc/bin`
and adds the RISC-V targets to rustup. `esparc new` scaffolds an esp-hal project
for the ESP32-C6 (`--chip` for another), and `esparc run` builds, flashes and
opens the serial monitor. With one board connected no port is needed.

Xtensa chips (ESP32, S2, S3) need Espressif's Rust fork:

```sh
esparc setup --chip esp32s3
```

## Updating

```sh
esparc update
```

esparc checks once a day in the background and verifies the SHA-256 of every
download before it replaces the binary. Re-running `esparc setup` updates the
tools. Set `ESPARC_NO_UPDATE_CHECK=1` to turn the check off.

## API

The same endpoints the CLI and the install script read. No authentication, CORS
open to any origin. Every path answers in JSON, and in flat `key=value` text at
the same path with `.txt` appended.

```
GET /v1/latest?target=<triple>&current=<version>&version=<pin>
GET /v1/latest.txt?target=<triple>
GET /v1/tools?target=<triple>
GET /v1/tools.txt?target=<triple>
GET /v1/manifest.json
GET /v1/download/<version>/<file>
GET /v1/download/tools/<tool>/<version>/<file>
```

```sh
curl -s "https://esparc.arc1.io/v1/tools.txt?target=aarch64-apple-darwin"
```

```
espflash.version=4.5.0
espflash.file=espflash-4.5.0-aarch64-apple-darwin.tar.gz
espflash.sha256=<64 hex characters>
espflash.size=7757150
espflash.url=https://esparc.arc1.io/v1/download/tools/espflash/4.5.0/espflash-4.5.0-aarch64-apple-darwin.tar.gz
```

Builds exist for `aarch64-apple-darwin`, `aarch64-unknown-linux-gnu` and
`x86_64-unknown-linux-gnu`. Anything else, Intel macs included, has to build
from source.

Source: https://github.com/arc1hq/esparc
