npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

avrload

v1.0.0

Published

Prepare AVR flash buffers from Intel HEX files, and program them over serial using the DanceBoot bootloader protocol.

Readme

avrload

Prepare AVR flash images from Intel HEX files, and program them over serial using the DanceBoot RS-485 bootloader protocol.

  • TypeScript, ESM, full type declarations.
  • Two pieces, used together or independently:
    • Flash buffer prep — allocate a buffer sized to a chip's user-flash region, load a .hex file into it, append a CRC.
    • Wire protocol + programmer — encode page-erase / page-write frames and send them over any object that implements a minimal write + drain interface (e.g. a serialport's SerialPort, or a mock for testing).
  • Built-in chip definitions for common AVRs (ATmega328P, ATmega2560, ATmega32U4, ATtiny85, ATtiny84). Pass your own def for anything else.

Install

npm install avrload

Prepare a flash image

import {
  loadHexIntoFlashBuffer,
  appendCRC16Modbus,
} from 'avrload';

const flash = await loadHexIntoFlashBuffer('firmware.hex', {
  chip: 'atmega328p',
  // or: chip: { totalFlashSizeWords: 16384, pageSizeWords: 64, bootloaderFlashWords: 1024 }
});
appendCRC16Modbus(flash); // last 2 bytes get a CRC16-modbus over the rest

The buffer length is userFlashSizeWords * 2 bytes, filled with 0xFF (the erased value) and patched with the HEX file's data records. By default userFlashSizeWords = totalFlashSizeWords - bootloaderFlashWords; override userFlashSizeWords directly to bypass that.

Send it to a DanceBoot bootloader

import { SerialPort } from 'serialport';
import { DanceProgrammer } from 'avrload';

const port = new SerialPort({ path: '/dev/ttyUSB0', baudRate: 115200 });
await new Promise(r => port.on('open', r));

const prog = new DanceProgrammer(port);
await prog.program(flash, /* pageSizeBytes */ 128);
// Or target a specific node on the bus:
// await prog.program(flash, 128, { id: 7 });

pageSizeBytes must be one of 32, 64, 128, 256 (AVR page sizes) and must divide flash.length evenly. Pages that are entirely 0xFF are erased but not written, which is a meaningful speedup on partially-used chips. Pass { skipBlankPages: false } if you want to write every page unconditionally.

DanceProgrammer accepts any object implementing { write(buf, cb), drain(cb) } — a real SerialPort, a stream, or a mock for unit tests.

DanceMessage wire format

For reference, every frame on the bus is:

[0xFF, 0xFF, ID, length, ...payload, CRC_LO, CRC_HI]
  • 0xFFFF — fixed header (also matches the AVR-flash erased pattern, which is convenient).
  • ID — recipient (0 = broadcast).
  • length — payload length in bytes (max 255).
  • CRC — CRC16-modbus over [ID, length, ...payload], little-endian.

The page commands are:

  • [0xF2, pageNum] — erase page.
  • [0xF1, pageNum, ...pageBytes] — write page.

API

| Export | What it does | | --- | --- | | makeFlashBuffer(opts) | Allocate a 0xFF-filled Buffer sized to the chip's user-flash region. | | loadHexIntoFlashBuffer(file, opts) | makeFlashBuffer then ihex.loadFileIntoBuffer. | | appendCRC16Modbus(buffer) | Write a CRC16-modbus into the last 2 bytes of buffer. | | resolveChip(name \| def) | Look up a chip def by name, or pass through an object. | | CHIP_DEFAULTS | The built-in Record<string, AVRChipDef>. | | DanceMessage | Construct, mutate, and serialize a DanceBoot wire frame. | | DanceProgrammer | Page-by-page programmer over a SerialPortLike. |

Types: AVRChipDef, AVRFlashOptions, SerialPortLike, ProgramOptions.

Requirements

  • Node.js >= 22.

License

ISC.