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.

unable to run TI CPSW Switch Example. plz help

Hi, I have my custom made am335x, that comes with two PHYs, 1 being SMSC 100Mbps and Marvell 1Gbps.I have followed kernel configuration and installed.

Now I am trying to run example provided by ti wiki, to set two network as switch mode. I have successfully compiled example. But when I run it, it prints: Command failed

ti example: http://processors.wiki.ti.com/index.php/AM335x_CPSW_(Ethernet)_Driver's_Guide
my code created as a gist: https://gist.github.com/c2h2/5989540

Has anyone ever tried to make it working?

  • Hi,

    Please add a variable to store the error number that is returned by ioctl in the lines shown below and print it. The kernel uses standard error enumeration, which can be easily interpreted to understand why exactly is something failing.


    if (ioctl(sockfd, SIOCSWITCHCONFIG, &ifr) < 0)
        {
    printf("Command failed\n");

    Best regards,
    Miroslav

  • Hi,

          I've got an identical problem. The error code returned is "-1". Looking at "errno.h" I don't see that specific error value defined. The declaration of "ioctl" command in "ioctl.h" however has this comment above it:


    /* Perform the I/O control operation specified by REQUEST on FD.
       One argument may follow; its presence and type depend on REQUEST.
       Return value depends on REQUEST.  Usually -1 indicates error.  */
    extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;

    So "-1" indicates an error-- that's all that's said about it. What next? Any other suggestions in understanding what exactly is the error?


    Thanks.

  • Arturs, the lower error numbers are defined inside errno-base.h:

    #define	EPERM		 1	/* Operation not permitted */

    Best regards,
    Miroslav

  • Thanks Miroslav,
           In my case though the problem was that I was loading up the "cmd_struct" field with all configuration parameters and then doing:

    memset(&cmd_struct, 0, sizeof(struct net_switch_config));

    Once I've moved my configuration setup AFTER the initialisation line I am now able to run the example just fine. So it was just an oversight on my part really.


    Thanks.