Version 0.5 (20040407)

This commit is contained in:
Olaf Rempel 2006-05-01 19:13:32 +02:00
parent 85f5e95b07
commit f32c7e3131
5 changed files with 119 additions and 208 deletions

View File

@ -1,81 +0,0 @@
:103800000C942A1C0C94451C0C94451C0C94451CCF
:103810000C94451C0C94451C0C94451C0C94451CA4
:103820000C94451C0C94451C0C94451C0C94451C94
:103830000C94451C0C94451C0C94451C0C94451C84
:103840000C94451C0C94451C0C94451C0C94451C74
:103850000C94451C11241FBECFE5D4E0DEBFCDBFC4
:1038600010E0A0E6B0E0E6EEFCE302C005900D92A9
:10387000A036B107D9F710E0A0E6B0E001C01D9274
:10388000A33EB107E1F70C945D1C0C94001C81E48D
:103890000E94401E86E50E94401E82E50E94401E56
:1038A00082E40E94401E8FE40E94401E8FE40E942A
:1038B000401E84E50E94401E0895CFE5D4E0DEBF9F
:1038C000CDBFC0E0D0E001E005BF82E085BF60E091
:1038D0008BE090E00E94361E8FEF8BBBCF9B07C022
:1038E0001BBA81E085BF15BEFE0109950FC00E947D
:1038F000551E8B3141F40E94551E8335E1F70E941D
:10390000471C00E003C08FE30E94401E002331F7F4
:103910000E94551E682F813611F489E5C3C0813499
:10392000A9F40E94551E99279093E1008093E0002E
:10393000182F00270E94551E9927082B192B000FBE
:10394000111F1093E1000093E00052C0823641F451
:1039500089E50E94401E80E00E94401E80E8A2C0CF
:10396000823489F40E94551E9927182F00270E943F
:10397000551E9927082B192B0E94551E682FC80128
:103980000E94551D8FC0873689F40E94551E9927C5
:10399000182F00270E94551E9927082B192B0E94CB
:1039A000551E682FC8010E94F41DB2CF853611F54F
:1039B0008091E2008537C1F41092E1001092E0009E
:1039C00020E030E083E0F90180935700E89507B6E6
:1039D00000FCFDCF20583F4F88E32030380790F39C
:1039E0003093E1002093E00081E180935700E89557
:1039F0008DE058C0853451F488E190E028E00FB69E
:103A0000F894A89581BD0FBE21BDF2CF803581F31A
:103A10008C3471F3803711F483E544C0863421F48B
:103A200069E080E090E005C0823731F469E081E030
:103A300090E00E94691E36C08E3421F469E083E074
:103A400090E0F7CF813569F1843729F485E70E944A
:103A5000401E80E027C08857823018F40E94551E0F
:103A6000C7CF643529F40E94551E8093E200C0CF71
:103A7000633519F40E94471C4BCF663529F480E367
:103A80000E94401E84E30EC0633741F483E00E942D
:103A9000401E84E90E94401E8EE104C06B3109F48F
:103AA00037CF8FE30E94401E33CFDF92EF92FF9219
:103AB0000F931F93CF93DF938C01D62E60E070E0BD
:103AC000EB01C05ADF4F7B010894E11CF11C601729
:103AD000710718F40E94551E01C08FEF8883B7014B
:103AE0006038710568F360E070E0C091E000D0914B
:103AF000E1008CB399279C012270307081FDF9CFD1
:103B00008091E200853709F066C0FFB6F89486E43C
:103B1000D81609F03EC04091E0005091E100DB0171
:103B2000A05ABF4F8D91282F33278D919927982F19
:103B30008827282B392B6E5F7F4F81E00901FA011E
:103B400080935700E89511244E5F5F4F025010405C
:103B500049F75093E1004093E000C07885E0FE0112
:103B600080935700E89507B600FCFDCF81E1809374
:103B70005700E8958091E0009091E1009C01207849
:103B80008217930731F020583F4F3093E100209384
:103B9000E00085E4D816D9F4FB01E05AFF4F80918C
:103BA000E0008EBB8091E0009091E100292F332747
:103BB0002FBB01969093E1008093E00081918DBB33
:103BC000E29AE19AE199FECF0150104041F7FFBE21
:103BD0008DE090E001C0C901DF91CF911F910F915D
:103BE000FF90EF90DF900895FF920F931F93CF9374
:103BF000DF93EC01FFB6F894E199FECF6534B1F4A0
:103C00008091E0008EBB8091E0009091E100292F2F
:103C100033272FBB01969093E1008093E000E09A58
:103C20008DB30E94401E219759F719C060E0809122
:103C3000E0009091E1000E94691E8C010E94401EEC
:103C4000812F99270E94401E8091E0009091E10011
:103C500002969093E1008093E000229739F7FFBE2F
:103C6000DF91CF911F910F91FF9008959C01832FB9
:103C7000992780BD29B988E18AB986E880BD089571
:103C800020E030E08CB90FB607FE0BC05E990BC088
:103C90002F5F3F4F5E9907C087E220313807C4F39A
:103CA00002C05E9BFECF5E9A089580E090E00FB662
:103CB00007FE0AC05F990AC001965F9907C027E214
:103CC00080319207CCF302C05F9BFECF8CB1992765
:103CD0000895FC0160FD60935700C895802DE39521
:063CE000C895902D089527
:0400000300003800C1
:00000001FF

View File

@ -1,77 +0,0 @@
:103800000C942A1C0C94451C0C94451C0C94451CCF
:103810000C94451C0C94451C0C94451C0C94451CA4
:103820000C94451C0C94451C0C94451C0C94451C94
:103830000C94451C0C94451C0C94451C0C94451C84
:103840000C94451C0C94451C0C94451C0C94451C74
:103850000C94451C11241FBECFE5D4E0DEBFCDBFC4
:1038600010E0A0E6B0E0EAEAFCE302C005900D92A9
:10387000A036B107D9F710E0A0E6B0E001C01D9274
:10388000A33EB107E1F70C945D1C0C94001C81E48D
:103890000E94221E86E50E94221E82E50E94221EB0
:1038A00082E40E94221E8FE40E94221E8FE40E9466
:1038B000221E84E50E94221E0895CFE5D4E0DEBFDB
:1038C000CDBF81E085BF82E085BF60E087E190E009
:1038D0000E94181E0E94371E682F813611F489E558
:1038E000C3C08134A9F40E94371E99279093E10048
:1038F0008093E000182F00270E94371E9927082B7D
:10390000192B000F111F1093E1000093E00052C02B
:10391000823641F489E50E94221E80E00E94221E28
:1039200080E8A2C0823489F40E94371E9927182F9C
:1039300000270E94371E9927082B192B0E94371E3B
:10394000682FC8010E94371D8FC0873689F40E94F6
:10395000371E9927182F00270E94371E9927082BFA
:10396000192B0E94371E682FC8010E94D61DB2CFA6
:10397000853611F58091E2008537C1F41092E1009F
:103980001092E00020E030E083E0F90180935700DE
:10399000E89507B600FCFDCF20583F4F88E3203064
:1039A000380790F33093E1002093E00081E18093A9
:1039B0005700E8958DE058C0853451F488E190E0D7
:1039C00028E00FB6F894A89581BD0FBE21BDF2CFB7
:1039D000803581F38C3471F3803711F483E544C072
:1039E000863421F469E080E090E005C0823731F44C
:1039F00069E081E090E00E944B1E36C08E3421F4D5
:103A000069E083E090E0F7CF813569F1843729F4EC
:103A100085E70E94221E80E027C08857823018F474
:103A20000E94371EC7CF643529F40E94371E809349
:103A3000E200C0CF633519F40E94471C4BCF6635B6
:103A400029F480E30E94221E84E30EC0633741F410
:103A500083E00E94221E84E90E94221E8EE104C09F
:103A60006B3109F437CF8FE30E94221E33CFDF92F0
:103A7000EF92FF920F931F93CF93DF938C01D62E7B
:103A800060E070E0EB01C05ADF4F7B010894E11C5D
:103A9000F11C6017710718F40E94371E01C08FEFE8
:103AA0008883B7016038710568F360E070E0C09109
:103AB000E000D091E1008CB399279C012270307016
:103AC00081FDF9CF8091E200853709F066C0FFB62D
:103AD000F89486E4D81609F03EC04091E000509179
:103AE000E100DB01A05ABF4F8D91282F33278D9124
:103AF0009927982F8827282B392B6E5F7F4F81E0DD
:103B00000901FA0180935700E89511244E5F5F4F39
:103B10000250104049F75093E1004093E000C07814
:103B200085E0FE0180935700E89507B600FCFDCFC5
:103B300081E180935700E8958091E0009091E10049
:103B40009C0120788217930731F020583F4F309323
:103B5000E1002093E00085E4D816D9F4FB01E05A97
:103B6000FF4F8091E0008EBB8091E0009091E100DA
:103B7000292F33272FBB01969093E1008093E0001B
:103B800081918DBBE29AE19AE199FECF01501040FC
:103B900041F7FFBE8DE090E001C0C901DF91CF91F8
:103BA0001F910F91FF90EF90DF900895FF920F9378
:103BB0001F93CF93DF93EC01FFB6F894E199FECF0A
:103BC0006534B1F48091E0008EBB8091E00090916B
:103BD000E100292F33272FBB01969093E1008093BA
:103BE000E000E09A8DB30E94221E219759F719C078
:103BF00060E08091E0009091E1000E944B1E8C01FA
:103C00000E94221E812F99270E94221E8091E0008F
:103C10009091E10002969093E1008093E00022975A
:103C200039F7FFBEDF91CF911F910F91FF9008955B
:103C30009C01832F992780BD29B988E18AB986E83C
:103C400080BD089520E030E08CB90FB607FE0BC0B0
:103C50005E990BC02F5F3F4F5E9907C087E220310E
:103C60003807C4F302C05E9BFECF5E9A089580E0E1
:103C700090E00FB607FE0AC05F990AC001965F99EF
:103C800007C027E280319207CCF302C05F9BFECFD2
:103C90008CB199270895FC0160FD60935700C89589
:0A3CA000802DE395C895902D08953E
:0400000300003800C1
:00000001FF

118
main.c
View File

@ -1,9 +1,9 @@
/***************************************************************************** /*****************************************************************************
* *
* AVRPROG compatible boot-loader * AVRPROG compatible boot-loader
* Version : 0.4 (6. Apr. 2004) * Version : 0.5 (7. Apr. 2004)
* Compiler : avr-gcc 3.3.1 / avr-libc 1.0 * Compiler : avr-gcc 3.3.1 / avr-libc 1.0
* size : ( larger than 512 words :-( ) * size : depends on features and startup ( minmal features < 512 words)
* by : Martin Thomas, Kaiserslautern, Germany * by : Martin Thomas, Kaiserslautern, Germany
* eversmith@heizung-thomas.de * eversmith@heizung-thomas.de
* *
@ -41,10 +41,12 @@
* options for the newly created section. See the avr-libc FAQ, the avr- * options for the newly created section. See the avr-libc FAQ, the avr-
* libc's avr/boot.h documentation and the makefile for further details. * libc's avr/boot.h documentation and the makefile for further details.
* *
* Sorry, so far efforts to shrink to 512 words failed.
* See the makefile for information how to adopt the linker-settings to * See the makefile for information how to adopt the linker-settings to
* the selected Boot Size (_Bxxx below) * the selected Boot Size (_Bxxx below)
* *
* With BOOT_SIMPLE this bootloader has 0x3DE bytes size and should fit
* into a 512word bootloader-section.
*
****************************************************************************/ ****************************************************************************/
/* /*
Does not work so far: Does not work so far:
@ -53,34 +55,52 @@
*/ */
// programmers-notepad tabsize 4 // programmers-notepad tabsize 4
#define VERSION_HIGH '0'
#define VERSION_LOW '5'
#include <inttypes.h> #include <inttypes.h>
#include <avr/io.h> #include <avr/io.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include <avr/wdt.h> #include <avr/wdt.h>
/* BOOTICE-Mode - to flash the JTAGICE upgrade.ebn file. /* Port and Pin in this port that has to grounded
No startup-sequence in this mode. Jump directly to the (active low) to start the bootloader */
parser-loop on reset #define BLPORT PORTC
XTAL in BOOTICEMODE must be 7372800 Hz to be compatible #define BLPIN PINC
with the org. JTAGICE-Firmware */ #define BLPNUM PINC0
// #define BOOTICEMODE
// UART handling - some definitions from P. Fleury's Library - thanks /*
#define BAUDRATE 19200 Select startup-mode
* SIMPLE-Mode - Jump to bootloader main BL-loop if key is
pressed (Pin grounded) "during" reset or jump to the
application if the pin is not grounded (=pulled up by
internal pull-up-resistor)
* POWERSAVE-Mode - Startup is separated in two loops
which makes power-saving a little easier if no firmware
is on the chip. Needs more memory
* BOOTICE-Mode - to flash the JTAGICE upgrade.ebn file.
No startup-sequence in this mode. Jump directly to the
parser-loop on reset
XTAL in BOOTICEMODE must be 7372800 Hz to be compatible
with the org. JTAGICE-Firmware */
#define START_SIMPLE
//#define START_POWERSAVE
//#define START_BOOTICE
#ifndef BOOTICEMODE #ifndef START_BOOTICE
#define XTAL 3686400 #define XTAL 3686400
#else #else
#warning "BOOTICE mode - External Crystal/Oszillator must be 7,3728 MHz" #warning "BOOTICE mode - External Crystal/Oszillator must be 7,3728 MHz"
#define XTAL 7372800 #define XTAL 7372800
#endif #endif
// UART handling - some definitions from P. Fleury's Library - thanks
#define BAUDRATE 19200
#include "uart.h" #include "uart.h"
/* enable/disable readout of fuse and lock-bits /* enable/disable readout of fuse and lock-bits
(will not work for Mega169 since not supported by AVRPROG 1.37 */ (will not work for Mega169 since not supported by AVRPROG 1.37 */
#define ENABLEREADFUSELOCK // #define ENABLEREADFUSELOCK
/* enable/disable write of lock-bits /* enable/disable write of lock-bits
WARNING: lock-bits can not be reseted by bootloader (as far as I know) WARNING: lock-bits can not be reseted by bootloader (as far as I know)
@ -90,11 +110,10 @@
*/ */
// #define WRITELOCKBITS // #define WRITELOCKBITS
/* Select Boot Size (select one, comment out the others) /* Select Boot Size (select one, comment out the others) */
select at least _B1024 */
// NO! #define _B128 // NO! #define _B128
// NO! #define _B256 // NO! #define _B256
// NO! #define _B512 // MAYBE: #define _B512
#define _B1024 #define _B1024
//#define _B2048 //#define _B2048
@ -131,13 +150,16 @@ void send_boot(void)
sendchar('T'); sendchar('T');
} }
void (*jump_to_app)(void) = 0x0000;
int main(void) int main(void)
{ {
void (*funcptr)( void ) = 0x0000; // Set up function pointer unsigned short tempi;
unsigned short tempi;
char val; char val;
char OK = 1;
#ifdef START_POWERSAVE
char OK = 1;
#endif
MCUCR = (1<<IVCE); MCUCR = (1<<IVCE);
MCUCR = (1<<IVSEL); //move interruptvectors to the Boot sector MCUCR = (1<<IVSEL); //move interruptvectors to the Boot sector
@ -145,26 +167,24 @@ int main(void)
USART_Init(UART_BAUD_SELECT(BAUDRATE,XTAL),UARTSINGLE); // single speed USART_Init(UART_BAUD_SELECT(BAUDRATE,XTAL),UARTSINGLE); // single speed
// USART_Init(UART_BAUD_SELECT(BAUDRATE/2,XTAL),UARTDOUBLE); // double speed // USART_Init(UART_BAUD_SELECT(BAUDRATE/2,XTAL),UARTDOUBLE); // double speed
#if defined(START_POWERSAVE)
/* /*
This is an adoption of the Butterfly Bootloader startup-sequence. This is an adoption of the Butterfly Bootloader startup-sequence.
It may look a little strange but separating the login-loop from It may look a little strange but separating the login-loop from
the main parser-loop gives a lot a possibilities (timeout, sleep-modes the main parser-loop gives a lot a possibilities (timeout, sleep-modes
etc.). etc.).
*/ */
BLPORT = 0xFF; // Enable pullups on Port C
#ifndef BOOTICEMODE
PORTA = 0xFF; // Enable pullups on Port A
for(;OK;) for(;OK;)
{ {
if((PINA & (1<<PINA7))) if((BLPIN & (1<<BLPNUM)))
{ {
// jump to main app if PIN A7 is not grounded // jump to main app if PIN C0 is not grounded
PORTA = 0x00; // set to default BLPORT = 0x00; // set to default
MCUCR = (1<<IVCE); MCUCR = (1<<IVCE);
MCUCR = (0<<IVSEL); //move interruptvectors to the Application sector MCUCR = (0<<IVSEL); //move interruptvectors to the Application sector
funcptr(); // Jump to application sector jump_to_app(); // Jump to application sector
} }
else else
{ {
@ -182,14 +202,29 @@ int main(void)
else else
sendchar('?'); sendchar('?');
} }
// Power-Save code here
} }
#else
#elif defined(START_SIMPLE)
BLPORT = 0xFF; // Enable pullups on Port C
if((BLPIN & (1<<BLPNUM)))
{
// jump to main app if PIN C0 is not grounded
BLPORT = 0x00; // set to default
MCUCR = (1<<IVCE);
MCUCR = (0<<IVSEL); //move interruptvectors to the Application sector
jump_to_app(); // Jump to application sector
}
#elif defined(START_BOOTICE)
#warning "BOOTICE mode - no startup-condition" #warning "BOOTICE mode - no startup-condition"
#else
#error "Select START_ condition for bootloader in main.c"
#endif #endif
for(;;) for(;;)
{ {
val=recchar(); val=recchar();
if(val=='a') //Autoincrement? if(val=='a') //Autoincrement?
{ {
@ -380,7 +415,7 @@ int main(void)
#endif #endif
// end of ENABLEREADFUSELOCK section // end of ENABLEREADFUSELOCK section
else if(val=='t') // Return programmer type else if(val=='t') // Return device type
{ {
sendchar(devtype); sendchar(devtype);
sendchar(0); sendchar(0);
@ -405,8 +440,8 @@ int main(void)
else if (val=='V') // Return Software Version else if (val=='V') // Return Software Version
{ {
sendchar('0'); sendchar(VERSION_HIGH);
sendchar('4'); sendchar(VERSION_LOW);
} }
else if (val=='s') // Return Signature Byte else if (val=='s') // Return Signature Byte
@ -462,7 +497,10 @@ unsigned char BufferLoad(unsigned int size, unsigned char mem)
} while(size); // Loop until all bytes written } while(size); // Loop until all bytes written
/* commented out since not compatible with mega8 -
secondary benefit: saves memory
tempaddress &= 0xFF80; // Ensure the address points to the first byte in the page tempaddress &= 0xFF80; // Ensure the address points to the first byte in the page
*/
//write_page((tempaddress),0x05); // Program page contents //write_page((tempaddress),0x05); // Program page contents
boot_page_write(tempaddress); boot_page_write(tempaddress);
@ -470,15 +508,19 @@ unsigned char BufferLoad(unsigned int size, unsigned char mem)
// write_page(tempaddress,(1<<RWWSRE) + (1<<SPMEN)); // write_page(tempaddress,(1<<RWWSRE) + (1<<SPMEN));
boot_rww_enable(); //Re-enable the RWW section boot_rww_enable(); //Re-enable the RWW section
/* commented out since not compatible with mega8
if (address != (address & 0xFF80)) if (address != (address & 0xFF80))
{ // Ensure that the address points to the beginning of the next page { // Ensure that the address points to the beginning of the next page
address &= 0xFF80; address &= 0xFF80;
address += SPM_PAGESIZE; address += SPM_PAGESIZE;
} }
*/
} // End FLASH } // End FLASH
if (mem == 'E') // Start EEPROM if (mem == 'E') // Start EEPROM
{ {
address>>=1;
do { do {
EEARL = address; // Setup EEPROM address EEARL = address; // Setup EEPROM address
EEARH = (address >> 8); EEARH = (address >> 8);
@ -508,16 +550,20 @@ unsigned char BufferLoad(unsigned int size, unsigned char mem)
void BlockRead(unsigned int size, unsigned char mem) void BlockRead(unsigned int size, unsigned char mem)
{ {
unsigned int data; unsigned int data;
// Disable interrupts if needed
/*
unsigned char sreg; unsigned char sreg;
// Disable interrupts. sreg = SREG;
sreg = SREG;
cli(); cli();
*/
my_eeprom_busy_wait(); my_eeprom_busy_wait();
if (mem == 'E') // Read EEPROM if (mem == 'E') // Read EEPROM
{ {
// address>>=1; // not needed here - hmm, somehow inconsistant TODO
do { do {
EEARL = address; // Setup EEPROM address EEARL = address; // Setup EEPROM address
EEARH = (address >> 8); EEARH = (address >> 8);
@ -538,6 +584,6 @@ void BlockRead(unsigned int size, unsigned char mem)
} while (size); // Repeat until all block has been read } while (size); // Repeat until all block has been read
} }
// Re-enable interrupts (if they were ever enabled). // Re-enable interrupts (if they were ever enabled).
SREG=sreg; /*SREG=sreg;*/
} }

View File

@ -31,7 +31,21 @@
# MCU name # MCU name
MCU = atmega16 ## MCU = atmega16
MCU = atmega8
################## BOOTLOADER ######################
# mt: Boot loader support. So far not done with a separate section
# to get the interrupt vector into the bootloader area.
# Bootloader address in datasheet and stk500 is given as
# "word", gcc toolchain needs "byte"-address
# (see LDFLAGS further down)
# 0x1C00*2=0x3800 for ATmega16 1024 words Boot Size
## MT_BOOTLOADER_ADDRESS = 3800
# 0x0C00*2=0x1800 for ATmega8 1024 words Boot Size
MT_BOOTLOADER_ADDRESS = 1800
# Output format. (can be srec, ihex, binary) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -123,11 +137,8 @@ LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
LDFLAGS += -lm LDFLAGS += -lm
################## BOOTLOADER ###################### ################## BOOTLOADER ######################
# mt: Boot loader support. So far not done with a separate section # MT_BOOTLOADER_ADDRESS (=Start of Boot Loader section
# to get the interrupt vector into the bootloader area. # in bytes - not words) is defined above.
# bootloader address in datasheet and stk500 is given as
# "word", gcc toolchain needs "byte"-address (here: 0x1C00*2)
MT_BOOTLOADER_ADDRESS = 3800
LDFLAGS += -Wl,--section-start=.text=$(MT_BOOTLOADER_ADDRESS) LDFLAGS += -Wl,--section-start=.text=$(MT_BOOTLOADER_ADDRESS)
# Programming support using avrdude. Settings and variables. # Programming support using avrdude. Settings and variables.

View File

@ -15,6 +15,18 @@
====================================================== ======================================================
7. Apr. 2004 - Version 0.5
* added different startup-methods
* compatible with ATmega8 now
* included makefile adopted to ATmega8 now
(ATmega16 options still available)
* fixed jump to application which did not work
reliably before
* tested with ATmega8
* minimal options and startup-code result in
bootloader-size < 512 words
6. Apr. 2004 - Version 0.4 6. Apr. 2004 - Version 0.4
* Buffered read of chars from UART during programming * Buffered read of chars from UART during programming
@ -29,7 +41,7 @@ out during the development of the STK-500-compatible
bootloader. But setting lock-bits still does not bootloader. But setting lock-bits still does not
work with this bootloader. work with this bootloader.
* read of the low-fuse byte works (high byte still TODO) * read of the low-fuse byte works (high byte still TODO)
* read of the lock-byte works (wirte still TODO) * read of the lock-byte works (write still TODO)
27. Mar 2004 - Version 0.3 27. Mar 2004 - Version 0.3