Commit 80d85090 authored by Dean Camera's avatar Dean Camera
Browse files

Fixed AVRISP project sending a LOAD EXTENDED ADDRESS command to 128KB AVRs...

Fixed AVRISP project sending a LOAD EXTENDED ADDRESS command to 128KB AVRs after programming or reading from the last page of FLASH.
parent 6b7770ef
......@@ -6,26 +6,18 @@
/** \page Page_ChangeLog Project Changelog
*
* \section Sec_ChangeLog100513 Version 100513
* \section Sec_ChangeLogXXXXXX Version XXXXXX
* <b>New:</b>
* - N/A
* N/A
*
* <b>Changed:</b>
* - The TeensyHID bootloader has been removed, per request from Paul at PJRC
* - The LIBUSB_FILTERDRV_COMPAT compile time option in the XPLAINBridge and AVRISP-MKII projects has been renamed
* LIBUSB_DRIVER_COMPAT, as it applies to all software on all platforms using the libUSB driver
* N/A
*
* <b>Fixed:</b>
* - Fixed possible device lockup when INTERRUPT_CONTROL_ENDPOINT is enabled and the control endpoint is not properly
* selected when the ISR completes
* - Fixed AVRISP-MKII clone project not correctly issuing LOAD EXTENDED ADDRESS commands when the extended address
* boundary is crossed during programming or readback (thanks to Gerard Sexton)
* - Fixed warnings when building the AVRISP-MKII clone project with the ENABLE_XPROG_PROTOCOL compile time option disabled
* - Remove incorrect check for the current device state in the Set Configuration request handler of DevChapter9, which broke
* Set Configuration requests to the device under most circumstances.
*
* \section Sec_ChangeLog100512 Version 100512
* - Fixed AVRISP project sending a LOAD EXTENDED ADDRESS command to 128KB AVRs after programming or reading from
* the last page of FLASH
*
* \section Sec_ChangeLog100513 Version 100513
* <b>New:</b>
* - Added incomplete MIDIToneGenerator project
* - Added new Relay Controller Board project (thanks to OBinou)
......@@ -63,8 +55,18 @@
* properly reset to their defaults
* - Device mode class driver callbacks are now fired before the control request status stage is sent to prevent the host from
* timing out if another request is immediately fired and the device has a lengthy callback routine
* - The TeensyHID bootloader has been removed, per request from Paul at PJRC
* - The LIBUSB_FILTERDRV_COMPAT compile time option in the XPLAINBridge and AVRISP-MKII projects has been renamed
* LIBUSB_DRIVER_COMPAT, as it applies to all software on all platforms using the libUSB driver
*
* <b>Fixed:</b>
* - Fixed possible device lockup when INTERRUPT_CONTROL_ENDPOINT is enabled and the control endpoint is not properly
* selected when the ISR completes
* - Fixed AVRISP-MKII clone project not correctly issuing LOAD EXTENDED ADDRESS commands when the extended address
* boundary is crossed during programming or readback (thanks to Gerard Sexton)
* - Fixed warnings when building the AVRISP-MKII clone project with the ENABLE_XPROG_PROTOCOL compile time option disabled
* - Remove incorrect check for the current device state in the Set Configuration request handler of DevChapter9, which broke
* Set Configuration requests to the device under most circumstances.
* - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin
* - Fixed TWI_StartTransmission() corrupting the contents of the GPIOR0 register
* - Fixed TWI driver not aborting when faced with no response after attempting to address a device on the bus
......
......@@ -10,11 +10,10 @@
* to the next version released. It does not indicate all new additions to the library in each version change, only
* areas relevant to making older projects compatible with the API changes of each new release.
*
* \section Sec_Migration100513 Migrating from 100512 to 100513
* This release was made shortly after the 100512 release, to fix a critical device-mode error. No specific migration
* information applies to this release - see \ref Sec_Migration100512 for migration information of the previous release.
* \section Sec_Migration100513 Migrating from 100219 to 100513
* N/A
*
* \section Sec_Migration100512 Migrating from 100219 to 100512
* \section Sec_Migration100513 Migrating from 100219 to 100513
*
* <b>Non-USB Library Components</b>
* - The \ref TWI_StartTransmission() function now takes in a timeout period, expressed in milliseconds, within which the addressed
......
......@@ -186,22 +186,18 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
Write_Memory_Params.PollValue2;
uint8_t* NextWriteByte = Write_Memory_Params.ProgData;
/* Check to see if the host has issued a SET ADDRESS command and we haven't sent a
* LOAD EXTENDED ADDRESS command (if needed, used when operating beyond the 128KB
* FLASH barrier) */
if (MustSetAddress)
{
if (CurrentAddress & (1UL << 31))
ISPTarget_LoadExtendedAddress();
MustSetAddress = false;
}
/* Check the programming mode desired by the host, either Paged or Word memory writes */
if (Write_Memory_Params.ProgrammingMode & PROG_MODE_PAGED_WRITES_MASK)
{
uint16_t StartAddress = (CurrentAddress & 0xFFFF);
/* Check to see if we need to send a LOAD EXTENDED ADDRESS command to the target */
if (MustLoadExtendedAddress)
{
ISPTarget_LoadExtendedAddress();
MustLoadExtendedAddress = false;
}
/* Paged mode memory programming */
for (uint16_t CurrentByte = 0; CurrentByte < Write_Memory_Params.BytesToWrite; CurrentByte++)
{
......@@ -252,7 +248,7 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
/* Check to see if the FLASH address has crossed the extended address boundary */
if ((V2Command == CMD_PROGRAM_FLASH_ISP) && !(CurrentAddress & 0xFFFF))
ISPTarget_LoadExtendedAddress();
MustLoadExtendedAddress = true;
}
}
else
......@@ -263,6 +259,13 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
bool IsOddByte = (CurrentByte & 0x01);
uint8_t ByteToWrite = *(NextWriteByte++);
/* Check to see if we need to send a LOAD EXTENDED ADDRESS command to the target */
if (MustLoadExtendedAddress)
{
ISPTarget_LoadExtendedAddress();
MustLoadExtendedAddress = false;
}
SPI_SendByte(Write_Memory_Params.ProgrammingCommands[0]);
SPI_SendByte(CurrentAddress >> 8);
SPI_SendByte(CurrentAddress & 0xFF);
......@@ -291,14 +294,12 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
/* 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
* address boundary has been crossed */
if (V2Command == CMD_PROGRAM_EEPROM_ISP)
if ((CurrentByte & 0x01) || (V2Command == CMD_PROGRAM_EEPROM_ISP))
{
CurrentAddress++;
}
else if (IsOddByte)
{
if (!(++CurrentAddress & 0xFFFF))
ISPTarget_LoadExtendedAddress();
if ((V2Command != CMD_PROGRAM_EEPROM_ISP) && !(CurrentAddress & 0xFFFF))
MustLoadExtendedAddress = true;
}
}
}
......@@ -330,21 +331,17 @@ void ISPProtocol_ReadMemory(uint8_t V2Command)
Endpoint_Write_Byte(V2Command);
Endpoint_Write_Byte(STATUS_CMD_OK);
/* Check to see if the host has issued a SET ADDRESS command and we haven't sent a
* LOAD EXTENDED ADDRESS command (if needed, used when operating beyond the 128KB
* FLASH barrier) */
if (MustSetAddress)
{
if (CurrentAddress & (1UL << 31))
ISPTarget_LoadExtendedAddress();
MustSetAddress = false;
}
/* Read each byte from the device and write them to the packet for the host */
for (uint16_t CurrentByte = 0; CurrentByte < Read_Memory_Params.BytesToRead; CurrentByte++)
{
/* Check to see if we need to send a LOAD EXTENDED ADDRESS command to the target */
if (MustLoadExtendedAddress)
{
ISPTarget_LoadExtendedAddress();
MustLoadExtendedAddress = false;
}
/* Read the next byte from the desired memory space in the device */
SPI_SendByte(Read_Memory_Params.ReadMemoryCommand);
SPI_SendByte(CurrentAddress >> 8);
......@@ -366,14 +363,12 @@ void ISPProtocol_ReadMemory(uint8_t V2Command)
/* 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
* address boundary has been crossed */
if (V2Command == CMD_READ_EEPROM_ISP)
if ((CurrentByte & 0x01) || (V2Command == CMD_READ_EEPROM_ISP))
{
CurrentAddress++;
}
else if (CurrentByte & 0x01)
{
if (!(++CurrentAddress & 0xFFFF))
ISPTarget_LoadExtendedAddress();
if ((V2Command != CMD_READ_EEPROM_ISP) && !(CurrentAddress & 0xFFFF))
MustLoadExtendedAddress = true;
}
}
......
......@@ -39,8 +39,8 @@
/** Current memory address for FLASH/EEPROM memory read/write commands */
uint32_t CurrentAddress;
/** Flag to indicate that the next read/write operation must update the device's current address */
bool MustSetAddress;
/** Flag to indicate that the next read/write operation must update the device's current extended FLASH address */
bool MustLoadExtendedAddress;
/** ISR to manage timeouts whilst processing a V2Protocol command */
......@@ -251,7 +251,8 @@ static void V2Protocol_LoadAddress(void)
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
MustSetAddress = true;
if (CurrentAddress & (1UL << 31))
MustLoadExtendedAddress = true;
Endpoint_Write_Byte(CMD_LOAD_ADDRESS);
Endpoint_Write_Byte(STATUS_CMD_OK);
......
......@@ -84,7 +84,7 @@
/* External Variables: */
#if !defined(__ASSEMBLER__)
extern uint32_t CurrentAddress;
extern bool MustSetAddress;
extern bool MustLoadExtendedAddress;
#endif
/* Function Prototypes: */
......
......@@ -44,11 +44,11 @@ static ParameterItem_t ParameterTable[] =
{
{ .ParamID = PARAM_BUILD_NUMBER_LOW,
.ParamPrivileges = PARAM_PRIV_READ,
.ParamValue = (LUFA_VERSION_INTEGER >> 8) },
.ParamValue = 0 },
{ .ParamID = PARAM_BUILD_NUMBER_HIGH,
.ParamPrivileges = PARAM_PRIV_READ,
.ParamValue = (LUFA_VERSION_INTEGER & 0xFF), },
.ParamValue = 0 },
{ .ParamID = PARAM_HW_VER,
.ParamPrivileges = PARAM_PRIV_READ,
......@@ -87,8 +87,7 @@ static ParameterItem_t ParameterTable[] =
/** Loads saved non-volatile parameter values from the EEPROM into the parameter table, as needed. */
void V2Params_LoadNonVolatileParamValues(void)
{
/* Target RESET line polarity is a non-volatile value, retrieve current parameter value from EEPROM -
* NB: Cannot call V2Protocol_SetParameterValue() here, as that will cause another EEPROM write! */
/* Target RESET line polarity is a non-volatile value, retrieve current parameter value from EEPROM */
V2Params_GetParamFromTable(PARAM_RESET_POLARITY)->ParamValue = eeprom_read_byte(&EEPROM_Rest_Polarity);
}
......@@ -154,7 +153,7 @@ void V2Params_SetParameterValue(const uint8_t ParamID, const uint8_t Value)
ParamInfo->ParamValue = Value;
/* The target RESET line polarity is a non-volatile parameter, save to EEPROM when changed */
if (ParamID == PARAM_RESET_POLARITY)
if ((ParamID == PARAM_RESET_POLARITY) && (eeprom_read_byte(&EEPROM_Rest_Polarity) != Value))
eeprom_write_byte(&EEPROM_Rest_Polarity, Value);
}
......
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