Skip to content

2ck/stm-webusb

Repository files navigation

ST-Link WebUSB Interface (Demo Here)

This project provides a web-based interface for interacting with ST-Link devices using the WebUSB standard.

It allows:

  • fetching information about the ST-Link
  • flashing firmware in .bin format

⚠️ Note: This tool has only been tested with a NUCLEO-H753ZI board, which has an integrated ST-LINK v3.

Limitations

Your browser must support WebUSB. (TLDR: No Firefox.)

SharedArrayBuffer must be enabled, which requires the following two headers to be set:

Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

Building

This project uses a Nix flake for most actions. Nix flakes provide a reproducible way to manage dependencies and build configurations.

Prerequisites

  1. Install Nix: Follow the installation instructions from the Nix website.
  2. Enable Flakes: You can either enable experimental features for individual commands or enable flakes globally.
    • Use the --experimental-features 'nix-command flakes' flag, or
    • Add the following lines to your Nix configuration file (usually ~/.config/nix/nix.conf):
      experimental-features = nix-command flakes

You can then build the project with:

nix build

(Optional) Serving Locally

You can start a local server to serve the application at http://localhost:8000 with:

nix run

Remember to use a supported browser.

(Optional) Development Environment

You can start a development shell with all necessary dependencies with:

nix develop

Repository Structure

Building and Development

  • flake.nix: Nix flake for building, running, and providing a development shell.
  • flake.lock: Lock file for the Nix flake.

Web Interface

  • index.html: The main HTML file for the web interface.
  • styles.css: The CSS file for styling the web interface.
  • script.js: The main JavaScript file that contains the logic for interacting with the ST-Link device.
  • wrapper.js: A JavaScript file that wraps the necessary functions for WebAssembly.

Build process outputs (result/)

  • libstlink.js: The JavaScript glue code generated by Emscripten for the ST-Link library.
  • libstlink.wasm: The WebAssembly binary for the ST-Link library.
  • libstlink.worker.js: A Web Worker script for the ST-Link library.
  • libstlink.data: The data file generated by Emscripten.
  • chips/: Directory containing the chip configuration files from the ST-Link library.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published