WARP Project Forums - Wireless Open-Access Research Platform

You are not logged in.

#1 2007-Mar-12 13:59:43

jlliu
Member
Registered: 2007-Jan-25
Posts: 31

Questions About Ethernet control

Hi,

We are try to use Warp Board to communicate with host PC by ethernet. Unfortunately, we haven't been successful on this front. Basically, we read ackmac.c and took out codes that relate to the ethernet communication. According to these codes, we made a simple code, as attached, to perform the following task --- whenever PPC gets a packet from ethernet, it sends it back over ethernet right away. We use ethereal (http://www.ethereal.com/) at the host PC to monitor packets.

We have two problems:

Problems

Problem (A):

We used the attached code, in two different project settings: First, Rice's OFDM reference design project, in which we only replaced ackmac.c with EMAC_Test.c; Second, we created a new project using the standalone OS with only two peripherals -- RS232 and Ethernet_MAC.

Using Rice's OFDM reference design project, we can see the Ethernet_mac was initialized successfully, and the loop works fine. From stdout, we can see the debug info outputs are as expected --- "*******received data from ethernet" and "*******transmit data back to ethernet". On the other hand, using the project we built, compilation is OK, but the
initialization of ethernet_mac fails at self test! Since the code is the same, most likely the cause lies in project settings. We would like to seek your help to resolve this issue. The .mss file of our project is attached.

Problem (B):

From the Ethereal, we can see the content of the packet transmitted or received in the Ethernet Card of the host PC. After the warp board receive the ethernet packet from the host PC I have tried to transmit the packet with different content back to the host PC. We can see the host PC received the packet from the warp board correctly from the Ethereal.

Since we can not see the source and destination MAC address of packet transmitted or received in the Ethernet Card of the host PC by the Ethereal. We can not figure out the MAC address set function "XEmac_SetMacAddress" does work or not. Can you give us some advice to verify the Mac address of Power PC is set correctly.

Code

#include "xparameters.h"
#include <stdio.h>
#include <pthread.h>
#include <errno.h>
#include <stdlib.h>
#include "xutil.h"
#include "xcache_l.h"
#include "xexception_l.h"
#include "xcache_l.h"
#include "xutil.h"
#include "xemac_l.h"
#include "xemac.h"
#include "xuartlite_l.h"

#include "xbasic_types.h"
#include "xstatus.h"
#include "xio.h"

//Ethernet - Parameters used for Ethernet
#define MY_XEM_MAX_FRAME_SIZE 2000
#define MY_XEM_MAX_FRAME_SIZE_IN_WORDS 2000
XEmac Emac;
XEmac *InstancePtr1 = &Emac;
Xuint8 RXBuffer[MY_XEM_MAX_FRAME_SIZE_IN_WORDS];
Xuint8 TXBuffer[MY_XEM_MAX_FRAME_SIZE_IN_WORDS];

int warpmac_init1();
int main()
{
    xil_printf("************Program begins from Main()\r\n");

    int l;
    int tmp_i;

    Xuint32 FrameLen = MY_XEM_MAX_FRAME_SIZE;
    XStatus Status;
    Xuint32 Options;
   
    char fullmac[6];
    fullmac[0] = 0;
    fullmac[1] = 1;
    fullmac[2] = 2;
    fullmac[3] = 3;
    fullmac[4] = 4;
    fullmac[5] = 5;

    warpmac_init1();
   
   xil_printf("entering while...\r\n");

    while(1)
    {

        FrameLen = MY_XEM_MAX_FRAME_SIZE;
        Status = XEmac_PollRecv(InstancePtr1, (Xuint8 *)RXBuffer, &FrameLen);
        if (Status != XST_SUCCESS)
        {
            if (!(Status == XST_NO_DATA || Status == XST_BUFFER_TOO_SMALL))
            {
                XEmac_Reset(InstancePtr1);
                XEmac_SetMacAddress(InstancePtr1, fullmac);
                Options = ( XEM_INSERT_FCS_OPTION |
                        XEM_INSERT_PAD_OPTION |
                        XEM_UNICAST_OPTION |
                        XEM_BROADCAST_OPTION |
                        XEM_POLLED_OPTION|
                        XEM_PROMISC_OPTION|
                        XEM_STRIP_PAD_FCS_OPTION );
                XEmac_SetOptions(InstancePtr1, Options);
                XEmac_Start(InstancePtr1);               
                xil_printf("no data received...\r\n");
            }           
        }
        else
        {
            for (tmp_i=0;tmp_i<FrameLen;tmp_i++)
            {
                TXBuffer[tmp_i] = RXBuffer[tmp_i];
            }
            xil_printf("*******received data from ethernet\r\n");
            XEmac_PollSend(InstancePtr1, &TXBuffer, FrameLen);
            xil_printf("*******transmit data back to ethernet\r\n");
        }
    }   
    return 0;
}

int warpmac_init1()
{

    xil_printf("    Initializing Ethernet...");
    /////////////////////////ETHERNET///////////////////////
    int i,l;
    XStatus Status;
    Xuint32 Options;
    Xuint16 DeviceId = XPAR_ETHERNET_MAC_DEVICE_ID;
    /*
     * Initialize the XEmac component. The device ID chosen should be
     * configured without DMA (see the xemac_g.c file)
     */
   Status = XEmac_Initialize(InstancePtr1, DeviceId);
    if (Status != XST_SUCCESS)
   {
        return XST_FAILURE;
   }
    /*
     * Run self-test on the device, which verifies basic sanity of the
     * device and the driver.
     */
    Status = XEmac_SelfTest(InstancePtr1);
   if (Status != XST_SUCCESS)
   {
        xil_printf("Test Fail...");
      return XST_FAILURE;
    }

    /*
     * Configure the device to be promiscuous
     */
    Options = XEmac_GetOptions(InstancePtr1);
    Options |= (XEM_INSERT_FCS_OPTION |
                XEM_INSERT_PAD_OPTION |
                XEM_UNICAST_OPTION |
                XEM_BROADCAST_OPTION |
                XEM_POLLED_OPTION|
                XEM_PROMISC_OPTION|
                XEM_STRIP_PAD_FCS_OPTION);

    Status = XEmac_SetOptions(InstancePtr1, Options);
    if (Status != XST_SUCCESS)
    {
        return XST_FAILURE;
    }

    /*
     * Set the MAC Addrees
     */
    //Status = XEmac_SetMacAddress(InstancePtr1, LocalAddress); //Note: Even though we are setting a MAC
                                                             //Address for the node, it is in promiscuous
                                                             //mode
    if (Status != XST_SUCCESS)
    {
        return XST_FAILURE;
    }

    /*
     * Start the device, which enables the transmitter and receiver
     */
    Status = XEmac_Start(InstancePtr1);
    if (Status != XST_SUCCESS)
    {
        return XST_FAILURE;
    }

    Status = XEmac_Initialize(InstancePtr1, DeviceId);
    if (Status != XST_SUCCESS)
    {
        return XST_FAILURE;
    }

    /*
     * Run self-test on the device, which verifies basic sanity of the
     * device and the driver.
     */
    Status = XEmac_SelfTest(InstancePtr1);
    if (Status != XST_SUCCESS)
    {
        return XST_FAILURE;
    }
    xil_printf("--  finish initial process --\r\n");
    return 0;
}

MSS file

PARAMETER VERSION = 2.2.0


BEGIN OS
PARAMETER OS_NAME = standalone
PARAMETER OS_VER = 1.00.a
PARAMETER PROC_INSTANCE = ppc405_1
END

BEGIN OS
PARAMETER OS_NAME = xilkernel
PARAMETER OS_VER = 3.00.a
PARAMETER PROC_INSTANCE = ppc405_0
PARAMETER stdout = RS232
PARAMETER stdin = RS232
END


BEGIN PROCESSOR
PARAMETER DRIVER_NAME = cpu_ppc405
PARAMETER DRIVER_VER = 1.00.a
PARAMETER HW_INSTANCE = ppc405_0
PARAMETER COMPILER = powerpc-eabi-gcc
PARAMETER ARCHIVER = powerpc-eabi-ar
PARAMETER CORE_CLOCK_FREQ_HZ = 100000000
END

BEGIN PROCESSOR
PARAMETER DRIVER_NAME = cpu_ppc405
PARAMETER DRIVER_VER = 1.00.a
PARAMETER HW_INSTANCE = ppc405_1
PARAMETER COMPILER = powerpc-eabi-gcc
PARAMETER ARCHIVER = powerpc-eabi-ar
END


BEGIN DRIVER
PARAMETER DRIVER_NAME = generic
PARAMETER DRIVER_VER = 1.00.a
PARAMETER HW_INSTANCE = jtagppc_0
END

BEGIN DRIVER
PARAMETER DRIVER_NAME = generic
PARAMETER DRIVER_VER = 1.00.a
PARAMETER HW_INSTANCE = iocm_cntlr
END

BEGIN DRIVER
PARAMETER DRIVER_NAME = generic
PARAMETER DRIVER_VER = 1.00.a
PARAMETER HW_INSTANCE = docm_cntlr
END

BEGIN DRIVER
PARAMETER DRIVER_NAME = plbarb
PARAMETER DRIVER_VER = 1.01.a
PARAMETER HW_INSTANCE = plb
END

BEGIN DRIVER
PARAMETER DRIVER_NAME = opbarb
PARAMETER DRIVER_VER = 1.02.a
PARAMETER HW_INSTANCE = opb
END

BEGIN DRIVER
PARAMETER DRIVER_NAME = plb2opb
PARAMETER DRIVER_VER = 1.00.a
PARAMETER HW_INSTANCE = plb2opb
END

BEGIN DRIVER
PARAMETER DRIVER_NAME = uartlite
PARAMETER DRIVER_VER = 1.01.a
PARAMETER HW_INSTANCE = RS232
END

BEGIN DRIVER
PARAMETER DRIVER_NAME = generic
PARAMETER DRIVER_VER = 1.00.a
PARAMETER HW_INSTANCE = CLKBRDCONFIG_0
END

BEGIN DRIVER
PARAMETER DRIVER_NAME = emac
PARAMETER DRIVER_VER = 1.00.e
PARAMETER HW_INSTANCE = Ethernet_MAC
END

End

That is all. Thanks.

Offline

 

#2 2007-Mar-12 16:10:52

zrcao
Member
From: Vienna, VA
Registered: 2007-Jan-24
Posts: 121

Re: Questions About Ethernet control

Please ignore problem (B), we believe it is clear to us now. In short, for setting up a link between two host PCs, the MAC addresses of the Tx/Rx WARP boards are transparent to host PCs. It is done by encapsulation in the callback functions based on MACframe structure. The dest/src addresses of the host PCs are regarded as data in the MACframe structure.

Please let us know if more information if needed for problem (A). Thanks.

Last edited by zrcao (2007-Mar-12 16:12:12)

Offline

 

#3 2007-Mar-12 16:57:28

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 5159

Re: Questions About Ethernet control

When you use the PLB Ethernet MAC, the PLB clock frequency must be at least 65MHz. I suspect when you created the new project (using Base System Builder?), you selected a bus clock frequency of 50MHz. Try building a new project with a bus clock frequency of 100MHz.

Base System Builder cannot generate projects with different clocks for the PLB and OPB. But the PLB Ethernet requires at least 65MHz, and the OPB OFDM core requires 50MHz. As a result, we must customize the clocking setup in the OFDM reference design. One DCM module is used to produce three clocks (200MHz for PowerPC, 100MHz for PLB and 50MHz for OPB). You can see this customization in the MHS file. Each OPB peripheral has a line like 'PORT OPB_Clk = sys_clk_OPB', and the DCM_module has a line like 'PORT CLKDV = sys_clk_OPB'.

Offline

 

#4 2007-Mar-12 18:09:14

zrcao
Member
From: Vienna, VA
Registered: 2007-Jan-24
Posts: 121

Re: Questions About Ethernet control

Thanks.

So, if I want OPB Bus & ADAC run at 60MHz, PLB run at 100MHz, and PPC run at 200MHz, all I need is to set corresponding values in the .MHS file? Any other place I should visit to change clock setting?

Last edited by zrcao (2007-Mar-12 18:10:14)

Offline

 

#5 2007-Mar-12 23:18:43

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 5159

Re: Questions About Ethernet control

The ratio of PLB:OPB clocks must be one of 1:1, 2:1, 3:1 or 4:1. See the plb2opb bridge datasheet for more details on this requirement (C:\EDK\hw\XilinxProcessorIPLib\pcores\plb2opb_bridge_v1_01_a\doc\plb2opb_bridge.pdf).

Given this constraint, I recommend the clock configuration we use in the OFDM reference design (200/100/50 for PPC/PLB/OPB).

Offline

 

#6 2007-Mar-16 13:03:18

zrcao
Member
From: Vienna, VA
Registered: 2007-Jan-24
Posts: 121

Re: Questions About Ethernet control

For the new version of WARP, you've indicated that the default clock for OPB is 40MHz.  So you will change the oscillator?

Offline

 

#7 2007-Mar-16 13:44:19

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 5159

Re: Questions About Ethernet control

The 40MHz clock will come from a WARP Clock Board, mounted on your FPGA board. The clock board contains two oscillators- one 20MHz for the radio reference, one 40MHz for the analog converters. It also has two very low jitter clock buffers which will distribute these clock signals to (up to) four radio boards. The analog converter clock is also driven into an FPGA GCLK pin; the OPB/PLB/PPC clocks will be derived from this signal, allowing everything to be synchronous with the sampling clock.

Offline

 

Board footer