This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

About NDK RawETH developing on AM335x by using Industrual SDK

Other Parts Discussed in Thread: SYSBIOS

Hi All,

I am doing the developing of a RAWETH communication by using the NDK,SYSBIOS and AM335x industrual SDK.

After some porting job according to ind SDK os_drivers,I think I have already succeed to register the EMAC to NDK by calling NIMURegister() command.But I still be confused with how to use the socket commands and how the socket commands is connected with NIMU level.I also tried to find sample codes about RAWETH develop on NDK but failed.

So could some one provide a detail step by step guide after the NIMURegister() Job according to the industrual SDK done?

My code is like this, lt looks like can get the socket,but not able to make a send call.

void main()

{

Task_Params_init(&taskParams);
taskParams.priority = 5;
taskParams.stackSize = 0x400;
uartTask = Task_create (UARTproc, &taskParams, NULL);

...hardware initial codes....

if(AddNetifEntryFn(CPSW_NETIF_INIT) == 0)
BIOS_exit(0);

BIOS_start();

}

in task:

Void UARTproc(UArg arg1, UArg arg2)
{

/* Allocate the file environment for this task */
fdOpenSession(TaskSelf());

s_step = 100;

/* Initialize the allocated memory block. */
bzero(&PSA,sizeof(struct sockaddr_in));

PSA.sin_family = AF_RAWETH;
PSA.sin_len = sizeof(PSA);


for(i = 8;i<10;i++)
{
*(&pbuf+1) = 0;
}

while(1)

{

switch(s_step)
{
case 100:
sraw = INVALID_SOCKET;
s_step = 200;
break;

case 200:
sraw = socket(AF_RAWETH, SOCK_RAWETH, 0x88a4);
if(sraw != INVALID_SOCKET)
s_step = 300;
break;

case 300:
/* Configure the transmit device */
val = 1;
retVal = setsockopt(sraw, SOL_SOCKET, SO_IFDEVICE, &val, sizeof(val));
if(retVal)
System_printf("error in setsockopt \n");

s_step = 400;
break;

case 400:
/* Configure the EMAC channel number */
val = 3;
retVal = setsockopt(sraw, SOL_SOCKET, SO_PRIORITY, &val, sizeof(val));
if(retVal)
System_printf("error in setsockopt \n");
s_step = 500;
break;

case 500:
retVal = sendto(sraw, pbuf, 10, 0, (struct sockaddr*)&PSA,sizeof(PSA));
if (retVal == -1)
err = fdError();
break;

}

}

}

  • Bin Hu1,

    Have you brought in the NDK via your SYS/BIOS configuration file (*.cfg file)?  It may be helpful if you could attach your *.cfg file that you are using with the above application.

    I would suggest that you try to get a "standard socket" working first.  What I mean is, instead of starting with a raw socket, you might be better off starting with a TCP socket.  Since getting raw data to come into the stack may require some special hardware configuration, you socket code could be correct but if the hardware is configured to drop packets, then it would be hard to tell if it were your sockets code or the hardware.

    You should try a basic TCP app first, since TCP data should come through without frames being dropped in h/w.

    Then, once you get that to work, try the raw socket communication.

    Steve

  • Hello Steve,

    Thank you! Now I think I have succeed to do the NIMURegister() cause when carryout the BIOS_start(), System managed to call the currespond CpswEmacInit and CpswEmacStart functoin that I defined in the instance.

    I am trying to make a TCP sample first but these things confused me:

    1. After calling NIMURegister() to regist the hardware instance into NIMUDeviceTable.How the socket can really connect or hook to the hardware? Cause from socket() function I cannot find anywhere to input any Handle to it.

    2. From sample we can find that we can call socket commands to new a socket and send  in the task.But base on the first question, How can we managed to do this? Casue all of the samples in SPRU523 and SPRU524 files,The sample task always have input parameter of sockaddr of IP addr and so on.

    hello.cfg
  • Hello Steve.

    This afternoon I tried out the example of "Hello world" which took from L138 NSP package.It can run on my Beaglebone board now.I can ping from my PC and carryout helloworld test and get response.

    Now How can I start to play with RawEth package?Can I also use the "DaemonNew" command to create a RAWETH?

  • Bin Hu1,

    The NDK client example that shipped in NDK 2.0.0 has example code that uses raw sockets.  Please have a look at that, I've attached it for your convenience.

    Steve

    8867.client.c

  • Hello Steve,

    Thank you very much! I will study on that first.

  • Hello Steve,

    Thanks and Now I am able to send out the raw package from my am335x now. But when I try to receive the data by recvnc() function. It will never return. I dig into the ROV of SYSBIOS and found it is witing for a sem forever.

    This make me remember that you mentioned that I have to put the EMAC into promiscuous mode. Also in this topic tell this thing.http://e2e.ti.com/support/embedded/tirtos/f/355/p/106536/387932.aspx#387932

    But problem is my hardware is quite different as C6xxx DSP.So could you help me about how to change the os_drive of AM335x SDK to put EMAC in promiscuous receive mode?

    Thank you!