Skip to content

Commit 07dfd77

Browse files
WestfWdamellis
authored andcommitted
Allow the READ PARAMETER command to return our version number.
(significant size impact: 14 bytes!) Initialized "address" to eliminate compiler warning (4 bytes!) Add "atmega168" as a more accurate target name than "diecimila" (keep diecimila as well for backward compatibility) Reduce the .hex and .lst targets that are stored in source control to the three basics: atmega8, atmega168, atmega328. The other targets remain in the makefile and makeall, but will need to be built from source if wanted. Which should be less of a problem now that the source is buildable without installing crosspack. (cherry picked from commit 7b1ee0f1b0192143fffbbed66dc046b6568f4386)
1 parent 3b4fbd0 commit 07dfd77

22 files changed

+346
-5157
lines changed

bootloaders/optiboot/Makefile

+20-1
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,27 @@ pro16_isp: LFUSE = C6
177177
pro16_isp: EFUSE = 04
178178
pro16_isp: isp
179179

180-
# Diecimila and NG use identical bootloaders
180+
# Diecimila, Duemilanove with m168, and NG use identical bootloaders
181+
# Call it "atmega168" for generality and clarity, keep "diecimila" for
182+
# backward compatibility of makefile
181183
#
184+
atmega168: TARGET = atmega168
185+
atmega168: MCU_TARGET = atmega168
186+
atmega168: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
187+
atmega168: AVR_FREQ = 16000000L
188+
atmega168: $(PROGRAM)_atmega168.hex
189+
atmega168: $(PROGRAM)_atmega168.lst
190+
191+
atmega168_isp: atmega168
192+
atmega168_isp: TARGET = atmega168
193+
# 2.7V brownout
194+
atmega168_isp: HFUSE = DD
195+
# Low power xtal (16MHz) 16KCK/14CK+65ms
196+
atmega168_isp: LFUSE = FF
197+
# 512 byte boot
198+
atmega168_isp: EFUSE = 04
199+
atmega168_isp: isp
200+
182201
diecimila: TARGET = diecimila
183202
diecimila: MCU_TARGET = atmega168
184203
diecimila: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'

bootloaders/optiboot/README.TXT

+11
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,14 @@ variables when you invoke make:
6868

6969
make ISPTOOL=stk500v1 ISPPORT=/dev/tty.usbserial-A20e1eAN \
7070
ISPSPEED=-b19200 atmega328_isp
71+
72+
The "atmega8_isp" target does not currently work, because the mega8
73+
doesn't have the "extended" fuse that the generic ISP target wants to
74+
pass on to avrdude. You'll need to run avrdude manually.
75+
76+
77+
Standard Targets
78+
79+
I've reduced the pre-built and source-version-controlled targets
80+
(.hex and .lst files included in the git repository) to just the
81+
three basic 16MHz targets: atmega8, atmega16, atmega328.

bootloaders/optiboot/makeall

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
#!/bin/bash
22
make clean
3+
#
4+
# The "big three" standard bootloaders.
5+
make atmega8
6+
make atmega168
7+
make atmega328
8+
#
9+
# additional buildable platforms of
10+
# somewhat questionable support level
311
make lilypad
412
make lilypad_resonator
513
make pro8
614
make pro16
715
make pro20
8-
make diecimila
9-
make atmega328
1016
make atmega328_pro8
1117
make sanguino
1218
make mega
13-
make atmega8
1419
make atmega88
1520
make luminet

bootloaders/optiboot/optiboot.c

+23-5
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@
132132
/**********************************************************/
133133
/* Edit History: */
134134
/* */
135+
/* 4.4 WestfW: add initialization of address to keep */
136+
/* the compiler happy. Change SC'ed targets. */
137+
/* Return the SW version via READ PARAM */
135138
/* 4.3 WestfW: catch framing errors in getch(), so that */
136139
/* AVRISP works without HW kludges. */
137140
/* http://code.google.com/p/arduino/issues/detail?id=368n*/
@@ -141,7 +144,7 @@
141144
/**********************************************************/
142145

143146
#define OPTIBOOT_MAJVER 4
144-
#define OPTIBOOT_MINVER 3
147+
#define OPTIBOOT_MINVER 4
145148

146149
#define MAKESTR(a) #a
147150
#define MAKEVER(a, b) MAKESTR(a*256+b)
@@ -261,8 +264,10 @@ int main(void) {
261264
/*
262265
* Making these local and in registers prevents the need for initializing
263266
* them, and also saves space because code no longer stores to memory.
267+
* (initializing address keeps the compiler happy, but isn't really
268+
* necessary, and uses 4 bytes of flash.)
264269
*/
265-
register uint16_t address;
270+
register uint16_t address = 0;
266271
register uint8_t length;
267272

268273
// After the zero init loop, this is the first code to run.
@@ -324,9 +329,22 @@ int main(void) {
324329
ch = getch();
325330

326331
if(ch == STK_GET_PARAMETER) {
327-
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
328-
getNch(1);
329-
putch(0x03);
332+
unsigned char which = getch();
333+
verifySpace();
334+
if (which == 0x82) {
335+
/*
336+
* Send optiboot version as "minor SW version"
337+
*/
338+
putch(OPTIBOOT_MINVER);
339+
} else if (which == 0x81) {
340+
putch(OPTIBOOT_MAJVER);
341+
} else {
342+
/*
343+
* GET PARAMETER returns a generic 0x03 reply for
344+
* other parameters - enough to keep Avrdude happy
345+
*/
346+
putch(0x03);
347+
}
330348
}
331349
else if(ch == STK_SET_DEVICE) {
332350
// SET DEVICE is ignored
+31-30
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1-
:107E0000112484B714BE81FFE7D085E08093810000
1+
:107E0000112484B714BE81FFF0D085E080938100F7
22
:107E100082E08093C00088E18093C10086E0809377
3-
:107E2000C20080E18093C4008EE0C0D0259A86E035
3+
:107E2000C20080E18093C4008EE0C9D0259A86E02C
44
:107E300020E33CEF91E0309385002093840096BBD3
5-
:107E4000B09BFECF1D9AA8958150A9F799249394D1
6-
:107E5000A5E0AA2EF1E1BF2E9DD0813421F481E06E
7-
:107E6000B3D083E01FC0823411F484E103C08534B1
8-
:107E700019F485E0A9D083C0853579F48BD0E82E3C
9-
:107E8000FF2488D0082F10E0102F00270E291F296B
10-
:107E9000000F111F91D0680172C0863529F484E06B
11-
:107EA00093D080E06FD06BC0843609F042C072D0AE
12-
:107EB00071D0082F6FD080E0C81680E7D80620F474
13-
:107EC00083E0F60187BFE895C0E0D1E063D08993F5
14-
:107ED0000C17E1F7F0E0CF16F0E7DF0620F083E0C3
15-
:107EE000F60187BFE89568D007B600FCFDCFA60174
16-
:107EF000A0E0B1E02C9130E011968C91119790E0C8
17-
:107F0000982F8827822B932B1296FA010C0197BE8B
18-
:107F1000E89511244E5F5F4FF1E0A038BF0751F79D
19-
:107F2000F601A7BEE89507B600FCFDCFB7BEE89501
20-
:107F300026C08437B1F42ED02DD0F82E2BD03CD0D3
21-
:107F4000F601EF2C8F010F5F1F4F84911BD0EA9435
22-
:107F5000F801C1F70894C11CD11CFA94CF0CD11CB4
23-
:107F60000EC0853739F428D08EE10CD085E90AD0CF
24-
:107F70008FE098CF813511F488E018D01DD080E1D2
25-
:107F800001D06ACF982F8091C00085FFFCCF9093DD
26-
:107F9000C60008958091C00087FFFCCF8091C0008B
27-
:107FA00084FD01C0A8958091C6000895E0E6F0E048
28-
:107FB00098E1908380830895EDDF803219F088E0A6
29-
:107FC000F5DFFFCF84E1DECF1F93182FE3DF1150E1
30-
:107FD000E9F7F2DF1F91089580E0E8DFEE27FF2741
31-
:027FE000099402
32-
:027FFE0003047A
5+
:107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4
6+
:107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7
7+
:107E6000A2D0813461F49FD0082FAFD0023811F036
8+
:107E7000013811F484E001C083E08DD089C08234E0
9+
:107E800011F484E103C0853419F485E0A6D080C0E4
10+
:107E9000853579F488D0E82EFF2485D0082F10E0AE
11+
:107EA000102F00270E291F29000F111F8ED06801E7
12+
:107EB0006FC0863521F484E090D080E0DECF843638
13+
:107EC00009F040C070D06FD0082F6DD080E0C81688
14+
:107ED00080E7D80618F4F601B7BEE895C0E0D1E017
15+
:107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8
16+
:107EF00018F0F601B7BEE89568D007B600FCFDCFD4
17+
:107F0000A601A0E0B1E02C9130E011968C91119780
18+
:107F100090E0982F8827822B932B1296FA010C0160
19+
:107F200087BEE89511244E5F5F4FF1E0A038BF0790
20+
:107F300051F7F601A7BEE89507B600FCFDCF97BE46
21+
:107F4000E89526C08437B1F42ED02DD0F82E2BD052
22+
:107F50003CD0F601EF2C8F010F5F1F4F84911BD097
23+
:107F6000EA94F801C1F70894C11CD11CFA94CF0C13
24+
:107F7000D11C0EC0853739F428D08EE10CD085E9AC
25+
:107F80000AD08FE07ACF813511F488E018D01DD067
26+
:107F900080E101D065CF982F8091C00085FFFCCF94
27+
:107FA0009093C60008958091C00087FFFCCF809118
28+
:107FB000C00084FD01C0A8958091C6000895E0E648
29+
:107FC000F0E098E1908380830895EDDF803219F02E
30+
:107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA
31+
:107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6
32+
:047FF000FF270994CA
33+
:027FFE00040479
3334
:0400000300007E007B
3435
:00000001FF

0 commit comments

Comments
 (0)