aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2012-06-30 14:44:14 +0900
committertmk <nobody@nowhere>2012-06-30 14:44:14 +0900
commit6d79e6579f1b769f3547856b8af56bd357580adf (patch)
tree68e235f3802d21ac40541446c2c23fdbbeb5c18f
parent2c5d3ac76f0ef3c72aa0416aef8b775864b50eb1 (diff)
downloadqmk_firmware-6d79e6579f1b769f3547856b8af56bd357580adf.tar.gz
qmk_firmware-6d79e6579f1b769f3547856b8af56bd357580adf.zip
Add support of USBasp bootloader.
-rw-r--r--common/bootloader.c30
-rw-r--r--protocol/vusb.mk12
-rw-r--r--protocol/vusb/bootloader_usbasp.c47
3 files changed, 37 insertions, 52 deletions
diff --git a/common/bootloader.c b/common/bootloader.c
index e45295cd5..612b94964 100644
--- a/common/bootloader.c
+++ b/common/bootloader.c
@@ -24,12 +24,22 @@
24 24
25void bootloader_jump(void) { 25void bootloader_jump(void) {
26 cli(); 26 cli();
27
28 //
29 //Teensy
30 //
31#if defined(__AVR_AT90USB162__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
27 // disable watchdog, if enabled 32 // disable watchdog, if enabled
28 // disable all peripherals 33 // disable all peripherals
29 UDCON = 1; 34 UDCON = 1;
30 USBCON = (1<<FRZCLK); // disable USB 35 USBCON = (1<<FRZCLK); // disable USB
31 UCSR1B = 0; 36 UCSR1B = 0;
32 _delay_ms(5); 37 _delay_ms(5);
38#else
39 // This makes custom USBasploader come up.
40 MCUSR = 0;
41#endif
42
33#if defined(__AVR_AT90USB162__) 43#if defined(__AVR_AT90USB162__)
34 EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; 44 EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0;
35 TIMSK0 = 0; TIMSK1 = 0; UCSR1B = 0; 45 TIMSK0 = 0; TIMSK1 = 0; UCSR1B = 0;
@@ -52,6 +62,26 @@ void bootloader_jump(void) {
52 PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; 62 PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0;
53#endif 63#endif
54 64
65
66 //
67 //USBasp
68 //
69#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P)
70 // This makes custom USBasploader come up.
71 MCUSR = 0;
72
73 // initialize ports
74 PORTB = 0; PORTC= 0; PORTD = 0;
75 DDRB = 0; DDRC= 0; DDRD = 0;
76
77 // disable interrupts
78 EIMSK = 0; EECR = 0; SPCR = 0;
79 ACSR = 0; SPMCSR = 0; WDTCSR = 0; PCICR = 0;
80 TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0;
81 ADCSRA = 0; TWCR = 0; UCSR0B = 0;
82#endif
83
84
55 // start Bootloader 85 // start Bootloader
56 ((void (*)(void))BOOTLOADER_START)(); 86 ((void (*)(void))BOOTLOADER_START)();
57} 87}
diff --git a/protocol/vusb.mk b/protocol/vusb.mk
index 9e8e1fb39..4c5058115 100644
--- a/protocol/vusb.mk
+++ b/protocol/vusb.mk
@@ -1,10 +1,12 @@
1VUSB_DIR = protocol/vusb
2
1OPT_DEFS += -DHOST_VUSB 3OPT_DEFS += -DHOST_VUSB
2 4
3SRC += vusb.c \ 5SRC += $(VUSB_DIR)/main.c \
4 usbdrv.c \ 6 $(VUSB_DIR)/vusb.c \
5 usbdrvasm.S \ 7 $(VUSB_DIR)/usbdrv/usbdrv.c \
6 oddebug.c \ 8 $(VUSB_DIR)/usbdrv/usbdrvasm.S \
7 bootloader_usbasp.c \ 9 $(VUSB_DIR)/usbdrv/oddebug.c
8 10
9 11
10ifdef NO_UART 12ifdef NO_UART
diff --git a/protocol/vusb/bootloader_usbasp.c b/protocol/vusb/bootloader_usbasp.c
deleted file mode 100644
index 6ec99cbf2..000000000
--- a/protocol/vusb/bootloader_usbasp.c
+++ /dev/null
@@ -1,47 +0,0 @@
1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <avr/io.h>
19#include <avr/interrupt.h>
20#include "bootloader.h"
21
22
23void bootloader_jump(void) {
24 cli();
25 // This makes custom USBasploader come up.
26 MCUSR = 0;
27
28 // ATmega168PA
29 // initialize ports
30 PORTB = 0; PORTC= 0; PORTD = 0;
31 DDRB = 0; DDRC= 0; DDRD = 0;
32
33 // disable interrupts
34 EIMSK = 0; EECR = 0; SPCR = 0;
35 ACSR = 0; SPMCSR = 0; WDTCSR = 0; PCICR = 0;
36 TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0;
37 ADCSRA = 0; TWCR = 0; UCSR0B = 0;
38
39 // Boot Loader Section Start Address:
40 // BOOTSZ Size Address
41 // (lock bit) (word) (word) (byte)
42 // '11' 128 0x1F80 0x3F00
43 // '10' 256 0x1F00 0x3E00
44 // '01' 512 0x1E00 0x3C00
45 // '00' 1024 0x1C00 0x3800
46 asm volatile("jmp 0x3800");
47}