Skip to content

Commit b0261fd

Browse files
Add delay and safety check after DFU erase (v1.0.5)
1 parent a87b51e commit b0261fd

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

web-flasher/dfu.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,21 @@ class DFUDevice {
259259
await this.erase(this.startAddress);
260260
progressCallback({ stage: 'erase', percent: 10, message: 'Flash erased' });
261261

262+
// Wait a moment for the device to stabilize after mass erase
263+
await new Promise(resolve => setTimeout(resolve, 500));
264+
265+
// Check status to ensure we are still connected and ready
266+
try {
267+
const status = await this.getStatus();
268+
if (status.state === DFU_STATE.DFU_ERROR) {
269+
await this.clearStatus();
270+
}
271+
} catch (e) {
272+
console.warn('Status check failed between erase and write:', e);
273+
}
274+
275+
progressCallback({ stage: 'write', percent: 10, message: 'Preparing to write...' });
276+
262277
// Set address again for writing
263278
await this.setAddress(this.startAddress);
264279

web-flasher/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ <h4>Activity Log</h4>
125125
<p>Built with ❤️ using WebUSB API |
126126
<a href="https://github.com/willbearfruits/KarplusStrongMachine" target="_blank">View on GitHub</a> |
127127
<a href="README.md">Documentation</a> |
128-
<span class="version">Web Flasher v1.0.4</span>
128+
<span class="version">Web Flasher v1.0.5</span>
129129
</p>
130130
<p class="small">Requires Chrome/Chromium browser with WebUSB support</p>
131131
</footer>
132132
</div>
133133

134-
<script type="module" src="dfu.js?v=1.0.3"></script>
135-
<script type="module" src="flasher.js?v=1.0.3"></script>
134+
<script type="module" src="dfu.js?v=1.0.5"></script>
135+
<script type="module" src="flasher.js?v=1.0.5"></script>
136136
</body>
137137
</html>

0 commit comments

Comments
 (0)