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 🙏

© 2024 – Pkg Stats / Ryan Hefner

avr-multibootloader

v1.0.5

Published

An AVR bootloader that can program many devices over a multidrop bus (like RS485).

Downloads

8

Readme

Node AVR Multi-Bootloader

Build Status

Program many devices at once over a multidrop bus, like RS485. This was written with AVR devices in mind, via the AVR Multidrop Bootloader, but it can be usable for other devices that have adapted that bootloader.

Install

sudo npm install avr-multibootloader -g

CLI Interface

  Usage: multibootloader [options] <file ...>

  Send a file to all devices on a serial bus.

  Options:

    -h, --help                    output usage information
    -V, --version                 output the version number
    -l, --list                    List all serial devices
    -b, --baud <number>           Baud rate to the serial device
    -d, --device <name>           The serial device to connect to
    -s, --page-size <number>      The programming page size for your device.
    -c, --command <number>        The Disco Bus message command that puts the devices into the bootloader.
    -p, --prog-version <maj.min>  The major.minor version of your program (for example 1.5)
    <file ...>                    The file to program to your devices

Examples

Basic Programming

multibootloader --baud 115200 --device /dev/cu.usbDevice0 --page-size 128

This is the most basic usage, which passes the device, baud speed and the device page size.

IMPORTANT Page size will be different for all devices. Check your device's datasheet and look for "page size" and enter this value in bytes, not words. In the Atmega328 datasheet it's listed in section 31.5 as 64 words, which would be 128 bytes.

Triggering Program Mode

You can pass a pre-command that will be sent as a disco bus message to trigger the device into programming mode.

multibootloader --baud 115200 --device /dev/cu.usbDevice0 --page-size 128 --command 0xF0

In this example, the programmer will first send the disco bus message 0xF0 to all devices. Then, normal programming will continue after a 1 second delay.

The main program in these devices will need to watch for this message, and then swtich to the bootloader programming mode. You can see an example of a program that does this here.

API

MultiBootloader(serial, options)

The main constructor that creates a programmer instance.

Parameters

  • serial: An open SerialPort
  • options: Programmer options
    • pageSize: (required) The number of BYTES per page (not words)
    • maxTries: The maximum number of programming retries to make when there are errors.
    • timeBetweenPages: The number of milliseconds to pause between sending each page.
    • signalTimeout: Maximum time to wait for signal line to change to acknoledge nodes are ready.
    • version.major: The new program's version major number
    • version.minor: The new program's version minor number

readSignalLine()

Detects the signal line, which is used to detect if there are errors in programming. By defualt this looks at the DSR line on the serial connection, but this method can be overriden to detect the state another way.

Currently the SerialPort library does not support reading the DSR value. Until that support is added, you can use my fork of their library.

program(filepath)

Program all devices with this HEX program file. NOTE: This must be in Intel Hex format (generally the default hex format).

Parameters:

  • filepath: The path to the hex file to progrm the devices with.

Example using the API

const Multibootloader = require('avr-multibootloader');

// NOTE: this needs to use, my fork of the library to support the signal line reading (until v5.0.0 is stable):
// npm install https://github.com/jgillick/node-serialport/
const Serialport = require('serialport');

const PORT_NAME = '/dev/cu.usbDevice0'
const PORT_BAUD = 115200
const PAGE_SIZE = 128; // 64 words - atmega328

const programFile = './test_program.hex';

// Open serial port
const port = new SerialPort(PORT_NAME, { baudRate: PORT_BAUD },
  (portErr) => {
    if (portErr) {
      console.error('Error:', portErr);
      return;
    }

    // Create programmer
    const bootloader = new MultiBootloader(port, {
      pageSize: PAGE_SIZE
    });

    // Listen to programming events
    bootloader.on('status', (status) => {
      console.log(status.message);
    });
    bootloader.on('error', (err) => {
      console.log(err.message);
    });

    // Program
    bootloader.program(config.args[0])
    .then(() => {
      console.log('Programming complete!');
    })
    .catch((err) => {
      console.error(`FATAL ERROR: ${err}`);
    });
});