diff options
author | WestfW <westfw@gmail.com> | 2011-06-14 10:24:27 -0700 |
---|---|---|
committer | David A. Mellis <d.mellis@arduino.cc> | 2011-10-10 12:11:17 -0400 |
commit | 07dfd77554162dc9c2570ad0f605ae080c182b2e (patch) | |
tree | b3f580c2e0aceb5cab71ca86f80e9647fe8b2627 /bootloaders/optiboot/optiboot.c | |
parent | 3b4fbd0960351a9f9cd79e8cd7c8e2b4f20aabc7 (diff) |
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)
Diffstat (limited to 'bootloaders/optiboot/optiboot.c')
-rw-r--r-- | bootloaders/optiboot/optiboot.c | 28 |
1 files changed, 23 insertions, 5 deletions
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 |