namespace FirmwareFlasher; /// flash.json 의 한 영역 — 어떤 파일을 flash 어느 주소에 쓰는지. public sealed class FwRegion { public string? File { get; set; } // 보조 파일명 (app=true 면 비움) public bool App { get; set; } // 앱 영역 표시 public string Offset { get; set; } = "0x0"; public string Kind { get; set; } = "support"; // bootloader | support | app } /// /// 모델 프로파일 — 칩·offset·플래시 방식을 한 곳에 담는다. /// firmware 폴더의 flash.json 으로 덮어쓰거나, 빌트인을 그대로 쓴다. /// public sealed class FlashProfile { public string Name { get; set; } = "Custom"; public string Chip { get; set; } = "esp32"; // esp32 | esp32s3 | esp32p4 | ... public int Baud { get; set; } = 921600; public bool NoStub { get; set; } // DB720(SDM)=true public bool PerRegion { get; set; } // DB720=true(영역별 개별 호출), 클래식=false(한 번에) public int ConnectAttempts { get; set; } = 10; public string? FlashSize { get; set; } // DB720="16MB"; null=자동(스텁) public string? FlashMode { get; set; } // DB720="dio" public string? FlashFreq { get; set; } // DB720="80m" public string Before { get; set; } = "default-reset"; public string After { get; set; } = "hard-reset"; public bool AppOnlyErasesOtadata { get; set; } // DB720=true public string OtadataOffset { get; set; } = "0x11000"; public string OtadataSize { get; set; } = "0x2000"; public List Regions { get; set; } = new(); public string? FlashPortHint { get; set; } // "303A:1001" — 자동선택 우선 public string? ConsolePortHint { get; set; } // "10C4:EA60" — 경고만(막지 않음) public string? DownloadModeHint { get; set; } // 다운로드 모드 진입 안내 public string? Notes { get; set; } public bool FromFile { get; set; } // 폴더 flash.json 출처면 true(런타임) public FwRegion? AppRegion => Regions.FirstOrDefault(r => r.App); public FwRegion? Bootloader => Regions.FirstOrDefault(r => r.Kind == "bootloader"); public bool HasBootloader => Bootloader?.File is not null; public IEnumerable SupportRegions => Regions.Where(r => !r.App && r.File is not null); public string AppOffset => AppRegion?.Offset ?? "0x20000"; public string Summary => $"{Chip} · {(NoStub ? "no-stub" : "stub")} · {Baud}" + (FlashPortHint is not null ? $" · 포트 {FlashPortHint}" : ""); public override string ToString() => Name; }