# Bootloading Basics

## Overview

## What is a Bootloader?
![](https://cdn-learn.adafruit.com/assets/assets/000/076/575/medium800/microcontrollers_Atmega328.jpg?1560090715)

If you take a bare microcontroller chip fresh from the factory and apply power to it, the internal system clock will start ticking away.&nbsp; But nothing else will happen.&nbsp; Without a program to run, the chip will just sit there doing nothing.

## So, how do you load a program onto a brand-new microcontroller?

Most microcontroller chips have a special programming interface such as JTAG or AVRISP that allows you to burn programs into Flash memory.&nbsp; Unfortunately, these programming interfaces generally require specialized tools like a USBTinyISP or a Segger J-Link.

![](https://cdn-learn.adafruit.com/assets/assets/000/076/576/medium800/microcontrollers_USBTiny.jpg?1560090821)

![](https://cdn-learn.adafruit.com/assets/assets/000/076/577/medium800/microcontrollers_j_link.jpg?1560090839)

## What if you don't have one of those devices?

Most of the processor boards we carry have a pre-loaded program called a 'Bootloader'.&nbsp; A Bootloader is a program that allows you to load other programs via a more convenient interface like a standard USB cable.&nbsp; When you power-up or reset your microcontroller board, the bootloader checks to see if there is an upload request.&nbsp; If there is, it will upload the new program and burn it into Flash memory.&nbsp; If not, it will start running the last program that you loaded.

## So where do bootloaders come from?

Here at the Adafruit factory, we use custom-built programming fixtures to burn a bootloader onto each board as it comes off the manufacturing line.&nbsp; So when you get your processor board, you can just plug it into your PC and upload your own programs via a USB cable.

Instragram Bootloader timelapse: https://www.instagram.com/p/BcAMCZ9DeDS

# Bootloading Basics

## Why not build them in?

_You might wonder why the chip manufacturers don't just bake a bootloader into every microcontroller chip at the factory._

Keep in mind that the vast majority of microcontroller chips wind up embedded in products ranging from toasters to traffic lights.&nbsp; A modern automobile may have 100 or more embedded microcontrollers that only need to be programmed once by the parts supplier.&nbsp; Cost, performance or other constraints can easily outweigh any considerations of programming convenience.&nbsp;

There have been a few chips that come with a "ROM" (permanent) bootloader. Such as the ESP32 or the LPC11xx series with their USB mass storage bootloader, but these are very few-and-far-between.

![](https://cdn-learn.adafruit.com/assets/assets/000/077/163/medium800/microcontrollers_234A3233.jpg?1560888798 Fuel Injector with embedded microcontroller.  A processor in every cylinder!)

## Some of the reasons you may want to forgo the convenience of a bootloader:

### Memory

Bootloaders tend to be rather small programs. But they do take some space. &nbsp;For applications that need every last byte of program memory, the convenience of a bootloader may be an unnecessary luxury.

Embedded systems designers try to keep product costs down by using the smallest possible processor that can do the job.&nbsp; Investing in a proprietary programming interface for the manufacturing line is a one-time investment.&nbsp; Sizing up to a bigger processor adds cost to every unit sold.

### Start-up Time

Most bootloaders incur some dead-time on power-up or reset as they look for a potential upload.&nbsp; If ‘instant on’ is a requirement for your application, a stock bootloader may not be an option.

### Security

If you don’t want everyone with an Arduino IDE to be able to re-program your device, ditching the bootloader will add another obstacle for a would-be hacker.&nbsp;

_(Although any hacker worth her salt will probably have an AVRISP and/or JLink in her toolbox!)_

# Bootloading Basics

## Types of Bootloaders

There are thousands of different bootloaders.&nbsp; The design and capabilities vary depending on the processor architectures, hardware resources and intended usage.

## Basic Bootloaders

The simplest type of bootloader has just one function:&nbsp; Check for an upload at startup and load it.

### Arduino UNO Bootloader

A good example of a basic bootloader is the bootloader programmed into the Arduino UNO.&nbsp;

On power-up or reset, the bootloader watches the serial receive pin for a few seconds - waiting to receive the special sequence of bytes that indicates an upload attempt from the IDE.&nbsp; If that magic byte sequence is received, the bootloader will respond with an acknowledgement and the IDE will start sending the code.&nbsp; The bootloader will receive the code from the IDE and burn&nbsp;it into flash memory.&nbsp;

If the bootloader does not see the magic byte sequence, after a few seconds it will proceed to start running whatever code is already burned into flash.

## Advanced Bootloaders

More advanced bootloaders add additional functionality such as choosing between operating modes and/or performing some low-level diagnostics.

### CircuitPython UF2 Bootloader

A good example of an advanced bootloader is the UF2 bootloader used on our CircuitPython capable boards.&nbsp;

This bootloader can work like an Arduino and accept serial uploads via the USB connection.&nbsp; Or it can emulate a disk drive that lets you copy Python programs to it.

An on-board RGB LED is used to provide diagnostic feedback in the form of steady or flashing patterns in different colors to indicate the state of the bootloading process.

![](https://cdn-learn.adafruit.com/assets/assets/000/076/582/medium800/microcontrollers_arduino_compatibles_CircuitPython_Boot_Sequence_1.png?1560103943)

## Multi-stage bootstraps

Your notebook, desktop computer and even your smartphone most likely have at least two stages of bootstrapping.&nbsp; This gives you options such as selecting different operating modes, or even an entirely different operating system.

The BIOS or UEFI is burned into flash memory on the motherboard.&nbsp; At startup it will look for a bootable drive and load an operating system bootloader from the drive.&nbsp; At that point it turns control over to the operating system’s bootloader which takes care of loading your operating system.&nbsp; Once the operating system is up and running, you can just point and click to load and run any program you want.

![](https://cdn-learn.adafruit.com/assets/assets/000/077/096/medium800/microcontrollers_Windows_Advanced_Options_menu.png?1560700339)

# Bootloading Basics

## A Brief History of Bootstrapping

The word ‘Bootloader’ is a contraction of ‘bootstrap loader’.&nbsp; This is derived from the idea of ‘pulling yourself up by your bootstraps’. &nbsp;A computer without a program to run is a useless piece of machinery.&nbsp; So how do you get the program into the computer?

## Switches and Patch-Cables

In the early days of computing, computers were programmed literally bit-by-bit using patch cables or an array of toggle switches on the front panel.&nbsp; As you might imagine, this is quite tedious to do for anything more than a trivial program.

![](https://cdn-learn.adafruit.com/assets/assets/000/076/771/medium800/microcontrollers_Eniac.jpg?1560206463 Eniac Computer - US Army Photo - Public Domain)

## Punch-Cards and Paper Tape

One day, someone had a bright idea:&nbsp; Write a small program that knows how to load larger programs stored on punched cards or paper-tape.&nbsp; And the computer bootstrap loader was born.

![](https://cdn-learn.adafruit.com/assets/assets/000/076/772/medium800/microcontrollers_Honolulu_IFSS_Teletype1964.jpg?1560206501 NASA Photo - Public Domain)

## Programmable Read Only Memory

Although the bootstrap program saved lots of time, it was still rather tedious to have to toggle in the instructions every time you restarted the machine.&nbsp; Eventually, another engineer had another bright idea:&nbsp; Build the bootloader into the computer. &nbsp;

You could solder an array of diodes to program the 1’s and 0’s of the bootloader code at the required memory addresses to create a Read-Only Memory (ROM) for the bootloader.&nbsp; And the ROM boot was born.

![](https://cdn-learn.adafruit.com/assets/assets/000/076/808/medium800/microcontrollers_diode-matrix-1.jpg?1560213689 PDP-11 Diode Matrix ROM - Photo by Dave Fischer)

## EPROM, EEPROM and Flash

Moving on from the hard-wired diode boot, advanced in technology led to various forms of electrically programmable non-volatile memories.

These days, bootloaders are programmed into EEPROM or Flash memory.&nbsp; So you don’t need a soldering iron to modify or repair your bootloader.&nbsp; For more complex systems, bootloading may be performed in multiple stages with each stage loading a more complex piece of software.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/076/775/medium800/microcontrollers_EPROM_Intel_C1702A_%282%29.jpg?1560206914 Intel EPROM - Photo by Jakub Šerých - public domain)

![](https://cdn-learn.adafruit.com/assets/assets/000/077/098/medium800/microcontrollers_800px-Sony_VPL-HS1_-_SD_Card_board_-_SST_SST39VF800A-92498.jpg?1560704989 © Raimond Spekking / CC BY-SA 4.0 (via Wikimedia Commons))

## Bootstraps for the Bootstraps

Your notebook or desktop computer most likely has at least two stages of bootstraps. &nbsp;The BIOS or UEFI is burned into flash memory on the motherboard.&nbsp; At startup it will look for a bootable drive and load an operating system bootloader from the drive.&nbsp; At that point it turns control over to the operating system’s bootloader which takes care of loading your operating system.&nbsp; Once the operating system is up and running, you can just point and click to load and run any program you want.

# Bootloading Basics

## Bootloader Resources

First time with an unfamiliar bootloader?&nbsp; Not sure what that blinking LED means?&nbsp; Looking for a way to speed up your restart times?&nbsp; Or just feel like building a better bootloader?

The following pages contain links to other tutorials regarding the care and feeding of common bootloaders.

![](https://cdn-learn.adafruit.com/assets/assets/000/077/118/medium800/microcontrollers_234A3228_%282%29.jpg?1560807438 Two size-12 boot-loads of microcontrollers)

# Bootloading Basics

## Bootloader Usage

Most bootloaders are fairly simple to use. But the details vary somewhat depending on the platform and its capabilities. The links on this page describe the unique features of each one.

[Gemma Bootloader](https://learn.adafruit.com/introducing-gemma/about-the-bootloader)
[Trinket Bootloader](https://learn.adafruit.com/introducing-trinket/starting-the-bootloader)
[Pro Trinket Bootloader](https://learn.adafruit.com/introducing-pro-trinket/starting-the-bootloader)
[NRF52 Bootloader](https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide/using-the-bootloader)
## CircuitPython and Bootloaders
![](https://cdn-learn.adafruit.com/assets/assets/000/077/093/medium800/microcontrollers_py.jpg?1560698612)

Many people confuse the CircuitPython firmware with a bootloader. CircuitPython itself is not a bootloader. CircuitPython relies on the UF2 Bootloader to copy your Python program files to the board.

The UF2 bootloader emulates a USB mass storage device. When you connect a board with a UF2 bootloader to your computer, it looks like you plugged in a thumb-drive. It's not a real drive, so you can't use it to store all your favorite MP3s. But it will recognize certain file names as Python programs to load.

The UF2 loader can also operate in BOSSA compatible mode, so it can accept uploads of Arduino programs from the Arduino IDE.

The links below describe the CircuitPython system and the UF2 Bootloader in depth and how they work together to load your Python or Arduino programs.

[What is Circuit Python](https://learn.adafruit.com/adafruit-feather-m0-express-designed-for-circuit-python-circuitpython/what-is-circuitpython)
[The UF2 Bootloader](https://learn.adafruit.com/adafruit-feather-m0-express-designed-for-circuit-python-circuitpython/uf2-bootloader-details)
![](https://cdn-learn.adafruit.com/assets/assets/000/077/094/medium800/microcontrollers_arduino_compatibles_CircuitPython_Boot_Sequence_1.png?1560699099)

# Bootloading Basics

## BYOB! (Burn Your Own Bootloader)

There are a few reasons why you might want to burn a bootloader yourself:

- You are starting with a bare chip, fresh from the factory
- You have ‘bricked’ a processor board and want to repair it
- You have special requirements and want to install a custom bootloader

This page has a number of links to tools and instructions for repairing, customizing and/or burning bootloaders on various microcontrollers:

## Bootloader Customization, Installation and Repair
![](https://cdn-learn.adafruit.com/assets/assets/000/077/088/medium800/microcontrollers_adafruit_products_bitbang.jpg?1560697095)

## General Bootloader Programming and Repair
[Arduino Bootloader Hacks](https://learn.adafruit.com/arduino-tips-tricks-and-techniques/bootloader)
[Burning Arduino Bootloaders with an FTDI Friend](https://learn.adafruit.com/ftdi-friend/programming-the-arduino-bootloader)
[Burning Arudino Bootloaders with a Raspberry Pi](https://learn.adafruit.com/program-an-avr-or-arduino-using-raspberry-pi-gpio-pins)
[Pro Trinket Bootloader](https://learn.adafruit.com/introducing-pro-trinket/re-programming-bootloader)
[Trinket/Gemma Bootloader](https://learn.adafruit.com/introducing-trinket/repairing-bootloader)
[Programming SAMD Bootloaders](https://learn.adafruit.com/how-to-program-samd-bootloaders)
[Compiling the ATSAMD21 Bootloader](https://learn.adafruit.com/compiling-m0-atsamd21-bootloader)
[Flashing the NRF52 Bootloader](https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide/flashing-the-bootloader)
## Bootloader Programming Devices
### USBTiny ISP

This device can be used to flash bootloaders or other programs onto AVR Microcontroller boards with ICSP headers.

![microcontrollers_USBTiny.jpg](https://cdn-learn.adafruit.com/assets/assets/000/077/090/medium640/microcontrollers_USBTiny.jpg?1560888897)

[USBTiny ISP](https://learn.adafruit.com/usbtinyisp)
### Standalone AVR Chip Programmer

This board is designed for programming Atmel/Microchip AVR ATmega processors in 28 pin DIP packages.

![microcontrollers_manufacturing_extras.jpg](https://cdn-learn.adafruit.com/assets/assets/000/077/091/medium640/microcontrollers_manufacturing_extras.jpg?1560888999)

Featured
### Standalone AVR ISP Programmer Shield Kit - includes blank chip!

[Standalone AVR ISP Programmer Shield Kit - includes blank chip!](https://www.adafruit.com/product/462)
This shield kit pack will allow you to turn any Arduino into an AVR chip burner! It is specifically designed for people who want to program Atmega328P's to turn them into Arduino bootloader chips using an AVR-ISP sketch, but it can also be used to make a 'standalone' AVR ISP...

Out of Stock
[Buy Now](https://www.adafruit.com/product/462)
[Related Guides to the Product](https://learn.adafruit.com/products/462/guides)
![Angled shot of Standalone AVR ISP Programmer Shield Kit.](https://cdn-shop.adafruit.com/640x480/462-02.jpg)

[Standalone AVR Chip Programer](https://learn.adafruit.com/standalone-avr-chip-programmer)
### Mass AVR ISP Programmer

Another option for 28 pin ATmega processor chips.

![microcontrollers_tools_ezprog.jpg](https://cdn-learn.adafruit.com/assets/assets/000/077/092/medium640/microcontrollers_tools_ezprog.jpg?1560889102)

[Mass AVR ISP Programmer](https://learn.adafruit.com/mass-avr-isp-programmer/overview)
### Segger J-Link Programmer

Segger makes a variety of programmers designed for programming many different processor families and architectures.

![microcontrollers_j_link.jpg](https://cdn-learn.adafruit.com/assets/assets/000/077/089/medium640/microcontrollers_j_link.jpg?1560889176)

[Segger J-Link User Guide](https://cdn-shop.adafruit.com/product-files/3571/UM08001_JLink+(1).pdf)
[Segger Forums](https://forum.segger.com/)
Featured
### SEGGER J-Link BASE - JTAG/SWD Debugger

[SEGGER J-Link BASE - JTAG/SWD Debugger](https://www.adafruit.com/product/2209)
The SEGGER J-Link BASE is identical to the cheaper&nbsp;[J-Link EDU](https://www.adafruit.com/products/1369)&nbsp;model except for the **terms of use**.

If you're going to use your debugger strictly for personal, non-commercial projects, such as publishing...

In Stock
[Buy Now](https://www.adafruit.com/product/2209)
[Related Guides to the Product](https://learn.adafruit.com/products/2209/guides)
![SEGGER J-Link JTAG/SWD Debugger brick and JTAG cable](https://cdn-shop.adafruit.com/640x480/2209-00.jpg)

Featured
### SEGGER J-Link EDU Mini - JTAG/SWD Debugger

[SEGGER J-Link EDU Mini - JTAG/SWD Debugger](https://www.adafruit.com/product/3571)
Doing some serious development on any ARM-based platform, and tired of 'printf' plus an LED to debug? A proper JTAG/SWD HW debugger can make debugging more of a pleasure and less of a pain. It allows you to program your devices at the click of a button, read or write memory addresses...

In Stock
[Buy Now](https://www.adafruit.com/product/3571)
[Related Guides to the Product](https://learn.adafruit.com/products/3571/guides)
![Segger debugger in plastic housing.](https://cdn-shop.adafruit.com/640x480/3571-04.jpg)

And a variety of others!

Featured
### Black Magic Probe with JTAG Cable and Serial Cable

[Black Magic Probe with JTAG Cable and Serial Cable](https://www.adafruit.com/product/3839)
Toss away your boring old SWD/JTAG adapters! This **Black Magic Probe** , designed by [1BitSquared](http://1bitsquared.com/) with [Black Sphere Technologies](http://www.blacksphere.co.nz/main/), is a next-generation debugging tool, perfect for your ARM Cortex...

In Stock
[Buy Now](https://www.adafruit.com/product/3839)
[Related Guides to the Product](https://learn.adafruit.com/products/3839/guides)
![Black Magic Probe JTAG debugger](https://cdn-shop.adafruit.com/640x480/3839-10.jpg)


## Guide Products

### USBtinyISP AVR Programmer  Kit (USB SpokePOV Dongle)

[USBtinyISP AVR Programmer  Kit (USB SpokePOV Dongle)](https://www.adafruit.com/product/46)
USBtinyISP is a simple open-source USB AVR programmer and SPI interface. It is low cost, easy to make, works great with avrdude, has **both** [6 and 10 pin standard ISP cables](http://www.evilmadscientist.com/article.php/avrtargetboards), is AVRStudio-compatible and...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/46)
[Related Guides to the Product](https://learn.adafruit.com/products/46/guides)
### Standalone AVR ISP Programmer Shield Kit - includes blank chip!

[Standalone AVR ISP Programmer Shield Kit - includes blank chip!](https://www.adafruit.com/product/462)
This shield kit pack will allow you to turn any Arduino into an AVR chip burner! It is specifically designed for people who want to program Atmega328P's to turn them into Arduino bootloader chips using an AVR-ISP sketch, but it can also be used to make a 'standalone' AVR ISP...

Out of Stock
[Buy Now](https://www.adafruit.com/product/462)
[Related Guides to the Product](https://learn.adafruit.com/products/462/guides)
### SEGGER J-Link BASE - JTAG/SWD Debugger

[SEGGER J-Link BASE - JTAG/SWD Debugger](https://www.adafruit.com/product/2209)
The SEGGER J-Link BASE is identical to the cheaper&nbsp;[J-Link EDU](https://www.adafruit.com/products/1369)&nbsp;model except for the **terms of use**.

If you're going to use your debugger strictly for personal, non-commercial projects, such as publishing...

In Stock
[Buy Now](https://www.adafruit.com/product/2209)
[Related Guides to the Product](https://learn.adafruit.com/products/2209/guides)
### SEGGER J-Link EDU - JTAG/SWD Debugger

[SEGGER J-Link EDU - JTAG/SWD Debugger](https://www.adafruit.com/product/1369)
[Discontinued - **you can grab&nbsp;** SEGGER J-Link EDU Mini - JTAG/SWD Debugger **instead!**](https://www.adafruit.com/product/3571)

The SEGGER J-Link EDU is identical to the more expensive [J-Link BASE](https://www.adafruit.com/products/2209) model except...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1369)
[Related Guides to the Product](https://learn.adafruit.com/products/1369/guides)
### SEGGER J-Link EDU Mini - JTAG/SWD Debugger

[SEGGER J-Link EDU Mini - JTAG/SWD Debugger](https://www.adafruit.com/product/3571)
Doing some serious development on any ARM-based platform, and tired of 'printf' plus an LED to debug? A proper JTAG/SWD HW debugger can make debugging more of a pleasure and less of a pain. It allows you to program your devices at the click of a button, read or write memory addresses...

In Stock
[Buy Now](https://www.adafruit.com/product/3571)
[Related Guides to the Product](https://learn.adafruit.com/products/3571/guides)
### Black Magic Probe with JTAG Cable and Serial Cable

[Black Magic Probe with JTAG Cable and Serial Cable](https://www.adafruit.com/product/3839)
Toss away your boring old SWD/JTAG adapters! This **Black Magic Probe** , designed by [1BitSquared](http://1bitsquared.com/) with [Black Sphere Technologies](http://www.blacksphere.co.nz/main/), is a next-generation debugging tool, perfect for your ARM Cortex...

In Stock
[Buy Now](https://www.adafruit.com/product/3839)
[Related Guides to the Product](https://learn.adafruit.com/products/3839/guides)
### Particle Debugger

[Particle Debugger](https://www.adafruit.com/product/4001)
Discontinued - **you can grab the&nbsp;** [Black Magic Probe with JTAG Cable and Serial Cable - V2.3](https://www.adafruit.com/product/3839)&nbsp; **instead!&nbsp;**

If you've got a modern ARM chip devboard you'll notice that it has one of...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/4001)
[Related Guides to the Product](https://learn.adafruit.com/products/4001/guides)
### IBDAP - CMSIS-DAP JTAG/SWD Debug Adapter Kit

[IBDAP - CMSIS-DAP JTAG/SWD Debug Adapter Kit](https://www.adafruit.com/product/2764)
A lot of debug adapters cost money that you'd much rather spend on tinkering. &nbsp;But not the **IBDAP - CMSIS-DAP JTAG/SWD Debug Adapter Kit** &nbsp;from armstart &nbsp;- a vendor independent debug interface that works with your PC over USB and targets ARM devices over its...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2764)
[Related Guides to the Product](https://learn.adafruit.com/products/2764/guides)

## Related Guides

- [Adafruit Metro ESP32-S3](https://learn.adafruit.com/adafruit-metro-esp32-s3.md)
- [Adafruit Metro M0 Express](https://learn.adafruit.com/adafruit-metro-m0-express.md)
- [Debugging CircuitPython On SAMD w/Atmel Studio 7](https://learn.adafruit.com/circuitpython-samd-debugging-w-atmel-studio-7.md)
- [How to Program SAMD Bootloaders](https://learn.adafruit.com/how-to-program-samd-bootloaders.md)
- [Blinking an LED with the Zephyr RTOS](https://learn.adafruit.com/blinking-led-with-zephyr-rtos.md)
- [Adafruit Metro M4 Express featuring ATSAMD51](https://learn.adafruit.com/adafruit-metro-m4-express-featuring-atsamd51.md)
- [Introducing the Adafruit Grand Central M4 Express](https://learn.adafruit.com/adafruit-grand-central.md)
- [Adafruit Metro RP2040](https://learn.adafruit.com/adafruit-metro-rp2040.md)
- [Adafruit Metro M4 Express AirLift (WiFi)](https://learn.adafruit.com/adafruit-metro-m4-express-airlift-wifi.md)
- [Adafruit Metro ESP32-S2](https://learn.adafruit.com/adafruit-metro-esp32-s2.md)
- [Adafruit Metro M7 1011 with AirLift](https://learn.adafruit.com/adafruit-metro-m7-with-airlift.md)
- [Adafruit Metro M7 with microSD](https://learn.adafruit.com/adafruit-metro-m7-microsd.md)
- [Debugging the SAMD21 with GDB](https://learn.adafruit.com/debugging-the-samd21-with-gdb.md)
- [Return to The Matrix with the Metro RP2350 or Fruit Jam](https://learn.adafruit.com/return-to-the-matrix-with-the-metro-rp2350.md)
- [Adafruit CH552 QT Py](https://learn.adafruit.com/adafruit-ch552-qt-py.md)
