mirror of
https://github.com/Optiboot/optiboot.git
synced 2025-07-06 04:02:29 +03:00
Merge branch 'master' into m2560
This commit is contained in:
17
README.md
17
README.md
@ -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)
|
||||
|
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
#
|
||||
@ -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
|
||||
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
@ -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 {
|
||||
/*
|
||||
@ -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);
|
||||
@ -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);
|
||||
@ -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);
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------ */
|
||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
|
||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
|
||||
/*------------------------------------------------------------------------ */
|
||||
|
||||
/* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove
|
||||
@ -61,7 +61,7 @@
|
||||
# define UART_SRL UBRR2L
|
||||
# define UART_UDR UDR2
|
||||
#elif UART == 3
|
||||
#if !defined(UDR1)
|
||||
#if !defined(UDR3)
|
||||
#error UART == 3, but no UART3 on device
|
||||
#endif
|
||||
# define UART_SRA UCSR3A
|
||||
@ -71,7 +71,7 @@
|
||||
# define UART_UDR UDR3
|
||||
#endif
|
||||
|
||||
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega32__)
|
||||
#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega16__)
|
||||
//Name conversion R.Wiersma
|
||||
#define UCSR0A UCSRA
|
||||
#define UDR0 UDR
|
||||
@ -81,7 +81,7 @@
|
||||
#define TIFR1 TIFR
|
||||
#define WDTCSR WDTCR
|
||||
#endif
|
||||
#if defined(__AVR_ATmega32__)
|
||||
#if defined (__AVR_ATmega32__) || defined (__AVR_ATmega16__)
|
||||
#define WDCE WDTOE
|
||||
#endif
|
||||
|
||||
@ -106,7 +106,7 @@
|
||||
|
||||
/*------------------------------------------------------------------------ */
|
||||
/* Sanguino support (and other 40pin DIP cpus) */
|
||||
#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega32__)
|
||||
#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega32__) || defined (__AVR_ATmega16__)
|
||||
/*------------------------------------------------------------------------ */
|
||||
/* Onboard LED is connected to pin PB0 on Sanguino */
|
||||
#if !defined(LED)
|
||||
|
@ -42,6 +42,8 @@
|
||||
#define STK_READ_OSCCAL 0x76 // 'v'
|
||||
#define STK_READ_FUSE_EXT 0x77 // 'w'
|
||||
#define STK_READ_OSCCAL_EXT 0x78 // 'x'
|
||||
#define STK_SW_MAJOR 0x81 // ' '
|
||||
#define STK_SW_MINOR 0x82 // ' '
|
||||
|
||||
/* AVR raw commands sent via STK_UNIVERSAL */
|
||||
#define AVR_OP_LOAD_EXT_ADDR 0x4d
|
||||
|
@ -23,6 +23,7 @@ uint8_t resetFlags __attribute__ ((section(".noinit")));
|
||||
* to the variable. Again, avr-gcc provides special code sections for this.
|
||||
*/
|
||||
void resetFlagsInit(void) __attribute__ ((naked))
|
||||
__attribute__ ((used))
|
||||
__attribute__ ((section (".init0")));
|
||||
void resetFlagsInit(void)
|
||||
{
|
||||
@ -36,47 +37,48 @@ void resetFlagsInit(void)
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600); // Initialize serial port
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
Serial.println("Reset flag test");
|
||||
while (Serial.read() < 0)
|
||||
; // wait for some type-in
|
||||
|
||||
|
||||
Serial.print("Have reset flag value 0x");
|
||||
Serial.print(resetFlags, HEX);
|
||||
|
||||
/*
|
||||
* check for the usual bits. Note that the symnbols defined in wdt.h are
|
||||
* bit numbers, so they have to be shifted before comparison.
|
||||
*/
|
||||
switch (resetFlags) {
|
||||
case 1<<WDRF:
|
||||
Serial.println(" (Watchdog)\n");
|
||||
break;
|
||||
case 1<<BORF:
|
||||
Serial.println(" (Brownout)\n");
|
||||
break;
|
||||
case 1<<EXTRF:
|
||||
Serial.println(" (External Reset)\n");
|
||||
break;
|
||||
case 1<<PORF:
|
||||
case ((1<<PORF) | (1<<BORF)):
|
||||
// A poweron can frequently result in both PORF and BORF being set, as the
|
||||
// power switch bounces or the voltage rises slowly.
|
||||
Serial.println(" (PowerOn)\n");
|
||||
break;
|
||||
default:
|
||||
// Multiple bits can be set under various circumstances. For example, the
|
||||
// "hold down reset while powering up" trick used to recover from certain
|
||||
// problems can leave both PORF and EXTRF set.
|
||||
Serial.println(" (Unknown)\n");
|
||||
break;
|
||||
if (resetFlags & (1<<WDRF))
|
||||
{
|
||||
Serial.print(" Watchdog");
|
||||
resetFlags &= ~(1<<WDRF);
|
||||
}
|
||||
/*
|
||||
* Now we'll let the Watchdog reset the chip, and see if that cause is reported
|
||||
* correctly. Older versions of optiboot could not easily distinguish between
|
||||
* WDRF and EXTRF resets, since the WDT was used inside the bootloader.
|
||||
*/
|
||||
wdt_enable(WDTO_1S);
|
||||
if (resetFlags & (1<<BORF))
|
||||
{
|
||||
Serial.print(" Brownout");
|
||||
resetFlags &= ~(1<<BORF);
|
||||
}
|
||||
if (resetFlags & (1<<EXTRF))
|
||||
{
|
||||
Serial.print(" External");
|
||||
resetFlags &= ~(1<<EXTRF);
|
||||
}
|
||||
if (resetFlags & (1<<PORF))
|
||||
{
|
||||
Serial.print(" PowerOn");
|
||||
resetFlags &= ~(1<<PORF);
|
||||
}
|
||||
if (resetFlags != 0x00)
|
||||
{
|
||||
// It should never enter here
|
||||
Serial.print(" Unknown");
|
||||
}
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.println("Send something to reset through watchdog peripheral");
|
||||
while (Serial.read() < 0) ;
|
||||
wdt_enable(WDTO_15MS);
|
||||
while (1); // To prevent the loop to start again before WDT resets the board
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#%/bin/bash
|
||||
|
||||
#
|
||||
# Use like: "sh release.sh <versionno>"
|
||||
#
|
||||
# Build a "release" .zip file for Optiboot bootloader
|
||||
# Run from the build directory
|
||||
|
||||
@ -28,14 +30,14 @@ mkdir -p $TOP/libraries/
|
||||
# mkdir -p $TOP/system/
|
||||
|
||||
#
|
||||
# Copy files from whereever into the release director
|
||||
# Copy files from whereever into the release directory
|
||||
cp ../../boards-1.6.txt $TOP/boards.txt
|
||||
#cp -R ../../examples $TOP/libraries/
|
||||
#cp -R ../../variants $TOP/
|
||||
#cp -R ../../system $TOP/
|
||||
|
||||
#
|
||||
# Create platform.tx, because it contains the "group" name for the boards menu
|
||||
# Create platform.txt, because it contains the "group" name for the boards menu
|
||||
echo name=Optiboot $1 > $TOP/platform.txt
|
||||
echo version=$1 >> $TOP/platform.txt
|
||||
|
||||
|
Reference in New Issue
Block a user