SkillAgentSearch skills...

Webdfu

Driver for working with DFU in a browser over WebUSB

Install / Use

/learn @flipperdevices/Webdfu
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

WebDFU

NPM package CI in main branch

WebDFU — driver for working with DFU and DfuseDriver in a browser over Web USB or Web Bluetooth.

  • Reading and writing the current device firmware by DFU 1.1
  • ST DfuSe download and upload firmware
  • Switching from the runtime configuration to the DFU bootloader (DFU detach)

Install

npm i dfu

Usage

Full example in: webdfu/demo

Basic example:

import { WebDFU } from "dfu";

async function connect() {
  // Load the device by WebUSB
  const selectedDevice = await navigator.usb.requestDevice({ filters: [] });

  // Create and init the WebDFU instance
  const webdfu = new WebDFU(selectedDevice, { forceInterfacesName: true });
  await webdfu.init();

  if (webdfu.interfaces.length == 0) {
    throw new Error("The selected device does not have any USB DFU interfaces.");
  }

  // Connect to first device interface
  await webdfu.connect(0);

  console.log({
    Version: webdfu.properties.DFUVersion.toString(16),
    CanUpload: webdfu.properties.CanUpload,
    CanDownload: webdfu.properties.CanDownload,
    TransferSize: webdfu.properties.TransferSize,
    DetachTimeOut: webdfu.properties.DetachTimeOut,
  });

  // Read firmware from device
  try {
    const firmwareFile = await webdfu.read();

    console.log("Read: ", firmwareFile);
  } catch (error) {
    console.error(error);
  }

  // Write firmware in device
  try {
    // Your firmware in binary mode
    const firmwareFile = new ArrayBuffer("");
    await webdfu.write(1024, firmwareFile);

    console.log("Written!");
  } catch (error) {
    console.error(error);
  }
}

/*
  The browser's security policy requires that WebUSB be accessed only by an explicit user action.
  Add the button in your html and run the WebDFu after click in button.
  In HTML: <button id="connect-button">Connect</button>
*/
document.getElementById("connect-button").addEventListener("click", connect);
View on GitHub
GitHub Stars41
CategoryDevelopment
Updated23d ago
Forks11

Languages

TypeScript

Security Score

95/100

Audited on Mar 14, 2026

No findings