Commit 958b20a8 authored by Dean Camera's avatar Dean Camera
Browse files

Fixed possible programming problem in the AVRISP-MKII clone project when...

Fixed possible programming problem in the AVRISP-MKII clone project when programming specific patterns into a target memory space that is only byte (not page) addressable.
parent bfa622d2
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
* - Fixed broken HID_REQ_GetReport request handler in the Low Level GenericHID demo * - Fixed broken HID_REQ_GetReport request handler in the Low Level GenericHID demo
* - Fixed possible lost data in the XPLAINBridge, USBtoSerial and Benito projects when the host exceeds the packet * - Fixed possible lost data in the XPLAINBridge, USBtoSerial and Benito projects when the host exceeds the packet
* timeout period on received packets as set by USB_STREAM_TIMEOUT_MS (thanks to Justin Rajewski) * timeout period on received packets as set by USB_STREAM_TIMEOUT_MS (thanks to Justin Rajewski)
* - Fixed possible programming problem in the AVRISP-MKII clone project when programming specific patterns into a target
* memory space that is only byte (not page) addressable
* *
* \section Sec_ChangeLog101122 Version 101122 * \section Sec_ChangeLog101122 Version 101122
* <b>New:</b> * <b>New:</b>
......
...@@ -20,7 +20,10 @@ ...@@ -20,7 +20,10 @@
* -# Re-add interrupt Pipe/Endpoint support * -# Re-add interrupt Pipe/Endpoint support
* -# Add HID report macros to make HID report editing easier * -# Add HID report macros to make HID report editing easier
* -# Investigate dynamically created device descriptors * -# Investigate dynamically created device descriptors
* -# Check if ALL the workaround reg save/restore code in the unordered EP config is required * - Known Bugs
* -# Errors with AVRISP-MKII program with full EEPROM programming on the ATMEGA8 (and others?)
* -# No wakeup when plugged into hub, and hub plugged into host
* -# Incomplete TMC class demo errors
* - Documentation/Support * - Documentation/Support
* -# Add detailed overviews of how each demo works * -# Add detailed overviews of how each demo works
* -# Add board overviews * -# Add board overviews
......
...@@ -146,8 +146,6 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command) ...@@ -146,8 +146,6 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
Endpoint_Read_Stream_LE(&Write_Memory_Params, (sizeof(Write_Memory_Params) - Endpoint_Read_Stream_LE(&Write_Memory_Params, (sizeof(Write_Memory_Params) -
sizeof(Write_Memory_Params.ProgData)), NO_STREAM_CALLBACK); sizeof(Write_Memory_Params.ProgData)), NO_STREAM_CALLBACK);
Write_Memory_Params.BytesToWrite = SwapEndian_16(Write_Memory_Params.BytesToWrite); Write_Memory_Params.BytesToWrite = SwapEndian_16(Write_Memory_Params.BytesToWrite);
if (Write_Memory_Params.BytesToWrite > sizeof(Write_Memory_Params.ProgData)) if (Write_Memory_Params.BytesToWrite > sizeof(Write_Memory_Params.ProgData))
...@@ -224,15 +222,16 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command) ...@@ -224,15 +222,16 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
ISPTarget_SendByte(StartAddress & 0xFF); ISPTarget_SendByte(StartAddress & 0xFF);
ISPTarget_SendByte(0x00); ISPTarget_SendByte(0x00);
/* Check if polling is possible and enabled, if not switch to timed delay mode */ /* Check if polling is enabled and possible, if not switch to timed delay mode */
if (!(PollAddress) && (Write_Memory_Params.ProgrammingMode & PROG_MODE_PAGED_VALUE_MASK)) if ((Write_Memory_Params.ProgrammingMode & PROG_MODE_PAGED_VALUE_MASK) && !(PollAddress))
{ {
Write_Memory_Params.ProgrammingMode &= ~PROG_MODE_PAGED_VALUE_MASK; Write_Memory_Params.ProgrammingMode = (Write_Memory_Params.ProgrammingMode & ~PROG_MODE_PAGED_VALUE_MASK) |
Write_Memory_Params.ProgrammingMode |= PROG_MODE_PAGED_TIMEDELAY_MASK; PROG_MODE_PAGED_TIMEDELAY_MASK;
} }
ProgrammingStatus = ISPTarget_WaitForProgComplete(Write_Memory_Params.ProgrammingMode, PollAddress, PollValue, ProgrammingStatus = ISPTarget_WaitForProgComplete(Write_Memory_Params.ProgrammingMode, PollAddress, PollValue,
Write_Memory_Params.DelayMS, Write_Memory_Params.ProgrammingCommands[2]); Write_Memory_Params.DelayMS,
Write_Memory_Params.ProgrammingCommands[2]);
/* Check to see if the FLASH address has crossed the extended address boundary */ /* Check to see if the FLASH address has crossed the extended address boundary */
if ((V2Command == CMD_PROGRAM_FLASH_ISP) && !(CurrentAddress & 0xFFFF)) if ((V2Command == CMD_PROGRAM_FLASH_ISP) && !(CurrentAddress & 0xFFFF))
...@@ -271,17 +270,20 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command) ...@@ -271,17 +270,20 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
{ {
if (IsOddByte && (V2Command == CMD_PROGRAM_FLASH_ISP)) if (IsOddByte && (V2Command == CMD_PROGRAM_FLASH_ISP))
Write_Memory_Params.ProgrammingCommands[2] |= READ_WRITE_HIGH_BYTE_MASK; Write_Memory_Params.ProgrammingCommands[2] |= READ_WRITE_HIGH_BYTE_MASK;
else
Write_Memory_Params.ProgrammingCommands[2] &= ~READ_WRITE_HIGH_BYTE_MASK;
PollAddress = (CurrentAddress & 0xFFFF); PollAddress = (CurrentAddress & 0xFFFF);
} }
else if (!(Write_Memory_Params.ProgrammingMode & PROG_MODE_WORD_READYBUSY_MASK)) else if (!(Write_Memory_Params.ProgrammingMode & PROG_MODE_WORD_READYBUSY_MASK))
{ {
Write_Memory_Params.ProgrammingMode &= ~PROG_MODE_WORD_VALUE_MASK; Write_Memory_Params.ProgrammingMode = (Write_Memory_Params.ProgrammingMode & ~PROG_MODE_WORD_VALUE_MASK) |
Write_Memory_Params.ProgrammingMode |= PROG_MODE_WORD_TIMEDELAY_MASK; PROG_MODE_WORD_TIMEDELAY_MASK;
} }
ProgrammingStatus = ISPTarget_WaitForProgComplete(Write_Memory_Params.ProgrammingMode, PollAddress, PollValue, ProgrammingStatus = ISPTarget_WaitForProgComplete(Write_Memory_Params.ProgrammingMode, PollAddress, PollValue,
Write_Memory_Params.DelayMS, Write_Memory_Params.ProgrammingCommands[2]); Write_Memory_Params.DelayMS,
Write_Memory_Params.ProgrammingCommands[2]);
/* Restore previous programming mode mask in case the current word needed to change it */ /* Restore previous programming mode mask in case the current word needed to change it */
Write_Memory_Params.ProgrammingMode = PreviousProgrammingMode; Write_Memory_Params.ProgrammingMode = PreviousProgrammingMode;
...@@ -293,7 +295,7 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command) ...@@ -293,7 +295,7 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
/* EEPROM just increments the address each byte, flash needs to increment on each word and /* EEPROM just increments the address each byte, flash needs to increment on each word and
* also check to ensure that a LOAD EXTENDED ADDRESS command is issued each time the extended * also check to ensure that a LOAD EXTENDED ADDRESS command is issued each time the extended
* address boundary has been crossed */ * address boundary has been crossed */
if ((CurrentByte & 0x01) || (V2Command == CMD_PROGRAM_EEPROM_ISP)) if (IsOddByte || (V2Command == CMD_PROGRAM_EEPROM_ISP))
{ {
CurrentAddress++; CurrentAddress++;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment