Giter Site home page Giter Site logo

ubaboot's Introduction

ubaboot v0.5 atmega32u4 bootloader

ubaboot v0.5 is a USB bootloader for atmega32u4 in 512 bytes.

Overview

  • Targets atmega32u4-based boards
  • Compiles to less than 512 bytes
  • Tested with Adafruit Feather 32u4 and Teensy 2.0
  • Can write and read (verify) both flash and eeprom memory
  • Also reads signature/lock/fuse bytes
  • Sample pyusb driver program included
  • Works with Linux; other platforms may work but not tested

ubaboot uses a custom (vendor-defined) USB protocol. See below for details.

The included ubaboot.py driver program can upload and verify firmware.

Getting started

You must configure ubaboot to work with your board. See config.h.

  1. Install dependencies:
    • avr-gcc
    • avr-libc
    • make
    • avrdude
    • pyusb
  2. Edit config.h to set required and optional configuration.
  3. Build via make.
  4. Set your fuses for a 512 byte bootloader.
  5. Program your board via "make program". This uses avrdude to flash the firmware; set AVRDUDE_PROGRAMMER in the Makefile for your programmer.
  6. Install a udev rule so you can use your device without root privilege.
  7. Use ubaboot.py to load programs via the bootloader.

Configuration overview

Required configuration:

  • Choose a vendor and product ID.
  • Set crystal/oscillator frequency for your board.
  • Set low-speed mode if using the internal RC oscillator.
  • Enable USB voltage regulator if needed for your board.

Optional configuration:

  • Setup registers and pin number for blinky USB activity LED.

Protocol details

Note: ubaboot does not come with a USB vendor ID/product ID. You must configure one before using ubaboot.

All operations are control transfers type vendor and recipient device.

Read Signature

Returns the three device signature bytes.

SETUP field Value
bmRequestType 0xc0
bRequest 1
wValue ignored
wIndex ignored
wLength 3

Read Flash

Reads program flash memory.

SETUP field Value
bmRequestType 0xc0
bRequest 2
wValue address to read
wIndex ignored
wLength length to read

Address and length need not be aligned to flash pages.

Write Flash

Writes program memory.

SETUP field Value
bmRequestType 0x40
bRequest 3
wValue address to write
wIndex ignored
wLength length to write

Both address and length must be aligned to page boundary (128 bytes for atmega32u4).

Allow 20 ms timeout per page being programmed.

Reboot

Reboots into the target program.

SETUP field Value
bmRequestType 0x40
bRequest 4
wValue ignored
wIndex ignored
wLength 0

Read EEPROM

Reads EEPROM memory.

SETUP field Value
bmRequestType 0xc0
bRequest 5
wValue address to read
wIndex ignored
wLength length to read

Write EEPROM

Writes EEPROM memory.

SETUP field Value
bmRequestType 0x40
bRequest 6
wValue address to write
wIndex ignored
wLength length to write

Allow 10 ms timeout per byte being programmed.

Read Fuse/Lock Bytes

Reads the fuse bytes and lock byte.

SETUP field Value
bmRequestType 0xc0
bRequest 7
wValue ignored
wIndex ignored
wLength 4

The bytes are returned in the following order:

Offset Value
0 low fuse
1 lock byte
2 extended fuse
3 high fuse

Notes

The firmware allows max 64 kib transfers but your USB stack might not.

libusb on linux is limited to 4 kib per control transfer.

Thanks

Thank you Richard Woodbury for reviewing lots of code and testing!

Copyright notice

Copyright 2017 by Robert Evans ([email protected])

ubaboot is licensed under the terms of GPLv3. See LICENSE for details.

This documentation is licensed under the terms of CC BY-SA 4.0

ubaboot's People

Contributors

rrevans avatar rpwoodbu avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.