Gravar firmware da balança pela web (Web Serial + esptool-js) — v1.37.0#46
Merged
Conversation
…37.0 Página Admin → Estação de pesagem (/admin/scale, só admin) grava o firmware do ESP32-C3 direto do navegador via Web Serial + esptool-js — irmão do gravador Niimbot (Web Bluetooth). Chrome/Edge, HTTPS ou localhost, sem instalar nada. - build-firmware-bin.sh: compila e gera os 4 PEDAÇOS separados (bootloader 0x0, partitions 0x8000, boot_app0 0xe000, app 0x10000) + manifesto em static/firmware/, versionados no git (deploy por clone público/git archive; sem build no servidor). - vendor-esptool.sh: vendora esptool-js@0.6.0 (bundle ESM) em static/esptool.js, sem CDN/runtime. esp-flash.js: adaptador que lê o manifesto e grava cada pedaço. - Validado em hardware (ESP32-C3 SuperMini). Aprendizados que importam: gravar PEDAÇOS separados (não imagem merged em 0x0, que o esptool-js erra no meio) e passar data como Uint8Array (binary string → pako expande bytes >=0x80 em UTF-8 → stub rejeita o bloco final com ESP_TOO_MUCH_DATA). É como o ESP Web Tools/ESPHome fazem. - Sem mudança de CSP (Web Serial é API JS; scripts 'self'). i18n EN/ES. Testes em tests/test_scale_flash.py (gate admin, entrega dos pedaços+manifesto). Docs em docs/balanca-web-flash.md. Escopo: só GRAVAÇÃO. Provisionamento (Wi-Fi/URL/chave via serial-JSON + SoftAP) virá depois. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nova página Admin → Estação de pesagem (
/admin/scale, só admin) que grava o firmware do ESP32‑C3 direto do navegador via Web Serial + esptool‑js — o irmão do gravador Niimbot (Web Bluetooth). Chrome/Edge, HTTPS oulocalhost, sem instalar nada. Validado em hardware (ESP32‑C3 SuperMini).O que entra
deploy/build-firmware-bin.sh— compila o firmware e gera os 4 pedaços (bootloader 0x0 · partitions 0x8000 · boot_app0 0xe000 · app 0x10000) + manifesto emstatic/firmware/, versionados no git (deploy por clone público/git archive; sem build no servidor).deploy/vendor-esptool.sh— vendoraesptool-js@0.6.0(bundle ESM) emstatic/esptool.js, sem CDN/runtime (mesma postura do driver Niimbot).static/esp-flash.js— adaptador: lê o manifesto, baixa os pedaços, grava cada um no seu offset./admin/scale+templates/admin/scale.html+ item no nav admin; i18n EN/ES;docs/balanca-web-flash.md; testes emtests/test_scale_flash.py.Por que pedaços separados + Uint8Array (aprendido na marra, validando em hardware)
pio uploadfaz.datacomoUint8Array, não "binary string": passar string faz o pako expandir os bytes ≥ 0x80 como UTF‑8 → o stub infla mais do que o declarado e rejeita o bloco final comESP_TOO_MUCH_DATA(0xC9). É exatamente como o ESP Web Tools / ESPHome fazem.Não muda
'self'). 155 testes verdes (sem regressão).Escopo
Só gravação. Provisionamento (Wi‑Fi/URL/chave de API via handshake serial‑JSON + fallback SoftAP) virá numa próxima versão; o lado servidor (
/api/weigh) já existe.🤖 Generated with Claude Code