From 70d5a20eb3ea3748a2c3aa32d5af029b24bc2dbf Mon Sep 17 00:00:00 2001 From: Olaf Rempel Date: Sat, 20 May 2006 00:30:03 +0200 Subject: [PATCH] update doc - move remaining defines into main.c --- main.c | 89 +++++++++++++++++++++++++++++++++++++------------------- makefile | 39 +++---------------------- 2 files changed, 63 insertions(+), 65 deletions(-) diff --git a/main.c b/main.c index 8e0c39c..c86b017 100644 --- a/main.c +++ b/main.c @@ -1,8 +1,8 @@ /***************************************************************************** * * AVRPROG compatible boot-loader -* Version : 0.75 (Feb. 2006) -* Compiler : avr-gcc 3.4.1 / avr-libc 1.0.2 +* Version : 0.80 (May 2006) +* Compiler : avr-gcc 3.4.6 / avr-libc 1.4.4 * size : depends on features and startup ( minmal features < 512 words) * by : Martin Thomas, Kaiserslautern, Germany * eversmith@heizung-thomas.de @@ -15,6 +15,7 @@ * Additional code and improvements contributed by: * - Uwe Bonnes * - Bjoern Riemer +* - Olaf Rempel * * * Tested with ATmega8, ATmega16, ATmega32, ATmega128, AT90CAN128 @@ -33,23 +34,18 @@ * **************************************************************************** * -* The boot interrupt vector is included (this bootloader is completly in -* ".text" section). If you need this space for further functions you have to -* add a separate section for the bootloader-functions and add an attribute -* for this section to _all_ function prototypes of functions in the loader. -* With this the interrupt vector will be placed at .0000 and the bootloader -* code (without interrupt vector) at the adress you define in the linker -* 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. -* * See the makefile for information how to adopt the linker-settings to -* the selected Boot Size (_Bxxx below) +* the selected Boot Size (BOOTSIZE=xxxx), the AVR clock-frequency and the +* MCU-type in * -* With BOOT_SIMPLE this bootloader has 0x3DE bytes size and should fit -* into a 512word bootloader-section. -* -* Set AVR clock-frequency and the baudrate below, set MCU-type in -* makefile. +* With BOOT_SIMPLE this bootloader has +* 0x2EA - atmega8 +* 0x368 - atmega16 +* 0x382 - atmega169 +* 0x368 - atmega32 +* 0x360 - atmega128 +* 0x372 - at90can128 +* bytes size and should fit into a 512word bootloader-section. * ****************************************************************************/ /* @@ -73,25 +69,58 @@ /* use second UART on mega128 / can128 */ //#define UART_USE_SECOND +/* + * Pin "STARTPIN" on port "STARTPORT" in this port has to grounded + * (active low) to start the bootloader + */ +#define BLPORT PORTB +#define BLDDR DDRB +#define BLPIN PINB +#define BLPNUM PINB0 + +/* + * 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 + * F_CPU in BOOTICEMODE must be 7372800 Hz to be compatible + * with the org. JTAGICE-Firmware + * WAIT-mode waits 1 sec for the S command if nothing is recived + * then the user prog is started .. + */ +#define START_SIMPLE +//#define START_WAIT +//#define START_POWERSAVE +//#define START_BOOTICE + +/* + * enable/disable readout of fuse and lock-bits + * (will not work for Mega169 since not supported by AVRPROG 1.37 + */ +//#define ENABLEREADFUSELOCK + + /* enable/disable write of lock-bits + * WARNING: lock-bits can not be reseted by bootloader (as far as I know) + * Only protection no unprotection, "chip erase" from bootloader only + * clears the flash but does no real "chip erase" (this is not possible + * with a bootloader as far as I know) + * Keep this undefined! + */ +//#define WRITELOCKBITS + #include #include #include #include #include -/* enable/disable readout of fuse and lock-bits - (will not work for Mega169 since not supported by AVRPROG 1.37 */ -#define ENABLEREADFUSELOCK - -/* enable/disable write of lock-bits - WARNING: lock-bits can not be reseted by bootloader (as far as I know) - Only protection no unprotection, "chip erase" from bootloader only - clears the flash but does no real "chip erase" (this is not possible - with a bootloader as far as I know) - Keep this undefined! - */ -// #define WRITELOCKBITS - #include "chipdef.h" uint8_t gBuffer[SPM_PAGESIZE]; diff --git a/makefile b/makefile index 8a624cb..a775d4a 100644 --- a/makefile +++ b/makefile @@ -39,40 +39,12 @@ MCU = atmega8 ## MCU = atmega32 ## MCU = at90can128 -#Pin "STARTPIN" on port "STARTPORT" in this port has to grounded -# (active low) to start the bootloader -BLPORT = PORTB -BLDDR = DDRB -BLPIN = PINB -BLPNUM = PINB0 - -# 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 -# F_CPU in BOOTICEMODE must be 7372800 Hz to be compatible -# with the org. JTAGICE-Firmware */ -# * 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 - #/* Select Boot Size in Words (select one, comment out the others) */ ## NO! BOOTSIZE=128 ## NO! BOOTSIZE=256 ## MAYBE: BOOTSIZE=512 -#BOOTSIZE=512 -BOOTSIZE=1024 +BOOTSIZE=512 +#BOOTSIZE=1024 ##BOOTSIZE=2048 @@ -220,11 +192,8 @@ EXTRAINCDIRS = CSTANDARD = -std=gnu99 # Place -D or -U options here -CDEFS = -DBLPORT=$(BLPORT) -DBLDDR=$(BLDDR) -DBLPIN=$(BLPIN) -DBLPNUM=$(BLPNUM) -CDEFS += -D$(STARTMODE) -DBOOTSIZE=$(BOOTSIZE) -ifdef XTAL - CDEFS += -DXTAL=$(XTAL) -endif +CDEFS = -DBOOTSIZE=$(BOOTSIZE) + # Place -I options here CINCS =