From 30dc672dff670b3dba59fb56843cfa74e1c8e365 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sat, 11 Oct 2008 19:27:10 +0000 Subject: [PATCH] * Updating version number to 0013. * Updating ATmega168 bootloader to work with standard distributions of avrdude (responding to signature requests made with the universal SPI command) and correctly store EEPROM data. Thanks to ladyada. * Changing compilation process to generate .eep file and allow for use of EEMEM directive (although not yet uploading EEPROM data). --- app/Base.java | 4 +- app/Compiler.java | 10 +- .../bootloaders/atmega168/ATmegaBOOT_168.c | 105 ++++---- .../atmega168/ATmegaBOOT_168_diecimila.hex | 237 ++++++++--------- .../atmega168/ATmegaBOOT_168_ng.hex | 221 ++++++++-------- .../atmega168/ATmegaBOOT_168_pro_8MHz.hex | 239 +++++++++--------- hardware/bootloaders/atmega168/Makefile | 4 + readme.txt | 8 + todo.txt | 27 +- 9 files changed, 428 insertions(+), 427 deletions(-) diff --git a/app/Base.java b/app/Base.java index f9e3748a4..fa3fdbbfb 100644 --- a/app/Base.java +++ b/app/Base.java @@ -53,8 +53,8 @@ import processing.core.*; * files and images, etc) that comes from that. */ public class Base { - static final int VERSION = 12; - static final String VERSION_NAME = "0012 Alpha"; + static final int VERSION = 13; + static final String VERSION_NAME = "0013 Alpha"; /** * Path of filename opened on the command line, diff --git a/app/Compiler.java b/app/Compiler.java index a1d571458..1ccfa1444 100644 --- a/app/Compiler.java +++ b/app/Compiler.java @@ -211,16 +211,20 @@ public class Compiler implements MessageConsumer { List commandObjcopy; commandObjcopy = new ArrayList(baseCommandObjcopy); - commandObjcopy.add(2, "srec"); + commandObjcopy.add(2, "ihex"); + commandObjcopy.set(3, "-j"); commandObjcopy.add(".eeprom"); + commandObjcopy.add("--set-section-flags=.eeprom=alloc,load"); + commandObjcopy.add("--change-section-lma"); + commandObjcopy.add(".eeprom=0"); commandObjcopy.add(buildPath + File.separator + sketch.name + ".elf"); - commandObjcopy.add(buildPath + File.separator + sketch.name + ".rom"); + commandObjcopy.add(buildPath + File.separator + sketch.name + ".eep"); if (execAsynchronously(commandObjcopy) != 0) return false; commandObjcopy = new ArrayList(baseCommandObjcopy); commandObjcopy.add(2, "ihex"); - commandObjcopy.add(".flash"); + commandObjcopy.add(".eeprom"); commandObjcopy.add(buildPath + File.separator + sketch.name + ".elf"); commandObjcopy.add(buildPath + File.separator + sketch.name + ".hex"); if (execAsynchronously(commandObjcopy) != 0) diff --git a/hardware/bootloaders/atmega168/ATmegaBOOT_168.c b/hardware/bootloaders/atmega168/ATmegaBOOT_168.c index f1c1cdfcb..6a3c634b4 100755 --- a/hardware/bootloaders/atmega168/ATmegaBOOT_168.c +++ b/hardware/bootloaders/atmega168/ATmegaBOOT_168.c @@ -65,7 +65,7 @@ #include #include #include - +#include /* the current avr-libc eeprom functions do not support the ATmega168 */ /* own eeprom write/read functions are used instead */ @@ -448,8 +448,9 @@ int main(void) } - /* Enter programming mode */ - else if(ch=='P') { + /* P: Enter programming mode */ + /* R: Erase device, don't care as we will erase one page at a time anyway. */ + else if(ch=='P' || ch=='R') { nothing_response(); } @@ -465,12 +466,6 @@ int main(void) } - /* Erase device, don't care as we will erase one page at a time anyway. */ - else if(ch=='R') { - nothing_response(); - } - - /* Set address, little endian. EEPROM in bytes, FLASH in words */ /* Perhaps extra address bytes may be added in future to support > 128kB FLASH. */ /* This might explain why little endian was used here, big endian used everywhere else. */ @@ -483,8 +478,21 @@ int main(void) /* Universal SPI programming command, disabled. Would be used for fuses and lock bits. */ else if(ch=='V') { - getNch(4); - byte_response(0x00); + if (getch() == 0x30) { + getch(); + ch = getch(); + getch(); + if (ch == 0) { + byte_response(SIG1); + } else if (ch == 1) { + byte_response(SIG2); + } else { + byte_response(SIG3); + } + } else { + getNch(3); + byte_response(0x00); + } } @@ -499,6 +507,7 @@ int main(void) } if (getch() == ' ') { if (flags.eeprom) { //Write to EEPROM one byte at a time + address.word <<= 1; for(w=0;w0x7FFF) flags.rampz = 1; // No go with m256, FIXME else flags.rampz = 0; #endif + address.word = address.word << 1; // address * 2 -> byte location if (getch() == 'E') flags.eeprom = 1; - else { - flags.eeprom = 0; - address.word = address.word << 1; // address * 2 -> byte location - } + else flags.eeprom = 0; if (getch() == ' ') { // Command terminator putch(0x14); for (w=0;w < length.word;w++) { // Can handle odd and even lengths okay @@ -817,42 +824,42 @@ int main(void) } -char gethex(void) { - char ah,al; +char gethexnib(void) { + char a; + a = getch(); putch(a); + if(a >= 'a') { + return (a - 'a' + 0x0a); + } else if(a >= '0') { + return(a - '0'); + } + return a; +} - ah = getch(); putch(ah); - al = getch(); putch(al); - if(ah >= 'a') { - ah = ah - 'a' + 0x0a; - } else if(ah >= '0') { - ah -= '0'; - } - if(al >= 'a') { - al = al - 'a' + 0x0a; - } else if(al >= '0') { - al -= '0'; - } - return (ah << 4) + al; + +char gethex(void) { + return (gethexnib() << 4) + gethexnib(); } void puthex(char ch) { - char ah,al; + char ah; - ah = (ch & 0xf0) >> 4; + ah = ch >> 4; if(ah >= 0x0a) { ah = ah - 0x0a + 'a'; } else { ah += '0'; } - al = (ch & 0x0f); - if(al >= 0x0a) { - al = al - 0x0a + 'a'; + + ch &= 0x0f; + if(ch >= 0x0a) { + ch = ch - 0x0a + 'a'; } else { - al += '0'; + ch += '0'; } + putch(ah); - putch(al); + putch(ch); } @@ -917,8 +924,7 @@ char getch(void) void getNch(uint8_t count) { - uint8_t i; - for(i=0;i after other #include's? (prevent it from interfering with standard libraries) -[done] Add LiquidCrystal library. -[done] Add Servo library. -[done] Fix millis() so it overflows on a nice variable-size boundary; see: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1205949448 -[done] Factor out print statements into a common base class for Serial, LiquidCrystal, etc. +0013 arduino AVR +Use stdlib random() function: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1211798802 +Remove cast macros for built-in types. +Allow hardcoding of R/W line to ground with LiquidCrystal library. Improve shiftOut() performance: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1216659239/0 Add String library. Add Encoder library. @@ -52,6 +34,7 @@ Add SPI library. Add OneWire library. Add pulseOut(), etc. functions from Wiring. Add Ping example. +Switch to ServoTimer2 library? http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1222201226/0#5 Add ContinuousServo library that inherits from Servo? LiquidCrystal library: support going to the next line with println(). Ethernet library: