소스 검색

Use path instead of filename in firmware

Paulus Schoutsen 4 년 전
부모
커밋
1f643f3aa4
3개의 변경된 파일11개의 추가작업 그리고 11개의 파일을 삭제
  1. 5 5
      firmware_build/manifest.json
  2. 1 1
      src/const.ts
  3. 5 5
      src/start-flash.ts

+ 5 - 5
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 }]
     }
   ]
 }

+ 1 - 1
src/const.ts

@@ -2,7 +2,7 @@ export interface Build {
   chipFamily: "ESP32" | "ESP8266";
   improv: boolean;
   parts: {
-    filename: string;
+    path: string;
     offset: number;
   }[];
 }

+ 5 - 5
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();