Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/.cSpellWords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,7 @@ XPBL
Xplorer
XPROT
xpsr
XSCUGIC
xtopology
xtopologyp
xzvf
Expand Down
20 changes: 12 additions & 8 deletions source/portable/NetworkInterface/Zynq/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,21 @@ struct xtopology_t xXTopologies[ XPAR_XEMACPS_NUM_INSTANCES ] =
{
[ 0 ] =
{
.emac_baseaddr = XPAR_PS7_ETHERNET_0_BASEADDR,
.emac_baseaddr = ZYNQ_ETHERNET_0_BASEADDR,
.emac_type = xemac_type_emacps,
.intc_baseaddr = 0x0,
.intc_emac_intr = 0x0,
.scugic_baseaddr = XPAR_PS7_SCUGIC_0_BASEADDR,
.scugic_baseaddr = ZYNQ_SCUGIC_0_BASEADDR,
.scugic_emac_intr = 0x36,
},
#if ( XPAR_XEMACPS_NUM_INSTANCES > 1 )
[ 1 ] =
{
.emac_baseaddr = XPAR_PS7_ETHERNET_1_BASEADDR,
.emac_baseaddr = ZYNQ_ETHERNET_1_BASEADDR,
.emac_type = xemac_type_emacps,
.intc_baseaddr = 0x0,
.intc_emac_intr = 0x0,
.scugic_baseaddr = XPAR_PS7_SCUGIC_0_BASEADDR,
.scugic_baseaddr = ZYNQ_SCUGIC_0_BASEADDR,
.scugic_emac_intr = 0x4D, /* See "7.2.3 Shared Peripheral Interrupts (SPI)" */
},
#endif
Expand All @@ -173,14 +173,18 @@ XEmacPs_Config mac_configs[ XPAR_XEMACPS_NUM_INSTANCES ] =
{
[ 0 ] =
{
.DeviceId = XPAR_PS7_ETHERNET_0_DEVICE_ID, /**< Unique ID of device, used for 'xEMACIndex' */
.BaseAddress = XPAR_PS7_ETHERNET_0_BASEADDR /**< Physical base address of IPIF registers */
#ifndef SDT
.DeviceId = XPAR_PS7_ETHERNET_0_DEVICE_ID, /**< Unique ID of device, used for 'xEMACIndex' */
#endif
.BaseAddress = ZYNQ_ETHERNET_0_BASEADDR /**< Physical base address of IPIF registers */
},
#if ( XPAR_XEMACPS_NUM_INSTANCES > 1 )
[ 1 ] =
{
.DeviceId = XPAR_PS7_ETHERNET_1_DEVICE_ID, /**< Unique ID of device */
.BaseAddress = XPAR_PS7_ETHERNET_1_BASEADDR /**< Physical base address of IPIF registers */
#ifndef SDT
.DeviceId = XPAR_PS7_ETHERNET_1_DEVICE_ID, /**< Unique ID of device */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I'm building on an environment that doesn't have SDT defined and XPAR_XEMACPS_NUM_INSTANCES > 1, there is a build failure:

Description	Resource	Path	Location	Type
'XPAR_PS7_ETHERNET_1_DEVICE_ID' undeclared here (not in a function); did you mean 'XPAR_PS7_ETHERNET_0_DEVICE_ID'?	NetworkInterface.c	/aws_demos/libraries/freertos_plus/standard/freertos_plus_tcp/source/portable/NetworkInterface/Zynq	line 185	C/C++ Problem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be resolved after adding the defines back in.

#endif
.BaseAddress = ZYNQ_ETHERNET_1_BASEADDR /**< Physical base address of IPIF registers */
},
#endif
};
Expand Down
6 changes: 5 additions & 1 deletion source/portable/NetworkInterface/Zynq/uncached_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@
#ifndef uncMEMORY_SIZE
#define uncMEMORY_SIZE uncMINIMAL_MEMORY_SIZE
#endif
#define DDR_MEMORY_END ( XPAR_PS7_DDR_0_S_AXI_HIGHADDR + 1 )
#ifndef SDT
#define DDR_MEMORY_END ( XPAR_PS7_DDR_0_S_AXI_HIGHADDR + 1 )
#else
#define DDR_MEMORY_END ( XPAR_PS7_DDR_0_HIGHADDRESS + 1 )
#endif
#define uncMEMORY_ATTRIBUTE 0x1C02
#endif /* ( ipconfigULTRASCALE == 1 ) */

Expand Down
17 changes: 15 additions & 2 deletions source/portable/NetworkInterface/Zynq/x_emacpsif.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,19 @@
extern "C" {
#endif

#define XPAR_PS7_ETHERNET_1_DEVICE_ID 1
#define XPAR_PS7_ETHERNET_1_BASEADDR 0xE000C000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason these macros are removed now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment. This must be the cause of the other errors so I will comment here.

I should have mentioned that my dev board only has 1 ethernet, so I wasn't able to check this case. XPAR_PS7_ETHERNET_0_DEVICE_ID and XPAR_PS7_ETHERNET_0_BASEADDR are defined in the xilinx file xparameters.h. I had assumed that xilinx would provide these definitions for additional ethernet, but maybe it is a bug that they are missing from the xilinx file. The deleted lines may have been a workaround for that.

I could look at your xparameters.h file if you post it. But it sounds like XPAR_PS7_ETHERNET_1_DEVICE_ID is missing. In that case it is no problem to revert the deletion. Is XPAR_PS7_ETHERNET_1_BASEADDR also missing from the xparameters.h?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it sounds like XPAR_PS7_ETHERNET_1_DEVICE_ID is missing. In that case it is no problem to revert the deletion. Is XPAR_PS7_ETHERNET_1_BASEADDR also missing from the xparameters.h?

Yes, both macros are missing; I just defined XPAR_XEMACPS_NUM_INSTANCES to 2 to just check the build. I believe ideally the xparameters.h should be updated with macros.

For backward compatibility for anyone already using the library with XPAR_XEMACPS_NUM_INSTANCES > 1, I believe it would be good to keep those macros optionally defined if they're not defined in xparameters.h maybe with #ifndef's.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have put the defines back in with #ifndef. They will be active when SDT is not defined.

#ifdef SDT
#define ZYNQ_SCUGIC_0_BASEADDR XPAR_XSCUGIC_0_BASEADDR
#define ZYNQ_ETHERNET_0_BASEADDR XPAR_XEMACPS_0_BASEADDR
#if ( XPAR_XEMACPS_NUM_INSTANCES > 1 )
#define ZYNQ_ETHERNET_1_BASEADDR XPAR_XEMACPS_1_BASEADDR
#endif
#else
#define ZYNQ_SCUGIC_0_BASEADDR XPAR_PS7_SCUGIC_0_BASEADDR
#define ZYNQ_ETHERNET_0_BASEADDR XPAR_PS7_ETHERNET_0_BASEADDR
#if ( XPAR_XEMACPS_NUM_INSTANCES > 1 )
#define ZYNQ_ETHERNET_1_BASEADDR XPAR_PS7_ETHERNET_1_BASEADDR
Copy link
Member

@tony-josi-aws tony-josi-aws Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I'm building on an environment that doesn't have SDT defined and XPAR_XEMACPS_NUM_INSTANCES > 1, there is a build failure:

Description	Resource	Path	Location	Type
'XPAR_PS7_ETHERNET_1_DEVICE_ID' undeclared here (not in a function); did you mean 'XPAR_PS7_ETHERNET_0_DEVICE_ID'?	NetworkInterface.c	/aws_demos/libraries/freertos_plus/standard/freertos_plus_tcp/source/portable/NetworkInterface/Zynq	line 185	C/C++ Problem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be resolved after adding the defines back in.

#endif
#endif /* ifdef SDT */

extern XEmacPs_Config mac_configs[ XPAR_XEMACPS_NUM_INSTANCES ];

Expand Down Expand Up @@ -145,6 +156,8 @@
void clean_dma_txdescs( xemacpsif_s * xemacpsif );
void resetrx_on_no_rxdata( xemacpsif_s * xemacpsif );

BaseType_t get_xEMACIndex( const XEmacPs * xemacpsp );

/**
* @brief Initialise the interface number 'xIndex'. Do not call directly.
*/
Expand Down
16 changes: 8 additions & 8 deletions source/portable/NetworkInterface/Zynq/x_emacpsif_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static void prvPassEthMessages( NetworkBufferDescriptor_t * pxDescriptor );
int is_tx_space_available( xemacpsif_s * xemacpsif )
{
size_t uxCount;
BaseType_t xEMACIndex = xemacpsif->emacps.Config.DeviceId;
BaseType_t xEMACIndex = get_xEMACIndex( &xemacpsif->emacps );

if( xTXDescriptorSemaphores[ xEMACIndex ] != NULL )
{
Expand All @@ -147,7 +147,7 @@ void emacps_check_tx( xemacpsif_s * xemacpsif )
{
int tail = xemacpsif->txTail;
int head = xemacpsif->txHead;
BaseType_t xEMACIndex = xemacpsif->emacps.Config.DeviceId;
BaseType_t xEMACIndex = get_xEMACIndex( &xemacpsif->emacps );
size_t uxCount = ( ( UBaseType_t ) ipconfigNIC_N_TX_DESC ) - uxSemaphoreGetCount( xTXDescriptorSemaphores[ xEMACIndex ] );

/* uxCount is the number of TX descriptors that are in use by the DMA. */
Expand Down Expand Up @@ -210,7 +210,7 @@ void emacps_send_handler( void * arg )
BaseType_t xEMACIndex;

xemacpsif = ( xemacpsif_s * ) arg;
xEMACIndex = xemacpsif->emacps.Config.DeviceId;
xEMACIndex = get_xEMACIndex( &xemacpsif->emacps );

/* This function is called from an ISR. The Xilinx ISR-handler has already
* cleared the TXCOMPL and TXSR_USEDREAD status bits in the XEMACPS_TXSR register.
Expand Down Expand Up @@ -254,7 +254,7 @@ XStatus emacps_send_message( xemacpsif_s * xemacpsif,
int txHead = xemacpsif->txHead;
int iHasSent = 0;
uint32_t ulBaseAddress = xemacpsif->emacps.Config.BaseAddress;
BaseType_t xEMACIndex = xemacpsif->emacps.Config.DeviceId;
BaseType_t xEMACIndex = get_xEMACIndex( &xemacpsif->emacps );
TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 5000U );

/* This driver wants to own all network buffers which are to be transmitted. */
Expand Down Expand Up @@ -362,7 +362,7 @@ void emacps_recv_handler( void * arg )

xemacpsif = ( xemacpsif_s * ) arg;
xemacpsif->isr_events |= EMAC_IF_RX_EVENT;
xEMACIndex = xemacpsif->emacps.Config.DeviceId;
xEMACIndex = get_xEMACIndex( &xemacpsif->emacps );

/* The driver has already cleared the FRAMERX, BUFFNA and error bits
* in the XEMACPS_RXSR register,
Expand Down Expand Up @@ -491,7 +491,7 @@ int emacps_check_rx( xemacpsif_s * xemacpsif,
int rx_bytes;
volatile int msgCount = 0;
int rxHead = xemacpsif->rxHead;
BaseType_t xEMACIndex = xemacpsif->emacps.Config.DeviceId;
BaseType_t xEMACIndex = get_xEMACIndex( &xemacpsif->emacps );
BaseType_t xAccepted;

#if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 )
Expand Down Expand Up @@ -632,7 +632,7 @@ void clean_dma_txdescs( xemacpsif_s * xemacpsif )
{
int index;
unsigned char * ucTxBuffer;
BaseType_t xEMACIndex = xemacpsif->emacps.Config.DeviceId;
BaseType_t xEMACIndex = get_xEMACIndex( &xemacpsif->emacps );

/* Clear all TX descriptors and assign uncached memory to each descriptor.
* "tx_space" points to the first available TX buffer. */
Expand All @@ -653,7 +653,7 @@ void clean_dma_txdescs( xemacpsif_s * xemacpsif )
XStatus init_dma( xemacpsif_s * xemacpsif )
{
NetworkBufferDescriptor_t * pxBuffer;
BaseType_t xEMACIndex = xemacpsif->emacps.Config.DeviceId;
BaseType_t xEMACIndex = get_xEMACIndex( &xemacpsif->emacps );

int iIndex;
UBaseType_t xRxSize;
Expand Down
18 changes: 16 additions & 2 deletions source/portable/NetworkInterface/Zynq/x_emacpsif_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void emacps_error_handler( void * arg,
BaseType_t xEMACIndex;

xemacpsif = ( xemacpsif_s * ) ( arg );
xEMACIndex = xemacpsif->emacps.Config.DeviceId;
xEMACIndex = get_xEMACIndex( &xemacpsif->emacps );

if( ( Direction != XEMACPS_SEND ) || ( ErrorWord != XEMACPS_TXSR_USEDREAD_MASK ) )
{
Expand Down Expand Up @@ -158,7 +158,7 @@ static void emacps_handle_error( void * arg,
xemacpsif = ( xemacpsif_s * ) ( arg );

xemacps = &xemacpsif->emacps;
xEMACIndex = xemacps->Config.DeviceId;
xEMACIndex = get_xEMACIndex( xemacps );

last_err_msg = NULL;

Expand Down Expand Up @@ -253,3 +253,17 @@ void HandleTxErrors( xemacpsif_s * xemacpsif )
}
/*taskEXIT_CRITICAL( ); */
}

BaseType_t get_xEMACIndex( const XEmacPs * xemacpsp )
{
#if ( XPAR_XEMACPS_NUM_INSTANCES == 1 )
( void ) xemacpsp;
return 0;
#else
#ifndef SDT
return xemacpsp->Config.DeviceId;
#else
return xemacpsp->Config.BaseAddress != ZYNQ_ETHERNET_0_BASEADDR;
#endif
#endif
}
22 changes: 15 additions & 7 deletions source/portable/NetworkInterface/Zynq/x_emacpsif_physpeed.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static int detect_phy( XEmacPs * xemacpsp )
{
/* Found a valid PHY address */
FreeRTOS_printf( ( "XEmacPs detect_phy: PHY detected at address %d.\n", ( unsigned ) phy_addr ) );
phy_detected[ xemacpsp->Config.DeviceId ] = phy_addr;
phy_detected[ get_xEMACIndex( xemacpsp ) ] = phy_addr;
return phy_addr;
}
}
Expand Down Expand Up @@ -506,7 +506,7 @@ static void SetUpSLCRDivisors( int mac_baseaddr,
volatile u32 slcrBaseAddress;

#ifndef PEEP
u32 SlcrDiv0;
u32 SlcrDiv0 = 0;
u32 SlcrDiv1 = 0;
u32 SlcrTxClkCntrl;
#endif
Expand Down Expand Up @@ -591,11 +591,19 @@ static void SetUpSLCRDivisors( int mac_baseaddr,
}
}

SlcrTxClkCntrl = *( volatile unsigned int * ) ( slcrBaseAddress );
SlcrTxClkCntrl &= EMACPS_SLCR_DIV_MASK;
SlcrTxClkCntrl |= ( SlcrDiv1 << 20 );
SlcrTxClkCntrl |= ( SlcrDiv0 << 8 );
*( volatile unsigned int * ) ( slcrBaseAddress ) = SlcrTxClkCntrl;
/* SDT drivers should not write to the register */
#ifndef SDT
SlcrTxClkCntrl = *( volatile unsigned int * ) ( slcrBaseAddress );
SlcrTxClkCntrl &= EMACPS_SLCR_DIV_MASK;
SlcrTxClkCntrl |= ( SlcrDiv1 << 20 );
SlcrTxClkCntrl |= ( SlcrDiv0 << 8 );
*( volatile unsigned int * ) ( slcrBaseAddress ) = SlcrTxClkCntrl;
#else
( void ) SlcrTxClkCntrl;
( void ) SlcrDiv0;
( void ) SlcrDiv1;
( void ) slcrBaseAddress;
#endif
#endif /* ifdef PEEP */
*( volatile unsigned int * ) ( SLCR_LOCK_ADDR ) = SLCR_LOCK_KEY_VALUE;
}
Expand Down
Loading