diff --git a/product-status.md b/product-status.md index cc3a613d3..d121adc8a 100644 --- a/product-status.md +++ b/product-status.md @@ -5,7 +5,6 @@ This is an *early test release* of the next version of Chrysalis, the graphical ## What doesn't work - Firmware updates for the Model 100 -- Loading stock firmware for the Atreus and Model 01 - Loading "pre-configured" layouts - Device disconnect detection - Backup and restore (outside of flashing) @@ -17,6 +16,7 @@ This is an *early test release* of the next version of Chrysalis, the graphical - Changing device settings - Factory reset - Custom firmware updates for the Atreus and Model 01 +- Loading stock firmware for the Atreus and Model 01 ## Device support diff --git a/public/EZ/ErgoDox/default.hex b/public/firmware/EZ/ErgoDox/default.hex similarity index 100% rename from public/EZ/ErgoDox/default.hex rename to public/firmware/EZ/ErgoDox/default.hex diff --git a/public/Keyboardio/Atreus/default.hex b/public/firmware/Keyboardio/Atreus/default.hex similarity index 100% rename from public/Keyboardio/Atreus/default.hex rename to public/firmware/Keyboardio/Atreus/default.hex diff --git a/public/Keyboardio/Atreus/layouts/colemak.json b/public/firmware/Keyboardio/Atreus/layouts/colemak.json similarity index 100% rename from public/Keyboardio/Atreus/layouts/colemak.json rename to public/firmware/Keyboardio/Atreus/layouts/colemak.json diff --git a/public/Keyboardio/Atreus/layouts/dvorak.json b/public/firmware/Keyboardio/Atreus/layouts/dvorak.json similarity index 100% rename from public/Keyboardio/Atreus/layouts/dvorak.json rename to public/firmware/Keyboardio/Atreus/layouts/dvorak.json diff --git a/public/Keyboardio/Atreus/layouts/qwerty.json b/public/firmware/Keyboardio/Atreus/layouts/qwerty.json similarity index 100% rename from public/Keyboardio/Atreus/layouts/qwerty.json rename to public/firmware/Keyboardio/Atreus/layouts/qwerty.json diff --git a/public/Keyboardio/Model01/default.hex b/public/firmware/Keyboardio/Model01/default.hex similarity index 100% rename from public/Keyboardio/Model01/default.hex rename to public/firmware/Keyboardio/Model01/default.hex diff --git a/public/Keyboardio/Model01/layouts/colemak.json b/public/firmware/Keyboardio/Model01/layouts/colemak.json similarity index 100% rename from public/Keyboardio/Model01/layouts/colemak.json rename to public/firmware/Keyboardio/Model01/layouts/colemak.json diff --git a/public/Keyboardio/Model01/layouts/dvorak.json b/public/firmware/Keyboardio/Model01/layouts/dvorak.json similarity index 100% rename from public/Keyboardio/Model01/layouts/dvorak.json rename to public/firmware/Keyboardio/Model01/layouts/dvorak.json diff --git a/public/Keyboardio/Model01/layouts/qwerty.json b/public/firmware/Keyboardio/Model01/layouts/qwerty.json similarity index 100% rename from public/Keyboardio/Model01/layouts/qwerty.json rename to public/firmware/Keyboardio/Model01/layouts/qwerty.json diff --git a/public/Keyboardio/Model100/default.bin b/public/firmware/Keyboardio/Model100/default.bin similarity index 100% rename from public/Keyboardio/Model100/default.bin rename to public/firmware/Keyboardio/Model100/default.bin diff --git a/public/Keyboardio/Model100/layouts/colemak-dh.json b/public/firmware/Keyboardio/Model100/layouts/colemak-dh.json similarity index 100% rename from public/Keyboardio/Model100/layouts/colemak-dh.json rename to public/firmware/Keyboardio/Model100/layouts/colemak-dh.json diff --git a/public/Keyboardio/Model100/layouts/colemak.json b/public/firmware/Keyboardio/Model100/layouts/colemak.json similarity index 100% rename from public/Keyboardio/Model100/layouts/colemak.json rename to public/firmware/Keyboardio/Model100/layouts/colemak.json diff --git a/public/Keyboardio/Model100/layouts/dvorak.json b/public/firmware/Keyboardio/Model100/layouts/dvorak.json similarity index 100% rename from public/Keyboardio/Model100/layouts/dvorak.json rename to public/firmware/Keyboardio/Model100/layouts/dvorak.json diff --git a/public/Keyboardio/Model100/layouts/qwerty.json b/public/firmware/Keyboardio/Model100/layouts/qwerty.json similarity index 100% rename from public/Keyboardio/Model100/layouts/qwerty.json rename to public/firmware/Keyboardio/Model100/layouts/qwerty.json diff --git a/public/SOFTHRUF/Splitography/default.hex b/public/firmware/SOFTHRUF/Splitography/default.hex similarity index 100% rename from public/SOFTHRUF/Splitography/default.hex rename to public/firmware/SOFTHRUF/Splitography/default.hex diff --git a/public/Technomancy/Atreus/default.hex b/public/firmware/Technomancy/Atreus/default.hex similarity index 100% rename from public/Technomancy/Atreus/default.hex rename to public/firmware/Technomancy/Atreus/default.hex diff --git a/public/build-info.yml b/public/firmware/build-info.yml similarity index 100% rename from public/build-info.yml rename to public/firmware/build-info.yml diff --git a/public/firmware-changelog.md b/public/firmware/firmware-changelog.md similarity index 100% rename from public/firmware-changelog.md rename to public/firmware/firmware-changelog.md diff --git a/src/api/flash/AVR109Flasher.js b/src/api/flash/AVR109Flasher.js index 9049c02ae..5b2692a4f 100644 --- a/src/api/flash/AVR109Flasher.js +++ b/src/api/flash/AVR109Flasher.js @@ -38,6 +38,9 @@ const encoder = new TextEncoder(); const flash = async (port, filecontents) => { var enc = new TextDecoder("utf-8"); + console.log("filecontents"); + console.log(filecontents); + var hexAsText = enc.decode(filecontents); return new Promise((resolve, reject) => { (async () => { diff --git a/src/renderer/screens/FirmwareUpdate.js b/src/renderer/screens/FirmwareUpdate.js index 3ed206816..330e7e22a 100644 --- a/src/renderer/screens/FirmwareUpdate.js +++ b/src/renderer/screens/FirmwareUpdate.js @@ -84,17 +84,34 @@ const FirmwareUpdate = (props) => { const NOTIFICATION_THRESHOLD = 5; - const defaultFirmwareFilename = () => { + const loadDefaultFirmwareContent = async () => { const { vendor, product } = focusDeviceDescriptor.info; const firmwareType = focusDeviceDescriptor.info.firmwareType || "hex"; const cVendor = vendor.replace("/", ""), cProduct = product.replace("/", ""); - return cVendor + "/" + cProduct + "/default." + firmwareType; + const firmwareURL = `/assets/firmware/${cVendor}/${cProduct}/default.${firmwareType}`; + + let defaultFirmwareContent; + try { + const response = await fetch(firmwareURL); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + const firmwareBlob = await response.blob(); + defaultFirmwareContent = await firmwareBlob.arrayBuffer(); + } catch (err) { + console.error(`Failed to fetch firmware file from ${firmwareURL}:`, err); + throw err; + } + console.log("Firmware content", defaultFirmwareContent); + + setFirmwareContent(defaultFirmwareContent); + return defaultFirmwareContent; }; const doFactoryReset = async () => { const tasksInBootloaderMode = async () => { - await flashDeviceFirmwareFromBootloader(firmwareContent); + await flashDeviceFirmwareFromBootloader(); await onStepChange("reconnect"); @@ -121,13 +138,21 @@ const FirmwareUpdate = (props) => { const flashDeviceFirmwareFromBootloader = async () => { const flasher = activeDevice.getFlasher(); await onStepChange("flash"); + let firmwareToSend = firmwareContent; console.log(focus); - await flasher.flash(focus._port, firmwareContent); + if (selectedFirmwareType == "default") { + firmwareToSend = await loadDefaultFirmwareContent(); + } + console.log("about to flash"); + console.log(" firmware content is ", firmwareToSend); + await flasher.flash(focus._port, firmwareToSend); }; const updateDeviceFirmware = async () => { + // If the user selected the factory firmware, we need to fetch it from the + // server. Otherwise, we'll use the file the user uploaded. if (activeDevice.bootloaderDetected()) { - await flashDeviceFirmwareFromBootloader(firmwareContent); + await flashDeviceFirmwareFromBootloader(); return; } else { await onStepChange("saveEEPROM"); @@ -137,7 +162,7 @@ const FirmwareUpdate = (props) => { const tasksInBootloaderMode = async () => { console.trace(); console.log("Runing tasks in bootloader mode"); - await flashDeviceFirmwareFromBootloader(firmwareContent); + await flashDeviceFirmwareFromBootloader(); console.log("flashed device firmware"); await onStepChange("reconnect");