From: Stephan Baerwolf Date: Sat, 17 Nov 2012 23:29:26 +0000 (+0100) Subject: new feature "HAVE_FLASH_BYTE_READACCESS" to fix read bug in avrdude terminal X-Git-Tag: v0.95~10 X-Git-Url: http://git.linex4red.de/pub/USBaspLoader.git/commitdiff_plain/a4f6908ad005ecea32d3ea0830e01785ffde6468?ds=sidebyside new feature "HAVE_FLASH_BYTE_READACCESS" to fix read bug in avrdude terminal Signed-off-by: Stephan Baerwolf --- diff --git a/firmware/bootloaderconfig.h b/firmware/bootloaderconfig.h index 4f3f613..9072a09 100644 --- a/firmware/bootloaderconfig.h +++ b/firmware/bootloaderconfig.h @@ -239,6 +239,13 @@ these macros are defined, the boot loader usees them. * 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 diff --git a/firmware/main.c b/firmware/main.c index 53d1ae0..7e841e6 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -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 +#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);