mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-10 21:24:12 +01:00
Bootloaders: adds support for 328-nonp chips
This commit is contained in:
parent
3831c9c519
commit
59b5311cdf
@ -73,7 +73,7 @@
|
|||||||
|
|
||||||
/* the current avr-libc eeprom functions do not support the ATmega168 */
|
/* the current avr-libc eeprom functions do not support the ATmega168 */
|
||||||
/* own eeprom write/read functions are used instead */
|
/* own eeprom write/read functions are used instead */
|
||||||
#if !defined(__AVR_ATmega168__) || !defined(__AVR_ATmega328P__)
|
#if !defined(__AVR_ATmega168__) || !defined(__AVR_ATmega328P__) || !defined(__AVR_ATmega328__)
|
||||||
#include <avr/eeprom.h>
|
#include <avr/eeprom.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -202,6 +202,11 @@
|
|||||||
#define SIG3 0x0F
|
#define SIG3 0x0F
|
||||||
#define PAGE_SIZE 0x40U //64 words
|
#define PAGE_SIZE 0x40U //64 words
|
||||||
|
|
||||||
|
#elif defined __AVR_ATmega328__
|
||||||
|
#define SIG2 0x95
|
||||||
|
#define SIG3 0x14
|
||||||
|
#define PAGE_SIZE 0x40U //64 words
|
||||||
|
|
||||||
#elif defined __AVR_ATmega162__
|
#elif defined __AVR_ATmega162__
|
||||||
#define SIG2 0x94
|
#define SIG2 0x94
|
||||||
#define SIG3 0x04
|
#define SIG3 0x04
|
||||||
@ -367,7 +372,7 @@ int main(void)
|
|||||||
UBRRHI = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
|
UBRRHI = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
|
||||||
UCSRA = 0x00;
|
UCSRA = 0x00;
|
||||||
UCSRB = _BV(TXEN)|_BV(RXEN);
|
UCSRB = _BV(TXEN)|_BV(RXEN);
|
||||||
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined (__AVR_ATmega328__)
|
||||||
|
|
||||||
#ifdef DOUBLE_SPEED
|
#ifdef DOUBLE_SPEED
|
||||||
UCSR0A = (1<<U2X0); //Double speed mode USART0
|
UCSR0A = (1<<U2X0); //Double speed mode USART0
|
||||||
@ -556,7 +561,7 @@ int main(void)
|
|||||||
if (flags.eeprom) { //Write to EEPROM one byte at a time
|
if (flags.eeprom) { //Write to EEPROM one byte at a time
|
||||||
address.word <<= 1;
|
address.word <<= 1;
|
||||||
for(w=0;w<length.word;w++) {
|
for(w=0;w<length.word;w++) {
|
||||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
while(EECR & (1<<EEPE));
|
while(EECR & (1<<EEPE));
|
||||||
EEAR = (uint16_t)(void *)address.word;
|
EEAR = (uint16_t)(void *)address.word;
|
||||||
EEDR = buff[w];
|
EEDR = buff[w];
|
||||||
@ -677,7 +682,7 @@ int main(void)
|
|||||||
"rjmp write_page \n\t"
|
"rjmp write_page \n\t"
|
||||||
"block_done: \n\t"
|
"block_done: \n\t"
|
||||||
"clr __zero_reg__ \n\t" //restore zero register
|
"clr __zero_reg__ \n\t" //restore zero register
|
||||||
#if defined __AVR_ATmega168__ || __AVR_ATmega328P__ || __AVR_ATmega128__ || __AVR_ATmega1280__ || __AVR_ATmega1281__
|
#if defined __AVR_ATmega168__ || __AVR_ATmega328P__ || __AVR_ATmega328__ || __AVR_ATmega128__ || __AVR_ATmega1280__ || __AVR_ATmega1281__
|
||||||
: "=m" (SPMCSR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
|
: "=m" (SPMCSR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
|
||||||
#else
|
#else
|
||||||
: "=m" (SPMCR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
|
: "=m" (SPMCR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
|
||||||
@ -710,7 +715,7 @@ int main(void)
|
|||||||
putch(0x14);
|
putch(0x14);
|
||||||
for (w=0;w < length.word;w++) { // Can handle odd and even lengths okay
|
for (w=0;w < length.word;w++) { // Can handle odd and even lengths okay
|
||||||
if (flags.eeprom) { // Byte access EEPROM read
|
if (flags.eeprom) { // Byte access EEPROM read
|
||||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
while(EECR & (1<<EEPE));
|
while(EECR & (1<<EEPE));
|
||||||
EEAR = (uint16_t)(void *)address.word;
|
EEAR = (uint16_t)(void *)address.word;
|
||||||
EECR |= (1<<EERE);
|
EECR |= (1<<EERE);
|
||||||
@ -926,7 +931,7 @@ void putch(char ch)
|
|||||||
while (!(UCSR1A & _BV(UDRE1)));
|
while (!(UCSR1A & _BV(UDRE1)));
|
||||||
UDR1 = ch;
|
UDR1 = ch;
|
||||||
}
|
}
|
||||||
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined (__AVR_ATmega328__)
|
||||||
while (!(UCSR0A & _BV(UDRE0)));
|
while (!(UCSR0A & _BV(UDRE0)));
|
||||||
UDR0 = ch;
|
UDR0 = ch;
|
||||||
#else
|
#else
|
||||||
@ -964,7 +969,7 @@ char getch(void)
|
|||||||
return UDR1;
|
return UDR1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined (__AVR_ATmega328__)
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
while(!(UCSR0A & _BV(RXC0))){
|
while(!(UCSR0A & _BV(RXC0))){
|
||||||
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
|
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
|
||||||
@ -1001,7 +1006,7 @@ void getNch(uint8_t count)
|
|||||||
while(!(UCSR1A & _BV(RXC1)));
|
while(!(UCSR1A & _BV(RXC1)));
|
||||||
UDR1;
|
UDR1;
|
||||||
}
|
}
|
||||||
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined (__AVR_ATmega328__)
|
||||||
getch();
|
getch();
|
||||||
#else
|
#else
|
||||||
/* m8,16,32,169,8515,8535,163 */
|
/* m8,16,32,169,8515,8535,163 */
|
||||||
|
@ -165,6 +165,21 @@ atmega328_isp: LFUSE = FF
|
|||||||
atmega328_isp: EFUSE = 05
|
atmega328_isp: EFUSE = 05
|
||||||
atmega328_isp: isp
|
atmega328_isp: isp
|
||||||
|
|
||||||
|
atmega328_notp: TARGET = atmega328_notp
|
||||||
|
atmega328_notp: MCU_TARGET = atmega328
|
||||||
|
atmega328_notp: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600
|
||||||
|
atmega328_notp: AVR_FREQ = 16000000L
|
||||||
|
atmega328_notp: LDSECTION = --section-start=.text=0x7800
|
||||||
|
atmega328_notp: $(PROGRAM)_atmega328_notp.hex
|
||||||
|
|
||||||
|
atmega328_notp_isp: atmega328_notp
|
||||||
|
atmega328_notp_isp: TARGET = atmega328
|
||||||
|
atmega328_notp_isp: MCU_TARGET = atmega328
|
||||||
|
atmega328_notp_isp: HFUSE = DA
|
||||||
|
atmega328_notp_isp: LFUSE = FF
|
||||||
|
atmega328_notp_isp: EFUSE = 05
|
||||||
|
atmega328_notp_isp: isp
|
||||||
|
|
||||||
atmega328_pro8: TARGET = atmega328_pro_8MHz
|
atmega328_pro8: TARGET = atmega328_pro_8MHz
|
||||||
atmega328_pro8: MCU_TARGET = atmega328p
|
atmega328_pro8: MCU_TARGET = atmega328p
|
||||||
atmega328_pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600 -DDOUBLE_SPEED
|
atmega328_pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600 -DDOUBLE_SPEED
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
|
|
||||||
/* the current avr-libc eeprom functions do not support the ATmega168 */
|
/* the current avr-libc eeprom functions do not support the ATmega168 */
|
||||||
/* own eeprom write/read functions are used instead */
|
/* own eeprom write/read functions are used instead */
|
||||||
#if !defined(__AVR_ATmega168__) || !defined(__AVR_ATmega328P__)
|
#if !defined(__AVR_ATmega168__) || !defined(__AVR_ATmega328P__) || !defined(__AVR_ATmega328__)
|
||||||
#include <avr/eeprom.h>
|
#include <avr/eeprom.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -194,6 +194,11 @@
|
|||||||
#define SIG3 0x0F
|
#define SIG3 0x0F
|
||||||
#define PAGE_SIZE 0x40U //64 words
|
#define PAGE_SIZE 0x40U //64 words
|
||||||
|
|
||||||
|
#elif defined __AVR_ATmega328__
|
||||||
|
#define SIG2 0x95
|
||||||
|
#define SIG3 0x14
|
||||||
|
#define PAGE_SIZE 0x40U //64 words
|
||||||
|
|
||||||
#elif defined __AVR_ATmega162__
|
#elif defined __AVR_ATmega162__
|
||||||
#define SIG2 0x94
|
#define SIG2 0x94
|
||||||
#define SIG3 0x04
|
#define SIG3 0x04
|
||||||
@ -335,7 +340,7 @@ int main(void)
|
|||||||
UBRRHI = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
|
UBRRHI = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
|
||||||
UCSRA = 0x00;
|
UCSRA = 0x00;
|
||||||
UCSRB = _BV(TXEN)|_BV(RXEN);
|
UCSRB = _BV(TXEN)|_BV(RXEN);
|
||||||
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
|
|
||||||
UBRR0H = ((F_CPU / 16 + BAUD_RATE / 2) / BAUD_RATE - 1) >> 8;
|
UBRR0H = ((F_CPU / 16 + BAUD_RATE / 2) / BAUD_RATE - 1) >> 8;
|
||||||
UBRR0L = ((F_CPU / 16 + BAUD_RATE / 2) / BAUD_RATE - 1);
|
UBRR0L = ((F_CPU / 16 + BAUD_RATE / 2) / BAUD_RATE - 1);
|
||||||
@ -557,7 +562,7 @@ putch(0x0D);
|
|||||||
if (getch() == ' ') {
|
if (getch() == ' ') {
|
||||||
if (flags.eeprom) { //Write to EEPROM one byte at a time
|
if (flags.eeprom) { //Write to EEPROM one byte at a time
|
||||||
for(w=0;w<length.word;w++) {
|
for(w=0;w<length.word;w++) {
|
||||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
while(EECR & (1<<EEPE));
|
while(EECR & (1<<EEPE));
|
||||||
EEAR = (uint16_t)(void *)address.word;
|
EEAR = (uint16_t)(void *)address.word;
|
||||||
EEDR = buff[w];
|
EEDR = buff[w];
|
||||||
@ -675,7 +680,7 @@ putch(0x0D);
|
|||||||
"rjmp write_page \n\t"
|
"rjmp write_page \n\t"
|
||||||
"block_done: \n\t"
|
"block_done: \n\t"
|
||||||
"clr __zero_reg__ \n\t" //restore zero register
|
"clr __zero_reg__ \n\t" //restore zero register
|
||||||
#if defined __AVR_ATmega168__ || __AVR_ATmega328P__
|
#if defined __AVR_ATmega168__ || __AVR_ATmega328P__ || __AVR_ATmega_328__
|
||||||
: "=m" (SPMCSR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
|
: "=m" (SPMCSR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
|
||||||
#else
|
#else
|
||||||
: "=m" (SPMCR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
|
: "=m" (SPMCR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
|
||||||
@ -707,7 +712,7 @@ putch(0x0D);
|
|||||||
putch(0x14);
|
putch(0x14);
|
||||||
for (w=0;w < length.word;w++) { // Can handle odd and even lengths okay
|
for (w=0;w < length.word;w++) { // Can handle odd and even lengths okay
|
||||||
if (flags.eeprom) { // Byte access EEPROM read
|
if (flags.eeprom) { // Byte access EEPROM read
|
||||||
#if defined __AVR_ATmega168__ || __AVR_ATmega328P__
|
#if defined __AVR_ATmega168__ || __AVR_ATmega328P__ || __AVR_ATmega328__
|
||||||
while(EECR & (1<<EEPE));
|
while(EECR & (1<<EEPE));
|
||||||
EEAR = (uint16_t)(void *)address.word;
|
EEAR = (uint16_t)(void *)address.word;
|
||||||
EECR |= (1<<EERE);
|
EECR |= (1<<EERE);
|
||||||
@ -921,7 +926,7 @@ void putch(char ch)
|
|||||||
while (!(UCSR1A & _BV(UDRE1)));
|
while (!(UCSR1A & _BV(UDRE1)));
|
||||||
UDR1 = ch;
|
UDR1 = ch;
|
||||||
}
|
}
|
||||||
#elif defined (__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
#elif defined (__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
while (!(UCSR0A & _BV(UDRE0)));
|
while (!(UCSR0A & _BV(UDRE0)));
|
||||||
UDR0 = ch;
|
UDR0 = ch;
|
||||||
#else
|
#else
|
||||||
@ -944,7 +949,7 @@ char getch(void)
|
|||||||
return UDR1;
|
return UDR1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#elif defined (__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
#elif defined (__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
while(!(UCSR0A & _BV(RXC0))){
|
while(!(UCSR0A & _BV(RXC0))){
|
||||||
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
|
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
|
||||||
@ -982,7 +987,7 @@ void getNch(uint8_t count)
|
|||||||
while(!(UCSR1A & _BV(RXC1)));
|
while(!(UCSR1A & _BV(RXC1)));
|
||||||
UDR1;
|
UDR1;
|
||||||
}
|
}
|
||||||
#elif (defined __AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
#elif (defined __AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
while(!(UCSR0A & _BV(RXC0)));
|
while(!(UCSR0A & _BV(RXC0)));
|
||||||
UDR0;
|
UDR0;
|
||||||
#else
|
#else
|
||||||
|
@ -231,7 +231,7 @@ void appStart() __attribute__ ((naked));
|
|||||||
#if defined(__AVR_ATmega168__)
|
#if defined(__AVR_ATmega168__)
|
||||||
#define RAMSTART (0x100)
|
#define RAMSTART (0x100)
|
||||||
#define NRWWSTART (0x3800)
|
#define NRWWSTART (0x3800)
|
||||||
#elif defined(__AVR_ATmega328P__)
|
#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
#define RAMSTART (0x100)
|
#define RAMSTART (0x100)
|
||||||
#define NRWWSTART (0x7000)
|
#define NRWWSTART (0x7000)
|
||||||
#elif defined (__AVR_ATmega644P__)
|
#elif defined (__AVR_ATmega644P__)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
|
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
|
||||||
/* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove */
|
/* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove */
|
||||||
#define LED_DDR DDRB
|
#define LED_DDR DDRB
|
||||||
#define LED_PORT PORTB
|
#define LED_PORT PORTB
|
||||||
|
@ -327,8 +327,8 @@
|
|||||||
|
|
||||||
|
|
||||||
//**************************************************************************************************
|
//**************************************************************************************************
|
||||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
#pragma mark __AVR_ATmega168__ / __AVR_ATmega328P__
|
#pragma mark __AVR_ATmega168__ / __AVR_ATmega328P__ / __AVR_ATmega328__
|
||||||
|
|
||||||
#define _INTERRUPT_NAMES_DEFINED_
|
#define _INTERRUPT_NAMES_DEFINED_
|
||||||
|
|
||||||
@ -496,8 +496,8 @@ PGM_P gInterruptNameTable[] PROGMEM =
|
|||||||
|
|
||||||
|
|
||||||
//**************************************************************************************************
|
//**************************************************************************************************
|
||||||
#if defined(__AVR_ATmega324P__ ) || defined(__AVR_ATmega644__ ) || defined(__AVR_ATmega644P__)
|
#if defined(__AVR_ATmega324P__ ) || defined(__AVR_ATmega644__ ) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
|
||||||
#pragma mark __AVR_ATmega324P__ __AVR_ATmega644__ __AVR_ATmega644P__
|
#pragma mark __AVR_ATmega324P__ __AVR_ATmega644__ __AVR_ATmega644P__ __AVR_ATmega1284P__
|
||||||
|
|
||||||
#define _INTERRUPT_NAMES_DEFINED_
|
#define _INTERRUPT_NAMES_DEFINED_
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user