Files
fmini-1/web/make_site.py
T
Claude 1b0b5c6b1c SMK-37 port: the board layer (genkigenki/Felucca smk37, b67312c) on FMini-1
The SMK-37 target from github.com/genkigenki/Felucca branch smk37 (commit
b67312c on Felucca 1.6.1, = hugelton/Felucca#237; the fm1-to-smk37 kit's
Felucca layer), applied to FMini-1, whose firmware/hal and firmware/loader are
Felucca 1.6.1's:

- BOARD=smk37 / MODEL=pro|elite|mke (tools/build.py, build.sh), the SMK flash
  map with its protected ranges (fm1_flash_map.h), the update path and its
  size checks (ota.c, ldr_core.c), the SMK input HAL, LCD and pad LEDs, the
  owner tag of the store, installers and tests.
- Conflicts resolved for FMini-1: packages fmini-1-fm1-<version>.fwsc and
  fmini-1-smk37[-elite|-mke]-<version>.fwsc; FL_JEDEC_OK keeps the UC25HQ80
  (0xB36014) on the FM-1 and accepts it on the SMK too; the official V16
  length stays FM-1 only; the sample slots stay gone (FMini-1 has no SAMPLE
  engine: the layer's eng_sample.c and editor sample hunks are not taken);
  main.c keeps FMini-1's UI_* hooks with the SMK calls around them.
- The FM-1 build is byte-identical to 2.5.0 (app, package and loader
  hashes). The SMK build does not link yet: FMini-1's preset objects need
  places in the SMK store, and fmini_app.c's LED code is FM-1 sized.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUF6pQ1NkTwmBC8SR8AK94
2026-11-09 12:46:23 -03:00

92 lines
4.5 KiB
Python

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-only
# Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
"""Make the site (GitHub Pages):
index.html redirect to the installer (the old URL keeps working)
firmware/felucca-VER.fwsc the package (+ LICENSE, LICENSING.md, LICENSES/: the package holds
JieLi SDK files under Apache-2.0, see LICENSING.md)
webapp/installer/index.html index_pkg.html, self-contained (fm1pkg.js, fm1ota.js, metadata inlined)
webapp/editor/index.html editor.html (+ fukiai.ttf, FUKIAI-LICENSE.txt)
src/ not touched
web/make_site.py build/felucca-X.Y.fwsc X.Y OUT_DIR
The package must be one made by tools/fm1pkg_make.py (Felucca's own loader, no vendor files).
Its identity (FM-1_9xx) is read from the package; the device must report it after
the install.
"""
import json
import re
import shutil
import sys
from pathlib import Path
HERE = Path(__file__).resolve().parent
BLOCKS, BLK, KEEP = 20, 0x30, 0x2F
def strip_module(src):
src = re.sub(r"^export\s+", "", src, flags=re.M)
return re.sub(r"^import .*?;\n", "", src, flags=re.M)
def product_of(raw):
"""the package identity: one marker byte after each of the first 20 blocks (fm1pkg.js productOf)"""
return "".join(chr((m - i - 1) & 0xFF) for i in range(BLOCKS) if (m := raw[i * BLK + KEEP]) != 0x7D)
def main(pkg, version, out):
pkg, out = Path(pkg), Path(out)
raw = pkg.read_bytes()
product = product_of(raw)
if not re.fullmatch(r"(FM-1|SMK-37 Pro)_9\d\d", product):
raise SystemExit(f"{pkg}: identity {product!r} is not a Felucca package (FM-1_9xx, SMK-37 Pro_9xx)")
if b"FELUCCA-LOADER-1" not in raw: # Felucca loader marker: never publish a package with vendor files
raise SystemExit(f"{pkg}: no Felucca loader in it; the site ships only fm1pkg_make.py packages "
"(a package patched from an official one carries vendor files)")
html = (HERE / "index_pkg.html").read_text(encoding="utf-8")
lib = strip_module((HERE / "fm1pkg.js").read_text(encoding="utf-8")) + "\n" + \
strip_module((HERE / "fm1ota.js").read_text(encoding="utf-8")) + "\n" + \
strip_module((HERE / "fm1backup.js").read_text(encoding="utf-8"))
name = f"felucca-{re.sub(r'[^A-Za-z0-9.-]', '-', version)}.fwsc"
meta = json.dumps({"version": version, "product": product, "pkg": "../../firmware/" + name})
for mark in ("/*LIB*/", "/*META*/"):
if html.count(mark) != 1:
raise SystemExit(f"index_pkg.html must contain {mark} once; update make_site.py")
html = html.replace("/*LIB*/", lib).replace("/*META*/", meta)
inst, ed, fw = out / "webapp" / "installer", out / "webapp" / "editor", out / "firmware"
for d in (inst, ed, fw):
d.mkdir(parents=True, exist_ok=True)
for old in fw.glob("felucca-*.fwsc"): # one package: the current one
old.unlink()
(inst / "index.html").write_text(html, encoding="utf-8")
shutil.copy(pkg, fw / name)
lic = HERE.parent / "LICENSES" # the package holds JieLi SDK files (Apache-2.0): their
(fw / "LICENSES").mkdir(exist_ok=True) # licence travels next to it, with Felucca's own
names = sorted(f.name for f in lic.glob("*.txt"))
for n in names:
shutil.copy(lic / n, fw / "LICENSES" / n)
(fw / "LICENSES" / "index.html").write_text( # the installer links this folder: Pages lists no folders
'<!doctype html><meta charset="utf-8"><title>Felucca licences</title><h1>Licence texts</h1><ul>'
+ "".join(f'<li><a href="{n}">{n}</a></li>' for n in names)
+ '</ul><p><a href="../LICENSING.md">LICENSING.md</a> · <a href="../LICENSE">LICENSE (GPL-3.0)</a></p>\n',
encoding="utf-8")
for doc in ("LICENSE", "LICENSING.md"):
shutil.copy(HERE.parent / doc, fw / doc)
shutil.copy(HERE / "editor.html", ed / "index.html")
for f in ("fukiai.ttf", "FUKIAI-LICENSE.txt", "fm1backup.js"):
if (HERE / f).exists():
shutil.copy(HERE / f, ed / f)
(out / "index.html").write_text(
'<!doctype html><meta charset="utf-8"><title>Felucca</title>'
'<meta http-equiv="refresh" content="0; url=webapp/installer/">'
'<a href="webapp/installer/">Felucca installer</a>\n', encoding="utf-8")
print(f"site: {out}: webapp/installer ({len(html)} B), webapp/editor, firmware/{name} ({len(raw)} B, {product})")
if __name__ == "__main__":
if len(sys.argv) != 4:
sys.exit(__doc__)
main(*sys.argv[1:4])