Add CYD SGP30 air quality dashboard with flashable firmware.
LVGL dual-gauge UI for eCO2/TVOC on GPIO22/27, plus archived cyd_28r bins and one-click flash scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
46
firmware/README.md
Normal file
46
firmware/README.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# 预编译固件(可随时刷写)
|
||||
|
||||
当前归档目录:[`cyd_28r/`](cyd_28r/)
|
||||
|
||||
对应板子:**CYD ESP32-2432S028R**(ILI9341),SGP30 → SDA=GPIO22 / SCL=GPIO27。
|
||||
版本信息见 [`cyd_28r/VERSION.txt`](cyd_28r/VERSION.txt)。
|
||||
|
||||
## 直接刷写(无需重新编译)
|
||||
|
||||
1. USB 连接板子
|
||||
2. 在本目录执行:
|
||||
|
||||
```powershell
|
||||
cd firmware\cyd_28r
|
||||
.\flash.ps1
|
||||
# 或指定端口
|
||||
.\flash.ps1 -Port COM3
|
||||
```
|
||||
|
||||
也可双击 / 运行 `flash.bat`。
|
||||
|
||||
依赖其一即可:
|
||||
|
||||
- 已安装 PlatformIO(`pio`,自带 esptool)
|
||||
- 或 `pip install esptool`
|
||||
|
||||
## 手动 esptool
|
||||
|
||||
```bash
|
||||
esptool.py --chip esp32 --port COM3 --baud 921600 write_flash -z ^
|
||||
--flash_mode dio --flash_freq 40m --flash_size 4MB ^
|
||||
0x1000 bootloader.bin ^
|
||||
0x8000 partitions.bin ^
|
||||
0xe000 boot_app0.bin ^
|
||||
0x10000 firmware.bin
|
||||
```
|
||||
|
||||
## 从源码重新打包进本目录
|
||||
|
||||
在仓库根目录:
|
||||
|
||||
```powershell
|
||||
.\firmware\export_from_build.ps1
|
||||
# 仅复制、不编译:
|
||||
.\firmware\export_from_build.ps1 -SkipBuild
|
||||
```
|
||||
16
firmware/cyd_28r/VERSION.txt
Normal file
16
firmware/cyd_28r/VERSION.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
name: CYD SGP30 air quality dashboard (cyd_28r)
|
||||
git: 5b1ffb8
|
||||
date: 2026-10-18
|
||||
board: ESP32-2432S028R (ILI9341)
|
||||
sgp30: SDA=GPIO22 SCL=GPIO27
|
||||
flash_size: 4MB
|
||||
offsets:
|
||||
0x1000 bootloader.bin
|
||||
0x8000 partitions.bin
|
||||
0xe000 boot_app0.bin
|
||||
0x10000 firmware.bin
|
||||
sha256:
|
||||
bootloader.bin 3D234A7471F67B013686DABD4DEE7C1FA915C9928463616A94BC9297ACF1ABF8
|
||||
boot_app0.bin F94C5D786A7A8FAB06AC5D10E33BF37711A6697636DC037559EA19CC410A17F0
|
||||
firmware.bin 4C4C87AE70BA6529F5B6E177564E5934CDFEC15F65E15ABC7D2483B5BECD79C1
|
||||
partitions.bin 0A8B5720E7B77FF11F1462458C3A509DEE79224E5279898F26D6A2E3AE0517B7
|
||||
BIN
firmware/cyd_28r/boot_app0.bin
Normal file
BIN
firmware/cyd_28r/boot_app0.bin
Normal file
Binary file not shown.
BIN
firmware/cyd_28r/bootloader.bin
Normal file
BIN
firmware/cyd_28r/bootloader.bin
Normal file
Binary file not shown.
BIN
firmware/cyd_28r/firmware.bin
Normal file
BIN
firmware/cyd_28r/firmware.bin
Normal file
Binary file not shown.
5
firmware/cyd_28r/flash.bat
Normal file
5
firmware/cyd_28r/flash.bat
Normal file
@@ -0,0 +1,5 @@
|
||||
@echo off
|
||||
setlocal
|
||||
cd /d "%~dp0"
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0flash.ps1" %*
|
||||
exit /b %ERRORLEVEL%
|
||||
84
firmware/cyd_28r/flash.ps1
Normal file
84
firmware/cyd_28r/flash.ps1
Normal file
@@ -0,0 +1,84 @@
|
||||
# Flash archived CYD SGP30 firmware (no rebuild needed)
|
||||
# Usage:
|
||||
# .\flash.ps1
|
||||
# .\flash.ps1 -Port COM5
|
||||
# .\flash.ps1 -Port COM5 -Baud 460800
|
||||
|
||||
param(
|
||||
[string]$Port = "",
|
||||
[int]$Baud = 921600
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
Set-Location $here
|
||||
|
||||
function Find-Esptool {
|
||||
$pio = Get-Command pio -ErrorAction SilentlyContinue
|
||||
if ($pio) {
|
||||
$pkg = Join-Path $env:USERPROFILE ".platformio\packages\tool-esptoolpy\esptool.py"
|
||||
if (Test-Path $pkg) { return @{ Kind = "py"; Path = $pkg } }
|
||||
}
|
||||
$py = Get-Command python -ErrorAction SilentlyContinue
|
||||
if ($py) {
|
||||
try {
|
||||
& python -c "import esptool" 2>$null
|
||||
if ($LASTEXITCODE -eq 0) { return @{ Kind = "mod"; Path = "esptool" } }
|
||||
} catch {}
|
||||
}
|
||||
$esp = Get-Command esptool.py -ErrorAction SilentlyContinue
|
||||
if ($esp) { return @{ Kind = "py"; Path = $esp.Source } }
|
||||
return $null
|
||||
}
|
||||
|
||||
if (-not $Port) {
|
||||
$ports = @()
|
||||
try {
|
||||
Add-Type -AssemblyName System.IO.Ports -ErrorAction SilentlyContinue | Out-Null
|
||||
$ports = [System.IO.Ports.SerialPort]::GetPortNames() | Sort-Object
|
||||
} catch {}
|
||||
if (-not $ports -or $ports.Count -eq 0) {
|
||||
$ports = Get-CimInstance Win32_SerialPort -ErrorAction SilentlyContinue |
|
||||
Select-Object -ExpandProperty DeviceID | Sort-Object
|
||||
}
|
||||
if (-not $ports -or $ports.Count -eq 0) {
|
||||
Write-Error "No serial ports found. Plug in the CYD USB cable, then retry with -Port COMx"
|
||||
}
|
||||
if ($ports.Count -eq 1) {
|
||||
$Port = $ports[0]
|
||||
} else {
|
||||
Write-Host "Available ports: $($ports -join ', ')"
|
||||
$Port = $ports[-1]
|
||||
Write-Host "Using last port: $Port (override with -Port)"
|
||||
}
|
||||
}
|
||||
|
||||
$tool = Find-Esptool
|
||||
if (-not $tool) {
|
||||
Write-Error "esptool not found. Install PlatformIO (`pio`) or: pip install esptool"
|
||||
}
|
||||
|
||||
$argsCommon = @(
|
||||
"--chip", "esp32",
|
||||
"--port", $Port,
|
||||
"--baud", "$Baud",
|
||||
"--before", "default_reset",
|
||||
"--after", "hard_reset",
|
||||
"write_flash", "-z",
|
||||
"--flash_mode", "dio",
|
||||
"--flash_freq", "40m",
|
||||
"--flash_size", "4MB",
|
||||
"0x1000", "bootloader.bin",
|
||||
"0x8000", "partitions.bin",
|
||||
"0xe000", "boot_app0.bin",
|
||||
"0x10000", "firmware.bin"
|
||||
)
|
||||
|
||||
Write-Host "Flashing $here -> $Port @ $Baud"
|
||||
if ($tool.Kind -eq "mod") {
|
||||
& python -m esptool @argsCommon
|
||||
} else {
|
||||
& python $tool.Path @argsCommon
|
||||
}
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
Write-Host "Done. Open serial monitor at 115200 if needed."
|
||||
BIN
firmware/cyd_28r/partitions.bin
Normal file
BIN
firmware/cyd_28r/partitions.bin
Normal file
Binary file not shown.
57
firmware/export_from_build.ps1
Normal file
57
firmware/export_from_build.ps1
Normal file
@@ -0,0 +1,57 @@
|
||||
# Rebuild (optional) and refresh firmware/cyd_28r from PlatformIO build output.
|
||||
# Usage:
|
||||
# .\firmware\export_from_build.ps1
|
||||
# .\firmware\export_from_build.ps1 -SkipBuild
|
||||
|
||||
param([switch]$SkipBuild)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||
Set-Location $root
|
||||
|
||||
if (-not $SkipBuild) {
|
||||
pio run -e cyd_28r
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
}
|
||||
|
||||
$src = Join-Path $root ".pio\build\cyd_28r"
|
||||
$dst = Join-Path $root "firmware\cyd_28r"
|
||||
New-Item -ItemType Directory -Force -Path $dst | Out-Null
|
||||
|
||||
Copy-Item (Join-Path $src "bootloader.bin") $dst -Force
|
||||
Copy-Item (Join-Path $src "partitions.bin") $dst -Force
|
||||
Copy-Item (Join-Path $src "firmware.bin") $dst -Force
|
||||
|
||||
$bootApp = Join-Path $env:USERPROFILE ".platformio\packages\framework-arduinoespressif32\tools\partitions\boot_app0.bin"
|
||||
if (-not (Test-Path $bootApp)) {
|
||||
Write-Error "boot_app0.bin not found under PlatformIO packages"
|
||||
}
|
||||
Copy-Item $bootApp (Join-Path $dst "boot_app0.bin") -Force
|
||||
|
||||
$git = "nogit"
|
||||
try {
|
||||
$git = (git -C $root rev-parse --short HEAD 2>$null).Trim()
|
||||
if (-not $git) { $git = "nogit" }
|
||||
} catch { $git = "nogit" }
|
||||
|
||||
$date = Get-Date -Format "yyyy-MM-dd"
|
||||
$hashes = Get-FileHash (Join-Path $dst "*.bin") -Algorithm SHA256
|
||||
$lines = @(
|
||||
"name: CYD SGP30 air quality dashboard (cyd_28r)",
|
||||
"git: $git",
|
||||
"date: $date",
|
||||
"board: ESP32-2432S028R (ILI9341)",
|
||||
"sgp30: SDA=GPIO22 SCL=GPIO27",
|
||||
"flash_size: 4MB",
|
||||
"offsets:",
|
||||
" 0x1000 bootloader.bin",
|
||||
" 0x8000 partitions.bin",
|
||||
" 0xe000 boot_app0.bin",
|
||||
" 0x10000 firmware.bin",
|
||||
"sha256:"
|
||||
)
|
||||
foreach ($h in $hashes) {
|
||||
$lines += (" {0,-15} {1}" -f (Split-Path $h.Path -Leaf), $h.Hash)
|
||||
}
|
||||
$lines | Set-Content -Encoding utf8 (Join-Path $dst "VERSION.txt")
|
||||
Write-Host "Exported -> $dst (git $git)"
|
||||
Reference in New Issue
Block a user