Skip to content

Commit b454705

Browse files
committed
made changes to core to support more than 2 serial ports, and to support some
of the (major) differences in the 'E' series and some minor tweeks for 'A'. Also added variant and bootloader for 'cc0 atxmega32e5 breakout' board.
1 parent 4a761bf commit b454705

26 files changed

+21188
-256
lines changed

bootloaders/cc0_atxmega_e5/Makefile

+189
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# Makefile for xmega bootloader for ATxmega32e5 processor
2+
#
3+
# (some comments from original retained for reference)
4+
#
5+
# Makefile for ATmegaBOOT
6+
# E.Lins, 18.7.2005
7+
# $Id: Makefile,v 1.4 2008/10/05 17:41:43 cvs Exp $
8+
#
9+
10+
# program name should not be changed...
11+
PROGRAM = xmegaBOOT
12+
13+
# enter the parameters for the avrdude isp tool
14+
ISPTOOL = avrispmkii
15+
ISPPORT = usb
16+
ISPSPEED =
17+
18+
# added by me - conf file is 'special' for the xmega
19+
ISPCONF = ./avrdude.conf
20+
21+
22+
# TODO: have multiple CPU-based targets that build the 'xmega' target but for a specific CPU
23+
MCU_TARGET = atxmega32e5
24+
BUILD_MCU_TARGET = atxmega32e5
25+
26+
# xmega32 bootloader starts at 8000H
27+
LDSECTION = --section-start=.text=0x8000
28+
29+
30+
# fuses are a little different for the xmega. these values are derived from
31+
# experimentation. They do NOT lock any of the NVRAM sections after flashing
32+
33+
34+
# xmega fuse assignments
35+
36+
# see pg 418 in 'E' manual, sect 28.12.1 'External Programming'
37+
# this gives you the correct addresses for everything for avrdude.conf
38+
39+
# lockbits - must have BOTH bits 0 and 1 SET or you'll have to chip erase to get them back
40+
# bit assignments: 11 = NOLOCK, 10 = WLOCK, 01 = RLOCK, 00 = RWLOCK (typically)
41+
# bit 7:6 bootloader bit 5:4 application bit 3:2 app table bit 1:0 programming interface
42+
#
43+
# to ONLY lock the bootloader, set LOCKBITS to 0xBF (bit 6 clear, all others set)
44+
#LOCKBITS_LOCK=0xFF
45+
LOCKBITS_LOCK=0xBF
46+
LOCKBITS_UNLOCK=0xFF
47+
48+
# 4.13.1
49+
# FUSEBYTE1 - watchdog timer bits - set to FF for now - see 9.7.1 and 9.7.2
50+
FUSE1=0xFF
51+
52+
# 4.13.2
53+
# FUSEBYTE2 - bit 6 = STARTUP (0 for bootloader, 1 for app address 0000)
54+
# bit 5 = TOSCSEL (set to 1, always - implies 'shared' when applicable)
55+
# bits 1:0 = sleep BOD mode/disable 11 to disable, 10 or 01 otherwise (see manual)
56+
#11111111 = FF (bit 6 set)
57+
#10111111 = BF (bit 6 clear)
58+
FUSE2=0xBF
59+
60+
61+
# 4.13.3
62+
# FUSEBYTE4 bit 4 = reset disable (0 to disable, 1 = normal)
63+
# bits 3:2 = startup time delay (00 = 64, 01 = 4, 11 = 0)
64+
# bit 1 = watchdog timer config lock (0 to lock, 1 = unlocked)
65+
# all other bits should be 1 (note bit 0 may be read as a 0!)
66+
FUSE4=0xFF
67+
68+
69+
# 4.13.4
70+
# FUSEBYTE5 bits 5:4 = (running) BOD mode/disable 11 to disable, 10 or 01 otherwise (see manual)
71+
# bit 3 = 'preserve EEPROM during chip erase' - 0 to NOT erase EEPROM, 1 to erase
72+
# bits 2:0 = BOD level - see table 8-2 - 000 = 1.6, 111 = 3.0 at 0.2v increments
73+
#FUSE5=0xF8
74+
#FUSE5=0xF0
75+
FUSE5=0xEA
76+
# EA enables undervolts with mode 10 (continuous) and setting at 2.6v
77+
# TODO: determine if this is the best setting to use
78+
79+
#FUSEBYTE6 bit 7:6 are 'fault actions' for timers 5 and 4 (1 for default)
80+
# bits 5:0 are the corresponding value output on fault (inverted)
81+
FUSE6=0xFF
82+
83+
84+
#/usr/local/bin/avrdude -C/home/zelgadis/boardformula/avrdude.conf -p${MCU_TARGET} -cavrispmkII -Pusb -e \
85+
# -Ulockbits:w:${LOCKBITS_UNLOCK}:m -Ufuse1:w:${FUSE1}:m -Ufuse2:w:${FUSE2}:m \
86+
# -Ufuse4:w:${FUSE4}:m -Ufuse5:w:${FUSE5}:m -Ufuse6:w:${FUSE6}:m
87+
88+
#/usr/local/bin/avrdude -C/home/zelgadis/boardformula/avrdude.conf -p${MCU_TARGET} -cavrispmkII -Pusb \
89+
# -Uflash:w:${hex_file}:i -Ulockbits:w:${LOCKBITS_LOCK}:m
90+
91+
92+
OBJ = $(PROGRAM).o
93+
#OBJ += sp_driver.o
94+
OPTIMIZE = -O2
95+
96+
DEFS =
97+
LIBS =
98+
99+
CC = avr-gcc
100+
101+
OBJCOPY = avr-objcopy
102+
OBJDUMP = avr-objdump
103+
104+
CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(BUILD_MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
105+
LDFLAGS = -Wl,$(LDSECTION)
106+
# Override is only needed by avr-lib build system.
107+
#override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
108+
109+
110+
TARGET = xmega
111+
AVR_FREQ = 32000000L
112+
113+
# this next part should be modified as needed
114+
# I set the max time count to 1/8 the CPU frequency, 3 flashes on the LED,
115+
# and flash baud rate fixed at 115200 (just like the Uno, actually)
116+
117+
CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>3' '-DNUM_LED_FLASHES=3' '-DWATCHDOG_MODS' '-DDOUBLE_SPEED'
118+
119+
# change this next part for a different baud rate (but why would you?)
120+
CFLAGS += '-DBAUD_RATE=115200'
121+
122+
123+
all:
124+
125+
126+
xmega: $(PROGRAM)_xmega0.hex
127+
@echo building xmega
128+
129+
130+
$(PROGRAM)_xmega.hex: $(PROGRAM)_xmega.elf
131+
$(OBJCOPY) -j .text -j .data -O ihex $< $@
132+
133+
134+
$(PROGRAM)_xmega.elf: $(OBJ)
135+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
136+
137+
138+
#flashall: $(PROGRAM)_xmega_plus_image.hex fusesxmega
139+
# avrdude -C $(ISPCONF) -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
140+
# -U flash:w:$(PROGRAM)_xmega_plus_image.hex -U lockbits:w:$(LOCKBITS_LOCK):m
141+
142+
143+
fixhex: fixhex.c
144+
gcc -o fixhex fixhex.c
145+
146+
$(PROGRAM)_xmega0.hex: $(PROGRAM)_xmega.hex fixhex
147+
./fixhex $(PROGRAM)_xmega.hex $(PROGRAM)_xmega0.hex
148+
149+
150+
flashboot: xmega fusesxmega
151+
# in order to flash the boot loader I have to flash it as the "boot" section (no choice)
152+
# since the hex file begins with an extended address record, if I were to simply TRIM THAT OFF
153+
# then the atxmega32e5 will flash the bootloader correctly.
154+
# TODO: write a program to correctly manage this out of a combined file
155+
avrdude -C $(ISPCONF) -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
156+
-Uboot:w:$(PROGRAM)_xmega0.hex:i -Ulockbits:w:$(LOCKBITS_LOCK):m
157+
158+
159+
160+
# this next target programs the fuses and leaves lock bits 'unlocked' for flashing
161+
# it also performs a chip erase which normally includes the EEPROM as well
162+
fusesxmega:
163+
while ! avrdude -C $(ISPCONF) -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) -e \
164+
-Ulockbits:w:${LOCKBITS_UNLOCK}:m -Ufuse1:w:${FUSE1}:m -Ufuse2:w:${FUSE2}:m \
165+
-Ufuse4:w:${FUSE4}:m -Ufuse5:w:${FUSE5}:m -Ufuse6:w:${FUSE6}:m ; do sleep 1 ; done
166+
167+
erase:
168+
avrdude -C $(ISPCONF) -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) -e
169+
170+
171+
%.elf: $(OBJ)
172+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
173+
174+
clean:
175+
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
176+
177+
%.lst: %.elf
178+
$(OBJDUMP) -h -S $< > $@
179+
180+
%.hex: %.elf
181+
$(OBJCOPY) -j .text -j .data -O ihex $< $@
182+
183+
%.srec: %.elf
184+
$(OBJCOPY) -j .text -j .data -O srec $< $@
185+
186+
%.bin: %.elf
187+
$(OBJCOPY) -j .text -j .data -O binary $< $@
188+
189+

bootloaders/cc0_atxmega_e5/README

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
This is a modification of the Arduino bootloader, which is derived from the
2+
Adafruit bootloader 'as downloaded' that builds on POSIX-compatible systems
3+
and uses an AVRISPmkII to program the target.
4+
5+
make xmega; make flash
6+
7+
8+
original source:
9+
http://learn.adafruit.com/arduino-tips-tricks-and-techniques/bootloader
10+
http://ladyada.net/library/arduino/Adaboot328.zip
11+
12+
13+

0 commit comments

Comments
 (0)