Files
cydweb/README.md
DESKTOP-PUHFO60\dsx2016 ae63378fdb Add CYD browser flasher with Next.js, i18n, and Web Serial install.
Replace the starter app with a public/local flasher that discovers sibling firmwares, supports en/zh, and documents HTTPS deploy.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-19 19:38:53 +08:00

99 lines
2.7 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.
# CYD Flasher
Browser flasher for **Cheap Yellow Display** (ESP32-2432S028).
Stack: **Next.js 15** · **Web Serial** · **esp-web-tools** · **next-intl** · **Tailwind / shadcn-style UI**
| | |
|---|---|
| Locales | English (default) `/en` · 中文 `/zh` |
| SEO | `generateMetadata`, Open Graph, `/sitemap.xml`, `/robots.txt` |
| Flash | `0x1000` bootloader · `0x8000` partitions · `0xe000` boot_app0 · `0x10000` firmware |
## Quick start (local)
```powershell
cd c:\Users\dsx2016\Desktop\codes\cyd\cydweb
npm install
npm run dev
```
Open **Chrome** or **Edge**: [http://localhost:3000](http://localhost:3000) (redirects to `/en`).
1. Connect CYD with a data USB cable
2. Select a firmware
3. Click **Connect & flash** and choose the serial port (CH340 / CP210x)
Production locally:
```powershell
npm run build
npm start
```
## Firmware discovery
By default the app scans sibling projects:
```text
../<project>/firmware/<variant>/{bootloader,partitions,boot_app0,firmware}.bin
```
Examples currently picked up: `temperature`, `ld2420test`, `sgp30test`, `phtotest`, `tftest` (Pomodoro).
Override search root:
```env
CYD_FIRMWARE_ROOT=C:\Users\dsx2016\Desktop\codes\cyd
```
After rebuilding a project, refresh its `firmware/` archive (each repo’s `firmware\export_from_build.ps1`), then click **Refresh** on the page.
## Public deploy
Web Serial requires **HTTPS** (or localhost).
1. Mirror firmwares into this repo (no Desktop path dependency):
```powershell
npm run sync:firmware
# or: .\scripts\sync-firmware.ps1
```
2. Copy `.env.example` → `.env` and set:
```env
NEXT_PUBLIC_SITE_URL=https://your-domain.example
```
3. Deploy with Node (`npm run build && npm start`) or any Next.js host.
Mirrored binaries live under `firmware/` (gitignored). Run sync in CI before build if needed.
## Scripts
| Command | Description |
|---------|-------------|
| `npm run dev` | Dev server (Turbopack) |
| `npm run build` | Production build |
| `npm start` | Serve production build |
| `npm run sync:firmware` | Copy sibling `firmware/*` into `./firmware` |
| `npm run lint` | ESLint |
## Project layout
```text
app/[locale]/ # SSR pages (en / zh)
app/api/firmware/ # list · manifest · .bin
components/ # Flasher UI + shadcn-style primitives
messages/ # en.json · zh.json
lib/firmware.ts # discovery + flash offsets
scripts/ # sync-firmware.ps1
```
## 中文说明
本机:`npm install` → `npm run dev` → Chrome/Edge 打开 http://localhost:3000 ,右上角可切中文。
公网:先 `npm run sync:firmware`,配置 `NEXT_PUBLIC_SITE_URL`(必须 HTTPS),再部署。固件来自各 CYD 项目的 `firmware/` 预编译包,与 PlatformIO / esptool 刷写地址一致。