Skip to content

Commit

Permalink
Merge branch 'master' into m2560
Browse files Browse the repository at this point in the history
  • Loading branch information
majekw committed Jan 1, 2017
2 parents af82d7f + c811854 commit e31fc7f
Show file tree
Hide file tree
Showing 11 changed files with 283 additions and 64 deletions.
17 changes: 17 additions & 0 deletions README.md
Expand Up @@ -16,12 +16,29 @@ Optiboot is now installed by default on the Arduino Uno. It can be installed on
## Additional Documentation
More detailed documentation is being added (slowly) to the [repository wiki](https://github.com/Optiboot/optiboot/wiki).

## Notes on IDE Version compatability
Optiboot in "compatible", it a loose sense, will all versions of the Arduino IDE. It was originally written at about the same time as v1.0, and has some "quirks" that date back to that timeframe. Most significantly, install procedures and locations change between releases, and the ability to compile optiboot using only the tools installed with the IDE broke in the v1.5 timeframe.

## To install into the Arduino software ##
You do NOT need to "install" Optiboot if you are trying to update an installed platform that already uses some form of Optiboot. In that case, you should probably just find and replace the existing .hex files from the platform support directories. Using the optiboot "install" procedure does not install any cores or variants, so it is only useful for cpus that are already supported by the standard Arduino core. (or, if all you want to do is install bootloaders.)

The following instructions are based on using the Arduino "Board Manager", present in IDE versions 1.6.5 and later.

1. Find the desired Optiboot release on the [Optiboot Rlease page] (https://github.com/Optiboot/optiboot/releases).
2. Use the "Copy Link" feature of your browswer copy the URL of the associated **.json** file.
3. Paste this url into the "Additional Boards Manager URLs" field in the Arduino IDE "Preferences" pane. (Separate it from other URLs that might be present with a comma.)
4. After closing the preferences pain, the **Tools/Boards/Boards Manager** menu should include an entry for that version of Optiboot. Select that entry and click the **Install** button.

For addition installation information, see the [Optiboot AddingOptibootChipsToIde Wiki page] (https://github.com/Optiboot/optiboot/wiki/AddingOptibootChipsToIde)


<!---
1. Download the latest using Git or the Zip download feature of GitHub. If you download as a zip, also extract it.
1. You will need to be using a recent version of the [Arduino environment](http://arduino.cc), version 18 or later.
1. Create a 'hardware' directory inside your sketches folder.
1. Copy the optiboot directory into the hardware directory.
1. Restart the Arduino software. New boards will appear in the Tools>Board menu.
--->

## To burn Optiboot onto an Arduino board ##
1. Select the appropriate Optiboot board type (or non-Optiboot if you want to change back)
Expand Down
98 changes: 92 additions & 6 deletions optiboot/boards-1.6.txt
Expand Up @@ -20,7 +20,7 @@ optiboot28.upload.speed=115200

optiboot28.bootloader.tool=arduino:avrdude
optiboot28.bootloader.low_fuses=0xF7
optiboot28.bootloader.unlock_bits=0x0F
optiboot28.bootloader.unlock_bits=0x3F
optiboot28.bootloader.lock_bits=0x2F
optiboot28.build.f_cpu=16000000L

Expand Down Expand Up @@ -107,7 +107,6 @@ optiboot28.menu.cpu.atmega8.upload.maximum_data_size=1024

optiboot28.menu.cpu.atmega8.bootloader.high_fuses=0xCC
optiboot28.menu.cpu.atmega8.bootloader.low_fuses=0xBF
optiboot28.menu.cpu.8MHz.bootloader.low_fuses=0xE2
# optiboot28.menu.cpu.atmega8.bootloader.extended_fuses=0x00
optiboot28.menu.cpu.atmega8.bootloader.file=optiboot/optiboot_atmega8.hex

Expand Down Expand Up @@ -139,8 +138,8 @@ optiboot32.upload.speed=115200

optiboot32.bootloader.tool=arduino:avrdude
optiboot32.bootloader.low_fuses=0xF7
optiboot32.bootloader.unlock_bits=0x2F
optiboot32.bootloader.lock_bits=0x0F
optiboot32.bootloader.unlock_bits=0x3F
optiboot32.bootloader.lock_bits=0x2F
optiboot32.build.f_cpu=16000000L

#
Expand Down Expand Up @@ -269,8 +268,8 @@ optiboot1284.build.variant=arduino:standard
optiboot1284.upload.maximum_size=130048
optiboot1284.upload.maximum_data_size=16384

# Select full swing crystal oscillator (7F rather than FF)
optiboot1284.bootloader.low_fuses=0x7F
# Select full swing crystal oscillator (F7 rather than FF)
optiboot1284.bootloader.low_fuses=0xF7
optiboot1284.bootloader.high_fuses=0xDE
optiboot1284.bootloader.extended_fuses=0x05
optiboot1284.bootloader.file=optiboot/optiboot_atmega1284p.hex
Expand Down Expand Up @@ -373,3 +372,90 @@ optiboot2560.bootloader.extended_fuses=0xFD
optiboot2560.bootloader.file=optiboot/optiboot_atmega2560.hex

optiboot2560.build.mcu=atmega2560

##############################################################


optibootxmini168b.name=Optiboot Xplained Mini 168pb

optibootxmini168b.upload.tool=arduino:avrdude
optibootxmini168b.upload.protocol=arduino
optibootxmini168b.upload.speed=57600

optibootxmini168b.bootloader.tool=arduino:avrdude
optibootxmini168b.bootloader.unlock_bits=0x3F
optibootxmini168b.bootloader.lock_bits=0x2F

optibootxmini168b.build.f_cpu=16000000L

optibootxmini168b.build.board=AVR_UNO
optibootxmini168b.build.core=arduino:arduino
optibootxmini168b.build.variant=arduino:standard

optibootxmini168b.upload.maximum_size=15872
optibootxmini168b.upload.maximum_data_size=1024

optibootxmini168b.bootloader.low_fuses=0xBF
optibootxmini168b.bootloader.high_fuses=0xCE
optibootxmini168b.bootloader.extended_fuses=0xFF
optibootxmini168b.bootloader.file=optiboot/optiboot_xplained168b.hex

optibootxmini168b.build.mcu=atmega168

#############################


optibootxmini328pb.name=Optiboot Xplained Mini 328pb

optibootxmini328pb.upload.tool=arduino:avrdude
optibootxmini328pb.upload.protocol=arduino
optibootxmini328pb.upload.speed=57600

optibootxmini328pb.bootloader.tool=arduino:avrdude
optibootxmini328pb.bootloader.unlock_bits=0x3F
optibootxmini328pb.bootloader.lock_bits=0x2F

optibootxmini328pb.build.f_cpu=16000000L

optibootxmini328pb.build.board=AVR_UNO
optibootxmini328pb.build.core=arduino:arduino
optibootxmini328pb.build.variant=arduino:standard

optibootxmini328pb.upload.maximum_size=32128
optibootxmini328pb.upload.maximum_data_size=1024

optibootxmini328pb.bootloader.low_fuses=0xBF
optibootxmini328pb.bootloader.high_fuses=0xCE
optibootxmini328pb.bootloader.extended_fuses=0xFF
optibootxmini328pb.bootloader.file=optiboot/optiboot_xplained328pb.hex

optibootxmini328pb.build.mcu=atmega328p

#############################


optibootxmini328p.name=Optiboot Xplained Mini 328p

optibootxmini328p.upload.tool=arduino:avrdude
optibootxmini328p.upload.protocol=arduino
optibootxmini328p.upload.speed=57600

optibootxmini328p.bootloader.tool=arduino:avrdude
optibootxmini328p.bootloader.unlock_bits=0x3F
optibootxmini328p.bootloader.lock_bits=0x2F

optibootxmini328p.build.f_cpu=16000000L

optibootxmini328p.build.board=AVR_UNO
optibootxmini328p.build.core=arduino:arduino
optibootxmini328p.build.variant=arduino:standard

optibootxmini328p.upload.maximum_size=32128
optibootxmini328p.upload.maximum_data_size=1024

optibootxmini328p.bootloader.low_fuses=0xBF
optibootxmini328p.bootloader.high_fuses=0xCE
optibootxmini328p.bootloader.extended_fuses=0xFF
optibootxmini328p.bootloader.file=optiboot/optiboot_xplained328p.hex

optibootxmini328p.build.mcu=atmega328p
86 changes: 86 additions & 0 deletions optiboot/boards.txt
Expand Up @@ -263,3 +263,89 @@ mega2560o.build.mcu=atmega2560
mega2560o.build.f_cpu=16000000L
mega2560o.build.core=arduino:arduino
mega2560o.build.variant=arduino:mega

##############################################################

optibootxmini168b.name=Optiboot Xplained Mini 168pb

optibootxmini168b.upload.tool=arduino:avrdude
optibootxmini168b.upload.protocol=arduino
optibootxmini168b.upload.speed=57600

optibootxmini168b.bootloader.tool=arduino:avrdude
optibootxmini168b.bootloader.unlock_bits=0x3F
optibootxmini168b.bootloader.lock_bits=0x2F

optibootxmini168b.build.f_cpu=16000000L

optibootxmini168b.build.board=AVR_UNO
optibootxmini168b.build.core=arduino:arduino
optibootxmini168b.build.variant=arduino:standard

optibootxmini168b.upload.maximum_size=15872
optibootxmini168b.upload.maximum_data_size=1024

optibootxmini168b.bootloader.low_fuses=0xBF
optibootxmini168b.bootloader.high_fuses=0xCE
optibootxmini168b.bootloader.extended_fuses=0xFF
optibootxmini168b.bootloader.file=optiboot/optiboot_xplained168b.hex

optibootxmini168b.build.mcu=atmega168

#############################


optibootxmini328pb.name=Optiboot Xplained Mini 328pb

optibootxmini328pb.upload.tool=arduino:avrdude
optibootxmini328pb.upload.protocol=arduino
optibootxmini328pb.upload.speed=57600

optibootxmini328pb.bootloader.tool=arduino:avrdude
optibootxmini328pb.bootloader.unlock_bits=0x3F
optibootxmini328pb.bootloader.lock_bits=0x2F

optibootxmini328pb.build.f_cpu=16000000L

optibootxmini328pb.build.board=AVR_UNO
optibootxmini328pb.build.core=arduino:arduino
optibootxmini328pb.build.variant=arduino:standard

optibootxmini328pb.upload.maximum_size=32128
optibootxmini328pb.upload.maximum_data_size=1024

optibootxmini328pb.bootloader.low_fuses=0xBF
optibootxmini328pb.bootloader.high_fuses=0xCE
optibootxmini328pb.bootloader.extended_fuses=0xFF
optibootxmini328pb.bootloader.file=optiboot/optiboot_xplained328pb.hex

optibootxmini328pb.build.mcu=atmega328p

#############################


optibootxmini328p.name=Optiboot Xplained Mini 328p

optibootxmini328p.upload.tool=arduino:avrdude
optibootxmini328p.upload.protocol=arduino
optibootxmini328p.upload.speed=57600

optibootxmini328p.bootloader.tool=arduino:avrdude
optibootxmini328p.bootloader.unlock_bits=0x3F
optibootxmini328p.bootloader.lock_bits=0x2F

optibootxmini328p.build.f_cpu=16000000L

optibootxmini328p.build.board=AVR_UNO
optibootxmini328p.build.core=arduino:arduino
optibootxmini328p.build.variant=arduino:standard

optibootxmini328p.upload.maximum_size=32128
optibootxmini328p.upload.maximum_data_size=1024

optibootxmini328p.bootloader.low_fuses=0xBF
optibootxmini328p.bootloader.high_fuses=0xCE
optibootxmini328p.bootloader.extended_fuses=0xFF
optibootxmini328p.bootloader.file=optiboot/optiboot_xplained328p.hex

optibootxmini328p.build.mcu=atmega328p
7 changes: 7 additions & 0 deletions optiboot/bootloaders/optiboot/Makefile
Expand Up @@ -286,6 +286,13 @@ atmega168_isp: LFUSE ?= F7
atmega168_isp: EFUSE ?= 04
atmega168_isp: isp

atmega16: TARGET = atmega16
atmega16: MCU_TARGET = atmega16
atmega16: CFLAGS += $(COMMON_OPTIONS)
atmega16: AVR_FREQ ?= 16000000L
atmega16: $(PROGRAM)_atmega16.hex
atmega16: $(PROGRAM)_atmega16.lst

atmega328: TARGET = atmega328
atmega328: MCU_TARGET = atmega328p
atmega328: CFLAGS += $(COMMON_OPTIONS)
Expand Down
16 changes: 13 additions & 3 deletions optiboot/bootloaders/optiboot/Makefile.atmel
@@ -1,6 +1,16 @@
# Diecimila, Duemilanove with m168, and NG use identical bootloaders
# Call it "atmega168" for generality and clarity, keep "diecimila" for
# backward compatibility of makefile
#
# Support for the Atmel Xplained mini eval boards that are mostly
# compatible with Arduino. (168pb, 328p, and 328pb chips.)
#
# Currently these all masquerade as 168 or 328p, because the IDE
# does not yet have compiler support for the -pb variants.
#
# These boards have an mEDBG debug chip that:
# 1) means that optiboot can only be programmed via Atmel Studio
# 2) prevents optiboot from working at 115200bps.
# 3) provides 16MHz (at 5V) via Xin on the chip.
#
#
#
xplained168pb: TARGET = $@
xplained168pb: CHIP = atmega168
Expand Down
12 changes: 6 additions & 6 deletions optiboot/bootloaders/optiboot/makeall
Expand Up @@ -18,15 +18,15 @@ make atmega32
make atmega88
make atmega168p

#
# Atmel development board targets
make xplained168pb
make xplained328p
make xplained328pb

#
# The "big three" standard bootloaders.
# These need to be built AFTER the platforms, or they'll get renamed
make atmega8
make atmega168
make atmega328

#
# Atmel development board targets
make xplained168pb
make xplained328p
make xplained328pb
21 changes: 14 additions & 7 deletions optiboot/bootloaders/optiboot/optiboot.c
Expand Up @@ -360,7 +360,9 @@ void __attribute__((noinline)) verifySpace();
void __attribute__((noinline)) watchdogConfig(uint8_t x);

static inline void getNch(uint8_t);
#if LED_START_FLASHES > 0
static inline void flash_led(uint8_t);
#endif
static inline void watchdogReset();
static inline void writebuffer(int8_t memtype, uint8_t *mybuff,
uint16_t address, pagelen_t len);
Expand Down Expand Up @@ -465,7 +467,7 @@ int main(void) {
// If not, uncomment the following instructions:
// cli();
asm volatile ("clr __zero_reg__");
#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega16__)
SP=RAMEND; // This is done by hardware reset
#endif

Expand All @@ -475,8 +477,13 @@ int main(void) {
* can leave multiple reset flags set; we only want the bootloader to
* run on an 'external reset only' status
*/
#if !defined(__AVR_ATmega16__)
ch = MCUSR;
MCUSR = 0;
#else
ch = MCUCSR;
MCUCSR = 0;
#endif
if (ch & (_BV(WDRF) | _BV(BORF) | _BV(PORF)))
appStart(ch);

Expand All @@ -486,7 +493,7 @@ int main(void) {
#endif

#ifndef SOFT_UART
#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega16__)
UCSRA = _BV(U2X); //Double speed mode USART
UCSRB = _BV(RXEN) | _BV(TXEN); // enable Rx & Tx
UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0); // config USART; 8N1
Expand Down Expand Up @@ -529,9 +536,9 @@ int main(void) {
* Send optiboot version as "SW version"
* Note that the references to memory are optimized away.
*/
if (which == 0x82) {
if (which == STK_SW_MINOR) {
putch(optiboot_version & 0xFF);
} else if (which == 0x81) {
} else if (which == STK_SW_MAJOR) {
putch(optiboot_version >> 8);
} else {
/*
Expand Down Expand Up @@ -734,7 +741,7 @@ uint8_t getch(void) {
uint8_t ch;

#ifdef LED_DATA_FLASH
#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega16__)
LED_PORT ^= _BV(LED);
#else
LED_PIN |= _BV(LED);
Expand Down Expand Up @@ -785,7 +792,7 @@ uint8_t getch(void) {
#endif

#ifdef LED_DATA_FLASH
#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega16__)
LED_PORT ^= _BV(LED);
#else
LED_PIN |= _BV(LED);
Expand Down Expand Up @@ -834,7 +841,7 @@ void flash_led(uint8_t count) {
TCNT1 = -(F_CPU/(1024*16));
TIFR1 = _BV(TOV1);
while(!(TIFR1 & _BV(TOV1)));
#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega16__)
LED_PORT ^= _BV(LED);
#else
LED_PIN |= _BV(LED);
Expand Down

0 comments on commit e31fc7f

Please sign in to comment.