Update version number in +TCP code.

This commit is contained in:
Richard Barry 2019-02-21 18:08:36 +00:00
parent 5fe8465a35
commit 50e67a89f1
50 changed files with 505 additions and 2611 deletions

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
@ -1340,7 +1340,7 @@ TickType_t xTimeoutTime = pdMS_TO_TICKS( 200 );
{
BaseType_t x;
BaseType_t xFound = pdFALSE;
uint32_t ulCurrentTimeSeconds = ( xTaskGetTickCount() / portTICK_PERIOD_MS ) / 1000UL;
uint32_t ulCurrentTimeSeconds = ( xTaskGetTickCount() / portTICK_PERIOD_MS ) / 1000;
static BaseType_t xFreeEntry = 0;
/* For each entry in the DNS cache table. */

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
@ -1288,6 +1288,11 @@ static void prvProcessNetworkDownEvent( void )
}
#endif
/* Per the ARP Cache Validation section of https://tools.ietf.org/html/rfc1122,
treat network down as a "delivery problem" and flush the ARP cache for this
interface. */
FreeRTOS_ClearARP( );
/* The network has been disconnected (or is being initialised for the first
time). Perform whatever hardware processing is necessary to bring it up
again, or wait for it to be available again. This is hardware dependent. */

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
@ -199,7 +199,7 @@ extern void vListInsertGeneric( List_t * const pxList, ListItem_t * const pxNewL
/*-----------------------------------------------------------*/
/* TCP segement pool. */
/* TCP segment pool. */
#if( ipconfigUSE_TCP_WIN == 1 )
static TCPSegment_t *xTCPSegments = NULL;
#endif /* ipconfigUSE_TCP_WIN == 1 */
@ -673,6 +673,23 @@ const int32_t l500ms = 500;
}
/*-----------------------------------------------------------*/
#if( ipconfigUSE_TCP_WIN == 1 )
void vTCPSegmentCleanup( void )
{
/* Free and clear the TCP segments pointer. This function should only be called
* once FreeRTOS+TCP will no longer be used. No thread-safety is provided for this
* function. */
if( xTCPSegments != NULL )
{
vPortFreeLarge( xTCPSegments );
xTCPSegments = NULL;
}
}
#endif /* ipconfgiUSE_TCP_WIN == 1 */
/*-----------------------------------------------------------*/
/*=============================================================================
*
* ###### # #

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,3 +1,7 @@
Changes in V2.0.11
+ Updates some drivers in the portable layer.
Changes between 160919 and 180821 releases:
+ Multiple security improvements and fixes in packet parsing routines, DNS

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
@ -154,6 +154,9 @@ void vTCPWindowDestroy( TCPWindow_t *pxWindow );
/* Initialize a window */
void vTCPWindowInit( TCPWindow_t *pxWindow, uint32_t ulAckNumber, uint32_t ulSequenceNumber, uint32_t ulMSS );
/* Clean up allocated segments. Should only be called when FreeRTOS+TCP will no longer be used. */
void vTCPSegmentCleanup( void );
/*=============================================================================
*
* Rx functions

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.7
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.3
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,28 +1,27 @@
/*
* FreeRTOS+TCP V2.0.3
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* http://aws.amazon.com/freertos
* http://www.FreeRTOS.org
*/
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
http://aws.amazon.com/freertos
http://www.FreeRTOS.org
*/
/* Standard includes. */
#include <stdint.h>
@ -230,11 +229,6 @@ static SemaphoreHandle_t xTXDescriptorSemaphore = NULL;
BaseType_t xNetworkInterfaceInitialise( void )
{
BaseType_t xReturn = pdPASS;
static BaseType_t xHasInitialised = pdFALSE;
if( xHasInitialised == pdFALSE )
{
xHasInitialised = pdTRUE;
/* The interrupt will be turned on when a link is established. */
NVIC_DisableIRQ( ETHERNET_IRQn );
@ -285,6 +279,14 @@ static BaseType_t xHasInitialised = pdFALSE;
if( xReturn == pdPASS )
{
/* Guard against the task being created more than once and the
descriptors being initialised more than once. */
if( xRxHanderTask == NULL )
{
xReturn = xTaskCreate( prvEMACHandlerTask, "EMAC", nwRX_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, &xRxHanderTask );
configASSERT( xReturn );
}
if( xTXDescriptorSemaphore == NULL )
{
/* Create a counting semaphore, with a value of 'configNUM_TX_DESCRIPTORS'
@ -295,7 +297,10 @@ static BaseType_t xHasInitialised = pdFALSE;
/* Enable MAC interrupts. */
LPC_ETHERNET->DMA_INT_EN = nwDMA_INTERRUPT_MASK;
}
if( xReturn != pdFAIL )
{
/* Auto-negotiate was already started. Wait for it to complete. */
xReturn = prvSetLinkSpeed();
@ -321,28 +326,6 @@ static BaseType_t xHasInitialised = pdFALSE;
NVIC_SetPriority( ETHERNET_IRQn, configMAC_INTERRUPT_PRIORITY );
NVIC_EnableIRQ( ETHERNET_IRQn );
}
/* Guard against the task being created more than once and the
descriptors being initialised more than once. */
if( xRxHanderTask == NULL )
{
xReturn = xTaskCreate( prvEMACHandlerTask, "EMAC", nwRX_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, &xRxHanderTask );
configASSERT( xReturn );
}
}
}
/* Once prvEMACHandlerTask() has started, the variable
'ulPHYLinkStatus' will be updated by that task.
The IP-task will keep on calling this function untill
it finally returns pdPASS.
Only then can the DHCP-procedure start (if configured). */
if( ( ulPHYLinkStatus & PHY_LINK_CONNECTED ) != 0 )
{
xReturn = pdPASS;
}
else
{
xReturn = pdFAIL;
}
return xReturn;
@ -461,7 +444,7 @@ const TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 50 );
/* The DMA descriptor will 'own' this Network Buffer,
until it has been sent. So don't release it now. */
bReleaseAfterSend = pdFALSE;
bReleaseAfterSend = false;
}
#else
{
@ -667,6 +650,8 @@ BaseType_t xReturn;
}
/*-----------------------------------------------------------*/
uint32_t ulDataAvailable;
configPLACE_IN_SECTION_RAM
static BaseType_t prvNetworkInterfaceInput()
{
@ -680,7 +665,9 @@ NetworkBufferDescriptor_t *pxDescriptor;
#if( ipconfigZERO_COPY_RX_DRIVER != 0 )
NetworkBufferDescriptor_t *pxNewDescriptor;
#endif /* ipconfigZERO_COPY_RX_DRIVER */
#if( ipconfigUSE_LINKED_RX_MESSAGES == 0 )
IPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL };
#endif
/* Process each descriptor that is not still in use by the DMA. */
ulStatus = xDMARxDescriptors[ ulNextRxDescriptorToProcess ].STATUS;
@ -690,6 +677,7 @@ IPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL };
if( ( ulStatus & nwRX_STATUS_ERROR_BITS ) != 0 )
{
/* There is some reception error. */
intCount[ 3 ]++;
/* Clear error bits. */
ulStatus &= ~( ( uint32_t )nwRX_STATUS_ERROR_BITS );
}
@ -775,10 +763,19 @@ IPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL };
else
{
iptraceNETWORK_INTERFACE_RECEIVE();
/* The data that was available at the top of this
loop has been sent, so is no longer available. */
ulDataAvailable = pdFALSE;
}
}
}
}
else
{
/* The packet is discarded as uninteresting. */
ulDataAvailable = pdFALSE;
}
/* Got here because received data was sent to the IP task or the
data contained an error and was discarded. Give the descriptor
back to the DMA. */
@ -825,6 +822,7 @@ const uint32_t ulTxInterruptMask =
/* Remember that an RX event has happened. */
ulISREvents |= EMAC_IF_RX_EVENT;
vTaskNotifyGiveFromISR( xRxHanderTask, &xHigherPriorityTaskWoken );
intCount[ 0 ]++;
}
/* TX group interrupt(s). */
@ -833,6 +831,7 @@ const uint32_t ulTxInterruptMask =
/* Remember that a TX event has happened. */
ulISREvents |= EMAC_IF_TX_EVENT;
vTaskNotifyGiveFromISR( xRxHanderTask, &xHigherPriorityTaskWoken );
intCount[ 1 ]++;
}
/* Test for 'Abnormal interrupt summary'. */
@ -880,11 +879,11 @@ const TickType_t xAutoNegotiateDelay = pdMS_TO_TICKS( 5000UL );
if( ( ulPhyStatus & PHY_LINK_FULLDUPLX ) != 0x00 )
{
Chip_ENET_SetDuplex( LPC_ETHERNET, pdTRUE );
Chip_ENET_SetDuplex( LPC_ETHERNET, true );
}
else
{
Chip_ENET_SetDuplex( LPC_ETHERNET, pdFALSE );
Chip_ENET_SetDuplex( LPC_ETHERNET, false );
}
xReturn = pdPASS;

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -4,7 +4,7 @@
*/
/*
* FreeRTOS+TCP V2.0.1
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -4,7 +4,7 @@
*/
/*
* FreeRTOS+TCP V2.0.3
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
@ -28,7 +28,6 @@
* http://www.FreeRTOS.org
*/
/* Standard includes. */
#include <stdint.h>
#include <stdio.h>
@ -49,13 +48,21 @@
#include "NetworkInterface.h"
#include "phyHandling.h"
#define __STM32_HAL_LEGACY 1
/* ST includes. */
#ifdef STM32F7xx
#if defined( STM32F7xx )
#include "stm32f7xx_hal.h"
#else
#elif defined( STM32F4xx )
#include "stm32f4xx_hal.h"
#elif defined( STM32F2xx )
#include "stm32f2xx_hal.h"
#else
#error What part?
#endif
#include "stm32fxx_hal_eth.h"
/* Interrupt events to process. Currently only the Rx event is processed
although code for other events is included to allow for possible future
expansion. */
@ -69,7 +76,9 @@ expansion. */
ETH_DMA_IT_FBE | ETH_DMA_IT_RWT | ETH_DMA_IT_RPS | ETH_DMA_IT_RBU | ETH_DMA_IT_R | \
ETH_DMA_IT_TU | ETH_DMA_IT_RO | ETH_DMA_IT_TJT | ETH_DMA_IT_TPS | ETH_DMA_IT_T )
#ifndef niEMAC_HANDLER_TASK_PRIORITY
#define niEMAC_HANDLER_TASK_PRIORITY configMAX_PRIORITIES - 1
#endif
#define ipFRAGMENT_OFFSET_BIT_MASK ( ( uint16_t ) 0x0fff ) /* The bits in the two byte IP header field that make up the fragment offset value. */
@ -124,7 +133,11 @@ and the index of the PHY in use ( between 0 and 31 ). */
#endif /* STM32F7xx */
#endif /* ipconfigUSE_RMII */
#if( ipconfigUSE_RMII != 0 )
#warning Using RMII, make sure if this is correct
#else
#warning Using MII, make sure if this is correct
#endif
/*-----------------------------------------------------------*/
@ -235,9 +248,6 @@ __attribute__ ((section(".first_data")))
static __IO ETH_DMADescTypeDef *DMATxDescToClear;
#endif
/* ucMACAddress as it appears in main.c */
extern const uint8_t ucMACAddress[ 6 ];
/* Holds the handle of the task used as a deferred interrupt processor. The
handle is used so direct notifications can be sent to the task for all EMAC/DMA
related interrupts. */
@ -373,7 +383,7 @@ BaseType_t xResult;
/* Value of PhyAddress doesn't matter, will be probed for. */
xETH.Init.PhyAddress = 0;
xETH.Init.MACAddr = ( uint8_t *) ucMACAddress;
xETH.Init.MACAddr = ( uint8_t *)FreeRTOS_GetMACAddress();
xETH.Init.RxMode = ETH_RXINTERRUPT_MODE;
/* using the ETH_CHECKSUM_BY_HARDWARE option:
@ -427,7 +437,7 @@ BaseType_t xResult;
possible priority to ensure the interrupt handler can return directly
to it. The task's handle is stored in xEMACTaskHandle so interrupts can
notify the task when there is something to process. */
xTaskCreate( prvEMACHandlerTask, "EMAC", configEMAC_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, &xEMACTaskHandle );
xTaskCreate( prvEMACHandlerTask, "EMAC", configEMAC_TASK_STACK_SIZE, NULL, niEMAC_HANDLER_TASK_PRIORITY, &xEMACTaskHandle );
} /* if( xEMACTaskHandle == NULL ) */
if( xPhyObject.ulLinkStatusMask != 0 )
@ -580,6 +590,17 @@ __IO ETH_DMADescTypeDef *pxDmaTxDesc;
/* Do not wait too long for a free TX DMA buffer. */
const TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 50u );
/* Open a do {} while ( 0 ) loop to be able to call break. */
do
{
if( xCheckLoopback( pxDescriptor, bReleaseAfterSend ) != 0 )
{
/* The packet has been sent back to the IP-task.
The IP-task will further handle it.
Do not release the descriptor. */
bReleaseAfterSend = pdFALSE;
break;
}
#if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 )
{
ProtocolPacket_t *pxPacket;
@ -599,11 +620,7 @@ const TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 50u );
pxPacket->xICMPPacket.xICMPHeader.usChecksum = ( uint16_t )0u;
}
}
#endif
/* Open a do {} while ( 0 ) loop to be able to call break. */
do
{
#endif /* ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM */
if( xPhyObject.ulLinkStatusMask != 0 )
{
if( xSemaphoreTake( xTXDescriptorSemaphore, xBlockTimeTicks ) != pdPASS )
@ -653,6 +670,15 @@ const TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 50u );
pxDmaTxDesc->Status |= ETH_DMATXDESC_FS | ETH_DMATXDESC_LS;
/* Set frame size */
pxDmaTxDesc->ControlBufferSize = ( ulTransmitSize & ETH_DMATXDESC_TBS1 );
#if( NETWORK_BUFFERS_CACHED != 0 )
{
BaseType_t xlength = CACHE_LINE_SIZE * ( ( ulTransmitSize + NETWORK_BUFFER_HEADER_SIZE + CACHE_LINE_SIZE - 1 ) / CACHE_LINE_SIZE );
uint32_t *pulBuffer = ( uint32_t )( pxDescriptor->pucEthernetBuffer - NETWORK_BUFFER_HEADER_SIZE );
cache_clean_invalidate_by_addr( pulBuffer, xlength );
}
#endif
/* Set Own bit of the Tx descriptor Status: gives the buffer back to ETHERNET DMA */
pxDmaTxDesc->Status |= ETH_DMATXDESC_OWN;
@ -787,11 +813,16 @@ uint8_t *pucBuffer;
}
/* Obtain the size of the packet and put it into the "usReceivedLength" variable. */
/* get received frame */
if( xReceivedLength > 0ul )
{
/* In order to make the code easier and faster, only packets in a single buffer
will be accepted. This can be done by making the buffers large enough to
hold a complete Ethernet packet (1536 bytes). */
if( xReceivedLength > 0ul && xReceivedLength < ETH_RX_BUF_SIZE )
{
hold a complete Ethernet packet (1536 bytes).
Therefore, two sanity checks: */
configASSERT( xReceivedLength <= ETH_RX_BUF_SIZE );
if( ( pxDMARxDescriptor->Status & ( ETH_DMARXDESC_CE | ETH_DMARXDESC_IPV4HCE | ETH_DMARXDESC_FT ) ) != ETH_DMARXDESC_FT )
{
/* Not an Ethernet frame-type or a checmsum error. */
@ -936,25 +967,6 @@ HAL_StatusTypeDef xHALResult;
}
/*-----------------------------------------------------------*/
void phy_test()
{
BaseType_t xPhyCount;
BaseType_t xPhyIndex;
vPhyInitialise( &xPhyObject, xSTM32_PhyRead, xSTM32_PhyWrite );
xPhyCount = xPhyDiscover( &xPhyObject );
FreeRTOS_printf( ( "PHY count %ld\n", xPhyCount ) );
for( xPhyIndex = 0; xPhyIndex < xPhyCount; xPhyIndex++ )
{
FreeRTOS_printf( ( "PHY[%d] at address %d ( 0x%08X )\n",
xPhyIndex,
xPhyObject.ucPhyIndexes[ xPhyIndex ],
xPhyObject.ulPhyIDs[ xPhyIndex ] ) );
}
}
void vMACBProbePhy( void )
{
vPhyInitialise( &xPhyObject, xSTM32_PhyRead, xSTM32_PhyWrite );
@ -1061,14 +1073,11 @@ BaseType_t xReturn;
/* Uncomment this in case BufferAllocation_1.c is used. */
/*
#define niBUFFER_1_PACKET_SIZE 1536
static __attribute__ ((section(".first_data"))) uint8_t ucNetworkPackets[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS * niBUFFER_1_PACKET_SIZE ] __attribute__ ( ( aligned( 32 ) ) );
void vNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkBuffers[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ] )
{
static __attribute__ ((section(".first_data"))) uint8_t ucNetworkPackets[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS * niBUFFER_1_PACKET_SIZE ] __attribute__ ( ( aligned( 32 ) ) );
uint8_t *ucRAMBuffer = ucNetworkPackets;
uint32_t ul;
@ -1079,7 +1088,6 @@ uint32_t ul;
ucRAMBuffer += niBUFFER_1_PACKET_SIZE;
}
}
*/
/*-----------------------------------------------------------*/
static void prvEMACHandlerTask( void *pvParameters )

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
@ -38,6 +38,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_IP_Private.h"
#include "FreeRTOS_ARP.h"
#include "NetworkBufferManagement.h"
#include "NetworkInterface.h"
@ -50,10 +51,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* Provided memory configured as uncached. */
#include "uncached_memory.h"
#ifndef BMSR_LINK_STATUS
#define BMSR_LINK_STATUS 0x0004UL
#ifndef niEMAC_HANDLER_TASK_PRIORITY
#define niEMAC_HANDLER_TASK_PRIORITY configMAX_PRIORITIES - 1
#endif
#define niBMSR_LINK_STATUS 0x0004UL
#define niBMSR_AN_COMPLETE 0x0020u /* Auto-Negotiation process completed */
#ifndef PHY_LS_HIGH_CHECK_TIME_MS
/* Check if the LinkSStatus in the PHY is still high after 15 seconds of not
receiving packets. */
@ -188,7 +192,7 @@ const TickType_t xWaitLinkDelay = pdMS_TO_TICKS( 7000UL ), xWaitRelinkDelay = pd
possible priority to ensure the interrupt handler can return directly
to it. The task's handle is stored in xEMACTaskHandle so interrupts can
notify the task when there is something to process. */
xTaskCreate( prvEMACHandlerTask, "EMAC", configEMAC_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, &xEMACTaskHandle );
xTaskCreate( prvEMACHandlerTask, "EMAC", configEMAC_TASK_STACK_SIZE, NULL, niEMAC_HANDLER_TASK_PRIORITY, &xEMACTaskHandle );
}
else
{
@ -206,7 +210,34 @@ const TickType_t xWaitLinkDelay = pdMS_TO_TICKS( 7000UL ), xWaitRelinkDelay = pd
BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxBuffer, BaseType_t bReleaseAfterSend )
{
if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 )
if( xCheckLoopback( pxBuffer, bReleaseAfterSend ) != 0 )
{
/* The packet has been sent back to the IP-task.
The IP-task will further handle it.
Do not release the descriptor. */
return pdTRUE;
}
#if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 )
{
ProtocolPacket_t *pxPacket;
/* If the peripheral must calculate the checksum, it wants
the protocol checksum to have a value of zero. */
pxPacket = ( ProtocolPacket_t * ) ( pxBuffer->pucEthernetBuffer );
if( pxPacket->xICMPPacket.xIPHeader.ucProtocol == ipPROTOCOL_ICMP )
{
IPHeader_t *pxIPHeader = &( pxPacket->xUDPPacket.xIPHeader );
pxPacket->xICMPPacket.xICMPHeader.usChecksum = ( uint16_t )0u;
pxIPHeader->usHeaderChecksum = 0u;
pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0UL, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER );
pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum );
usGenerateProtocolChecksum( (uint8_t*)&( pxPacket->xUDPPacket ), pxBuffer->xDataLength, pdTRUE );
}
}
#endif /* ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM */
if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) != 0 )
{
iptraceNETWORK_INTERFACE_TRANSMIT();
emacps_send_message( &xEMACpsif, pxBuffer, bReleaseAfterSend );
@ -249,7 +280,7 @@ BaseType_t xReturn;
}
ulPHYLinkStatus = ulReadMDIO( PHY_REG_01_BMSR );
if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 )
if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) != 0 )
{
xReturn = pdTRUE;
break;
@ -281,7 +312,7 @@ BaseType_t xGetPhyLinkStatus( void )
{
BaseType_t xReturn;
if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) == 0 )
if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) == 0 )
{
xReturn = pdFALSE;
}
@ -298,11 +329,12 @@ static void prvEMACHandlerTask( void *pvParameters )
{
TimeOut_t xPhyTime;
TickType_t xPhyRemTime;
UBaseType_t uxLastMinBufferCount = 0;
UBaseType_t uxCurrentCount;
BaseType_t xResult = 0;
uint32_t xStatus;
const TickType_t ulMaxBlockTime = pdMS_TO_TICKS( 100UL );
UBaseType_t uxLastMinBufferCount = 0;
UBaseType_t uxCurrentBufferCount = 0;
/* Remove compiler warnings about unused parameters. */
( void ) pvParameters;
@ -316,14 +348,14 @@ const TickType_t ulMaxBlockTime = pdMS_TO_TICKS( 100UL );
for( ;; )
{
uxCurrentCount = uxGetMinimumFreeNetworkBuffers();
if( uxLastMinBufferCount != uxCurrentCount )
uxCurrentBufferCount = uxGetMinimumFreeNetworkBuffers();
if( uxLastMinBufferCount != uxCurrentBufferCount )
{
/* The logging produced below may be helpful
while tuning +TCP: see how many buffers are in use. */
uxLastMinBufferCount = uxCurrentCount;
uxLastMinBufferCount = uxCurrentBufferCount;
FreeRTOS_printf( ( "Network buffers: %lu lowest %lu\n",
uxGetNumberOfFreeNetworkBuffers(), uxCurrentCount ) );
uxGetNumberOfFreeNetworkBuffers(), uxCurrentBufferCount ) );
}
#if( ipconfigCHECK_IP_QUEUE_SPACE != 0 )
@ -364,7 +396,6 @@ const TickType_t ulMaxBlockTime = pdMS_TO_TICKS( 100UL );
xEMACpsif.isr_events &= ~EMAC_IF_ERR_EVENT;
emacps_check_errors( &xEMACpsif );
}
if( xResult > 0 )
{
/* A packet was received. No need to check for the PHY status now,
@ -372,19 +403,22 @@ const TickType_t ulMaxBlockTime = pdMS_TO_TICKS( 100UL );
vTaskSetTimeOutState( &xPhyTime );
xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS );
xResult = 0;
/* Indicate that the Link Status is high, so that
xNetworkInterfaceOutput() can send packets. */
ulPHYLinkStatus |= niBMSR_LINK_STATUS;
}
else if( xTaskCheckForTimeOut( &xPhyTime, &xPhyRemTime ) != pdFALSE )
{
xStatus = ulReadMDIO( PHY_REG_01_BMSR );
if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != ( xStatus & BMSR_LINK_STATUS ) )
if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) != ( xStatus & niBMSR_LINK_STATUS ) )
{
ulPHYLinkStatus = xStatus;
FreeRTOS_printf( ( "prvEMACHandlerTask: PHY LS now %d\n", ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) );
FreeRTOS_printf( ( "prvEMACHandlerTask: PHY LS now %d\n", ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) != 0 ) );
}
vTaskSetTimeOutState( &xPhyTime );
if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 )
if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) != 0 )
{
xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS );
}

View File

@ -1,5 +1,3 @@
#warning Temoporary file and a dependent on the Zynq network interface.
/*
* uncached_memory.c
*
@ -19,6 +17,21 @@
* uncached memory.
*/
/* Standard includes. */
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
/* FreeRTOS+TCP includes. */
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_IP_Private.h"
#include "Zynq/x_emacpsif.h"
#include "Zynq/x_topology.h"
#include "xstatus.h"
@ -28,12 +41,8 @@
#include "xil_exception.h"
#include "xil_mmu.h"
#include "FreeRTOS.h"
#include "uncached_memory.h"
#include "Demo_Logging.h"
#define UNCACHED_MEMORY_SIZE 0x100000ul
#define DDR_MEMORY_END (XPAR_PS7_DDR_0_S_AXI_HIGHADDR+1)
@ -100,7 +109,7 @@ static void vInitialiseUncachedMemory( )
if( ( ( u32 )pucStartOfMemory ) + UNCACHED_MEMORY_SIZE > DDR_MEMORY_END )
{
vLoggingPrintf("vInitialiseUncachedMemory: Can not allocate uncached memory\n" );
// vLoggingPrintf("vInitialiseUncachedMemory: Can not allocate uncached memory\n" );
}
else
{
@ -109,7 +118,11 @@ static void vInitialiseUncachedMemory( )
* address range that starts after "_end" is made uncached
* by setting appropriate attributes in the translation table.
*/
Xil_SetTlbAttributes( ( uint32_t )pucStartOfMemory, 0xc02 ); // addr, attr
/* FIXME claudio rossi. Modified to prevent data abort exception (misaligned access)
* when application is compiled with -O1 or more optimization flag.
*/
/* Xil_SetTlbAttributes( ( uint32_t )pucStartOfMemory, 0xc02 ); // addr, attr */
Xil_SetTlbAttributes( ( uint32_t )pucStartOfMemory, 0x1c02 ); // addr, attr
/* For experiments in the SDIO driver, make the remaining uncached memory public */
pucHeadOfMemory = pucStartOfMemory;

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
@ -23,15 +23,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
http://www.FreeRTOS.org
*/
#include "Zynq/x_emacpsif.h"
#include "Zynq/x_topology.h"
#include "xstatus.h"
#include "xparameters.h"
#include "xparameters_ps.h"
#include "xil_exception.h"
#include "xil_mmu.h"
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
@ -43,6 +34,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "FreeRTOS_IP_Private.h"
#include "NetworkBufferManagement.h"
#include "Zynq/x_emacpsif.h"
#include "Zynq/x_topology.h"
#include "xstatus.h"
#include "xparameters.h"
#include "xparameters_ps.h"
#include "xil_exception.h"
#include "xil_mmu.h"
#include "uncached_memory.h"
/* Two defines used to set or clear the EMAC interrupt */
@ -201,7 +201,7 @@ BaseType_t xReturn;
XStatus emacps_send_message(xemacpsif_s *xemacpsif, NetworkBufferDescriptor_t *pxBuffer, int iReleaseAfterSend )
{
int head = xemacpsif->txHead;
int tail = xemacpsif->txTail;
//int tail = xemacpsif->txTail;
int iHasSent = 0;
uint32_t ulBaseAddress = xemacpsif->emacps.Config.BaseAddress;
TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 5000u );
@ -313,10 +313,7 @@ void emacps_recv_handler(void *arg)
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}
static NetworkBufferDescriptor_t *ethMsg = NULL;
static NetworkBufferDescriptor_t *ethLast = NULL;
static void passEthMessages( void )
static void passEthMessages( NetworkBufferDescriptor_t *ethMsg )
{
IPStackEvent_t xRxEvent;
@ -338,20 +335,50 @@ IPStackEvent_t xRxEvent;
iptraceETHERNET_RX_EVENT_LOST();
FreeRTOS_printf( ( "passEthMessages: Can not queue return packet!\n" ) );
}
ethMsg = ethLast = NULL;
}
TickType_t ack_reception_delay = 10;
int emacps_check_rx( xemacpsif_s *xemacpsif )
{
NetworkBufferDescriptor_t *pxBuffer, *pxNewBuffer;
int rx_bytes;
volatile int msgCount = 0;
int head = xemacpsif->rxHead;
BaseType_t bHasDataPacket = pdFALSE;
NetworkBufferDescriptor_t *ethMsg = NULL;
NetworkBufferDescriptor_t *ethLast = NULL;
/* There seems to be an issue (SI# 692601), see comments below. */
resetrx_on_no_rxdata(xemacpsif);
{
static int maxcount = 0;
int count = 0;
for( ;; )
{
if( ( ( xemacpsif->rxSegments[ head ].address & XEMACPS_RXBUF_NEW_MASK ) == 0 ) ||
( pxDMA_rx_buffers[ head ] == NULL ) )
{
break;
}
count++;
if( ++head == ipconfigNIC_N_RX_DESC )
{
head = 0;
}
if( head == xemacpsif->rxHead )
{
break;
}
}
if (maxcount < count) {
maxcount = count;
FreeRTOS_printf( ( "emacps_check_rx: %d packets\n", maxcount ) );
}
head = xemacpsif->rxHead;
}
/* This FreeRTOS+TCP driver shall be compiled with the option
"ipconfigUSE_LINKED_RX_MESSAGES" enabled. It allows the driver to send a
chain of RX messages within one message to the IP-task. */
@ -384,7 +411,10 @@ int head = xemacpsif->rxHead;
rx_bytes = xemacpsif->rxSegments[ head ].flags & XEMACPS_RXBUF_LEN_MASK;
pxBuffer->xDataLength = rx_bytes;
if( rx_bytes > 60 )
{
bHasDataPacket = 1;
}
if( ucIsCachedMemory( pxBuffer->pucEthernetBuffer ) != 0 )
{
Xil_DCacheInvalidateRange( ( ( uint32_t )pxBuffer->pucEthernetBuffer ) - ipconfigPACKET_FILLER_SIZE, (unsigned)rx_bytes );
@ -421,8 +451,11 @@ int head = xemacpsif->rxHead;
addr |= XEMACPS_RXBUF_WRAP_MASK;
}
/* Clearing 'XEMACPS_RXBUF_NEW_MASK' 0x00000001 *< Used bit.. */
xemacpsif->rxSegments[ head ].address = addr;
xemacpsif->rxSegments[ head ].flags = 0;
xemacpsif->rxSegments[ head ].address = addr;
if (xemacpsif->rxSegments[ head ].address) {
// Just to read it
}
}
}
@ -435,7 +468,11 @@ int head = xemacpsif->rxHead;
if( ethMsg != NULL )
{
passEthMessages( );
if( bHasDataPacket == pdFALSE )
{
// vTaskDelay( ack_reception_delay );
}
passEthMessages( ethMsg );
}
return msgCount;
@ -455,9 +492,9 @@ unsigned char *ucTxBuffer;
xemacpsif->txSegments[ index ].address = ( uint32_t )ucTxBuffer;
xemacpsif->txSegments[ index ].flags = XEMACPS_TXBUF_USED_MASK;
#if( ipconfigZERO_COPY_TX_DRIVER != 0 )
pxDMA_tx_buffers[ index ] = ( void* )NULL;
pxDMA_tx_buffers[ index ] = ( unsigned char * )NULL;
#else
pxDMA_tx_buffers[ index ] = ( void* )( ucTxBuffer + TX_OFFSET );
pxDMA_tx_buffers[ index ] = ( unsigned char * )( ucTxBuffer + TX_OFFSET );
#endif
ucTxBuffer += xemacpsif->uTxUnitSize;
}
@ -601,6 +638,7 @@ void resetrx_on_no_rxdata(xemacpsif_s *xemacpsif)
tempcntr = XEmacPs_ReadReg( xemacpsif->emacps.Config.BaseAddress, XEMACPS_RXCNT_OFFSET );
if ( ( tempcntr == 0 ) && ( xemacpsif->last_rx_frms_cntr == 0 ) )
{
FreeRTOS_printf( ( "resetrx_on_no_rxdata: RESET~\n" ) );
regctrl = XEmacPs_ReadReg(xemacpsif->emacps.Config.BaseAddress,
XEMACPS_NWCTRL_OFFSET);
regctrl &= (~XEMACPS_NWCTRL_RXEN_MASK);

View File

@ -22,19 +22,19 @@
#include <stdio.h>
#include <stdlib.h>
#include "Zynq/x_emacpsif.h"
/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
///* FreeRTOS+TCP includes. */
/* FreeRTOS+TCP includes. */
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_IP_Private.h"
#include "NetworkBufferManagement.h"
#include "NetworkInterface.h"
#include "Zynq/x_emacpsif.h"
extern TaskHandle_t xEMACTaskHandle;
@ -42,8 +42,6 @@ extern TaskHandle_t xEMACTaskHandle;
*** to run it on a PEEP board
***/
unsigned int link_speed = 100;
void setup_isr( xemacpsif_s *xemacpsif )
{
/*
@ -141,8 +139,6 @@ int xResult;
return xResult;
}
BaseType_t xNetworkInterfaceInitialise( void );
static void emacps_handle_error(void *arg, u8 Direction, u32 ErrorWord)
{
xemacpsif_s *xemacpsif;

View File

@ -53,24 +53,23 @@
#include <stdio.h>
#include <stdlib.h>
#include "Zynq/x_emacpsif.h"
//#include "lwipopts.h"
#include "xparameters_ps.h"
#include "xparameters.h"
/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
///* FreeRTOS+TCP includes. */
/* FreeRTOS+TCP includes. */
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_IP_Private.h"
#include "NetworkBufferManagement.h"
#include "Zynq/x_emacpsif.h"
#include "xparameters_ps.h"
#include "xparameters.h"
int phy_detected = 0;
/*** IMPORTANT: Define PEEP in xemacpsif.h and sys_arch_raw.c
@ -99,6 +98,8 @@ int phy_detected = 0;
#define IEEE_CONTROL_REG_OFFSET 0
#define IEEE_STATUS_REG_OFFSET 1
#define IEEE_PHYSID1_OFFSET 2
#define IEEE_PHYSID2_OFFSET 3
#define IEEE_AUTONEGO_ADVERTISE_REG 4
#define IEEE_PARTNER_ABILITIES_1_REG_OFFSET 5
#define IEEE_1000_ADVERTISE_REG_OFFSET 9
@ -135,9 +136,6 @@ int phy_detected = 0;
#define IEEE_PAUSE_MASK 0x0400
#define IEEE_AUTONEG_ERROR_MASK 0x8000
#define PHY_DETECT_REG 1
#define PHY_DETECT_MASK 0x1808
#define XEMACPS_GMII2RGMII_SPEED1000_FD 0x140
#define XEMACPS_GMII2RGMII_SPEED100_FD 0x2100
#define XEMACPS_GMII2RGMII_SPEED10_FD 0x100
@ -163,19 +161,17 @@ int phy_detected = 0;
static int detect_phy(XEmacPs *xemacpsp)
{
u16 phy_reg;
u32 phy_addr;
u16 id_lower, id_upper;
u32 phy_addr, id;
for (phy_addr = 31; phy_addr > 0; phy_addr--) {
XEmacPs_PhyRead(xemacpsp, phy_addr, PHY_DETECT_REG,
&phy_reg);
for (phy_addr = 0; phy_addr < 32; phy_addr++) {
XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_PHYSID1_OFFSET, &id_lower);
if ((phy_reg != 0xFFFF) &&
((phy_reg & PHY_DETECT_MASK) == PHY_DETECT_MASK)) {
/* Found a valid PHY address */
FreeRTOS_printf( ("XEmacPs detect_phy: PHY detected at address %d.\r\n",
phy_addr));
FreeRTOS_printf( ("XEmacPs detect_phy: PHY detected.\n" ) );
if ((id_lower != ( u16 )0xFFFFu) && (id_lower != ( u16 )0x0u)) {
XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_PHYSID2_OFFSET, &id_upper);
id = ( ( ( uint32_t ) id_upper ) << 16 ) | ( id_lower & 0xFFF0 );
FreeRTOS_printf( ("XEmacPs detect_phy: %04lX at address %d.\n", id, phy_addr ) );
phy_detected = phy_addr;
return phy_addr;
}
@ -238,7 +234,7 @@ unsigned get_IEEE_phy_speed(XEmacPs *xemacpsp)
if (partner_capabilities & IEEE_AN1_ABILITY_MASK_10MBPS)
return 10;
xil_printf("%s: unknown PHY link speed, setting TEMAC speed to be 10 Mbps\r\n",
xil_printf("%s: unknown PHY link speed, setting TEMAC speed to be 10 Mbps\n",
__FUNCTION__);
return 10;
@ -257,7 +253,7 @@ unsigned get_IEEE_phy_speed(XEmacPs *xemacpsp)
case (IEEE_CTRL_LINKSPEED_10M):
return 10;
default:
xil_printf("%s: unknown PHY link speed (%d), setting TEMAC speed to be 10 Mbps\r\n",
xil_printf("%s: unknown PHY link speed (%d), setting TEMAC speed to be 10 Mbps\n",
__FUNCTION__, phylinkspeed);
return 10;
}
@ -282,7 +278,7 @@ unsigned get_IEEE_phy_speed(XEmacPs *xemacpsp)
#else
u32 phy_addr = detect_phy(xemacpsp);
#endif
xil_printf("Start PHY autonegotiation \r\n");
xil_printf("Start PHY autonegotiation \n");
#if XPAR_GIGE_PCS_PMA_CORE_PRESENT == 1
#else
@ -338,7 +334,7 @@ unsigned get_IEEE_phy_speed(XEmacPs *xemacpsp)
break;
}
#endif
xil_printf("Waiting for PHY to complete autonegotiation.\r\n");
xil_printf("Waiting for PHY to complete autonegotiation.\n");
XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_STATUS_REG_OFFSET, &status);
while ( !(status & IEEE_STAT_AUTONEGOTIATE_COMPLETE) ) {
@ -348,14 +344,14 @@ unsigned get_IEEE_phy_speed(XEmacPs *xemacpsp)
XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_COPPER_SPECIFIC_STATUS_REG_2,
&temp);
if (temp & IEEE_AUTONEG_ERROR_MASK) {
xil_printf("Auto negotiation error \r\n");
xil_printf("Auto negotiation error \n");
}
#endif
XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_STATUS_REG_OFFSET,
&status);
}
xil_printf("autonegotiation complete \r\n");
xil_printf("autonegotiation complete \n");
#if XPAR_GIGE_PCS_PMA_CORE_PRESENT == 1
#else
@ -363,7 +359,7 @@ unsigned get_IEEE_phy_speed(XEmacPs *xemacpsp)
#endif
#if XPAR_GIGE_PCS_PMA_CORE_PRESENT == 1
xil_printf("Waiting for Link to be up; Polling for SGMII core Reg \r\n");
xil_printf("Waiting for Link to be up; Polling for SGMII core Reg \n");
XEmacPs_PhyRead(xemacpsp, phy_addr, 5, &temp);
while(!(temp & 0x8000)) {
XEmacPs_PhyRead(xemacpsp, phy_addr, 5, &temp);
@ -380,7 +376,7 @@ unsigned get_IEEE_phy_speed(XEmacPs *xemacpsp)
XEmacPs_PhyRead(xemacpsp, phy_addr, 0, &temp);
return 10;
} else {
xil_printf("get_IEEE_phy_speed(): Invalid speed bit value, Deafulting to Speed = 10 Mbps\r\n");
xil_printf("get_IEEE_phy_speed(): Invalid speed bit value, Deafulting to Speed = 10 Mbps\n");
XEmacPs_PhyRead(xemacpsp, phy_addr, 0, &temp);
XEmacPs_PhyWrite(xemacpsp, phy_addr, 0, 0x0100);
return 10;
@ -579,7 +575,7 @@ unsigned Phy_Setup (XEmacPs *xemacpsp)
XEMACPS_GMII2RGMII_REG_NUM, convspeeddupsetting);
}
xil_printf("link speed: %d\r\n", link_speed);
xil_printf("link speed: %d\n", link_speed);
return link_speed;
}

View File

@ -1,5 +1,5 @@
/*
FreeRTOS+TCP V2.0.7
FreeRTOS+TCP V2.0.11
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of