Add INMP441 WAV recorder for CYD 2.8/3.5.

Record 16 kHz mono PCM to microSD /rec, with level meter and DAC2 playback.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-27 21:16:13 +08:00
commit ddff48d05b
33 changed files with 1975 additions and 0 deletions

26
firmware/README.md Normal file
View File

@@ -0,0 +1,26 @@
# 预编译固件(可随时刷写)
| 目录 | 板子 | INMP441 | 背光 |
|------|------|---------|------|
| [`cyd_28r/`](cyd_28r/) | ESP32-2432S028R(ILI9341) | WS=22 / SCK=27 / SD=35 | GPIO21 |
| [`cyd_35r/`](cyd_35r/) | ESP32-3248S035C(ST7796 + GT911) | WS=22 / SCK=21 / SD=35 | GPIO27 |
版本信息见各目录 `VERSION.txt`。引脚约定见 [`../CYD_PROJECT_GUIDE.md`](../../CYD_PROJECT_GUIDE.md)。
录音写入 microSD `/rec/Rxxxx.WAV`;回放经 GPIO26 DAC2。
## 直接刷写
```powershell
cd firmware\cyd_28r # 或 cyd_35r
.\flash.ps1
# .\flash.ps1 -Port COM3
```
## 从源码重新打包
```powershell
.\firmware\export_from_build.ps1
.\firmware\export_from_build.ps1 -Env cyd_35r
.\firmware\export_from_build.ps1 -SkipBuild
```

View File

@@ -0,0 +1,18 @@
name: CYD inmp441recondtest (cyd_28r)
git: unknown
date: 2026-10-27
board: ESP32-2432S028R (ILI9341)
inmp441: WS=GPIO22 SCK=GPIO27 SD=GPIO35
tft_bl: GPIO21
audio: record WAV /rec + play DAC2 GPIO26
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 8BDD28C452BF7406295B7E76FDC387917FE6BF223BE0FD18B6988BABD4EFF12E
partitions.bin 0A8B5720E7B77FF11F1462458C3A509DEE79224E5279898F26D6A2E3AE0517B7

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,5 @@
@echo off
setlocal
cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0flash.ps1" %*
exit /b %ERRORLEVEL%

View File

@@ -0,0 +1,84 @@
# Flash archived CYD INMP441 WAV recorder 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."

View File

@@ -0,0 +1,7 @@
{
"boardId": "esp32-2432s028",
"name": "CYD INMP441 WAV recorder",
"summary": "Record INMP441 audio to microSD as WAV; play via DAC2",
"description": "INMP441 on WS=GPIO22 / SCK=GPIO27 / SD=GPIO35. Saves 16 kHz mono PCM to /rec/Rxxxx.WAV. Playback on GPIO26. Requires FAT32 microSD.",
"tags": ["record", "inmp441", "i2s", "wav", "sd", "mic"]
}

Binary file not shown.

View File

@@ -0,0 +1,18 @@
name: CYD inmp441recondtest (cyd_35r)
git: unknown
date: 2026-10-27
board: ESP32-3248S035 (ST7796 + GT911)
inmp441: WS=GPIO22 SCK=GPIO21 SD=GPIO35
tft_bl: GPIO27
audio: record WAV /rec + play DAC2 GPIO26
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 0AFB4B303FDC198E8216D0BEEEC1BC8C9776E7BAE21FC798C4861C2FB2F6B0AC
partitions.bin 0A8B5720E7B77FF11F1462458C3A509DEE79224E5279898F26D6A2E3AE0517B7

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,5 @@
@echo off
setlocal
cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0flash.ps1" %*
exit /b %ERRORLEVEL%

View File

@@ -0,0 +1,84 @@
# Flash archived CYD INMP441 WAV recorder firmware for 3.5C (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."

View File

@@ -0,0 +1,7 @@
{
"boardId": "esp32-3248s035",
"name": "CYD INMP441 WAV recorder (3.5C)",
"summary": "Record INMP441 audio to microSD as WAV; play via DAC2",
"description": "INMP441 on WS=GPIO22 / SCK=GPIO21 / SD=GPIO35. TFT_BL=27. Saves 16 kHz mono PCM to /rec/Rxxxx.WAV. Playback on GPIO26. Requires FAT32 microSD.",
"tags": ["record", "inmp441", "i2s", "wav", "sd", "mic", "3.5"]
}

Binary file not shown.

View File

@@ -0,0 +1,74 @@
# Export firmware bins from PlatformIO build.
# Default: 2.8" (cyd_28r -> firmware/cyd_28r)
# 3.5": .\firmware\export_from_build.ps1 -Env cyd_35r
param(
[switch]$SkipBuild,
[ValidateSet("cyd_28r", "cyd_35r")]
[string]$Env = "cyd_28r"
)
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
Set-Location $root
$env:Path = "C:\Users\dsx2016\AppData\Local\Programs\Python\Python312\Scripts;" + $env:Path
if (-not $SkipBuild) {
pio run -e $Env
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
$src = Join-Path $root (".pio\build\" + $Env)
if ($Env -eq "cyd_35r") {
$dstName = "cyd_35r"
$boardLine = "board: ESP32-3248S035 (ST7796 + GT911)"
$micLine = "inmp441: WS=GPIO22 SCK=GPIO21 SD=GPIO35"
$blLine = "tft_bl: GPIO27"
} else {
$dstName = "cyd_28r"
$boardLine = "board: ESP32-2432S028R (ILI9341)"
$micLine = "inmp441: WS=GPIO22 SCK=GPIO27 SD=GPIO35"
$blLine = "tft_bl: GPIO21"
}
$dst = Join-Path $root ("firmware\" + $dstName)
New-Item -ItemType Directory -Force -Path $dst | Out-Null
foreach ($f in @("bootloader.bin", "partitions.bin", "firmware.bin")) {
$p = Join-Path $src $f
if (-not (Test-Path $p)) { Write-Error "Missing build artifact: $p — build with: pio run -e $Env" }
Copy-Item $p $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 = ""
try { $git = (git -C $root rev-parse --short HEAD).Trim() } catch { $git = "unknown" }
$date = Get-Date -Format "yyyy-MM-dd"
$hashes = Get-ChildItem (Join-Path $dst "*.bin") | Get-FileHash -Algorithm SHA256
$lines = @(
"name: CYD inmp441recondtest ($dstName)",
"git: $git",
"date: $date",
$boardLine,
$micLine,
$blLine,
"audio: record WAV /rec + play DAC2 GPIO26",
"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 (env=$Env git=$git)"