Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Develop and contribute

This page is for contributors. You need mise, which installs the pinned tools of mise.toml.

mise install

Before you push

ChangeRun
Any changemise 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/nano33blemise 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-webmise run web: builds the WebAssembly modules, checks their size, type-checks the package and runs its Node tests.
web/flashermise run pages: assembles the site in target/pages.

Other tasks:

TaskRole
mise run msrvBuilds the workspace with the minimum supported Rust version (1.95).
mise run featuresTests the library with each feature combination that matters.
mise run coverageWrites the coverage of the workspace to coverage.lcov.
mise run packagePackages every crate as crates.io would, and builds each one from its package.
mise run external-parsersChecks the Espressif partition table writer against ESP-IDF’s gen_esp32part.py.
mise run web-wasmBuilds the WebAssembly modules into web/src/wasm.
mise run web-sizeFails when a WebAssembly module is above 256000 bytes once compressed with gzip -9.
mise run web-testRuns the tests of the web package in Node, against a mocked Web Serial port.
mise run web-demoServes the demonstration page at http://localhost:8000/web/demo/.
mise run pages-serveServes the flasher site at http://localhost:8000/.
mise run test-qemu, test-samba-emulator, test-simavr, test-hardwareSee Run the hardware tests.

Rules of the code

  • Licence MIT OR Apache-2.0 on 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 the unsafe rule 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:flasher compiles the page to web/flasher/dist (ignored by git), after npm run build. The tests web/test/flasher.test.mjs and web/test/flasher-page.test.mjs (the trust gate, in a simulated browser page) import that output. On a fresh checkout, run mise run web-test, which builds it, and not npm test alone.
  • index.html carries a Content Security Policy in a meta element. It contains the SHA-256 hash of the import map, and flasher.test.mjs fails when the hash is wrong. Change the import map and the hash together.
  • After a change to web/flasher, run mise 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.