Skip to content
Merged

Sync #27

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/pages-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
release_tag:
description: "Existing release tag to publish on Pages (defaults to latest release)"
required: false
push:
branches: [main, master]
paths:
- "docs/**"
- ".github/workflows/pages-only.yml"

concurrency:
group: github-pages-${{ github.ref }}
Expand Down
49 changes: 33 additions & 16 deletions docs/janos_flash.html
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ <h2>Browser support</h2>
</div>
<footer>
M5MonsterC5-Tab5 -
<span id="pageVersion" class="mono">Web flasher v1.0.0</span>.
<span id="pageVersion" class="mono" data-page-version="1.0.1">Web flasher v1.0.1</span>.
</footer>

<script type="module">
Expand Down Expand Up @@ -335,7 +335,14 @@ <h2>Browser support</h2>
autoFlashTriggered: false,
};

const PAGE_VERSION = "1.0.0";
const PAGE_VERSION = ui.pageVersion?.dataset.pageVersion || "1.0.1";
const FLASH_PROFILE = Object.freeze({
connectReset: "default_reset",
afterReset: "hard_reset",
flashMode: "dio",
flashFreq: "80m",
flashSize: "16MB",
});

const setFooterVersion = (manifest) => {
if (!ui.pageVersion) return;
Expand Down Expand Up @@ -387,14 +394,19 @@ <h2>Browser support</h2>
}
};

const bufferToBinaryString = (buffer) => {
const bytes = new Uint8Array(buffer);
const chunk = 0x8000;
let result = "";
for (let i = 0; i < bytes.length; i += chunk) {
result += String.fromCharCode(...bytes.subarray(i, i + chunk));
const wordArrayFromBytes = (bytes) => {
const words = [];
for (let i = 0; i < bytes.length; i += 1) {
words[i >>> 2] = (words[i >>> 2] || 0) | (bytes[i] << (24 - (i % 4) * 8));
}
return CryptoJS.lib.WordArray.create(words, bytes.length);
};

const calculateMD5 = (image) => {
if (image instanceof Uint8Array) {
return CryptoJS.MD5(wordArrayFromBytes(image)).toString();
}
return result;
return CryptoJS.MD5(CryptoJS.enc.Latin1.parse(image)).toString();
};

const getRepoSlug = () => {
Expand Down Expand Up @@ -422,10 +434,13 @@ <h2>Browser support</h2>
}
return cleaned;
}
const branch = getBranch();
if (branch === "main") {
return cleaned;
}
if (cleaned.startsWith("firmware/")) {
cleaned = cleaned.replace(/^firmware\//, "binaries-esp32p4/");
}
const branch = getBranch();
return `https://raw.githubusercontent.com/${repo}/${branch}/${cleaned}`;
};

Expand All @@ -436,7 +451,7 @@ <h2>Browser support</h2>
if (branch === "main") return "manifest.json";
const repo = getRepoSlug();
if (!repo) return "manifest.json";
return `https://raw.githubusercontent.com/${repo}/${branch}/Docs/manifest.json`;
return `https://raw.githubusercontent.com/${repo}/${branch}/docs/manifest.json`;
};

const rewritePartsForBranch = (manifest, branch) => {
Expand Down Expand Up @@ -541,7 +556,7 @@ <h2>Browser support</h2>
state.esploader = new ESPLoader(loaderOptions);
setStatus("Syncing with chip (hold BOOT + RESET to enter ROM)");
log("Syncing with chip");
state.chip = await state.esploader.main();
state.chip = await state.esploader.main(FLASH_PROFILE.connectReset);
state.connected = true;
ui.chip.style.display = "inline-flex";
ui.chip.textContent = `Chip ${state.chip}`;
Expand Down Expand Up @@ -613,7 +628,7 @@ <h2>Browser support</h2>
log(`Fetching ${url} @ 0x${part.offset.toString(16)}`);
const { buf, usedUrl } = await resolveAssetUrl(url);
log(`Fetched ${usedUrl}`);
files.push({ data: bufferToBinaryString(buf), address: part.offset });
files.push({ data: new Uint8Array(buf), address: part.offset });
}
return files;
};
Expand Down Expand Up @@ -650,18 +665,20 @@ <h2>Browser support</h2>
log("Preparing flash writes");
const flashOptions = {
fileArray: files,
flashSize: "16MB",
flashMode: FLASH_PROFILE.flashMode,
flashFreq: FLASH_PROFILE.flashFreq,
flashSize: FLASH_PROFILE.flashSize,
eraseAll: false,
compress: true,
reportProgress: (fileIndex, written, total) => {
const pct = Math.min(100, Math.round((written / total) * 100));
ui.progress.style.width = `${pct}%`;
setStatus(`Flashing ${fileIndex + 1}/${files.length} ${pct}%`);
},
calculateMD5Hash: (image) => CryptoJS.MD5(CryptoJS.enc.Latin1.parse(image)),
calculateMD5Hash: calculateMD5,
};
await state.esploader.writeFlash(flashOptions);
await state.esploader.after();
await state.esploader.after(FLASH_PROFILE.afterReset);
const resetOk = await resetAfterFlash();
ui.progress.style.width = "100%";
if (resetOk) {
Expand Down
2 changes: 1 addition & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include "esp_http_server.h"
#include "lwip/sockets.h"

#define JANOS_TAB_VERSION "1.2.8"
#define JANOS_TAB_VERSION "1.3.0"
#define JANOS_VERSION_REQUIRED "1.6.1"
#include "lwip/netdb.h"
#include <dirent.h>
Expand Down
2 changes: 1 addition & 1 deletion post_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if(EXISTS "${BOOTLOADER}" AND EXISTS "${PART_TABLE}" AND EXISTS "${APP_BIN}")
execute_process(
COMMAND "${PYTHON_EXE}" -m esptool --chip esp32p4 merge_bin -o "${FULL_OUT}"
--flash_mode dio --flash_freq 80m --flash_size 16MB
0x0 "${BOOTLOADER}"
0x2000 "${BOOTLOADER}"
0x8000 "${PART_TABLE}"
0x10000 "${APP_BIN}"
RESULT_VARIABLE MERGE_RESULT
Expand Down
Loading