Add support for ESP32-C3 (#60)

This commit is contained in:
Paulus Schoutsen 2021-08-24 00:07:04 -07:00 committed by GitHub
parent 99b7ad81e8
commit 6a664ef67d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 7 deletions

View File

@ -24,6 +24,18 @@ Manifest definition:
{ "path": "firmware.bin", "offset": 65536 } { "path": "firmware.bin", "offset": 65536 }
] ]
}, },
{
"chipFamily": "ESP32-C3",
"parts": [
{ "path": "esp32-c3.bin", "offset": 0 },
]
},
{
"chipFamily": "ESP32-S2",
"parts": [
{ "path": "esp32-s2.bin", "offset": 0 },
]
},
{ {
"chipFamily": "ESP8266", "chipFamily": "ESP8266",
"parts": [ "parts": [
@ -98,7 +110,7 @@ state | The current [state](https://github.com/esphome/esp-web-tools/blob/main/s
message | A description of the current state message | A description of the current state
manifest | The loaded manifest manifest | The loaded manifest
build | The manifest's build that was selected build | The manifest's build that was selected
chipFamily | The chip that was detected; "ESP32" \| "ESP8266" \| "ESP32-S2" \| "Unknown Chip" chipFamily | The chip that was detected; "ESP32" \| "ESP8266" \| "ESP32-S2" \| "ESP32-C3" \| "Unknown Chip"
details | An optional extra field that is different [per state](https://github.com/esphome/esp-web-tools/blob/main/src/const.ts) details | An optional extra field that is different [per state](https://github.com/esphome/esp-web-tools/blob/main/src/const.ts)
## Development ## Development

View File

@ -1,5 +1,5 @@
export interface Build { export interface Build {
chipFamily: "ESP32" | "ESP8266"; chipFamily: "ESP32" | "ESP8266" | "ESP32-S2" | "ESP32-C3";
improv: boolean; improv: boolean;
parts: { parts: {
path: string; path: string;
@ -12,12 +12,12 @@ export interface Manifest {
builds: Build[]; builds: Build[];
} }
interface BaseFlashState { export interface BaseFlashState {
state: State; state: State;
message: string; message: string;
manifest?: Manifest; manifest?: Manifest;
build?: Build; build?: Build;
chipFamily?: "ESP32" | "ESP8266" | "ESP32-S2" | "Unknown Chip"; chipFamily?: Build["chipFamily"] | "Unknown Chip";
} }
export interface InitializingState extends BaseFlashState { export interface InitializingState extends BaseFlashState {

View File

@ -10,7 +10,7 @@ export const flash = async (
) => { ) => {
let manifest: Manifest; let manifest: Manifest;
let build: Build | undefined; let build: Build | undefined;
let chipFamily: "ESP32" | "ESP8266" | "ESP32-S2" | "Unknown Chip"; let chipFamily: ReturnType<typeof getChipFamilyName>;
const fireStateEvent = (stateUpdate: FlashState) => { const fireStateEvent = (stateUpdate: FlashState) => {
fireEvent(eventTarget, "state-changed", { fireEvent(eventTarget, "state-changed", {

View File

@ -2,10 +2,14 @@ import {
CHIP_FAMILY_ESP32, CHIP_FAMILY_ESP32,
CHIP_FAMILY_ESP32S2, CHIP_FAMILY_ESP32S2,
CHIP_FAMILY_ESP8266, CHIP_FAMILY_ESP8266,
CHIP_FAMILY_ESP32C3,
ESPLoader, ESPLoader,
} from "esp-web-flasher"; } from "esp-web-flasher";
import type { BaseFlashState } from "./const";
export const getChipFamilyName = (esploader: ESPLoader) => { export const getChipFamilyName = (
esploader: ESPLoader
): NonNullable<BaseFlashState["chipFamily"]> => {
switch (esploader.chipFamily) { switch (esploader.chipFamily) {
case CHIP_FAMILY_ESP32: case CHIP_FAMILY_ESP32:
return "ESP32"; return "ESP32";
@ -13,6 +17,8 @@ export const getChipFamilyName = (esploader: ESPLoader) => {
return "ESP8266"; return "ESP8266";
case CHIP_FAMILY_ESP32S2: case CHIP_FAMILY_ESP32S2:
return "ESP32-S2"; return "ESP32-S2";
case CHIP_FAMILY_ESP32C3:
return "ESP32-C3";
default: default:
return "Unknown Chip"; return "Unknown Chip";
} }