Pi AVR Programmer HAT Hookup Guide

Pages
Contributors: QCPete
Favorited Favorite 4

Introduction

In this tutorial we will use a Pi AVR Programmer HAT and a Raspberry Pi 3B+ to program an ATMega328P target IC (RedBoard). We will program the Arduino bootloader over SPI using the capsense pad to engage, and then do some programming using avrdude in the command line. We will also cover how the Pi AVR Programmer HAT hardware works in conjunction with Python, avrdude, and shell command files.

SparkFun Pi AVR Programmer HAT

DEV-14747
2 Retired

The Pi AVR Programmer HAT makes it easy to program AVRs directly from the SPI hardware pins on any Raspberry Pi. It was originally designed as an in-house solution for SparkFun production, but now is offered as a robust programming tool for anyone to purchase. It is by far one of the fastest, most reliable, and hack-able (fully open sourced) AVR programming solutions available. It can be used directly from the command line using avrdude commands, or with some simple setup steps, it can function as a stand-alone programmer with capsense-pad engage and status leds!

All of the design files, firmware, and example programming files can be found here:

There are many reasons for programming your AVR via an in-system programmer (ISP):

  • If your AVR doesn't have a bootloader on it, it's probably the only way to load code.
  • ISP provides a faster and more reliable code upload.
  • If your project requires that your hardware UART pins (RX/TX) be connected to another device, this can conflict with serial uploading of code. ISP programming does not require using these pins. Instead, it uses MOSI/MISO/SCK/RESET -- Arduino pins D11/D12/D13/RESET. This means you can leave RX and TX connected during development and re-program your AVR with new code without un-plugging and re-plugging any of your programming lines.
  • With ISP, you can overwrite the bootloader and squeeze out some extra flash space.
  • ISP allows you to poke at the fuse bits to change many settings, including the brown-out voltage.

Covered In This Tutorial

In this tutorial we will introduce you to all of the important aspects of the Pi AVR Programmer HAT. It's split into a series of sections, which cover:

  • Board Overview -- A look at the hardware components that make up the Pi AVR Programmer HAT.
  • Raspberry Pi Setup -- To get up and programming, there is a little bit of setup work to do on your Raspberry Pi. Here, we will show what settings to change and what files need to be modified and/or copied.
  • Closer Look at the Repository Files -- Here you'll find a more detailed description of each file necessary to setup your Pi.
  • Hardware Hookup -- How to hookup the Pi AVR Programmer from your Raspi to the example Target AVR.
  • ISP Programming: Stand-Alone -- How to use the HAT in stand-alone mode and program an arduino bootloader (or any hex file) via SPI onto an ATMega328p target IC (the Redboard).
  • ISP Programming: Command Line -- A more advanced, command-line-based approach to using the Pi AVR Programmer HAT.
  • ISP Programming: Within the Arduino IDE -- How to use the HAT from within the Arduino IDE. A nice one-click solution for programming your Arduino with the speed of ISP.
  • Speed Test -- We take the HAT for a speed test and see just how fast it goes!

Required Materials

To complete this tutorial, you will need the following hardware. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.

Suggested Reading

To read even more about the history behind this project and design choices, check out the full tutorial/write up here:

Raspberry Pi Stand-Alone Programmer

March 8, 2018

This tutorial will show you how to use a headless Raspberry Pi to flash hex files onto AVR microcontrollers as a stand-alone programmer. It also tells the story about production programming challenges, how SparkFun came to this solution, and all the lessons learned along the way.

Whether you're a beginner or experienced electronics enthusiast, the Pi AVR Programmer HAT should be easy to get up-and-running. If you've programmed an Arduino before, you'll be well-prepared for the next step. Here are some addtional tutorials we'd recommend reading before continuing on with this one.

Serial Peripheral Interface (SPI)

SPI is commonly used to connect microcontrollers to peripherals such as sensors, shift registers, and SD cards.

Installing an Arduino Bootloader

This tutorial will teach you what a bootloader is and why you would need to install or reinstall it. We will also go over the process of burning a bootloader by flashing a hex file to an Arduino microcontroller.

What is an Arduino?

What is this 'Arduino' thing anyway? This tutorials dives into what an Arduino is and along with Arduino projects and widgets.

Installing Arduino IDE

A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.

Logic Levels

Learn the difference between 3.3V and 5V devices and logic levels.

Serial Terminal Basics

This tutorial will show you how to communicate with your serial devices using a variety of terminal emulator applications.

Raspberry Pi 3 Starter Kit Hookup Guide

Guide for getting going with the Raspberry Pi 3 Model B and Raspberry Pi 3 Model B+ starter kit.