bootloadHID/firmware/Makefile modified to atmega164a
bootloadHID/firmware/bootloader.h modified to use BL/RUN switch to detect bootload mode.
This commit is contained in:
parent
1be25c4434
commit
38e51a91c5
|
|
@ -6,6 +6,9 @@
|
||||||
# Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
# Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
# License: GNU GPL v2 (see License.txt)
|
# License: GNU GPL v2 (see License.txt)
|
||||||
# This Revision: $Id: Makefile 788 2010-05-30 20:54:41Z cs $
|
# This Revision: $Id: Makefile 788 2010-05-30 20:54:41Z cs $
|
||||||
|
#
|
||||||
|
# Edited for INL Retro-Prog "kazzo" project
|
||||||
|
# Uses Atmega164p
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Configure the following variables according to your AVR. The example below
|
# Configure the following variables according to your AVR. The example below
|
||||||
|
|
@ -14,29 +17,56 @@
|
||||||
# make flash # to load the boot loader into flash
|
# make flash # to load the boot loader into flash
|
||||||
# make lock # to protect the boot loader from overwriting
|
# make lock # to protect the boot loader from overwriting
|
||||||
|
|
||||||
DEVICE = atmega8
|
DEVICE = atmega164a
|
||||||
BOOTLOADER_ADDRESS = 1800
|
#BOOTLOADER_ADDRESS = datasheet: 0x1C00 * 2words/address = 0x3800
|
||||||
F_CPU = 12000000
|
BOOTLOADER_ADDRESS = 3800
|
||||||
FUSEH = 0xc0
|
F_CPU = 16000000
|
||||||
FUSEL = 0xBF
|
LOCK = 0xFB
|
||||||
LOCK = 0x0F
|
EFUSE = 0xFD
|
||||||
# Fuse high byte:
|
FUSEH = 0x98
|
||||||
# 0xc0 = 1 1 0 0 0 0 0 0 <-- BOOTRST (boot reset vector at 0x1800)
|
FUSEL = 0xDF
|
||||||
# ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0
|
#
|
||||||
# | | | | | +-------- BOOTSZ1
|
# Lock bit byte: 0xFB
|
||||||
# | | | | + --------- EESAVE (preserve EEPROM over chip erase)
|
# Default: all set 0xFF
|
||||||
# | | | +-------------- CKOPT (full output swing)
|
# +------------------- unused/reserved (def prgm = 1)
|
||||||
# | | +---------------- SPIEN (allow serial programming)
|
# | +---------------- BLB12 read app section 1=allowed
|
||||||
# | +------------------ WDTON (WDT not always on)
|
# | | +-------------- BLB11 write app section 1=allowed
|
||||||
# +-------------------- RSTDISBL (reset pin is enabled)
|
# | | | +---------- BLB02 read BL section 1=allowed
|
||||||
# Fuse low byte:
|
# | | | | +-------- BLB01 write BL section 0=not allowed
|
||||||
# 0xBF = 1 0 1 1 1 1 1 1
|
# / \ v v v v /-v---- LB[1:0] lock chip 11=unlocked
|
||||||
# ^ ^ \ / \--+--/
|
# 0xFB = 1 1 1 1 1 0 1 1
|
||||||
# | | | +------- CKSEL 3..0 (external >8M crystal)
|
#
|
||||||
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled)
|
#
|
||||||
# | +------------------ BODEN (BrownOut Detector enabled)
|
# Extended fuse byte: 0xFD
|
||||||
# +-------------------- BODLEVEL (2.7V)
|
# Default: all set 0xFF
|
||||||
|
# +--------------- unused/reserved (def prgm = 1)
|
||||||
|
# | +------ BODLEVEL[2:0]
|
||||||
|
# /----+----\ /-+-\ 111=BOD disbl 110=BOD 1.8V
|
||||||
|
# 0xFD = 1 1 1 1 1 1 0 1 101=BOD 2.7V 100=BOD 4.3V
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Fuse high byte: 0x98
|
||||||
|
# Default: 0x99
|
||||||
|
# +-------------------- OCDEN 1=On-Chip-Debugger disabled
|
||||||
|
# | +------------------ JTAGEN 0=JTAG enabled
|
||||||
|
# | | +---------------- SPIEN 0=SPI prgm/dwnld enabled
|
||||||
|
# | | | +-------------- WDTON 1=WDT not always on
|
||||||
|
# | | | |
|
||||||
|
# | | | | +---------- EESAVE 1=eeprom not preserved w/chip erase
|
||||||
|
# | | | | | +------- BOOTSZ[1:0] bootloader size
|
||||||
|
# v v v v v / \ 00=1Kwords App end= 0x1BFF BL start=0x1C00
|
||||||
|
# 0x98 = 1 0 0 1 1 0 0 0 <-- BOOTRST 0=reset vector-> BL section
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Fuse low byte: 0xDF
|
||||||
|
# Default: 0x62
|
||||||
|
# +-------------------- CKDIV8 1=Clock not divided by 8
|
||||||
|
# | +------------------ CKOUT 1=Don't allow CLK O/P on PORTB1
|
||||||
|
# | | +--------------- SUT[1:0] 01=xtal BOD enabled
|
||||||
|
# | | | +------- CKSEL[3:0] 1111=low pwr xtal 8-16Mhz
|
||||||
|
# v v / \ /--^--\ [3:1] 111=low power 8-16Mhz
|
||||||
|
# 0xDF = 1 1 0 1 1 1 1 1 [0] 1= xtal
|
||||||
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
AVRDUDE = avrdude -c stk500v2 -P avrdoper -p $(DEVICE)
|
AVRDUDE = avrdude -c stk500v2 -P avrdoper -p $(DEVICE)
|
||||||
|
|
@ -74,7 +104,7 @@ readflash:
|
||||||
$(AVRDUDE) -U flash:r:read.hex:i
|
$(AVRDUDE) -U flash:r:read.hex:i
|
||||||
|
|
||||||
fuse:
|
fuse:
|
||||||
$(AVRDUDE) -U hfuse:w:$(FUSEH):m -U lfuse:w:$(FUSEL):m
|
$(AVRDUDE) -U hfuse:w:$(FUSEH):m -U lfuse:w:$(FUSEL):m -U efuse:w:$(EFUSE)
|
||||||
|
|
||||||
lock:
|
lock:
|
||||||
$(AVRDUDE) -U lock:w:$(LOCK):m
|
$(AVRDUDE) -U lock:w:$(LOCK):m
|
||||||
|
|
@ -99,3 +129,7 @@ disasm: main.bin
|
||||||
|
|
||||||
cpp:
|
cpp:
|
||||||
$(COMPILE) -E main.c
|
$(COMPILE) -E main.c
|
||||||
|
|
||||||
|
size: ${TARGET}
|
||||||
|
@echo
|
||||||
|
@avr-size -C --mcu=${MCU} ${TARGET}
|
||||||
|
|
|
||||||
|
|
@ -39,15 +39,15 @@ these macros are defined, the boot loader usees them.
|
||||||
|
|
||||||
/* ---------------------------- Hardware Config ---------------------------- */
|
/* ---------------------------- Hardware Config ---------------------------- */
|
||||||
|
|
||||||
#define USB_CFG_IOPORTNAME B
|
#define USB_CFG_IOPORTNAME D
|
||||||
/* This is the port where the USB bus is connected. When you configure it to
|
/* This is the port where the USB bus is connected. When you configure it to
|
||||||
* "B", the registers PORTB, PINB and DDRB will be used.
|
* "B", the registers PORTB, PINB and DDRB will be used.
|
||||||
*/
|
*/
|
||||||
#define USB_CFG_DMINUS_BIT 0
|
#define USB_CFG_DMINUS_BIT 4
|
||||||
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
|
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
|
||||||
* This may be any bit in the port.
|
* This may be any bit in the port.
|
||||||
*/
|
*/
|
||||||
#define USB_CFG_DPLUS_BIT 1
|
#define USB_CFG_DPLUS_BIT 2
|
||||||
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
|
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
|
||||||
* This may be any bit in the port. Please note that D+ must also be connected
|
* This may be any bit in the port. Please note that D+ must also be connected
|
||||||
* to interrupt pin INT0! [You can also use other interrupts, see section
|
* to interrupt pin INT0! [You can also use other interrupts, see section
|
||||||
|
|
@ -105,7 +105,7 @@ these macros are defined, the boot loader usees them.
|
||||||
* an example: http://git.lochraster.org:2080/?p=fd0/usbload;a=tree
|
* an example: http://git.lochraster.org:2080/?p=fd0/usbload;a=tree
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TIMEOUT_ENABLED 1
|
#define TIMEOUT_ENABLED 0
|
||||||
/* If TIMEOUT_ENABLED is defined to 1 then the boot loader will always load
|
/* If TIMEOUT_ENABLED is defined to 1 then the boot loader will always load
|
||||||
* and stay active until the programmer closes the connection or the time
|
* and stay active until the programmer closes the connection or the time
|
||||||
* out period has elapsed. Since the boot loader always loads there is no
|
* out period has elapsed. Since the boot loader always loads there is no
|
||||||
|
|
@ -131,7 +131,8 @@ these macros are defined, the boot loader usees them.
|
||||||
#ifndef __ASSEMBLER__ /* assembler cannot parse function definitions */
|
#ifndef __ASSEMBLER__ /* assembler cannot parse function definitions */
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
|
||||||
#define JUMPER_BIT 7 /* jumper is connected to this bit in port D, active low */
|
#define JUMPER_PORT PORTD /* jumper is connected to this port */
|
||||||
|
#define JUMPER_BIT 6 /* jumper is connected to this bit in port D, active low */
|
||||||
|
|
||||||
#ifndef MCUCSR /* compatibility between ATMega8 and ATMega88 */
|
#ifndef MCUCSR /* compatibility between ATMega8 and ATMega88 */
|
||||||
# define MCUCSR MCUSR
|
# define MCUCSR MCUSR
|
||||||
|
|
@ -144,7 +145,7 @@ these macros are defined, the boot loader usees them.
|
||||||
static inline void bootLoaderInit(void)
|
static inline void bootLoaderInit(void)
|
||||||
{
|
{
|
||||||
#if !TIMEOUT_ENABLED
|
#if !TIMEOUT_ENABLED
|
||||||
PORTD |= (1 << JUMPER_BIT); /* activate pull-up */
|
JUMPER_PORT |= (1 << JUMPER_BIT); /* activate pull-up */
|
||||||
_delay_us(10); /* wait for levels to stabilize */
|
_delay_us(10); /* wait for levels to stabilize */
|
||||||
#endif
|
#endif
|
||||||
if(!(MCUCSR & (1 << EXTRF))) /* If this was not an external reset, ignore */
|
if(!(MCUCSR & (1 << EXTRF))) /* If this was not an external reset, ignore */
|
||||||
|
|
@ -156,12 +157,11 @@ static inline void bootLoaderExit(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if !TIMEOUT_ENABLED
|
#if !TIMEOUT_ENABLED
|
||||||
PORTD = 0; /* undo bootLoaderInit() changes */
|
JUMPER_PORT = 0; /* undo bootLoaderInit() changes */
|
||||||
#else
|
#else
|
||||||
TCCR1B = 0; // turn off timer1 and reset to initial value
|
TCCR1B = 0; // turn off timer1 and reset to initial value
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DDRC = 0; // turn off LEDs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TIMEOUT_ENABLED
|
#if !TIMEOUT_ENABLED
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue