Make Control Endpoint stream transfers more reliable by adding in early aborts for unexpected new SETUP tokens, or unexpected status stage during control stream writes.

Fix corruption in Device RNDIS demos TCP stack when too many connections attempted simultaneously, freezing the device when a page was re-fetched before the first connection was closed.

Fix incorrect model compatibility information in the Host LowLevel demo overview text files.
pull/1469/head
Dean Camera 15 years ago
parent a9d5e129b7
commit 4421782b7f

@ -381,19 +381,24 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, void* TCPHeaderInStart, void
case TCP_Connection_Listen:
if (TCPHeaderIN->Flags == TCP_FLAG_SYN)
{
/* SYN connection when closed starts a connection with a peer */
/* SYN connection starts a connection with a peer */
if (TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress,
TCPHeaderIN->SourcePort, TCP_Connection_SYNReceived))
{
TCPHeaderOUT->Flags = (TCP_FLAG_SYN | TCP_FLAG_ACK);
TCPHeaderOUT->Flags = (TCP_FLAG_SYN | TCP_FLAG_ACK);
PacketResponse = true;
TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort,
TCP_Connection_SYNReceived);
ConnectionInfo = TCP_GetConnectionInfo(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort);
ConnectionInfo = TCP_GetConnectionInfo(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort);
ConnectionInfo->SequenceNumberIn = (SwapEndian_32(TCPHeaderIN->SequenceNumber) + 1);
ConnectionInfo->SequenceNumberOut = 0;
ConnectionInfo->Buffer.InUse = false;
ConnectionInfo->SequenceNumberIn = (SwapEndian_32(TCPHeaderIN->SequenceNumber) + 1);
ConnectionInfo->SequenceNumberOut = 0;
ConnectionInfo->Buffer.InUse = false;
}
else
{
TCPHeaderOUT->Flags = TCP_FLAG_RST;
}
PacketResponse = true;
}
break;

@ -49,7 +49,7 @@
#define MAX_OPEN_TCP_PORTS 1
/** Maximum number of TCP connections which can be sustained at the one time */
#define MAX_TCP_CONNECTIONS 1
#define MAX_TCP_CONNECTIONS 3
/** TCP window size, giving the maximum number of bytes which can be buffered at the one time */
#define TCP_WINDOW_SIZE 512

@ -381,19 +381,24 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, void* TCPHeaderInStart, void
case TCP_Connection_Listen:
if (TCPHeaderIN->Flags == TCP_FLAG_SYN)
{
/* SYN connection when closed starts a connection with a peer */
/* SYN connection starts a connection with a peer */
if (TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress,
TCPHeaderIN->SourcePort, TCP_Connection_SYNReceived))
{
TCPHeaderOUT->Flags = (TCP_FLAG_SYN | TCP_FLAG_ACK);
TCPHeaderOUT->Flags = (TCP_FLAG_SYN | TCP_FLAG_ACK);
PacketResponse = true;
TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort,
TCP_Connection_SYNReceived);
ConnectionInfo = TCP_GetConnectionInfo(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort);
ConnectionInfo = TCP_GetConnectionInfo(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort);
ConnectionInfo->SequenceNumberIn = (SwapEndian_32(TCPHeaderIN->SequenceNumber) + 1);
ConnectionInfo->SequenceNumberOut = 0;
ConnectionInfo->Buffer.InUse = false;
ConnectionInfo->SequenceNumberIn = (SwapEndian_32(TCPHeaderIN->SequenceNumber) + 1);
ConnectionInfo->SequenceNumberOut = 0;
ConnectionInfo->Buffer.InUse = false;
}
else
{
TCPHeaderOUT->Flags = TCP_FLAG_RST;
}
PacketResponse = true;
}
break;

@ -49,7 +49,7 @@
#define MAX_OPEN_TCP_PORTS 1
/** Maximum number of TCP connections which can be sustained at the one time */
#define MAX_TCP_CONNECTIONS 1
#define MAX_TCP_CONNECTIONS 3
/** TCP window size, giving the maximum number of bytes which can be buffered at the one time */
#define TCP_WINDOW_SIZE 512

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

File diff suppressed because one or more lines are too long

@ -76,7 +76,7 @@ void Endpoint_ClearStatusStage(void)
if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST)
{
while (!(Endpoint_IsOUTReceived()))
{
{
if (USB_DeviceState == DEVICE_STATE_Unattached)
return;
}

@ -4,6 +4,12 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
while (Length)
{
if (Endpoint_IsSETUPReceived())
return ENDPOINT_RWCSTREAM_HostAborted;
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
if (Endpoint_IsOUTReceived())
{
while (Length && Endpoint_BytesInEndpoint())
@ -13,10 +19,7 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
}
Endpoint_ClearOUT();
}
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
}
}
while (!(Endpoint_IsINReady()))

@ -6,36 +6,28 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
if (Length > USB_ControlRequest.wLength)
Length = USB_ControlRequest.wLength;
while (Length && !(Endpoint_IsOUTReceived()))
while (Length || LastPacketFull)
{
while (!(Endpoint_IsINReady()))
{
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
}
while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
{
TEMPLATE_TRANSFER_BYTE(DataStream);
Length--;
}
if (Endpoint_IsSETUPReceived())
return ENDPOINT_RWCSTREAM_HostAborted;
if (Endpoint_IsOUTReceived())
break;
LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
Endpoint_ClearIN();
}
if (Endpoint_IsOUTReceived())
return ENDPOINT_RWCSTREAM_HostAborted;
if (LastPacketFull)
{
while (!(Endpoint_IsINReady()))
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
if (Endpoint_IsINReady())
{
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
{
TEMPLATE_TRANSFER_BYTE(DataStream);
Length--;
}
LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
Endpoint_ClearIN();
}
Endpoint_ClearIN();
}
while (!(Endpoint_IsOUTReceived()))

@ -85,6 +85,7 @@
* - Fixed report data alignment issues in the MouseHostWithParser demo when X and Y movement data size is not a multiple of 8 bits
* - Fixed HID Report Descriptor Parser not correctly resetting internal states when a REPORT ID element is encountered
* - Fixed incorrect BUTTONS_BUTTON1 for the STK526 target
* - Fixed RNDIS demos freezing when more than one connection was attempted simultaneously, causing memory corruption
*
*
* \section Sec_ChangeLog090605 Version 090605

Loading…
Cancel
Save