From ff850ee36c1ba01057092d2c3d95a9b72e9d73bc Mon Sep 17 00:00:00 2001 From: ricklon Date: Sat, 26 Mar 2011 20:07:43 -0400 Subject: [PATCH] Changes to fix issue 392. --- .../arduino/bootloaders/stk500v2/stk500boot.c | 68 ++++++++++++++----- .../examples/ATS_Issue392/ATS_Issue392.pde | 46 +++++++++++++ 2 files changed, 98 insertions(+), 16 deletions(-) create mode 100644 libraries/ArduinoTestSuite/examples/ATS_Issue392/ATS_Issue392.pde diff --git a/hardware/arduino/bootloaders/stk500v2/stk500boot.c b/hardware/arduino/bootloaders/stk500v2/stk500boot.c index 13dec895182..e9960983ff2 100755 --- a/hardware/arduino/bootloaders/stk500v2/stk500boot.c +++ b/hardware/arduino/bootloaders/stk500v2/stk500boot.c @@ -164,6 +164,7 @@ Description: add timeout feature like previous Wiring bootloader #define F_CPU 16000000UL #endif +#define _BLINK_LOOP_COUNT_ (F_CPU / 2250) /* * UART Baudrate, AVRStudio AVRISP only accepts 115200 bps */ @@ -228,6 +229,13 @@ Description: add timeout feature like previous Wiring bootloader #define SIGNATURE_BYTES 0x1E9801 #elif defined (__AVR_ATmega2561__) #define SIGNATURE_BYTES 0x1e9802 +#elif defined (__AVR_ATmega1284P__) + #define SIGNATURE_BYTES 0x1e9705 +#elif defined (__AVR_ATmega640__) + #define SIGNATURE_BYTES 0x1e9608 +#elif defined (__AVR_ATmega64__) + #define SIGNATURE_BYTES 0x1E9602 + #else #error "no signature definition for MCU available" #endif @@ -442,7 +450,16 @@ int main(void) unsigned long boot_timer; unsigned int boot_state; #ifdef ENABLE_MONITOR - unsigned int exPointCntr = 0; + unsigned int exPointCntr = 0; + unsigned int rcvdCharCntr = 0; +#endif + +#if 1 + asm volatile ( ".set __stack, %0" :: "i" (RAMEND) ); + asm volatile ( "ldi 16, %0" :: "i" (RAMEND >> 8) ); + asm volatile ( "out %0,16" :: "i" (AVR_STACK_POINTER_HI_ADDR) ); + asm volatile ( "ldi 16, %0" :: "i" (RAMEND & 0x0ff) ); + asm volatile ( "out %0,16" :: "i" (AVR_STACK_POINTER_LO_ADDR) ); #endif @@ -516,7 +533,7 @@ int main(void) boot_state = 1; // (after ++ -> boot_state=2 bootloader timeout, jump to main 0x00000 ) } #ifdef BLINK_LED_WHILE_WAITING - if ((boot_timer % 7000) == 0) + if ((boot_timer % _BLINK_LOOP_COUNT_) == 0) { //* toggle the LED PROGLED_PORT ^= (1< 0x10000) theChar = pgm_read_byte_far((uint32_t)dataPtr + ii); + #else + theChar = pgm_read_byte_near((uint32_t)dataPtr + ii); + #endif if (theChar != 0) { sendchar(theChar); @@ -1388,7 +1412,11 @@ unsigned char *ramPtr; switch(dumpWhat) { case kDUMP_FLASH: + #if (FLASHEND > 0x10000) theValue = pgm_read_byte_far(myAddressPointer); + #else + theValue = pgm_read_byte_near(myAddressPointer); + #endif break; case kDUMP_EEPROM: @@ -1435,7 +1463,11 @@ int errorCount; PrintFromPROGMEMln(gTextMsg_WriteToEEprom, 0); PrintNewLine(); ii = 0; +#if (FLASHEND > 0x10000) while (((theChar = pgm_read_byte_far(gTextMsg_Explorer + ii)) != '*') && (ii < 512)) +#else + while (((theChar = pgm_read_byte_near(gTextMsg_Explorer + ii)) != '*') && (ii < 512)) +#endif { eeprom_write_byte((uint8_t *)ii, theChar); if (theChar == 0) @@ -1456,7 +1488,11 @@ int errorCount; PrintNewLine(); errorCount = 0; ii = 0; +#if (FLASHEND > 0x10000) while (((theChar = pgm_read_byte_far(gTextMsg_Explorer + ii)) != '*') && (ii < 512)) +#else + while (((theChar = pgm_read_byte_near(gTextMsg_Explorer + ii)) != '*') && (ii < 512)) +#endif { theEEPROMchar = eeprom_read_byte((uint8_t *)ii); if (theEEPROMchar == 0) diff --git a/libraries/ArduinoTestSuite/examples/ATS_Issue392/ATS_Issue392.pde b/libraries/ArduinoTestSuite/examples/ATS_Issue392/ATS_Issue392.pde new file mode 100644 index 00000000000..7915f3105f6 --- /dev/null +++ b/libraries/ArduinoTestSuite/examples/ATS_Issue392/ATS_Issue392.pde @@ -0,0 +1,46 @@ +//************************************************************************ +//* Arduino Test Example Skeleton +//* (C) 2010 by Rick Anderson +//* Open source as per standard Arduino code +//* +//************************************************************************ +//* Oct 16, 2010 Started on String Test +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include + +//************************************************************************ +void setup() +{ + + ATS_begin("Arduino", "Issue 392 Test"); + /* + * Test Run Start + * Test one passes because result is set to true + * Test two fails becuase result is set to false + * You can test memory for any set of tests by using the ATS_ReportMemoryUsage test + * There is also a way to print current memeory for debugging + */ + Serial.println("!!!"); + ATS_PrintTestStatus("1. Issue 392 !!! error", true); + /* + * Test Run End + */ + + ATS_end(); + +} + + +//************************************************************************ +void loop() +{ + + +} + + + +