Skip to content

Commit c940b9d

Browse files
committed
flasher fix
1 parent 0a9e560 commit c940b9d

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

docs/janos_flash.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ <h2>Browser support</h2>
389389
</div>
390390
<footer>
391391
Product of <a href="https://github.com/C5Lab/projectZero/">C5Lab/projectZero</a> -
392-
<span id="pageVersion" class="mono">Web flasher v1.0.5</span>.
392+
<span id="pageVersion" class="mono">Web flasher v1.0.6</span>.
393393
</footer>
394394

395395
<script type="module">
@@ -439,7 +439,7 @@ <h2>Browser support</h2>
439439
monitorConnected: false,
440440
};
441441

442-
const PAGE_VERSION = "1.0.5";
442+
const PAGE_VERSION = "1.0.6";
443443
const monitorEncoder = new TextEncoder();
444444

445445
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
@@ -520,8 +520,7 @@ <h2>Browser support</h2>
520520
monitorLog(`[${time}] ${msg}\n`);
521521
};
522522

523-
const bufferToBinaryString = (buffer) => {
524-
const bytes = new Uint8Array(buffer);
523+
const bytesToBinaryString = (bytes) => {
525524
const chunk = 0x8000;
526525
let result = "";
527526
for (let i = 0; i < bytes.length; i += chunk) {
@@ -530,6 +529,8 @@ <h2>Browser support</h2>
530529
return result;
531530
};
532531

532+
const bufferToBinaryString = (buffer) => bytesToBinaryString(new Uint8Array(buffer));
533+
533534
const resolveManifestPath = (path) => {
534535
if (!path) return path;
535536
try {
@@ -793,7 +794,7 @@ <h2>Browser support</h2>
793794
log(`Fetching ${url} @ 0x${part.offset.toString(16)}`);
794795
const { buf, usedUrl } = await resolveAssetUrl(url);
795796
log(`Fetched ${usedUrl}`);
796-
files.push({ data: bufferToBinaryString(buf), address: part.offset });
797+
files.push({ data: new Uint8Array(buf), address: part.offset });
797798
}
798799
return files;
799800
};
@@ -811,17 +812,20 @@ <h2>Browser support</h2>
811812
const files = await fetchFiles();
812813
setStatus("Uploading stub and flashing");
813814
log("Preparing flash writes");
815+
log("Flash settings: mode dio, freq 80m, size 8MB, seed ota_0 + ota_1.");
814816
const flashOptions = {
815817
fileArray: files,
816818
flashSize: "8MB",
819+
flashMode: "dio",
820+
flashFreq: "80m",
817821
eraseAll: !!ui.eraseAll?.checked,
818822
compress: true,
819823
reportProgress: (fileIndex, written, total) => {
820824
const pct = Math.min(100, Math.round((written / total) * 100));
821825
ui.progress.style.width = `${pct}%`;
822826
setStatus(`Flashing ${fileIndex + 1}/${files.length} ${pct}%`);
823827
},
824-
calculateMD5Hash: (image) => CryptoJS.MD5(CryptoJS.enc.Latin1.parse(image)),
828+
calculateMD5Hash: (image) => CryptoJS.MD5(CryptoJS.enc.Latin1.parse(bytesToBinaryString(image))).toString(),
825829
};
826830
await state.esploader.writeFlash(flashOptions);
827831
await state.esploader.after();

0 commit comments

Comments
 (0)