update doc
- move remaining defines into main.c
This commit is contained in:
parent
b253baf838
commit
70d5a20eb3
89
main.c
89
main.c
@ -1,8 +1,8 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*
|
*
|
||||||
* AVRPROG compatible boot-loader
|
* AVRPROG compatible boot-loader
|
||||||
* Version : 0.75 (Feb. 2006)
|
* Version : 0.80 (May 2006)
|
||||||
* Compiler : avr-gcc 3.4.1 / avr-libc 1.0.2
|
* Compiler : avr-gcc 3.4.6 / avr-libc 1.4.4
|
||||||
* size : depends on features and startup ( minmal features < 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
|
||||||
@ -15,6 +15,7 @@
|
|||||||
* Additional code and improvements contributed by:
|
* Additional code and improvements contributed by:
|
||||||
* - Uwe Bonnes
|
* - Uwe Bonnes
|
||||||
* - Bjoern Riemer
|
* - Bjoern Riemer
|
||||||
|
* - Olaf Rempel
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Tested with ATmega8, ATmega16, ATmega32, ATmega128, AT90CAN128
|
* 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
|
* 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
|
* With BOOT_SIMPLE this bootloader has
|
||||||
* into a 512word bootloader-section.
|
* 0x2EA - atmega8
|
||||||
*
|
* 0x368 - atmega16
|
||||||
* Set AVR clock-frequency and the baudrate below, set MCU-type in
|
* 0x382 - atmega169
|
||||||
* makefile.
|
* 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 */
|
/* use second UART on mega128 / can128 */
|
||||||
//#define UART_USE_SECOND
|
//#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 <stdint.h>
|
#include <stdint.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
#include <avr/boot.h>
|
#include <avr/boot.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
/* 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"
|
#include "chipdef.h"
|
||||||
|
|
||||||
uint8_t gBuffer[SPM_PAGESIZE];
|
uint8_t gBuffer[SPM_PAGESIZE];
|
||||||
|
39
makefile
39
makefile
@ -39,40 +39,12 @@ MCU = atmega8
|
|||||||
## MCU = atmega32
|
## MCU = atmega32
|
||||||
## MCU = at90can128
|
## 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) */
|
#/* Select Boot Size in Words (select one, comment out the others) */
|
||||||
## NO! BOOTSIZE=128
|
## NO! BOOTSIZE=128
|
||||||
## NO! BOOTSIZE=256
|
## NO! BOOTSIZE=256
|
||||||
## MAYBE: BOOTSIZE=512
|
## MAYBE: BOOTSIZE=512
|
||||||
#BOOTSIZE=512
|
BOOTSIZE=512
|
||||||
BOOTSIZE=1024
|
#BOOTSIZE=1024
|
||||||
##BOOTSIZE=2048
|
##BOOTSIZE=2048
|
||||||
|
|
||||||
|
|
||||||
@ -220,11 +192,8 @@ EXTRAINCDIRS =
|
|||||||
CSTANDARD = -std=gnu99
|
CSTANDARD = -std=gnu99
|
||||||
|
|
||||||
# Place -D or -U options here
|
# Place -D or -U options here
|
||||||
CDEFS = -DBLPORT=$(BLPORT) -DBLDDR=$(BLDDR) -DBLPIN=$(BLPIN) -DBLPNUM=$(BLPNUM)
|
CDEFS = -DBOOTSIZE=$(BOOTSIZE)
|
||||||
CDEFS += -D$(STARTMODE) -DBOOTSIZE=$(BOOTSIZE)
|
|
||||||
ifdef XTAL
|
|
||||||
CDEFS += -DXTAL=$(XTAL)
|
|
||||||
endif
|
|
||||||
# Place -I options here
|
# Place -I options here
|
||||||
CINCS =
|
CINCS =
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user