Skip to content

bandtank/Xmega_Bootloader

Repository files navigation

Welcome to the XmegaBl. This bootloader implements the AVR911 protocol and is
purposefully stripped of the unnecessary bloat in an effort to keep it simple
and efficient.

Please see these threads for helpful tips and information:
   1. http://www.avrfreaks.net/forum/tutsoft-xmega-bootloader-available
   2. http://www.avrfreaks.net/forum/xmega-serial-bootloader

!!!!!!!!!!
NOTE - the xmega E series does not work properly with the master branch of this
repository. Use the xmegaE branch, which has a temporary workaround. I will
update the main repository to handle xmega E series microcontrollers at some
point.
!!!!!!!!!!

Bootloader information:
   1. It works with all Xmegas, but may require you to add support if it isn't
      already in the makefile. Note: AVR-GCC has to support the particular
	  Xmega you want to use as well. AVRDUDE 5.10 lacks support for many, many
	  Xmegas, so you may need to acquire a newer version if you're simply using
	  the bundled version that came with Winavr.
   2. It requires AVR-GCC to build.
   3. It uses the AVR911 protocol.
   4. It works with avrdude version 5.10 and Avr-OSP II version .549.
   5. Compilation size should be 2600-3000 bytes depending on the size of your
      AVR (>64k flash = bigger code).
   6. Unless you are adding support for unsupported baud rates or Xmegas, you
      do NOT need to edit any source code.

Bootloader Instructions (configure each setting in the makefile):
   1. It checks a pin (Active high/low and Pin/Port are configurable) for
      bootloader entry or application entry.
   2. An LED can be turned on when the bootloader is entered. Active high/low
      and Pin/Port are configurable.
   3. The default baud rate is 115200, but this can be set to anything you want.
 
How to configure:
   In the makefile, you will see the following block of text at the top of the
   file. You should not need to edit anything other than this block of code
   unless you are adding support for additional baud rates or devices.

###############################################################################
# User modification section
###############################################################################
#  Choose one of the following MCUs:
#    If you have a different MCU, you will have to define these values:
#         Name in makefile                   Name in ioxxxx.h
#         ---------------------------        -----------------------------
#         BOOT_SECTION_START_IN_BYTES        BOOT_SECTION_START
#         BOOT_PAGE_SIZE                     BOOT_SECTION_PAGE_SIZE
#         APP_PAGE_SIZE                      APP_SECTION_PAGE_SIZE
#
#    You can find these files in the include path for your compiler. Examples:
#    1) Winavr:  C:\WinAVR-20100110\avr\include\avr\ioxxxx.h
#    2) Atmel 3.4.2: C:\Program Files (x86)\Atmel\Atmel Toolchain\AVR8 GCC\
#       Native\3.4.2.1002\avr8-gnu-toolchain\avr\include\avr\ioxxxx.h

# MCU = atxmega128a1
# MCU = atxmega64a3
MCU = atxmega64a3u
# MCU = atxmega32a4
# MCU = atxmega16a4
# MCU = atxmega16d4
  
# Choose a baud rate for the UART.
#    If you need a baud rate that is not listed in this makefile, you must add
#    new configuration statements in config.macros.h. Remember, Xmegas start-up
#    with a 2MHz clock.
# BAUD_RATE = 9600
# BAUD_RATE = 38400
# BAUD_RATE = 57600
  BAUD_RATE = 115200
  
# Specify a pin to check for entry into the bootloader. The notation is
# PORT,PIN. For example, if you wanted to use PIN 3 on PORTC, you would set
# the option as C,3. Then specifiy the logic value required to enable the
# bootloader code (1 = enable the bootloader if the pin is VCC, 0 = enable 
# the bootloader if the pin is GND).
  BOOTLOADER_PIN    = B,2
  BOOTLOADER_PIN_ON = 0
  
# Specify a pin to control an LED. The notation is PORT,PIN. For example, if
# you wanted to use PIN 6 on PORTA, you would set the option as A,6. Then
# specifiy the logic value required to enable the LED (1 = output VCC to turn
# on the LED, 0 = output GND to turn on the LED).
  LED_PIN = D,2
  LED_ON  = 0

# Specify which UART to use with PORT,NUM notation. For example, UART1 on
# PORTD would be D,1.
  UART = C,0

###############################################################################
# End user modification section
###############################################################################

If you use or fork this repository, please let me know how you're using it only
because I'm curious. Also, if you want to modify or improve the code, submit a
pull request and I'd be happy to investigate the changes.