Version 0.75

This commit is contained in:
Olaf Rempel 2006-05-01 19:20:40 +02:00
parent 722e6d5d68
commit 919606b3ab
4 changed files with 119 additions and 28 deletions

View File

@ -72,7 +72,8 @@
#define sig_byte2 0x93
#define sig_byte1 0x07
#define devtype 0x77 // Mega8 boot device code
//#define devtype 0x77 // Mega8 boot device code
#define devtype 0x76 // Mega8 boot device code
// #define PAGESIZE 64 // Size in Bytes

67
main.c
View File

@ -1,7 +1,7 @@
/*****************************************************************************
*
* AVRPROG compatible boot-loader
* Version : 0.7 (Feb. 2005)
* Version : 0.75 (Feb. 2006)
* Compiler : avr-gcc 3.4.1 / avr-libc 1.0.2
* size : depends on features and startup ( minmal features < 512 words)
* by : Martin Thomas, Kaiserslautern, Germany
@ -12,7 +12,12 @@
* owners in source-code and documentation of derived
* work. No warranty.
*
* Tested with ATmega8, ATmega16, ATmega32, ATmega128
* Additional code and improvements contributed by:
* - Uwe Bonnes
* - Bjoern Riemer
*
*
* Tested with ATmega8, ATmega16, ATmega32, ATmega128, AT90CAN128
*
* - based on the Butterfly Bootloader-Code
* Copyright (C) 1996-1998 Atmel Corporation
@ -133,9 +138,9 @@ int main(void)
cli();
MCUCR = (1<<IVCE);
MCUCR = (1<<IVSEL); //move interruptvectors to the Boot sector
MCUCR = (1<<IVCE); // move interruptvectors to the Boot sector
MCUCR = (1<<IVSEL); // device specific !
BLDDR &= ~(1<<BLPNUM); // set as Input
BLPORT |= (1<<BLPNUM); // Enable pullup
@ -155,8 +160,8 @@ int main(void)
{
// jump to main app if pin is not grounded
BLPORT &= ~(1<<BLPNUM); // set to default
MCUCR = (1<<IVCE);
MCUCR = (0<<IVSEL); // move interruptvectors to the Application sector
MCUCR = (1<<IVCE); // move interruptvectors to the Application sector
MCUCR = (0<<IVSEL); // device specific !
jump_to_app(); // Jump to application sector
}
else
@ -179,6 +184,7 @@ int main(void)
}
#elif defined(START_SIMPLE)
if((BLPIN & (1<<BLPNUM)))
{
// jump to main app if pin is not grounded
@ -187,6 +193,53 @@ int main(void)
MCUCR = (0<<IVSEL); //move interruptvectors to the Application sector
jump_to_app(); // Jump to application sector
}
#elif defined(START_WAIT)
// Timer-Setup for ATmega8
// - verify that the configuration is valid for the target AVR
#define F_OSC XTAL
#define UART0_STATUS UCSRA
#define UART0_DATA UDR
#define MY_WAIT 900
// wait ca 1 sec (900ms)
TCCR1A = 0; // timer setup
// F_OSC / 8 / 1000 -> 1ms
#if (((F_OSC / 8 / 1000)*MY_WAIT) < 65535)
#warning Information: setting prescaler to 8
#define WAIT_VALUE ((F_OSC / 8 / 1000)*MY_WAIT)
TCCR1B |= _BV(CS01);
#elif ((((F_OSC / 64 / 1000)*MY_WAIT) < 65535))
#warning Information: setting prescaler to 64
#define WAIT_VALUE ((F_OSC / 64 / 1000)*MY_WAIT)
TCCR1B |= _BV(CS01)| _BV(CS00);
#elif ((((F_OSC / 256 / 1000)*MY_WAIT) < 65535))
#warning Information: setting prescaler to 256
#define WAIT_VALUE ((F_OSC / 256 / 1000)*MY_WAIT)
TCCR1B |= _BV(CS02);
#else //((((F_OSC / 1024 / 1000)*MY_WAIT) < 65535))
#warning Information: setting prescaler to 1024
#define WAIT_VALUE ((F_OSC / 1024 / 1000)*MY_WAIT)
TCCR1B |= _BV(CS00) |_BV(CS02); //1024 prescaler
#endif
while(1){
if(UART0_STATUS & (1<<RXC)){
if (UART0_DATA == 'S')
break;
}
if (TCNT1 >= WAIT_VALUE){
BLPORT &= ~(1<<BLPNUM); // set to default
MCUCR = (1<<IVCE);
MCUCR = (0<<IVSEL); //move interruptvectors to the Application sector
TCCR1B = 0; // timer off
jump_to_app(); // Jump to application sector
}
}
TCCR1B = 0; // timer off
send_boot();
#elif defined(START_BOOTICE)
#warning "BOOTICE mode - no startup-condition"

View File

@ -35,13 +35,14 @@
# MCU name
## MCU = atmega16
## MCU = atmega8
MCU = atmega8
## MCU = atmega32
MCU = at90can128
## MCU = at90can128
XTAL=16000000
BAUDRATE=115200
#XTAL=2000000UL
#BAUDRATE=115200
BAUDRATE=9600UL
#Pin "STARTPIN" on port "STARTPORT" in this port has to grounded
# (active low) to start the bootloader
@ -63,7 +64,11 @@ BLPNUM = PINB0
# parser-loop on reset
# XTAL in BOOTICEMODE must be 7372800 Hz to be compatible
# with the org. JTAGICE-Firmware */
STARTMODE=START_SIMPLE
# * WAIT-mode waits 1 sec for the S command if nothing is recived
# then the user prog is started ..
#STARTMODE=START_SIMPLE
STARTMODE=START_WAIT
##STARTMODE=START_POWERSAVE
##STARTMODE=START_BOOTICE
@ -71,6 +76,7 @@ STARTMODE=START_SIMPLE
## NO! BOOTSIZE=_B128
## NO! BOOTSIZE=_B256
## MAYBE: BOOTSIZE=_B512
#BOOTSIZE=_B512
BOOTSIZE=_B1024
##BOOTSIZE=_B2048
@ -109,7 +115,8 @@ endif
# Output format. (can be srec, ihex, binary)
FORMAT = srec
FORMAT = ihex
#FORMAT = srec
# Target file name (without extension).
TARGET = main
@ -250,7 +257,7 @@ AVRDUDE_PROGRAMMER = stk500v2
# com1 = serial port. Use lpt1 to connect to parallel port.
#AVRDUDE_PORT = com1 # programmer connected to serial device
AVRDUDE_PORT = /dev/ttyS1 # programmer connected to serial device
AVRDUDE_PORT = /dev/ttyS0 # programmer connected to serial device
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
@ -280,25 +287,35 @@ AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
# ---------------------------------------------------------------------------
# Define directories, if needed.
DIRAVR = c:/winavr
DIRAVRBIN = $(DIRAVR)/bin
DIRAVRUTILS = $(DIRAVR)/utils/bin
DIRINC = .
DIRLIB = $(DIRAVR)/avr/lib
#DIRAVR = c:/winavr
#DIRAVRBIN = $(DIRAVR)/bin
#DIRAVRUTILS = $(DIRAVR)/utils/bin
#DIRINC = .
#DIRLIB = $(DIRAVR)/avr/lib
# Define programs and commands.
#SHELL = $(DIRAVRUTILS)/sh
#NM = $(DIRAVRBIN)/avr-nm
#CC = $(DIRAVRBIN)/avr-gcc
#OBJCOPY = $(DIRAVRBIN)/avr-objcopy
#OBJDUMP= $(DIRAVRBIN)/avr-objdump
#SIZE = $(DIRAVRBIN)/avr-size
#AVRDUDE = $(DIRAVRBIN)/avrdude.sh
#REMOVE = rm -f
#COPY = cp
# Define programs and commands.
SHELL = sh
CC = env WINEDLLOVERRIDES=msvcrt=n /spare/bon/wine/wine/wine c:/WinAVR/bin/avr-gcc
OBJCOPY = env WINEDLLOVERRIDES=msvcrt=n /spare/bon/wine/wine/wine c:/WinAVR/bin/avr-objcopy
OBJDUMP = env WINEDLLOVERRIDES=msvcrt=n /spare/bon/wine/wine/wine c:/WinAVR/bin/avr-objdump
SIZE = env WINEDLLOVERRIDES=msvcrt=n /spare/bon/wine/wine/wine c:/WinAVR/bin/avr-size
NM = env WINEDLLOVERRIDES=msvcrt=n /spare/bon/wine/wine/wine c:/WinAVR/bin/avr-nm
CC = avr-gcc
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
NM = avr-nm
AVRDUDE = avrdude
REMOVE = rm -f
COPY = cp
WINSHELL = cmd
# Define Messages

View File

@ -10,9 +10,28 @@
http://www.siwawi.arubi.uni-kl.de/avr_projects
Addtional code and improvements provided by
Uwe Bonnes and Bjoern Riemer.
======================================================
Programming-Software (on the "PC-Side"):
* AVRProg (included in AVRStudio) available at www.atmel.com.
MS-Windows only. AVRProg can be used as stand-alone application.
(avrprog.exe)
* avrdude available at http://savannah.nongnu.org/projects/avrdude/
"Multiplattform"
09. Feb. 2006 - Version 0.75
* additional STARTUP_WAIT support contributed by Bjoern Riemer
18. Aug. 2005 - Version 0.74
* AT90CAN128 support contributed by Uwe Bonnes
@ -144,7 +163,8 @@ not enabled (TODO).
or hold the key down until you see the AVRPROG dialog!
- Start AVRPROG (AVRStuido/Tools or stand-alone) -
keep PA7 grounded!
keep PA7 grounded! (avrdude is supported too, check
the avrdude manual for command-line options).
- AVRPROG will detect the bootloader, you may release
PA7 now