Revision 650
Added everything necessary to make the bay bootloader. The bayboardBOOT.c was modified from the ATmegaBOOT.c in the old repository. I took out all of the #ifdef crap that dealt with other processors and products.
branches/autonomous_recharging/code/projects/bay_bootloader/bayboardBOOT.c | ||
---|---|---|
1 |
/**********************************************************/ |
|
2 |
/* Serial Bootloader for Atmel megaAVR Controllers */ |
|
3 |
/* */ |
|
4 |
/* tested with ATmega8, ATmega128 and ATmega168 */ |
|
5 |
/* should work with other mega's, see code for details */ |
|
6 |
/* */ |
|
7 |
/* ATmegaBOOT.c */ |
|
8 |
/* */ |
|
9 |
/* build: 060610 */ |
|
10 |
/* date : 06.10.2006 */ |
|
11 |
/* */ |
|
12 |
/* Monitor and debug functions were added to the original */ |
|
13 |
/* code by Dr. Erik Lins, chip45.com. (See below) */ |
|
14 |
/* */ |
|
15 |
/* Borrowed and modified for Fun with Robots by bkirby */ |
|
16 |
/* */ |
|
17 |
/* Thanks to Karl Pitrich for fixing a bootloader pin */ |
|
18 |
/* problem and more informative LED blinking! */ |
|
19 |
/* */ |
|
20 |
/* For the latest version see: */ |
|
21 |
/* http://www.chip45.com/ */ |
|
22 |
/* */ |
|
23 |
/* ------------------------------------------------------ */ |
|
24 |
/* */ |
|
25 |
/* based on stk500boot.c */ |
|
26 |
/* Copyright (c) 2003, Jason P. Kyle */ |
|
27 |
/* All rights reserved. */ |
|
28 |
/* see avr1.org for original file and information */ |
|
29 |
/* */ |
|
30 |
/* This program is free software; you can redistribute it */ |
|
31 |
/* and/or modify it under the terms of the GNU General */ |
|
32 |
/* Public License as published by the Free Software */ |
|
33 |
/* Foundation; either version 2 of the License, or */ |
|
34 |
/* (at your option) any later version. */ |
|
35 |
/* */ |
|
36 |
/* This program is distributed in the hope that it will */ |
|
37 |
/* be useful, but WITHOUT ANY WARRANTY; without even the */ |
|
38 |
/* implied warranty of MERCHANTABILITY or FITNESS FOR A */ |
|
39 |
/* PARTICULAR PURPOSE. See the GNU General Public */ |
|
40 |
/* License for more details. */ |
|
41 |
/* */ |
|
42 |
/* You should have received a copy of the GNU General */ |
|
43 |
/* Public License along with this program; if not, write */ |
|
44 |
/* to the Free Software Foundation, Inc., */ |
|
45 |
/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ |
|
46 |
/* */ |
|
47 |
/* Licence can be viewed at */ |
|
48 |
/* http://www.fsf.org/licenses/gpl.txt */ |
|
49 |
/* */ |
|
50 |
/* Target = Atmel AVR m128,m64,m32,m16,m8,m162,m163,m169, */ |
|
51 |
/* m8515,m8535. ATmega161 has a very small boot block so */ |
|
52 |
/* isn't supported. */ |
|
53 |
/* */ |
|
54 |
/* Tested with m128,m8,m163 - feel free to let me know */ |
|
55 |
/* how/if it works for you. */ |
|
56 |
/* */ |
|
57 |
/**********************************************************/ |
|
58 |
|
|
59 |
|
|
60 |
/* some includes */ |
|
61 |
#include <inttypes.h> |
|
62 |
#include <avr/io.h> |
|
63 |
#include <avr/pgmspace.h> |
|
64 |
#include <avr/interrupt.h> |
|
65 |
#include <avr/wdt.h> |
|
66 |
#include <avr/eeprom.h> |
|
67 |
|
|
68 |
#define F_CPU 8000000 |
|
69 |
|
|
70 |
#include <util/delay.h> |
|
71 |
|
|
72 |
/* set the UART baud rate */ |
|
73 |
#define BAUD_RATE 57600 |
|
74 |
/* SW_MAJOR and MINOR needs to be updated from time to time to avoid warning message from AVR Studio */ |
|
75 |
/* never allow AVR Studio to do an update !!!! */ |
|
76 |
#define HW_VER 0x02 |
|
77 |
#define SW_MAJOR 0x01 |
|
78 |
#define SW_MINOR 0x0f |
|
79 |
|
|
80 |
|
|
81 |
/* Adjust to suit whatever pin your hardware uses to enter the bootloader */ |
|
82 |
/* ATmega128 has two UARTS so two pins are used to enter bootloader and select UART */ |
|
83 |
/* BL0... means UART0, BL1... means UART1 */ |
|
84 |
#define BL_DDR DDRA |
|
85 |
#define BL_PORT PORTA |
|
86 |
#define BL_PIN PINA |
|
87 |
#define BL PINA7 |
|
88 |
|
|
89 |
/* red and green channels of the tricolor*/ |
|
90 |
#define LED_DDR DDRD |
|
91 |
#define LED_PORT PORTD |
|
92 |
#define LED_PIN PIND |
|
93 |
#define LED1 PIND4 //red |
|
94 |
#define LED2 PIND6 //green |
|
95 |
|
|
96 |
|
|
97 |
/* define various device id's */ |
|
98 |
/* manufacturer byte is always the same */ |
|
99 |
#define SIG1 0x1E // Yep, Atmel is the only manufacturer of AVR micros. Single source :( |
|
100 |
#define SIG2 0x94 |
|
101 |
#define SIG3 0x0A |
|
102 |
#define PAGE_SIZE 0x40U //64 words |
|
103 |
|
|
104 |
|
|
105 |
/* function prototypes */ |
|
106 |
void putch(char); |
|
107 |
void putst(char *); |
|
108 |
char getch(void); |
|
109 |
void getNch(uint8_t); |
|
110 |
void byte_response(uint8_t); |
|
111 |
void nothing_response(void); |
|
112 |
char gethex(void); |
|
113 |
void puthex(char); |
|
114 |
void flash_led(uint8_t); |
|
115 |
|
|
116 |
/* some variables */ |
|
117 |
union address_union { |
|
118 |
uint16_t word; |
|
119 |
uint8_t byte[2]; |
|
120 |
} address; |
|
121 |
|
|
122 |
union length_union { |
|
123 |
uint16_t word; |
|
124 |
uint8_t byte[2]; |
|
125 |
} length; |
|
126 |
|
|
127 |
struct flags_struct { |
|
128 |
unsigned eeprom : 1; |
|
129 |
unsigned rampz : 1; |
|
130 |
} flags; |
|
131 |
|
|
132 |
uint8_t buff[256]; |
|
133 |
uint8_t address_high; |
|
134 |
|
|
135 |
uint8_t pagesz=0x80; |
|
136 |
|
|
137 |
uint8_t i; |
|
138 |
uint8_t bootuart = 0; |
|
139 |
|
|
140 |
void (*app_start)(void) = 0x0000; |
|
141 |
|
|
142 |
|
|
143 |
/* main program starts here */ |
|
144 |
int main(void) { |
|
145 |
uint8_t ch,ch2; |
|
146 |
uint16_t w; |
|
147 |
|
|
148 |
asm volatile("nop\n\t"); |
|
149 |
|
|
150 |
/* set pin direction for bootloader pin and enable pullup */ |
|
151 |
BL_DDR &= ~_BV(BL); |
|
152 |
BL_PORT |= _BV(BL); |
|
153 |
|
|
154 |
/* check if flash is programmed already, if not start bootloader anyway */ |
|
155 |
if(pgm_read_byte_near(0x0000) != 0xFF) { |
|
156 |
/* run program if the button is not pressed */ |
|
157 |
if(bit_is_set(BL_PIN, BL)) |
|
158 |
app_start(); |
|
159 |
} |
|
160 |
|
|
161 |
/* initialize UART */ |
|
162 |
UBRR0 = 16; |
|
163 |
UCSR0A = _BV(U2X0); |
|
164 |
UCSR0B = _BV(TXEN0)|_BV(RXEN0); |
|
165 |
UCSR0C = 0x06; |
|
166 |
|
|
167 |
/* set LED pins as output */ |
|
168 |
LED_PORT |= _BV(LED1) | _BV(LED2); |
|
169 |
LED_DDR |= _BV(LED1) | _BV(LED2); |
|
170 |
|
|
171 |
/* flash onboard LED to signal entering of bootloader */ |
|
172 |
flash_led(3); |
|
173 |
|
|
174 |
putch('\0'); |
|
175 |
|
|
176 |
/* forever loop */ |
|
177 |
for (;;) { |
|
178 |
|
|
179 |
/* get character from UART */ |
|
180 |
ch = getch(); |
|
181 |
|
|
182 |
/* A bunch of if...else if... gives smaller code than switch...case ! */ |
|
183 |
|
|
184 |
/* Hello is anyone home ? */ |
|
185 |
if(ch=='0') { |
|
186 |
nothing_response(); |
|
187 |
} |
|
188 |
|
|
189 |
/* Request programmer ID */ |
|
190 |
/* Not using PROGMEM string due to boot block in m128 being beyond 64kB boundry */ |
|
191 |
/* Would need to selectively manipulate RAMPZ, and it's only 9 characters anyway so who cares. */ |
|
192 |
else if(ch=='1') { |
|
193 |
if (getch() == ' ') { |
|
194 |
putch(0x14); |
|
195 |
putch('A'); putch('V'); putch('R'); putch(' '); |
|
196 |
putch('I'); putch('S'); putch('P'); putch(0x10); |
|
197 |
} |
|
198 |
} |
|
199 |
|
|
200 |
/* AVR ISP/STK500 board commands DON'T CARE so default nothing_response */ |
|
201 |
else if(ch=='@') { |
|
202 |
ch2 = getch(); |
|
203 |
if (ch2>0x85) getch(); |
|
204 |
nothing_response(); |
|
205 |
} |
|
206 |
|
|
207 |
/* AVR ISP/STK500 board requests */ |
|
208 |
else if(ch=='A') { |
|
209 |
ch2 = getch(); |
|
210 |
if(ch2==0x80) byte_response(HW_VER); // Hardware version |
|
211 |
else if(ch2==0x81) byte_response(SW_MAJOR); // Software major version |
|
212 |
else if(ch2==0x82) byte_response(SW_MINOR); // Software minor version |
|
213 |
else if(ch2==0x98) byte_response(0x03); // Unknown but seems to be required by avr studio 3.56 |
|
214 |
else byte_response(0x00); // Covers various unnecessary responses we don't care about |
|
215 |
} |
|
216 |
|
|
217 |
/* Device Parameters DON'T CARE, DEVICE IS FIXED */ |
|
218 |
else if(ch=='B') { |
|
219 |
getNch(20); |
|
220 |
nothing_response(); |
|
221 |
} |
|
222 |
|
|
223 |
/* Parallel programming stuff DON'T CARE */ |
|
224 |
else if(ch=='E') { |
|
225 |
getNch(5); |
|
226 |
nothing_response(); |
|
227 |
} |
|
228 |
|
|
229 |
/* Enter programming mode */ |
|
230 |
else if(ch=='P') { |
|
231 |
nothing_response(); |
|
232 |
} |
|
233 |
|
|
234 |
/* Leave programming mode */ |
|
235 |
else if(ch=='Q') { |
|
236 |
nothing_response(); |
|
237 |
} |
|
238 |
|
|
239 |
/* Erase device, don't care as we will erase one page at a time anyway. */ |
|
240 |
else if(ch=='R') { |
|
241 |
nothing_response(); |
|
242 |
} |
|
243 |
|
|
244 |
/* Set address, little endian. EEPROM in bytes, FLASH in words */ |
|
245 |
/* Perhaps extra address bytes may be added in future to support > 128kB FLASH. */ |
|
246 |
/* This might explain why little endian was used here, big endian used everywhere else. */ |
|
247 |
else if(ch=='U') { |
|
248 |
address.byte[0] = getch(); |
|
249 |
address.byte[1] = getch(); |
|
250 |
nothing_response(); |
|
251 |
} |
|
252 |
|
|
253 |
/* Universal SPI programming command, disabled. Would be used for fuses and lock bits. */ |
|
254 |
else if(ch=='V') { |
|
255 |
getNch(4); |
|
256 |
byte_response(0x00); |
|
257 |
} |
|
258 |
|
|
259 |
/* Write memory, length is big endian and is in bytes */ |
|
260 |
else if(ch=='d') { |
|
261 |
length.byte[1] = getch(); |
|
262 |
length.byte[0] = getch(); |
|
263 |
flags.eeprom = 0; |
|
264 |
if (getch() == 'E') flags.eeprom = 1; |
|
265 |
for (w=0;w<length.word;w++) { |
|
266 |
buff[w] = getch(); // Store data in buffer, can't keep up with serial data stream whilst programming pages |
|
267 |
} |
|
268 |
|
|
269 |
if (getch() == ' ') { |
|
270 |
if (flags.eeprom) { //Write to EEPROM one byte at a time |
|
271 |
for(w=0;w<length.word;w++) { |
|
272 |
eeprom_write_byte((void *)address.word,buff[w]); |
|
273 |
address.word++; |
|
274 |
} |
|
275 |
} |
|
276 |
else { //Write to FLASH one page at a time |
|
277 |
if (address.byte[1]>127) address_high = 0x01; //Only possible with m128, m256 will need 3rd address byte. FIXME |
|
278 |
else address_high = 0x00; |
|
279 |
address.word = address.word << 1; //address * 2 -> byte location |
|
280 |
|
|
281 |
if ((length.byte[0] & 0x01)) length.word++; //Even up an odd number of bytes |
|
282 |
|
|
283 |
cli(); //Disable interrupts, just to be sure |
|
284 |
|
|
285 |
while(bit_is_set(EECR,EEPE)); //Wait for previous EEPROM writes to complete |
|
286 |
|
|
287 |
asm volatile( |
|
288 |
"clr r17 \n\t" //page_word_count |
|
289 |
"lds r30,address \n\t" //Address of FLASH location (in bytes) |
|
290 |
"lds r31,address+1 \n\t" |
|
291 |
"ldi r28,lo8(buff) \n\t" //Start of buffer array in RAM |
|
292 |
"ldi r29,hi8(buff) \n\t" |
|
293 |
"lds r24,length \n\t" //Length of data to be written (in bytes) |
|
294 |
"lds r25,length+1 \n\t" |
|
295 |
"length_loop: \n\t" //Main loop, repeat for number of words in block |
|
296 |
"cpi r17,0x00 \n\t" //If page_word_count=0 then erase page |
|
297 |
"brne no_page_erase \n\t" |
|
298 |
"wait_spm1: \n\t" |
|
299 |
"lds r16,%0 \n\t" //Wait for previous spm to complete |
|
300 |
"andi r16,1 \n\t" |
|
301 |
"cpi r16,1 \n\t" |
|
302 |
"breq wait_spm1 \n\t" |
|
303 |
"ldi r16,0x03 \n\t" //Erase page pointed to by Z |
|
304 |
"sts %0,r16 \n\t" |
|
305 |
"spm \n\t" |
|
306 |
"wait_spm2: \n\t" |
|
307 |
"lds r16,%0 \n\t" //Wait for previous spm to complete |
|
308 |
"andi r16,1 \n\t" |
|
309 |
"cpi r16,1 \n\t" |
|
310 |
"breq wait_spm2 \n\t" |
|
311 |
"ldi r16,0x11 \n\t" //Re-enable RWW section |
|
312 |
"sts %0,r16 \n\t" |
|
313 |
"spm \n\t" |
|
314 |
"no_page_erase: \n\t" |
|
315 |
"ld r0,Y+ \n\t" //Write 2 bytes into page buffer |
|
316 |
"ld r1,Y+ \n\t" |
|
317 |
|
|
318 |
"wait_spm3: \n\t" |
|
319 |
"lds r16,%0 \n\t" //Wait for previous spm to complete |
|
320 |
"andi r16,1 \n\t" |
|
321 |
"cpi r16,1 \n\t" |
|
322 |
"breq wait_spm3 \n\t" |
|
323 |
"ldi r16,0x01 \n\t" //Load r0,r1 into FLASH page buffer |
|
324 |
"sts %0,r16 \n\t" |
|
325 |
"spm \n\t" |
|
326 |
|
|
327 |
"inc r17 \n\t" //page_word_count++ |
|
328 |
"cpi r17,%1 \n\t" |
|
329 |
"brlo same_page \n\t" //Still same page in FLASH |
|
330 |
"write_page: \n\t" |
|
331 |
"clr r17 \n\t" //New page, write current one first |
|
332 |
"wait_spm4: \n\t" |
|
333 |
"lds r16,%0 \n\t" //Wait for previous spm to complete |
|
334 |
"andi r16,1 \n\t" |
|
335 |
"cpi r16,1 \n\t" |
|
336 |
"breq wait_spm4 \n\t" |
|
337 |
"ldi r16,0x05 \n\t" //Write page pointed to by Z |
|
338 |
"sts %0,r16 \n\t" |
|
339 |
"spm \n\t" |
|
340 |
"wait_spm5: \n\t" |
|
341 |
"lds r16,%0 \n\t" //Wait for previous spm to complete |
|
342 |
"andi r16,1 \n\t" |
|
343 |
"cpi r16,1 \n\t" |
|
344 |
"breq wait_spm5 \n\t" |
|
345 |
"ldi r16,0x11 \n\t" //Re-enable RWW section |
|
346 |
"sts %0,r16 \n\t" |
|
347 |
"spm \n\t" |
|
348 |
"same_page: \n\t" |
|
349 |
"adiw r30,2 \n\t" //Next word in FLASH |
|
350 |
"sbiw r24,2 \n\t" //length-2 |
|
351 |
"breq final_write \n\t" //Finished |
|
352 |
"rjmp length_loop \n\t" |
|
353 |
"final_write: \n\t" |
|
354 |
"cpi r17,0 \n\t" |
|
355 |
"breq block_done \n\t" |
|
356 |
"adiw r24,2 \n\t" //length+2, fool above check on length after short page write |
|
357 |
"rjmp write_page \n\t" |
|
358 |
"block_done: \n\t" |
|
359 |
"clr __zero_reg__ \n\t" //restore zero register |
|
360 |
|
|
361 |
: "=m" (SPMCSR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31" |
|
362 |
); |
|
363 |
/* Should really add a wait for RWW section to be enabled, don't actually need it since we never */ |
|
364 |
/* exit the bootloader without a power cycle anyhow */ |
|
365 |
} |
|
366 |
putch(0x14); |
|
367 |
putch(0x10); |
|
368 |
} |
|
369 |
} |
|
370 |
|
|
371 |
|
|
372 |
/* Read memory block mode, length is big endian. */ |
|
373 |
else if(ch=='t') { |
|
374 |
length.byte[1] = getch(); |
|
375 |
length.byte[0] = getch(); |
|
376 |
if (getch() == 'E') flags.eeprom = 1; |
|
377 |
else { |
|
378 |
flags.eeprom = 0; |
|
379 |
address.word = address.word << 1; // address * 2 -> byte location |
|
380 |
} |
|
381 |
if (getch() == ' ') { // Command terminator |
|
382 |
putch(0x14); |
|
383 |
for (w=0;w < length.word;w++) { // Can handle odd and even lengths okay |
|
384 |
if (flags.eeprom) { // Byte access EEPROM read |
|
385 |
putch(eeprom_read_byte((void *)address.word)); |
|
386 |
address.word++; |
|
387 |
} |
|
388 |
else { |
|
389 |
|
|
390 |
if (!flags.rampz) putch(pgm_read_byte_near(address.word)); |
|
391 |
address.word++; |
|
392 |
} |
|
393 |
} |
|
394 |
putch(0x10); |
|
395 |
} |
|
396 |
} |
|
397 |
|
|
398 |
|
|
399 |
/* Get device signature bytes */ |
|
400 |
else if(ch=='u') { |
|
401 |
if (getch() == ' ') { |
|
402 |
putch(0x14); |
|
403 |
putch(SIG1); |
|
404 |
putch(SIG2); |
|
405 |
putch(SIG3); |
|
406 |
putch(0x10); |
|
407 |
} |
|
408 |
} |
|
409 |
|
|
410 |
|
|
411 |
/* Read oscillator calibration byte */ |
|
412 |
else if(ch=='v') { |
|
413 |
byte_response(0x00); |
|
414 |
} |
|
415 |
|
|
416 |
} |
|
417 |
/* end of forever loop */ |
|
418 |
|
|
419 |
} |
|
420 |
|
|
421 |
|
|
422 |
char gethex(void) { |
|
423 |
char ah,al; |
|
424 |
|
|
425 |
ah = getch(); putch(ah); |
|
426 |
al = getch(); putch(al); |
|
427 |
if(ah >= 'a') { |
|
428 |
ah = ah - 'a' + 0x0a; |
|
429 |
} else if(ah >= '0') { |
|
430 |
ah -= '0'; |
|
431 |
} |
|
432 |
if(al >= 'a') { |
|
433 |
al = al - 'a' + 0x0a; |
|
434 |
} else if(al >= '0') { |
|
435 |
al -= '0'; |
|
436 |
} |
|
437 |
return (ah << 4) + al; |
|
438 |
} |
|
439 |
|
|
440 |
|
|
441 |
void puthex(char ch) { |
|
442 |
char ah,al; |
|
443 |
|
|
444 |
ah = (ch & 0xf0) >> 4; |
|
445 |
if(ah >= 0x0a) { |
|
446 |
ah = ah - 0x0a + 'a'; |
|
447 |
} else { |
|
448 |
ah += '0'; |
|
449 |
} |
|
450 |
al = (ch & 0x0f); |
|
451 |
if(al >= 0x0a) { |
|
452 |
al = al - 0x0a + 'a'; |
|
453 |
} else { |
|
454 |
al += '0'; |
|
455 |
} |
|
456 |
putch(ah); |
|
457 |
putch(al); |
|
458 |
} |
|
459 |
|
|
460 |
|
|
461 |
void putch(char ch) |
|
462 |
{ |
|
463 |
while (!(UCSR0A & _BV(UDRE0))); |
|
464 |
UDR0 = ch; |
|
465 |
} |
|
466 |
|
|
467 |
|
|
468 |
char getch(void) |
|
469 |
{ |
|
470 |
while(!(UCSR0A & _BV(RXC0))); |
|
471 |
return UDR0; |
|
472 |
} |
|
473 |
|
|
474 |
|
|
475 |
void getNch(uint8_t count) |
|
476 |
{ |
|
477 |
uint8_t i; |
|
478 |
for(i=0;i<count;i++) { |
|
479 |
while(!(UCSR0A & _BV(RXC0))); |
|
480 |
UDR0; |
|
481 |
} |
|
482 |
} |
|
483 |
|
|
484 |
|
|
485 |
void byte_response(uint8_t val) |
|
486 |
{ |
|
487 |
if (getch() == ' ') { |
|
488 |
putch(0x14); |
|
489 |
putch(val); |
|
490 |
putch(0x10); |
|
491 |
} |
|
492 |
} |
|
493 |
|
|
494 |
|
|
495 |
void nothing_response(void) |
|
496 |
{ |
|
497 |
if (getch() == ' ') { |
|
498 |
putch(0x14); |
|
499 |
putch(0x10); |
|
500 |
} |
|
501 |
} |
|
502 |
|
|
503 |
|
|
504 |
void flash_led(uint8_t count) |
|
505 |
{ |
|
506 |
/* flash onboard LED three times to signal entering of bootloader */ |
|
507 |
uint32_t l; |
|
508 |
int i; |
|
509 |
if (count == 0) { |
|
510 |
count = 3; |
|
511 |
} |
|
512 |
|
|
513 |
for (i = 0; i < count; ++i) { |
|
514 |
LED_PORT |= _BV(LED1); |
|
515 |
LED_PORT &= ~_BV(LED2); |
|
516 |
for(l = 0; l < (15); ++l) |
|
517 |
_delay_ms(10); |
|
518 |
|
|
519 |
LED_PORT &= ~_BV(LED1); |
|
520 |
LED_PORT |= _BV(LED2); |
|
521 |
for(l = 0; l < (15); ++l) |
|
522 |
_delay_ms(10); |
|
523 |
|
|
524 |
} |
|
525 |
} |
|
526 |
|
|
527 |
|
|
528 |
/* end of file ATmegaBOOT.c */ |
branches/autonomous_recharging/code/projects/bay_bootloader/bayboardBOOT.hex | ||
---|---|---|
1 |
:103800000C943E1C0C94591C0C94591C0C94591C7F |
|
2 |
:103810000C94591C0C94591C0C94591C0C94591C54 |
|
3 |
:103820000C94591C0C94591C0C94591C0C94591C44 |
|
4 |
:103830000C94591C0C94591C0C94591C0C94591C34 |
|
5 |
:103840000C94591C0C94591C0C94591C0C94591C24 |
|
6 |
:103850000C94591C0C94591C0C94591C0C94591C14 |
|
7 |
:103860000C94591C0C94591C0C94591C0C94591C04 |
|
8 |
:103870000C94591C0C94591C0C94591C11241FBEF7 |
|
9 |
:10388000CFEFD4E0DEBFCDBF11E0A0E0B1E0EEE8C5 |
|
10 |
:10389000FEE302C005900D92A230B107D9F712E005 |
|
11 |
:1038A000A2E0B1E001C01D92AC30B107E1F70C9489 |
|
12 |
:1038B000DB1C0C94001CEF92FF920F931F93CF938D |
|
13 |
:1038C000DF93882309F483E060E070E0E82FFF27AE |
|
14 |
:1038D0001E161F066CF580E2E82E8EE4F82E012DF0 |
|
15 |
:1038E000112D5C9A5E982EE030E040E050E0C70178 |
|
16 |
:1038F0000197F1F7215030404040504057FFF7CF3B |
|
17 |
:103900005C985E9AA0E2BEE4C0E0D0E02EE030E039 |
|
18 |
:1039100040E050E0CD010197F1F7215030404040A8 |
|
19 |
:10392000504057FFF7CF6F5F7F4F6E177F07CCF286 |
|
20 |
:10393000DF91CF911F910F91FF90EF900895982FF5 |
|
21 |
:103940008091C00085FFFCCF9093C60008958091C0 |
|
22 |
:10395000C0008823E4F78091C600992787FD9095E1 |
|
23 |
:1039600008950E94A71C803209F0089584E10E9406 |
|
24 |
:103970009F1C80E10E949F1C0895CF93C82F0E9436 |
|
25 |
:10398000A71C803249F484E10E949F1C8C2F0E9466 |
|
26 |
:103990009F1C80E10E949F1CCF910895282F90E0EA |
|
27 |
:1039A00007C08091C0008823E4F78091C6009F5F24 |
|
28 |
:1039B0009217B8F30895CFEFD4E0DEBFCDBF00007B |
|
29 |
:1039C0000F98179AE0E0F0E084918F3F11F007998B |
|
30 |
:1039D000E1C180E190E09093C5008093C40082E053 |
|
31 |
:1039E0008093C00088E18093C10086E08093C2008C |
|
32 |
:1039F0008BB180658BB98AB180658AB983E00E94FA |
|
33 |
:103A00005B1C80E00E949F1C0E94A71C803361F118 |
|
34 |
:103A1000813369F1803409F449C0813409F44FC01D |
|
35 |
:103A2000823409F45DC0853409F460C08035E1F06A |
|
36 |
:103A30008135D1F08235C1F0853509F45BC086351A |
|
37 |
:103A400009F463C0843609F465C0843709F4BDC045 |
|
38 |
:103A5000853709F412C18637B9F680E00E94BD1C93 |
|
39 |
:103A60000E94A71C8033A1F60E94B11CCDCF0E94FA |
|
40 |
:103A7000A71CC82F803241F684E10E949F1C81E47C |
|
41 |
:103A80000E949F1C86E50E949F1C82E50E949F1C4D |
|
42 |
:103A90008C2F0E949F1C89E40E949F1C83E50E943A |
|
43 |
:103AA0009F1C80E50E949F1C80E1ACCF0E94A71C58 |
|
44 |
:103AB0008638D0F20E94A71C0E94B11CA5CF0E949C |
|
45 |
:103AC000A71C803809F46CC1813809F46DC18238B3 |
|
46 |
:103AD00009F46EC1883909F683E00E94BD1CC0CF8D |
|
47 |
:103AE00084E10E94CE1C0E94B11C8ECF85E00E9412 |
|
48 |
:103AF000CE1CF9CF0E94A71C809305010E94A71C31 |
|
49 |
:103B0000809306010E94B11C7FCF84E00E94CE1CEE |
|
50 |
:103B100080E0A4CF0E94A71C809308020E94A71CEB |
|
51 |
:103B20008093070280910B028E7F80930B020E948C |
|
52 |
:103B3000A71C853409F4B3C000E010E080910702AF |
|
53 |
:103B4000909108021816190670F4C7E0D1E00E949F |
|
54 |
:103B5000A71C89930F5F1F4F809107029091080265 |
|
55 |
:103B600008171907A0F30E94A71C803209F04CCF58 |
|
56 |
:103B700080910B0280FF9FC000E010E0809107025F |
|
57 |
:103B80009091080218161906E0F4A0910501B09171 |
|
58 |
:103B90000601E7E0F1E08191082E0E943B1FA09111 |
|
59 |
:103BA0000501B09106011196B0930601A09305019D |
|
60 |
:103BB0000F5F1F4F809107029091080208171907A5 |
|
61 |
:103BC00050F384E10E949F1C6FCF0E94A71C80933A |
|
62 |
:103BD00008020E94A71C809307020E94A71C85343C |
|
63 |
:103BE00009F463C080910B028E7F80930B02809159 |
|
64 |
:103BF000050190910601880F991F9093060180930B |
|
65 |
:103C000005010E94A71C803209F0FECE84E10E94CB |
|
66 |
:103C10009F1C00E010E0209107023091080212166C |
|
67 |
:103C2000130608F041CFA0910501B09106010EC026 |
|
68 |
:103C3000869580FFC1C01196B0930601A09305013F |
|
69 |
:103C40000F5F1F4F0217130708F02ECF80910B0252 |
|
70 |
:103C500080FFEECF0E94331F802D0E949F1CA091F9 |
|
71 |
:103C60000501B09106011196B0930601A0930501DC |
|
72 |
:103C70002091070230910802E3CF0E94A71C8032F6 |
|
73 |
:103C800009F0C2CE84E10E949F1C8EE10E949F1C1D |
|
74 |
:103C900084E90E949F1C8AE00E949F1C05CF8091AE |
|
75 |
:103CA0000B02816080930B0247CF80910B028160F1 |
|
76 |
:103CB00080930B02A6CF8091060187FD67C010920A |
|
77 |
:103CC0000A028091050190910601880F991F909337 |
|
78 |
:103CD0000601809305018091070280FF09C0809151 |
|
79 |
:103CE00007029091080201969093080280930702C0 |
|
80 |
:103CF000F894F999FECF1127E0910501F0910601A2 |
|
81 |
:103D0000C7E0D1E08091070290910802103091F451 |
|
82 |
:103D10000091570001700130D9F303E00093570080 |
|
83 |
:103D2000E8950091570001700130D9F301E100934B |
|
84 |
:103D30005700E895099019900091570001700130E3 |
|
85 |
:103D4000D9F301E000935700E8951395103498F0EB |
|
86 |
:103D500011270091570001700130D9F305E000935D |
|
87 |
:103D60005700E8950091570001700130D9F301E147 |
|
88 |
:103D700000935700E8953296029709F0C7CF1030AC |
|
89 |
:103D800011F00296E5CF112484E11CCF81E08093ED |
|
90 |
:103D90000A0297CFE0910201F0910301099519CE33 |
|
91 |
:103DA00082E00E94BD1C5CCE81E00E94BD1C58CE0A |
|
92 |
:103DB0008FE00E94BD1C54CEFD0184910E949F1C87 |
|
93 |
:103DC0002091070230910802A0910501B0910601EF |
|
94 |
:103DD00032CF1F93CF930E94A71CC82F0E949F1C15 |
|
95 |
:103DE0000E94A71C182F0E949F1CC1362CF0C7559B |
|
96 |
:103DF00011363CF0175508C0C033D4F3C053113608 |
|
97 |
:103E0000CCF710330CF01053C295C07FC10F8C2F2C |
|
98 |
:103E1000992787FD9095CF911F910895CF93282FD3 |
|
99 |
:103E2000992787FD9095807F9070959587959595BA |
|
100 |
:103E3000879595958795959587958A303CF0895A11 |
|
101 |
:103E4000C22FCF70CA303CF0C95A06C0805DC22F65 |
|
102 |
:103E5000CF70CA30CCF7C05D0E949F1C8C2F0E948F |
|
103 |
:103E60009F1CCF910895F999FECFB2BDA1BDF89ADC |
|
104 |
:103E7000119600B40895F999FECFB2BDA1BD00BC62 |
|
105 |
:0E3E800011960FB6F894FA9AF99A0FBE0895AB |
|
106 |
:023E8E008000B2 |
|
107 |
:0400000300003800C1 |
|
108 |
:00000001FF |
branches/autonomous_recharging/code/projects/bay_bootloader/Makefile | ||
---|---|---|
1 |
# Makefile for ATmegaBOOT |
|
2 |
# E.Lins, 18.7.2005 |
|
3 |
|
|
4 |
# version // year month day |
|
5 |
BUILD = 080322 |
|
6 |
|
|
7 |
# program name should not be changed... |
|
8 |
PROGRAM = bayboardBOOT |
|
9 |
|
|
10 |
# enter the product name for which you want to build the bootloader/monitor |
|
11 |
#PRODUCT = CRUMB8 |
|
12 |
#PRODUCT = CRUMB128 |
|
13 |
#PRODUCT = CRUMB168 |
|
14 |
#PRODUCT = PROBOMEGA128 |
|
15 |
#PRODUCT = SAVVY128 |
|
16 |
#PRODUCT = AVRELLUM2 |
|
17 |
#PRODUCT = FWRBOARD |
|
18 |
#PRODUCT = DRAGONFLY_128 |
|
19 |
PRODUCT = BAYBOARD |
|
20 |
|
|
21 |
# enter the target CPU frequency |
|
22 |
#AVR_FREQ = F3686400 |
|
23 |
#AVR_FREQ = F7372800 |
|
24 |
AVR_FREQ = F8000000 |
|
25 |
#AVR_FREQ = F14745600 |
|
26 |
#AVR_FREQ = F16000000 |
|
27 |
#AVR_FREQ = F20000000 |
|
28 |
|
|
29 |
# enter the parameters for the UISP isp tool |
|
30 |
# for an stk500 at com1 |
|
31 |
ISPTOOL = avrisp |
|
32 |
ISPPORT = usb |
|
33 |
ISPSPEED = -b 115200 |
|
34 |
# or an stk200 at lpt1 |
|
35 |
#ISPTOOL = stk200 |
|
36 |
#ISPPORT = lpt1 |
|
37 |
#ISPSPEED = |
|
38 |
|
|
39 |
|
|
40 |
############################################################ |
|
41 |
# You should not have to change anything below here. |
|
42 |
############################################################ |
|
43 |
|
|
44 |
ifeq ($(PRODUCT),CRUMB8) |
|
45 |
MCU_TARGET = atmega8 |
|
46 |
LDSECTION = --section-start=.text=0x1800 |
|
47 |
ISPFUSES = avrdude -c $(ISPTOOL) -p m8 -P $(ISPPORT) $(ISPSPEED) -u -U hfuse:w:0xc8:m -U lfuse:w:0xdf:m |
|
48 |
ISPFLASH = avrdude -c $(ISPTOOL) -p m8 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
|
49 |
endif |
|
50 |
|
|
51 |
ifeq ($(PRODUCT),FWRBOARD) |
|
52 |
MCU_TARGET = atmega168 |
|
53 |
LDSECTION = --section-start=.text=0x3800 |
|
54 |
ISPFUSES = ./avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xf8:m -U hfuse:w:0xdf:m -U lfuse:w:0xef:m |
|
55 |
ISPFLASH = ./avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM).hex |
|
56 |
endif |
|
57 |
|
|
58 |
ifeq ($(PRODUCT),CRUMB168) |
|
59 |
MCU_TARGET = atmega168 |
|
60 |
LDSECTION = --section-start=.text=0x3800 |
|
61 |
ISPFUSES = avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xf8:m -U hfuse:w:0xd7:m -U lfuse:w:0xaf:m |
|
62 |
ISPFLASH = avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
|
63 |
endif |
|
64 |
|
|
65 |
ifeq ($(PRODUCT),AVRELLUM2) |
|
66 |
MCU_TARGET = atmega128 |
|
67 |
LDSECTION = --section-start=.text=0x1E000 |
|
68 |
ISPFUSES = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xff:m -U hfuse:w:0xc8:m -U lfuse:w:0xdf:m |
|
69 |
ISPFLASH = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
|
70 |
endif |
|
71 |
|
|
72 |
ifeq ($(PRODUCT),DRAGONFLY_v3) |
|
73 |
MCU_TARGET = atmega1281 |
|
74 |
LDSECTION = --section-start=.text=0x1E000 |
|
75 |
ISPFUSES = avrdude -c $(ISPTOOL) -p m1281 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xff:m -U hfuse:w:0xc8:m -U lfuse:w:0xdf:m |
|
76 |
ISPFLASH = avrdude -c $(ISPTOOL) -p m1281 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
|
77 |
endif |
|
78 |
|
|
79 |
ifeq ($(PRODUCT),DRAGONFLY_128) |
|
80 |
MCU_TARGET = atmega128 |
|
81 |
LDSECTION = --section-start=.text=0x1E000 |
|
82 |
ISPFUSES = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xff:m -U hfuse:w:0xc8:m -U lfuse:w:0xdf:m |
|
83 |
ISPFLASH = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
|
84 |
endif |
|
85 |
|
|
86 |
ifeq ($(PRODUCT),CRUMB128) |
|
87 |
MCU_TARGET = atmega128 |
|
88 |
LDSECTION = --section-start=.text=0x1E000 |
|
89 |
ISPFUSES = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xff:m -U hfuse:w:0xc8:m -U lfuse:w:0xdf:m |
|
90 |
ISPFLASH = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
|
91 |
endif |
|
92 |
|
|
93 |
ifeq ($(PRODUCT),PROBOMEGA128) |
|
94 |
MCU_TARGET = atmega128 |
|
95 |
LDSECTION = --section-start=.text=0x1E000 |
|
96 |
ISPFUSES = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xff:m -U hfuse:w:0xc8:m -U lfuse:w:0xdf:m |
|
97 |
ISPFLASH = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
|
98 |
endif |
|
99 |
|
|
100 |
ifeq ($(PRODUCT),SAVVY128) |
|
101 |
MCU_TARGET = atmega128 |
|
102 |
LDSECTION = --section-start=.text=0x1E000 |
|
103 |
ISPFUSES = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xff:m -U hfuse:w:0xd8:m -U lfuse:w:0xe4:m |
|
104 |
ISPFLASH = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
|
105 |
endif |
|
106 |
|
|
107 |
ifeq ($(PRODUCT),BAYBOARD) |
|
108 |
MCU_TARGET = atmega164p |
|
109 |
LDSECTION = --section-start=.text=0x3800 |
|
110 |
ISPFUSES = avrdude -c $(ISPTOOL) -p m164 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xff:m -U hfuse:w:0x98:m -U lfuse:w:0xff:m |
|
111 |
ISPFLASH = avrdude -c $(ISPTOOL) -p m164 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
|
112 |
endif |
|
113 |
|
|
114 |
OBJ = $(PROGRAM).o |
|
115 |
OPTIMIZE = -O2 |
|
116 |
|
|
117 |
DEFS = |
|
118 |
LIBS = |
|
119 |
|
|
120 |
CC = avr-gcc |
|
121 |
|
|
122 |
|
|
123 |
# Override is only needed by avr-lib build system. |
|
124 |
|
|
125 |
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -D$(PRODUCT) -D$(AVR_FREQ) $(DEFS) |
|
126 |
override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION) |
|
127 |
|
|
128 |
OBJCOPY = avr-objcopy |
|
129 |
OBJDUMP = avr-objdump |
|
130 |
|
|
131 |
all: $(PROGRAM).elf lst text |
|
132 |
|
|
133 |
isp: $(PROGRAM).hex |
|
134 |
$(ISPFUSES) |
|
135 |
$(ISPFLASH) |
|
136 |
|
|
137 |
$(PROGRAM).elf: $(OBJ) |
|
138 |
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
|
139 |
|
|
140 |
clean: |
|
141 |
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep |
|
142 |
rm -rf $(PROGRAM).hex $(PROGRAM).srec $(PROGRAM).bin |
|
143 |
|
|
144 |
lst: $(PROGRAM).lst |
|
145 |
|
|
146 |
%.lst: %.elf |
|
147 |
$(OBJDUMP) -h -S $< > $@ |
|
148 |
|
|
149 |
# Rules for building the .text rom images |
|
150 |
|
|
151 |
text: hex bin srec |
|
152 |
|
|
153 |
hex: $(PROGRAM).hex |
|
154 |
bin: $(PROGRAM).bin |
|
155 |
srec: $(PROGRAM).srec |
|
156 |
|
|
157 |
%.hex: %.elf |
|
158 |
$(OBJCOPY) -j .text -j .data -O ihex $< $@ |
|
159 |
cp $@ $(PROGRAM)_$(PRODUCT)_$(AVR_FREQ)_$(BUILD).hex |
|
160 |
|
|
161 |
%.srec: %.elf |
|
162 |
$(OBJCOPY) -j .text -j .data -O srec $< $@ |
|
163 |
cp $@ $(PROGRAM)_$(PRODUCT)_$(AVR_FREQ)_$(BUILD).srec |
|
164 |
|
|
165 |
%.bin: %.elf |
|
166 |
$(OBJCOPY) -j .text -j .data -O binary $< $@ |
|
167 |
cp $@ $(PROGRAM)_$(PRODUCT)_$(AVR_FREQ)_$(BUILD).bin |
Also available in: Unified diff