From 876559d375ede56c6abbce7620e05046e98e20d2 Mon Sep 17 00:00:00 2001 From: Jenna Fox Date: Tue, 11 Sep 2012 09:06:41 +1000 Subject: [PATCH] Added ifdefs to disable APPCHECKSUM --- firmware/bootloaderconfig.h | 8 ++++---- firmware/main.c | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/firmware/bootloaderconfig.h b/firmware/bootloaderconfig.h index 3919357..4b4f4ef 100644 --- a/firmware/bootloaderconfig.h +++ b/firmware/bootloaderconfig.h @@ -174,15 +174,15 @@ these macros are defined, the boot loader uses them. # define MCUCSR MCUSR #endif -#define APPCHECKSUM +//#define APPCHECKSUM /* tiny85 Architecture Specifics */ #ifdef __AVR_ATtiny85__ # define TINY85MODE -# ifndef APPCHECKSUM -# define APPCHECKSUM -# endif +//# ifndef APPCHECKSUM +//# define APPCHECKSUM +//# endif // number of bytes before the boot loader vectors to store the tiny application vector table # define TINYVECTOR_RESET_OFFSET 4 diff --git a/firmware/main.c b/firmware/main.c index 89afdab..c22b248 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -164,8 +164,10 @@ static void writeWordToPageBuffer(uint16_t data) data = 0xC000 + (BOOTLOADER_ADDRESS/2) - 1; // write 2's complement of checksum +#ifdef APPCHECKSUM if(CURRENT_ADDRESS == BOOTLOADER_ADDRESS - APPCHECKSUM_POSITION) data = (uint8_t)(~checksum + 1); +#endif if(CURRENT_ADDRESS == BOOTLOADER_ADDRESS - TINYVECTOR_RESET_OFFSET) data = vectorTemp[0] + ((FLASHEND + 1) - BOOTLOADER_ADDRESS)/2 + 2 + RESET_VECTOR_OFFSET; @@ -173,8 +175,10 @@ static void writeWordToPageBuffer(uint16_t data) if(CURRENT_ADDRESS == BOOTLOADER_ADDRESS - TINYVECTOR_USBPLUS_OFFSET) data = vectorTemp[1] + ((FLASHEND + 1) - BOOTLOADER_ADDRESS)/2 + 1 + USBPLUS_VECTOR_OFFSET; +#ifdef APPCHECKSUM // only calculate checksum when we are writing new data to flash (ignore when writing vectors after bootloader programming) checksum += (uint8_t)(data/256) + (uint8_t)(data); +#endif // clear page buffer as a precaution before filling the buffer on the first page // TODO: maybe clear on the first byte of every page? @@ -544,7 +548,9 @@ static inline void tiny85FlashInit(void) // TODO: necessary to reset CURRENT_ADDRESS? CURRENT_ADDRESS = 0; - checksum = 0; +# ifdef APPCHECKSUM + checksum = 0; +# endif } static inline void tiny85FlashWrites(void) @@ -557,7 +563,9 @@ static inline void tiny85FlashWrites(void) eraseApplication(); sei(); +#ifdef APPCHECKSUM checksum = 0; +#endif eraseRequested = 0; } #endif