Learning Goals 5 min
Every Arduino board ships with a tiny program called the bootloader already in its flash. It runs at power-up, listens for a few seconds for an upload request, and either accepts a new sketch or jumps to the existing one. Today you learn what the bootloader does, and how to use one Arduino to program another (or a bare AVR chip) — "Arduino as ISP". By the end of this lesson you will:
- Explain in your own words what the bootloader does and why it exists.
- Use the Arduino IDE's "Arduino as ISP" example to turn a UNO into a programmer.
- Burn a fresh bootloader onto a target ATmega328P chip (or a second UNO) — the prep for tomorrow's standalone-ATmega328 build.
Warm-Up 10 min
Power up your UNO without uploading anything. The on-board LED on pin 13 blinks three times rapidly — that's the bootloader signalling "I'm here, waiting". After ~2 seconds it gives up and runs whatever sketch is in flash.
Two questions
- Why does the bootloader exist? Why not just upload sketches directly to the chip?
- Could you fit a 32 KB sketch on a UNO? (Flash is 32 KB total.)
Reveal
- Bootloader = self-update path. Without it, every sketch upload would need a dedicated hardware programmer (ISP/SPI cable directly to the chip). Bootloader trades a bit of flash space for the convenience of USB-based uploads.
- No. The UNO's bootloader takes ~0.5 KB of the 32 KB flash. So usable sketch space is ~31.5 KB.
New Concept · What the bootloader does 25 min
The bootloader lifecycle
- Chip resets (power-on, reset button, or auto-reset from USB).
- Execution jumps to the bootloader's start address (top of flash).
- Bootloader sets up Serial, blinks the LED briefly.
- Listens on Serial for the "new sketch" protocol (STK500) for ~1–2 seconds.
- If a host (Arduino IDE via avrdude) starts the upload protocol, bootloader accepts the new sketch into flash, then jumps to it.
- If no upload arrives, bootloader jumps to whatever sketch is already in flash.
Why a bootloader is "optional"
The chip can run a sketch without a bootloader at all — provided you have an ISP (In-System Programmer) to load the sketch directly to flash. Without bootloader, the chip jumps straight to the sketch on reset (no 2-second delay), and the saved bootloader space (~0.5 KB) is free for sketch use.
Trade-off:
| With bootloader | Without bootloader (ISP only) |
|---|---|
| Upload via USB | Upload via ISP cable + programmer |
| ~2 s boot delay | Instant boot |
| ~0.5 KB flash used | All flash available for sketch |
| Standard out-of-box experience | Pro / production firmware |
ISP — what it is
In-System Programmer: a device that talks the SPI-based programming protocol directly to the AVR chip. It can read fuses, write the bootloader, write the sketch, set the chip's clock source.
Options:
- Dedicated ISP hardware: USBasp (£3 clone), Atmel-ICE (£100 official). Reliable, requires no host MCU.
- Arduino as ISP: load a special sketch onto a UNO, use it as an ISP. Saves money; needs more wires.
Arduino-as-ISP wiring
| Programmer UNO pin | Target chip pin |
|---|---|
| D10 | RESET |
| D11 (MOSI) | MOSI |
| D12 (MISO) | MISO |
| D13 (SCK) | SCK |
| +5V | VCC |
| GND | GND |
Then in the Arduino IDE: Tools → Programmer → "Arduino as ISP". Use "Burn Bootloader" or "Upload Using Programmer".
The "burn bootloader" operation
Writes the bootloader (~0.5 KB) to the top of the target chip's flash, sets the fuse bits to point to it as the boot vector, and configures the chip's clock source. Required for any factory-fresh ATmega328P (the chip you can buy bare for $2 — comes blank). After burning, the chip can be uploaded to like any UNO.
Worked Example · Use Arduino as ISP to burn a bootloader 25 min
Step 1 — equipment
- Programmer: 1 × UNO.
- Target: 1 × fresh ATmega328P (or a second UNO you can sacrifice the bootloader of and re-burn).
- If you only have one UNO, you can "burn its own bootloader back on" using the Atmel-ICE or a USBasp.
- Jumper wires.
Step 2 — load the ArduinoISP sketch on the programmer
- File → Examples → 11.ArduinoISP → ArduinoISP.
- Tools → Board → Arduino UNO.
- Upload as normal.
After upload, the LED on pin 9 blinks the "heartbeat", pin 8 lights on programming errors, pin 7 lights during active programming.
Step 3 — wire programmer to target
Programmer UNO's D10 → target's RESET. D11 → MOSI. D12 → MISO. D13 → SCK. +5V → VCC. GND → GND. For a target UNO (board form factor), use the ICSP header (6-pin block near the top of the UNO).
Step 4 — burn the bootloader
- In the IDE, switch the BOARD setting to match your TARGET (Arduino UNO if target is a UNO).
- Tools → Programmer → "Arduino as ISP". (NOT "Arduino ISP" — they're different.)
- Tools → Burn Bootloader.
- Wait ~10 s. Watch the LED on pin 9 (heartbeat) and pin 7 (programming). Pin 8 stays off if all OK.
- Done. The target now has a fresh bootloader and can be uploaded to via its own USB port (if it has one) or via the programmer again with "Upload Using Programmer".
Step 5 — sanity check
Disconnect the programmer wires. Connect target's USB. Upload the Blink sketch as normal. The on-board LED should blink. Bootloader works.
Step 6 — alternative: upload a sketch directly (no bootloader needed)
If you want to skip the bootloader entirely:
- Same wiring as Step 3.
- Switch Programmer to "Arduino as ISP".
- Sketch → Upload Using Programmer (Ctrl+Shift+U).
- The sketch is written directly to flash, bootloader is overwritten / unused, chip boots instantly into your sketch on reset.
Useful for production / standalone builds where you don't want the 2-second boot delay.
Try It Yourself 15 min
Goal: Find the bootloader hex file on your machine (search for "optiboot_atmega328.hex" in the Arduino install). Note its size in bytes.
Goal: Wire up Arduino as ISP and verify the programmer with "Tools → Burn Bootloader". If you have only one UNO, simulate this by uploading the ArduinoISP sketch and watching the heartbeat — even if you have no target, you've confirmed the programmer is set up.
Goal: Burn a sketch directly to the target via "Upload Using Programmer". Compare the sketch's startup speed before/after (with vs without bootloader): the no-bootloader version should boot instantly on reset; the bootloader version delays ~2 s. Time both with a stopwatch.
Mini-Challenge · Sketch a programmer flowchart 10 min
- Draw the upload-to-Arduino process showing: USB → USB-serial chip (16U2 on UNO) → main MCU's UART → bootloader (in flash) → writes to flash & jumps to sketch.
- Add a second path: ISP programmer → main MCU's SPI → writes to flash → boots sketch.
- Note which is faster (ISP) and which is more convenient (USB).
Recap 5 min
The bootloader is the chip's self-update path — listens for USB uploads, then jumps to the sketch. ISP is the alternative — direct SPI programming, no bootloader required, faster boot. "Arduino as ISP" turns a UNO into a programmer for ~£0 instead of buying a USBasp. Tomorrow you'll use the same technique to build a standalone ATmega328 chip on a breadboard — Cluster A's capstone.
- Bootloader
- Small program in flash that runs first at boot, listens for upload, hands off to user sketch. Optiboot is the modern default on UNO (smaller, faster than the original).
- STK500 protocol
- The serial protocol the IDE uses to talk to the bootloader during upload.
- ISP (In-System Programmer)
- A device that talks AVR's SPI-based programming protocol directly to the chip. Can write the bootloader, sketch, fuses.
- Arduino as ISP
- The technique of loading the ArduinoISP sketch onto one UNO and using it to program another chip via SPI.
- Fuse bits
- Persistent configuration bits in the chip that select clock source, boot vector, brown-out level. Set during "burn bootloader".
- avrdude
- The open-source command-line tool the Arduino IDE uses to perform uploads. Speaks both STK500 (bootloader) and SPI (ISP).
- Upload Using Programmer
- IDE menu item that bypasses the bootloader and writes the sketch directly via ISP.
- Brick
- Slang for "render unusable by setting wrong fuses or corrupting bootloader". Usually recoverable with an ISP.
Homework 5 min
- Try the Arduino-as-ISP wiring + burn bootloader sequence on a spare target.
- Read ahead to ARD-L04-06 (Standalone ATmega328). Bring a bare ATmega328P chip + 16 MHz crystal + 2 × 22 pF caps if you have them.