diff options
| -rw-r--r-- | common/bootloader.c | 68 | ||||
| -rw-r--r-- | keyboard/macway/Makefile.lufa | 13 | ||||
| -rw-r--r-- | protocol/pjrc.mk | 3 | ||||
| -rw-r--r-- | protocol/pjrc/bootloader_teensy.c | 40 |
4 files changed, 62 insertions, 62 deletions
diff --git a/common/bootloader.c b/common/bootloader.c index 5cbfc72e5..cb971c704 100644 --- a/common/bootloader.c +++ b/common/bootloader.c | |||
| @@ -1,22 +1,56 @@ | |||
| 1 | /* | 1 | #include <avr/io.h> |
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | 2 | #include <avr/interrupt.h> |
| 3 | 3 | #include <util/delay.h> | |
| 4 | This program is free software: you can redistribute it and/or modify | 4 | #include "bootloader.h" |
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | 5 | ||
| 9 | This program is distributed in the hope that it will be useful, | 6 | /* Start Bootloader from Application |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 7 | * See |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 8 | * http://www.pjrc.com/teensy/jump_to_bootloader.html |
| 12 | GNU General Public License for more details. | 9 | * http://www.fourwalledcubicle.com/files/LUFA/Doc/120219/html/_page__software_bootloader_start.html |
| 10 | */ | ||
| 13 | 11 | ||
| 14 | You should have received a copy of the GNU General Public License | 12 | /* Boot Section Size in bytes |
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 13 | * Teensy halfKay 512 |
| 16 | */ | 14 | * Atmel DFU loader 4096 |
| 15 | * LUFA bootloader 4096 | ||
| 16 | */ | ||
| 17 | #ifndef BOOT_SIZE | ||
| 18 | #define BOOT_SIZE 512 | ||
| 19 | #endif | ||
| 17 | 20 | ||
| 18 | #include "bootloader.h" | 21 | #define FLASH_SIZE (FLASHEND + 1) |
| 22 | #define BOOTLOADER_START (FLASHEND - BOOT_SIZE) | ||
| 19 | 23 | ||
| 24 | void bootloader_jump(void) { | ||
| 25 | cli(); | ||
| 26 | // disable watchdog, if enabled | ||
| 27 | // disable all peripherals | ||
| 28 | UDCON = 1; | ||
| 29 | USBCON = (1<<FRZCLK); // disable USB | ||
| 30 | UCSR1B = 0; | ||
| 31 | _delay_ms(5); | ||
| 32 | #if defined(__AVR_AT90USB162__) | ||
| 33 | EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; | ||
| 34 | TIMSK0 = 0; TIMSK1 = 0; UCSR1B = 0; | ||
| 35 | DDRB = 0; DDRC = 0; DDRD = 0; | ||
| 36 | PORTB = 0; PORTC = 0; PORTD = 0; | ||
| 37 | #elif defined(__AVR_ATmega32U4__) | ||
| 38 | EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0; | ||
| 39 | TIMSK0 = 0; TIMSK1 = 0; TIMSK3 = 0; TIMSK4 = 0; UCSR1B = 0; TWCR = 0; | ||
| 40 | DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; TWCR = 0; | ||
| 41 | PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; | ||
| 42 | #elif defined(__AVR_AT90USB646__) | ||
| 43 | EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0; | ||
| 44 | TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; UCSR1B = 0; TWCR = 0; | ||
| 45 | DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; | ||
| 46 | PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; | ||
| 47 | #elif defined(__AVR_AT90USB1286__) | ||
| 48 | EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0; | ||
| 49 | TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; UCSR1B = 0; TWCR = 0; | ||
| 50 | DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; | ||
| 51 | PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; | ||
| 52 | #endif | ||
| 20 | 53 | ||
| 21 | void bootloader_jump(void) __attribute__ ((weak)); | 54 | // start Bootloader |
| 22 | void bootloader_jump(void) {} | 55 | ((void (*)(void))BOOTLOADER_START)(); |
| 56 | } | ||
diff --git a/keyboard/macway/Makefile.lufa b/keyboard/macway/Makefile.lufa index 8f50776df..2f2b6401d 100644 --- a/keyboard/macway/Makefile.lufa +++ b/keyboard/macway/Makefile.lufa | |||
| @@ -51,8 +51,7 @@ TARGET_DIR = . | |||
| 51 | # List C source files here. (C dependencies are automatically generated.) | 51 | # List C source files here. (C dependencies are automatically generated.) |
| 52 | SRC += keymap.c \ | 52 | SRC += keymap.c \ |
| 53 | matrix.c \ | 53 | matrix.c \ |
| 54 | led.c \ | 54 | led.c |
| 55 | protocol/pjrc/bootloader_teensy.c | ||
| 56 | 55 | ||
| 57 | CONFIG_H = config.h | 56 | CONFIG_H = config.h |
| 58 | 57 | ||
| @@ -95,7 +94,6 @@ ARCH = AVR8 | |||
| 95 | F_USB = $(F_CPU) | 94 | F_USB = $(F_CPU) |
| 96 | 95 | ||
| 97 | 96 | ||
| 98 | |||
| 99 | # Build Options | 97 | # Build Options |
| 100 | # comment out to disable the options. | 98 | # comment out to disable the options. |
| 101 | # | 99 | # |
| @@ -105,6 +103,15 @@ EXTRAKEY_ENABLE = yes # Audio control and System control | |||
| 105 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | 103 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support |
| 106 | 104 | ||
| 107 | 105 | ||
| 106 | # Boot Section Size in bytes | ||
| 107 | # Teensy halfKay 512 | ||
| 108 | # Atmel DFU loader 4096 | ||
| 109 | # LUFA bootloader 4096 | ||
| 110 | #ifndef BOOT_SIZE | ||
| 111 | #define BOOT_SIZE 512 | ||
| 112 | #endif | ||
| 113 | |||
| 114 | |||
| 108 | # Search Path | 115 | # Search Path |
| 109 | VPATH += $(TARGET_DIR) | 116 | VPATH += $(TARGET_DIR) |
| 110 | VPATH += $(TOP_DIR) | 117 | VPATH += $(TOP_DIR) |
diff --git a/protocol/pjrc.mk b/protocol/pjrc.mk index 1ceee0ad9..8aff6f28b 100644 --- a/protocol/pjrc.mk +++ b/protocol/pjrc.mk | |||
| @@ -5,8 +5,7 @@ OPT_DEFS += -DHOST_PJRC | |||
| 5 | SRC += $(PJRC_DIR)/pjrc.c \ | 5 | SRC += $(PJRC_DIR)/pjrc.c \ |
| 6 | $(PJRC_DIR)/usb_keyboard.c \ | 6 | $(PJRC_DIR)/usb_keyboard.c \ |
| 7 | $(PJRC_DIR)/usb_debug.c \ | 7 | $(PJRC_DIR)/usb_debug.c \ |
| 8 | $(PJRC_DIR)/usb.c \ | 8 | $(PJRC_DIR)/usb.c |
| 9 | $(PJRC_DIR)/bootloader_teensy.c | ||
| 10 | 9 | ||
| 11 | # Option modules | 10 | # Option modules |
| 12 | ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE) | 11 | ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE) |
diff --git a/protocol/pjrc/bootloader_teensy.c b/protocol/pjrc/bootloader_teensy.c deleted file mode 100644 index 9d34852f1..000000000 --- a/protocol/pjrc/bootloader_teensy.c +++ /dev/null | |||
| @@ -1,40 +0,0 @@ | |||
| 1 | /* See http://www.pjrc.com/teensy/jump_to_bootloader.html */ | ||
| 2 | #include <avr/io.h> | ||
| 3 | #include <avr/interrupt.h> | ||
| 4 | #include <util/delay.h> | ||
| 5 | #include "bootloader.h" | ||
| 6 | |||
| 7 | void bootloader_jump(void) { | ||
| 8 | cli(); | ||
| 9 | // disable watchdog, if enabled | ||
| 10 | // disable all peripherals | ||
| 11 | UDCON = 1; | ||
| 12 | USBCON = (1<<FRZCLK); // disable USB | ||
| 13 | UCSR1B = 0; | ||
| 14 | _delay_ms(5); | ||
| 15 | #if defined(__AVR_AT90USB162__) // Teensy 1.0 | ||
| 16 | EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; | ||
| 17 | TIMSK0 = 0; TIMSK1 = 0; UCSR1B = 0; | ||
| 18 | DDRB = 0; DDRC = 0; DDRD = 0; | ||
| 19 | PORTB = 0; PORTC = 0; PORTD = 0; | ||
| 20 | asm volatile("jmp 0x3E00"); | ||
| 21 | #elif defined(__AVR_ATmega32U4__) // Teensy 2.0 | ||
| 22 | EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0; | ||
| 23 | TIMSK0 = 0; TIMSK1 = 0; TIMSK3 = 0; TIMSK4 = 0; UCSR1B = 0; TWCR = 0; | ||
| 24 | DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; TWCR = 0; | ||
| 25 | PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; | ||
| 26 | asm volatile("jmp 0x7E00"); | ||
| 27 | #elif defined(__AVR_AT90USB646__) // Teensy++ 1.0 | ||
| 28 | EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0; | ||
| 29 | TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; UCSR1B = 0; TWCR = 0; | ||
| 30 | DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; | ||
| 31 | PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; | ||
| 32 | asm volatile("jmp 0xFC00"); | ||
| 33 | #elif defined(__AVR_AT90USB1286__) // Teensy++ 2.0 | ||
| 34 | EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0; | ||
| 35 | TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; UCSR1B = 0; TWCR = 0; | ||
| 36 | DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; | ||
| 37 | PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; | ||
| 38 | asm volatile("jmp 0x1FC00"); | ||
| 39 | #endif | ||
| 40 | } | ||
