How To FLASH 28Pins Firmware For The Very First Time

This page describes how to flash a completely new board, for example the 28Pins board which you have built by yourself. Important! This only work with 28Pins board, variant FIXED 5V with 16MHz crystals. If you have your own board with different crystal values, you will need to prepare your own firmware files. Have a look at How to Compile Firmware for 3V3 28Pins Variant.

Content

Requirements

Hardware

  • 28Pins board, variant FIXED 5V with 16MHz crystals
  • ATAVRDRAGON (possibly Arduino or 28Pins board)
  • 6 pin ribbon cable (2x header + cable)
  • 1x USB A to USB micro cable
  • 1x USB A to USB B cable

Software

Firmware (Files)

Installation

ATMEL FLIP Software

  1. Download FLIP from http://www.atmel.com/tools/FLIP.aspx
  2. Install the FLIP (just follow the installation wizard).

ATMEL Studio

  1. Download and Install ATMEL Studio from http://www.atmel.com/microsite/atmel_studio6/ When asked, install also all the drivers.

Arduino Software

  1. Download and Install Arduino Software from https://www.arduino.cc/en/Main/Software

Preparing 16U2

In this step we are going to change default factory settings of 16U2 microcontroller.

Note: If you do not have ATAVRDRAGON, you can use Arduino or 28Pins with MKII firmware. If you use Arduino, it will require some wiring.

  1. Connect ATAVRDRAGON to your PC
  2. Take your 28Pins board and fit a Link on the JP3 to short pins 3-4. Unfit all the other Links.
  3. Connect 28Pins to your PC
  4. Connect ribbon cable between ATAVDRAGON ISP and 28Pins ICSP1. Be aware of pin number 1!
    Dragon and 28Pins
  5. Start Atmel Studio. Go to Start -> All Programs -> Atmel -> Atmel Studio
  6. Go to: Tools -> Device Programming
  7. Select: Tool AVR Dragon; Device ATmega16U2; Interface ISP; and press "Apply" button.
  8. Go to: Device signature and click on "Read" button.
    16U2 ISP Clock 2
  9. Erase the chip: Click on Memories -> Device -> Erase Chip -> Erase now
    16U2 Erase chip 2
  10. Check the LOCK BITS: Click on "Lock bits". The LOCKBIT should be now 0xFF and everything should be NO_LOCK.
    16U2 LOCK BITS OFF
  11. Click on "Fuses". Set: EXTENDED = 0xF4; HIGH = 0xD9; LOW = 0xEF. Press "Program" button
    16U2 Program Fuses
  12. Click on "Memories". Find and select Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex then press "Program" button.
    16U2 Programing DFU 1
  13. You have successfully updated default settings of 16U2.

Change 16U2 to be a programmer

In this step we are going to change 16U2 firmware. After the firmware update 16U2 becomes MKII programmer.

  1. Fit a Link on the JP1 to short pins 2-3 (this link puts HWB pin Low tu support DFU mode).
    Programming 16U2 1
  2. Connect an USB cable between 28Pins and your PC.
  3. A new USB device should be recognized (16U2 is in DFU mode).
  4. Install Driver. It is located in "c:\Program Files\Atmel\Flip 3.4.7\usb\"
  5. Go to Device Manager (press Win+Pause -> (Hardware) -> Device Manager ) and check if you can see the driver properly installed. It will be under Atmel USB Devices -> ATmega16U2
    ATmega16U2 driver
  6. Start FLIP software (Start -> All Programs -> Flip -> Flip)
  7. Go to Settings -> Communication -> USB
  8. Press "Open".
  9. Go to File -> Load HEX file and select LUFA-AVRISP-MKII.hex
  10. Press "Run".
    16U2 flash LUFA
  11. The 16U2 is now AVRISP MKII. Disconnect the USB cable.

Flash a bootloader into ATMEGA328P

In this step, we will flash the Arduino bootloader into ATMEGA328P through ATMEGA16U2.

  1. Connect a ribbon cable between ICSP and ICSP1 connectors. This will connect MOSI, MISO and CLK pins between 16U2 and 328P.
  2. Fit JP3 jumper the way it shorts pins 2-3. This will connect 16U2 PB4 to RESET of 328P.
    Programming 328P
  3. Connect 28Pins to USB. The RX&TX LEDs should blink two times. Drivers should be correctly recognized (Jungo Connectivity -> AVRISP mkII)Atmel Studio AVRISP mkII driver
  4. Start Atmel Studio. Go to Start -> All Programs -> Atmel -> Atmel Studio
  5. Go to: Tools -> Device Programming
  6. Select: Tool AVRISP mkII; Device ATmega328P; Interface ISP; and press "Apply" button.
  7.  Go to: Device signature and click on "Read" button.
  8. Important: Set the ISP clock to 16.1kHz. Don't forget to click on the "Set" button.
    Atmel Studio setting SPI Speed
  9. Click on "Lock bits" and be sure they are all NO_LOCK (LOCKBIT = 0xFF)
    328P LOCK BITS
  10. Click on "Fuses" and set them as: EXTENDED = 0xFD; HIGH = 0xDE; LOW = 0xFF. Click on button "Program"
    328P Fuses
  11. Click on "Memories" and find the Arduino bootloader hex file. It is located in "C:\Program Files\Arduino\hardware\arduino\bootloaders\optiboot\optiboot_atmega328.hex"
  12. Press "Program" button
    Atmel Studio Programing
  13. You have successfully programmed 328P with Arduino bootloader. Now we need to re-flash 16U2 to become USB to Serial translator.

Flash 16U2 with USB to Serial firmware

In this step we are going to flash Serial to USB firmware into the 16U2. We will use FLIP again.

  1. Fit a Link on the JP1 to short pins 2-3.
    Programming 16U2 1
  2. Connect the USB cable.
  3. Start FLIP software. Go to: Start -> All Programs -> Flip -> Flip
  4. Go to: Settings -> Communication -> USB
  5. Click to "Open".
  6. Go to: File -> Load HEX file. Select this file "c:\Program Files\Arduino\hardware\arduino\firmwares\atmegaxxu2\arduino-usbserial\Arduino-usbserial-atmega16u2-Uno-Rev3.hex"
  7. Press "Run".
  8. Your 28Pins is now software compatible with Arduino board.

Run 28Pins with Arduino Software

We are going to upload Arduino "Blink" example to test the board.

  1. Fit a Link on the JP1 to short pins 1-2.
    28Pins - Jumper Arduino Compatible mode
  2. Connect the USB cable.
  3. A new USB device should be recognized. If driver is not installed automatically, you will find it in "c:\Program Files\Arduino\drivers\".
  4. Go to Device manager (Win+Pause -> (Hardware) -> Device manager) and check if the driver was loaded correctly. You should see it under Ports -> Arduino Uno
    28Pins - Device Manager COM6
  5. Start Arduino software (Start -> Arduino).
  6. Click on the "Open" icon (arrow Up) -> 01.Basics -> Blink.
  7. Select COM Port: Tools -> Serial Port -> COM(select the port where the board was recognized).
  8. Click to "Upload" icon (arrow Right).
    28Pins Arduino Software
  9. The user LED should start blinking :)
  10. Well done! You have successfully programmed both, ATMEGA16U2 and ATMEGA328P microcontrollers.