Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
21 years ago

LWIP doesn't work...

Hi!

I have tested stand-alone lwip with Nios2 standard example design, and it works fine. I implemented multiprocessor environment where is three standard nios 2 processors. One processor is going to handle interface to Internet and others have some other work. But stand-alone lwip doesn't work in Internet interface handler, sometimes it prints something like this "can't get mac-address, modify get_mac_address function...", and sometimes nothing, but telnet connection is not working.

Have someone any idea where to start looking the reason for this behaviour?

Thanks..

-CoolMan

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The get_mac_address function is coverred in the Nios II Software Developers Handbook in Chapter 9, you should read this first.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Coolman,

    Modify you mac_addr.c file to look something like this.

    #include "alt_types.h"# include "io.h"# include "lwip/netif.h"
    /*
    * read_mac_address
    *
    * Read the MAC address in a board specific way
    *
    */
    err_t read_mac_address(struct netif *netif)
    {
      err_t ret_code = ERR_IF;
      alt_u32 signature;
      /*
      * Our board has the MAC address stored at 0x7f000 in flash
      */# if defined(ALTERA_NIOS_DEV_BOARD_CYCLONE_1C20) ||
        defined(ALTERA_NIOS_DEV_BOARD_STRATIX_1S10) ||
        defined(ALTERA_NIOS_DEV_BOARD_STRATIX_1S10_ES) ||
        defined(ALTERA_NIOS_DEV_BOARD_STRATIX_1S40)
      signature = IORD_32DIRECT(0x7f0000, 0);
      if (signature != 0x00005afe)
      {
        fprintf(stderr, "\n-- FIX THIS -- Can't read the MAC address from flash -- FIX THIS -- .\nSetting MAC address to default FF:FF:FF:FF:FF:FF\n");
        netif->hwaddr_len = 6;
        netif->hwaddr = 0xFF;
        netif->hwaddr = 0xFF;
        netif->hwaddr = 0xFF;
        netif->hwaddr = 0xFF;
        netif->hwaddr = 0xFF;
        netif->hwaddr = 0xFF;
        ret_code = ERR_OK;    
      }
      else
      {
        /* Set MAC hardware address length */
        netif->hwaddr_len = 6;
        netif->hwaddr = IORD_8DIRECT(0x7f0000, 4);
        netif->hwaddr = IORD_8DIRECT(0x7f0000, 5);
        netif->hwaddr = IORD_8DIRECT(0x7f0000, 6);
        netif->hwaddr = IORD_8DIRECT(0x7f0000, 7);
        netif->hwaddr = IORD_8DIRECT(0x7f0000, 8);
        netif->hwaddr = IORD_8DIRECT(0x7f0000, 9);
        ret_code = ERR_OK;
      }# else
      fprintf(stderr, "Not an Altera board.\nYou need to modify the function read_mac_address to set a MAC address for your board.\n");# endif
      return ret_code;
    }

    Here you simply replace the FF's with the correct MAC address.

    NOTE this is an UGLY hack just to get it working. It CAN NOT / SHOULD NOT be used in a production system.

    It should at least give you an idea of where to look for your problem
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    thank for your advices. But unfortunately it is not working. Is there possibility to be something wrong with my hardware connections, bdf-file or sopc-builder-file?

    Have you any idea?

    Thanks..

    -CoolMan
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    originally posted by coolman@Oct 15 2004, 12:31 AM

    hi,

    thank for your advices. but unfortunately it is not working. is there possibility to be something wrong with my hardware connections, bdf-file or sopc-builder-file?

    have you any idea?

    thanks..

    -coolman

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=2106)

    --- quote end ---

    --- Quote End ---

    Hi Coolman,

    same prob here.... using nios II ide 5.0....

    quite frustrating as it is

    cheers,

    Danny
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    originally posted by dannyjacobs+nov 4 2005, 10:27 am--><div class='quotetop'>quote (dannyjacobs @ nov 4 2005, 10:27 am)</div>

    --- quote start ---

    <!--quotebegin-coolman@Oct 15 2004, 12:31 AM

    hi,

    thank for your advices. but unfortunately it is not working. is there possibility to be something wrong with my hardware connections, bdf-file or sopc-builder-file?

    have you any idea?

    thanks..

    -coolman

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=2106)

    --- quote end ---

    --- Quote End ---

    Hi Coolman,

    same prob here.... using nios II ide 5.0....

    quite frustrating as it is

    cheers,

    Danny

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=10796)</div>

    [/b]

    --- Quote End ---

    Hi all,

    solved it... your should remove the if statement and just assign an own MAC. It works http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif

    Danny