From 1f01799bbfd17eb04ec6322a123d6d26b21b09a0 Mon Sep 17 00:00:00 2001 From: WestfW Date: Tue, 14 Jun 2011 10:24:27 -0700 Subject: 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. --- bootloaders/optiboot/optiboot.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'bootloaders/optiboot/optiboot.c') diff --git a/bootloaders/optiboot/optiboot.c b/bootloaders/optiboot/optiboot.c index 3f4404d..d499d85 100644 --- a/bootloaders/optiboot/optiboot.c +++ b/bootloaders/optiboot/optiboot.c @@ -132,6 +132,9 @@ /**********************************************************/ /* Edit History: */ /* */ +/* 4.4 WestfW: add initialization of address to keep */ +/* the compiler happy. Change SC'ed targets. */ +/* Return the SW version via READ PARAM */ /* 4.3 WestfW: catch framing errors in getch(), so that */ /* AVRISP works without HW kludges. */ /* http://code.google.com/p/arduino/issues/detail?id=368n*/ @@ -141,7 +144,7 @@ /**********************************************************/ #define OPTIBOOT_MAJVER 4 -#define OPTIBOOT_MINVER 3 +#define OPTIBOOT_MINVER 4 #define MAKESTR(a) #a #define MAKEVER(a, b) MAKESTR(a*256+b) @@ -261,8 +264,10 @@ int main(void) { /* * Making these local and in registers prevents the need for initializing * them, and also saves space because code no longer stores to memory. + * (initializing address keeps the compiler happy, but isn't really + * necessary, and uses 4 bytes of flash.) */ - register uint16_t address; + register uint16_t address = 0; register uint8_t length; // After the zero init loop, this is the first code to run. @@ -324,9 +329,22 @@ int main(void) { ch = getch(); if(ch == STK_GET_PARAMETER) { - // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy - getNch(1); - putch(0x03); + unsigned char which = getch(); + verifySpace(); + if (which == 0x82) { + /* + * Send optiboot version as "minor SW version" + */ + putch(OPTIBOOT_MINVER); + } else if (which == 0x81) { + putch(OPTIBOOT_MAJVER); + } else { + /* + * GET PARAMETER returns a generic 0x03 reply for + * other parameters - enough to keep Avrdude happy + */ + putch(0x03); + } } else if(ch == STK_SET_DEVICE) { // SET DEVICE is ignored -- cgit v1.2.3-18-g5258