Develop and contribute
This page is for contributors. You need mise, which installs the pinned
tools of mise.toml.
mise install
Before you push
| Change | Run |
|---|---|
| Any change | mise run check (format, clippy, tests, cross builds for thumbv7em-none-eabihf and wasm32-unknown-unknown) and mise run deny (licences, advisories, bans and sources of the dependencies). |
The build or cargo features, or examples/nano33ble | mise run example: builds the example firmware, checks with layout check --image that its ELF file fits the application partition, and checks that the linker refuses a memory.x that appears after a build. |
The browser package, the web feature or nanoflash-web | mise run web: builds the WebAssembly modules, checks their size, type-checks the package and runs its Node tests. |
web/flasher | mise run pages: assembles the site in target/pages. |
Other tasks:
| Task | Role |
|---|---|
mise run msrv | Builds the workspace with the minimum supported Rust version (1.95). |
mise run features | Tests the library with each feature combination that matters. |
mise run coverage | Writes the coverage of the workspace to coverage.lcov. |
mise run package | Packages every crate as crates.io would, and builds each one from its package. |
mise run external-parsers | Checks the Espressif partition table writer against ESP-IDF’s gen_esp32part.py. |
mise run web-wasm | Builds the WebAssembly modules into web/src/wasm. |
mise run web-size | Fails when a WebAssembly module is above 256000 bytes once compressed with gzip -9. |
mise run web-test | Runs the tests of the web package in Node, against a mocked Web Serial port. |
mise run web-demo | Serves the demonstration page at http://localhost:8000/web/demo/. |
mise run pages-serve | Serves the flasher site at http://localhost:8000/. |
mise run test-qemu, test-samba-emulator, test-simavr, test-hardware | See Run the hardware tests. |
Rules of the code
- Licence
MIT OR Apache-2.0on every crate. - The invariants of the library (no panic, bounded loops, no
unsafe,no_std, features that only add code) are in Invariants. The example firmware follows theunsaferule too. - No code from BOSSA, avrdude, Optiboot, Caterina, the Arduino bootloaders or simavr is copied. They are a behaviour reference or a test tool only.
- Spell words out in identifiers, documentation and messages.
- Conventional commits, from which release-plz makes the releases and the changelog.
AGENTS.md at the root of the repository has the full list of invariants.
Work on the flasher page
Run the page on your computer
$ mise run pages-serve
This builds the WebAssembly modules, checks their size, builds the package, the page and the
guide, assembles the site in target/pages, and serves it at http://localhost:8000/. The
flasher page is at http://localhost:8000/flasher/. Open the page through
pages-serve: web/flasher/index.html alone does not work, because it needs flasher.css,
flasher/ (the compiled page) and nanoflash/ (the compiled package) next to it.
mise run pages only assembles the site in target/pages: the guide at the root with
sitemap.xml and robots.txt, and the flasher page in flasher/ with index.html,
flasher.css, flasher/ (the compiled page), nanoflash/ (the compiled package without type
declarations, with wasm/) and site.json.
Change the page
The page is in web/flasher, outside the npm package (files lists dist only).
npm run build:flashercompiles the page toweb/flasher/dist(ignored by git), afternpm run build. The testsweb/test/flasher.test.mjsandweb/test/flasher-page.test.mjs(the trust gate, in a simulated browser page) import that output. On a fresh checkout, runmise run web-test, which builds it, and notnpm testalone.index.htmlcarries a Content Security Policy in ametaelement. It contains the SHA-256 hash of the import map, andflasher.test.mjsfails when the hash is wrong. Change the import map and the hash together.- After a change to
web/flasher, runmise run pages.
Release and publish describes the deployment.
Write the documentation
The guide is in docs/src, in four parts: tutorials, how-to guides, reference and explanation.
docs/src/SUMMARY.md lists every page. Use relative links between pages.