new feature "HAVE_FLASH_BYTE_READACCESS" to fix read bug in avrdude terminal
authorStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Sat, 17 Nov 2012 23:29:26 +0000 (00:29 +0100)
committerStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Mon, 19 Nov 2012 15:16:57 +0000 (15:16 +0000)
Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
firmware/bootloaderconfig.h
firmware/main.c

index 4f3f613..9072a09 100644 (file)
@@ -239,6 +239,13 @@ these macros are defined, the boot loader usees them.
  * Therefore it is very small, which saves some PROGMEM bytes!
  */
 
  * Therefore it is very small, which saves some PROGMEM bytes!
  */
 
+#define HAVE_FLASH_BYTE_READACCESS     1
+/* If HAVE_FLASH_BYTE_READACCESS is defined to 1, byte mode access to FLASH is
+ * compiled in. Byte mode sometimes might be used by some programming softwares
+ * (avrdude in terminal mode). Without this feature the device would return "0"
+ * instead the right content of the flash memory.
+ */
+
 //#define SIGNATURE_BYTES             0x1e, 0x93, 0x07, 0     /* ATMega8 */
 /* This macro defines the signature bytes returned by the emulated USBasp to
  * the programmer software. They should match the actual device at least in
 //#define SIGNATURE_BYTES             0x1e, 0x93, 0x07, 0     /* ATMega8 */
 /* This macro defines the signature bytes returned by the emulated USBasp to
  * the programmer software. They should match the actual device at least in
index 53d1ae0..7e841e6 100644 (file)
@@ -248,6 +248,20 @@ static uchar    replyBuffer[4];
        #warning "HAVE_READ_LOCK_FUSE is activated but MCU unknown -> will not support this feature"
 #endif
 #endif
        #warning "HAVE_READ_LOCK_FUSE is activated but MCU unknown -> will not support this feature"
 #endif
 #endif
+#if HAVE_FLASH_BYTE_READACCESS
+        }else if(rq->wValue.bytes[0] == 0x20){  /* read FLASH low  byte */
+#if ((FLASHEND) > 65535)
+            rval = pgm_read_byte_far((((addr_t)address.word)<<1)+0);
+#else
+            rval = pgm_read_byte((((addr_t)address.word)<<1)+0);
+#endif
+        }else if(rq->wValue.bytes[0] == 0x28){  /* read FLASH high byte */
+#if ((FLASHEND) > 65535)
+            rval = pgm_read_byte_far((((addr_t)address.word)<<1)+1);
+#else
+            rval = pgm_read_byte((((addr_t)address.word)<<1)+1);
+#endif
+#endif
 #if HAVE_EEPROM_BYTE_ACCESS
         }else if(rq->wValue.bytes[0] == 0xa0){  /* read EEPROM byte */
             rval = eeprom_read_byte((void *)address.word);
 #if HAVE_EEPROM_BYTE_ACCESS
         }else if(rq->wValue.bytes[0] == 0xa0){  /* read EEPROM byte */
             rval = eeprom_read_byte((void *)address.word);