From 4f47c560acead413ccb8e16f82959392d0b45aa9 Mon Sep 17 00:00:00 2001 From: Thomas Fischl Date: Tue, 24 Jul 2007 16:43:25 +0000 Subject: [PATCH] usbasp.c: Added long addresses to support devices with more than 64kB (bug #20558) git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@746 81a1dc3b-b13d-400b-aceb-764788c761c2 --- avrdude/ChangeLog | 6 ++++++ avrdude/usbasp.c | 27 +++++++++++++++++++++++++++ avrdude/usbasp.h | 1 + 3 files changed, 34 insertions(+) diff --git a/avrdude/ChangeLog b/avrdude/ChangeLog index 7da9ebe4..e41359de 100644 --- a/avrdude/ChangeLog +++ b/avrdude/ChangeLog @@ -1,3 +1,9 @@ +2007-07-24 Thomas Fischl + + * usbasp.c: Added long addresses to support devices with more + than 64kB flash. Closes bug #20558: Long address problem with + USBasp. + 2007-06-27 Joerg Wunsch * Makefile.am (EXTRA_DIST): Add ChangeLog-2004-2006. diff --git a/avrdude/usbasp.c b/avrdude/usbasp.c index 434d8229..6bfe14e0 100644 --- a/avrdude/usbasp.c +++ b/avrdude/usbasp.c @@ -316,8 +316,22 @@ static int usbasp_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, wbytes = 0; } + /* set address (new mode) - if firmware on usbasp support newmode, then they use address from this command */ + unsigned char temp[4]; + memset(temp, 0, sizeof(temp)); cmd[0] = address & 0xFF; cmd[1] = address >> 8; + cmd[2] = address >> 16; + cmd[3] = address >> 24; + usbasp_transmit(1, USBASP_FUNC_SETLONGADDRESS, cmd, temp, sizeof(temp)); + + /* send command with address (compatibility mode) - if firmware on + usbasp doesn't support newmode, then they use address from this */ + cmd[0] = address & 0xFF; + cmd[1] = address >> 8; + // for compatibility - previous version of usbasp.c doesn't initialize this fields (firmware ignore it) + cmd[2] = 0; + cmd[3] = 0; n = usbasp_transmit(1, function, cmd, buffer, blocksize); @@ -366,6 +380,19 @@ static int usbasp_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, blockflags |= USBASP_BLOCKFLAG_LAST; } + /* set address (new mode) - if firmware on usbasp support newmode, then + they use address from this command */ + unsigned char temp[4]; + memset(temp, 0, sizeof(temp)); + cmd[0] = address & 0xFF; + cmd[1] = address >> 8; + cmd[2] = address >> 16; + cmd[3] = address >> 24; + usbasp_transmit(1, USBASP_FUNC_SETLONGADDRESS, cmd, temp, sizeof(temp)); + + /* normal command - firmware what support newmode - use address from previous command, + firmware what doesn't support newmode - ignore previous command and use address from this command */ + cmd[0] = address & 0xFF; cmd[1] = address >> 8; cmd[2] = page_size & 0xFF; diff --git a/avrdude/usbasp.h b/avrdude/usbasp.h index 003a6088..2da429bc 100644 --- a/avrdude/usbasp.h +++ b/avrdude/usbasp.h @@ -39,6 +39,7 @@ #define USBASP_FUNC_WRITEFLASH 6 #define USBASP_FUNC_READEEPROM 7 #define USBASP_FUNC_WRITEEEPROM 8 +#define USBASP_FUNC_SETLONGADDRESS 9 #define USBASP_BLOCKFLAG_FIRST 1 #define USBASP_BLOCKFLAG_LAST 2