From 1f643f3aa4adcf0d4520791703a2ddaadffb062f Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 4 Jun 2021 10:03:01 -0700 Subject: [PATCH] Use path instead of filename in firmware --- firmware_build/manifest.json | 10 +++++----- src/const.ts | 2 +- src/start-flash.ts | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/firmware_build/manifest.json b/firmware_build/manifest.json index 969b815..c7a53b0 100644 --- a/firmware_build/manifest.json +++ b/firmware_build/manifest.json @@ -5,15 +5,15 @@ "chipFamily": "ESP32", "improv": true, "parts": [ - { "filename": "bootloader.bin", "offset": 4096 }, - { "filename": "partitions.bin", "offset": 32768 }, - { "filename": "ota.bin", "offset": 57344 }, - { "filename": "firmware.bin", "offset": 65536 } + { "path": "bootloader.bin", "offset": 4096 }, + { "path": "partitions.bin", "offset": 32768 }, + { "path": "ota.bin", "offset": 57344 }, + { "path": "firmware.bin", "offset": 65536 } ] }, { "chipFamily": "ESP8266", - "parts": [{ "filename": "esp8266.bin", "offset": 0 }] + "parts": [{ "path": "esp8266.bin", "offset": 0 }] } ] } diff --git a/src/const.ts b/src/const.ts index 7be423e..cf86b34 100644 --- a/src/const.ts +++ b/src/const.ts @@ -2,7 +2,7 @@ export interface Build { chipFamily: "ESP32" | "ESP8266"; improv: boolean; parts: { - filename: string; + path: string; offset: number; }[]; } diff --git a/src/start-flash.ts b/src/start-flash.ts index 877680b..788b38f 100644 --- a/src/start-flash.ts +++ b/src/start-flash.ts @@ -45,9 +45,11 @@ export const startFlash = async ( return; } + const chipFamily = getChipFamilyName(esploader); + logEl.addRow({ id: "initializing", - content: html`Initialized. Found ${getChipFamilyName(esploader)}`, + content: html`Initialized. Found ${chipFamily}`, }); logEl.addRow({ id: "manifest", content: "Fetching manifest..." }); @@ -65,8 +67,6 @@ export const startFlash = async ( content: html`Found manifest for ${manifest.name}`, }); - const chipFamily = getChipFamilyName(esploader); - let build: Build | undefined; for (const b of manifest.builds) { if (b.chipFamily === chipFamily) { @@ -87,11 +87,11 @@ export const startFlash = async ( }); const filePromises = build.parts.map(async (part) => { - const url = new URL(part.filename, manifestURL).toString(); + const url = new URL(part.path, manifestURL).toString(); const resp = await fetch(url); if (!resp.ok) { throw new Error( - `Downlading firmware ${part.filename} failed: ${resp.status}` + `Downlading firmware ${part.path} failed: ${resp.status}` ); } return resp.arrayBuffer();