Revision 199
Bootloader is setup to read the address from the EEPROM now
bootloader.c | ||
---|---|---|
10 | 10 |
}; |
11 | 11 |
*/ |
12 | 12 |
|
13 |
|
|
14 |
|
|
15 | 13 |
// Error thresholds |
16 | 14 |
#define MAX_RETRIES 5 // Number of times to retry before giving up |
17 | 15 |
|
... | ... | |
59 | 57 |
uint16_t prog_len; |
60 | 58 |
uint8_t i; |
61 | 59 |
uint8_t retries; |
60 |
uint8_t addr; |
|
62 | 61 |
|
63 | 62 |
retry_jpnt: |
64 | 63 |
iteration = 0; |
65 | 64 |
retries = 0; |
65 |
addr = eeprom_read_byte(EEPROM_ADDR); |
|
66 | 66 |
|
67 | 67 |
// Clear the watchdog timer |
68 | 68 |
MCUSR &= ~_BV(WDRF); |
69 | 69 |
wdt_disable(); |
70 | 70 |
WDTCSR = 0; |
71 | 71 |
|
72 |
|
|
73 | 72 |
rs485_init(BAUD9600); |
74 | 73 |
|
75 | 74 |
//set LED pin as output |
... | ... | |
77 | 76 |
PORTB = 0x07; |
78 | 77 |
|
79 | 78 |
//Start bootloading process |
80 |
send_packet(TT_BOOT); |
|
79 |
send_packet(TT_BOOT, addr);
|
|
81 | 80 |
|
82 |
resp = parse_packet(mbuf); |
|
81 |
resp = parse_packet(mbuf, addr);
|
|
83 | 82 |
|
84 | 83 |
// Enter programming mode |
85 | 84 |
if (resp == TT_PROGM) { |
... | ... | |
98 | 97 |
main_start(); |
99 | 98 |
} |
100 | 99 |
|
101 |
send_packet(TT_ACK); |
|
100 |
send_packet(TT_ACK, addr);
|
|
102 | 101 |
|
103 | 102 |
while(1) { |
104 |
resp = parse_packet(mbuf); |
|
103 |
resp = parse_packet(mbuf, addr);
|
|
105 | 104 |
|
106 | 105 |
if (resp == TT_PROGD) { |
107 | 106 |
// We need to muck with the reset vector jump in the first page |
... | ... | |
129 | 128 |
caddr += PROGD_PACKET_SIZE; |
130 | 129 |
retries = 0; |
131 | 130 |
} else { |
132 |
send_packet(TT_NACK); |
|
131 |
send_packet(TT_NACK, addr);
|
|
133 | 132 |
retries++; |
134 | 133 |
|
135 | 134 |
// If we failed too many times, reset. This goes to the start |
... | ... | |
139 | 138 |
} |
140 | 139 |
} |
141 | 140 |
|
142 |
send_packet(TT_ACK); |
|
141 |
send_packet(TT_ACK, addr);
|
|
143 | 142 |
|
144 | 143 |
// Once we write the last packet we must override the jump to |
145 | 144 |
// user code to point to the correct address |
Also available in: Unified diff