world leader in high performance signal processing
Trace: » setting_up_the_network

Setting up the Network

There are two basic ways to set up the network - automatically, and manually. For the purpose of setting up the basics, it does not matter if you are connecting to a cross over cable to a different PC, or if you are connecting via a switch or hub to a network.

Automatic Network Setup

To set things up automatically, normally requires the use of Dynamic Host Configuration Protocol (dhcp). It is used to control networking parameters of hosts (running clients) with the help of a server. This requires that someone has set up a dhcp server on your network, and has it configured properly. If this describes your condition, then you can read further details about the dhcpcd client.

Manual Network Setup

If you are unfamiliar with Linux Networking, or IP networks in general, it would be a good idea to read some information to review some topics:

Configuring a network interface

When you have all of the information you need, you can start to configure your network interfaces. This information would include:

  • IP number which you want to set up the Blackfin on. Do not just randomly pick this number if you are on a network. If you have a cross over cable, which is connected to a PC, just add one to the PC's IP number and use that. (For example, if the PC has been set to 192.168.0.3, use 192.168.0.4 for the IP number on the Blackfin).
  • Default gateway (not necessary when PC ↔ Blackfin is on the same subnet, or cross over cable).
  • Default netmask (not necessary when PC ↔ Blackfin is on the same subnet, or cross over cable).

This is process of assigning appropriate addresses to a network device and to setting appropriate values for other configurable parameters of a network device.

  1. Set the IP number, and netmask:
    root:~> ifconfig eth0 10.64.204.245 netmask 255.255.255.0 up

    In this case the interface eth0 is configured with the IP address 10.64.204.245 and a network mask of 255.255.255.0. The up that trails the command tells the interface that it should become active. To shutdown an interface, you can just call ifconfig eth0 down.

  2. Check to make sure it was set properly:
    root:~> ifconfig eth0
    eth0      Link encap:Ethernet  HWaddr 00:E0:22:FE:47:33
              inet addr:10.64.204.245  Bcast:10.64.204.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:17 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000

    ifconfig has many options, which are described in ifconfig.

  3. Now, the default gateway must be set to tell the kernel networking code, how to talk to other IP addresses, not on the same subnet.
    root:~> route
    Kernel IP routing table
    Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
    10.64.204.0    *              255.255.255.0  U    0      0        0 eth0

    Here we can tell there is no default gateway. To add this:

    root:~> route add default gw 10.64.204.1
    root:~> route
    Kernel IP routing table
    Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
    10.64.204.0    *              255.255.255.0  U    0      0        0 eth0
    default        10.64.204.1    0.0.0.0        UG    0      0        0 eth0

    Now, we can check to make sure that traffic can come to/from other subnets (Note that the IP number we are pinging is not on the same subnet we are):

    root:~> ping -c 3 10.64.53.110
    PING 10.64.53.110 (10.64.53.110): 56 data bytes
    64 bytes from 10.64.53.110: icmp_seq=0 ttl=124 time=0.8 ms
    64 bytes from 10.64.53.110: icmp_seq=1 ttl=124 time=0.7 ms
    64 bytes from 10.64.53.110: icmp_seq=2 ttl=124 time=0.7 ms
    
    --- 10.64.53.110 ping statistics ---
    3 packets transmitted, 3 packets received, 0% packet loss
    round-trip min/avg/max = 0.7/0.7/0.8 ms
  4. At this point, the ethernet device is configured, but there is no way for you to do name lookups, to translate names, like www.google.com to IP addresses. To do this, the name Resolver must be set, in /etc/resolv.conf:
    root:~> cat /etc/resolv.conf
    search ad.analog.com
    nameserver 10.64.53.110
    nameserver 10.64.51.110
    nameserver 10.66.5.110
    nameserver 10.64.82.11
    root:~> nslookup www.google.com
    Server:    nwd2dc2.ad.analog.com
    Address:    10.64.53.110
    
    Name:      www.l.google.com
    Address:    64.233.161.147

There are many other things that should be done before a complete network is set up, but this should be the basics, and allow most people to continue.

All these manual steps can be done automatically with a properly configured dhcp server, by using the dhcpcd client on uClinux. If you do not know if your network has this or not, check with your network administrator.

Passing information from U-Boot

If you want to use the same network information from U-Boot, you must pass things in the U-Boot bootargs variable. In recent versions of U-Boot, this can be done with the addip command. To see if you have this command:

bf537> print addip
addip=setenv bootargs $(bootargs) ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname):eth0:off
bf537>

To use this, just run addip before doing the boot command. For example:

bf537> dhcp
Using MAC Address 00:E0:22:FE:42:7A
BOOTP broadcast 1
*** Unhandled DHCP Option in OFFER/ACK: 26
*** Unhandled DHCP Option in OFFER/ACK: 26
DHCP client bound to address 192.168.0.3
bf537> set serverip 192.168.0.4
bf537> tftp 0x1000000 uImage537-4
Using MAC Address 00:E0:22:FE:42:7A
TFTP from server 192.168.0.4; our IP address is 192.168.0.3
Filename 'uImage537-4'.
Load address: 0x1000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ################################################
done
Bytes transferred = 3240929 (3173e1 hex)
bf537> run addip
bf537> bootm
## Booting image at 01000000 ...
   Image Name:   uClinux Kernel and ext2
   Created:      2006-08-27   6:25:32 UTC
   Image Type:   Blackfin Linux Kernel Image (gzip compressed)
   Data Size:    3240865 Bytes =  3.1 MB
   Load Address: 00001000
   Entry Point:  00001000
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK
Starting Kernel at = 1000
Linux version 2.6.16.11-ADI-2006R1 (rgetz@home) (gcc version 3.4.5 (ADI cvs)) #1 Sun Aug 27 02:16:22 EDT 2006
Blackfin support (C) 2004-2006 Analog Devices, Inc.
Compiled for ADSP-BF537 Rev. 0.2
Blackfin uClinux support by http://blackfin.uclinux.org/
Processor Speed: 500 MHz core clock and 100 Mhz System Clock
Board Memory: 64MB
Kernel Managed Memory: 64MB
Memory map:
  text      = 0x00001000-0x00102fcc
  init      = 0x00103000-0x001104d0
  data      = 0x00110764-0x00141c20
  stack     = 0x00112000-0x00114000
  bss       = 0x00141c20-0x0014f81c
  available = 0x0014f81c-0x03700000
  rootfs    = 0x03700000-0x03f00000
  DMA Zone  = 0x03f00000-0x04000000
Instruction Cache Enabled
Data Cache Enabled (write-through)
Hardware Trace Enabled
Built 1 zonelists
Kernel command line: root=/dev/mtdblock0 rw ip=192.168.0.3:192.168.0.4:192.168.0.1:255.255.255.0:BF537:eth0:off
[...snip...]
NET: Registered protocol family 2
IP route cache hash table entries: 512 (order: -1, 2048 bytes)
TCP established hash table entries: 2048 (order: 1, 8192 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
TCP bic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
bfin_mac: Network is set to half duplex
IP-Config: Complete:
      device=eth0, addr=192.168.0.3, mask=255.255.255.0, gw=192.168.0.1,
     host=BF537, domain=, nis-domain=(none),
     bootserver=192.168.0.4, rootserver=192.168.0.4, rootpath=
[...snip...]
root:~> ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:E0:22:FE:42:7A
          inet addr:192.168.0.3  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
root:~>

The interesting thing to note is the kernel command line, where all the information is passed from U-Boot to the kernel.

Troubleshooting network problems

There are many common network issues, which can be resolved numerous ways. The first step is ensuring that your target (the Blackfin) can talk on the network. The second it to make sure your host can talk to the Blackfin.

Target issues

  • check you have the proper MAC Address:
    • To use the optional application macchanger:
      root:/> macchanger -s eth0
      Current MAC: 00:e0:22:fe:5c:74 (Analog Devices Inc.)
      
    • To use ifconfig:
      root:/> ifconfig eth0 | grep HWaddr
      eth0      Link encap:Ethernet  HWaddr 00:E0:22:FE:5C:74
      
      The advantage of using the macchanger application - is it will validate that the MAC address is a valid one, ifconfig will not.
    • If you need a MAC address - you must get one from the IEEE.
  • check you have the proper IP number:
    root:~> ifconfig eth0
    eth0      Link encap:Ethernet  HWaddr 00:E0:22:FE:47:33
              inet addr:10.64.204.116  Bcast:10.64.204.255  Mask:255.255.255.0
              UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:692 errors:0 dropped:0 overruns:0 frame:0
              TX packets:137 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000

    Other things to check are the MAC address - (HWaddr) - it should match the sticker on your hardware.

  • check the default routing table:
    root:~> route
    Kernel IP routing table
    Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
    10.64.204.0    *              255.255.255.0  U    0      0        0 eth0
    default        10.64.204.1    0.0.0.0        UG    0      0        0 eth0

    It should include a default gateway - make sure you can ping it.

  • Check nslookup to make sure that DNS is working.
    root:~> nslookup www.analog.com
    Server:    nwd2dc2.ad.analog.com
    Address:    10.64.53.110
    
    Name:      nwd2www1.analog.com
    Address:    137.71.25.68
  • Check the network path with traceroute:
    root:~> traceroute www.analog.com
    traceroute to nwd2www1.analog.com (137.71.25.68), 30 hops max, 40 byte packets
    1  10.64.204.1 (10.64.204.1)  1.903 ms  1.441 ms  1.242 ms
    2  10.64.1.77 (10.64.1.77)  1.675 ms  1.34 ms  -4.614 ms
    3  10.64.1.45 (10.64.1.45)  1.832 ms  1.537 ms  1.312 ms
    4  10.64.2.81 (10.64.2.81)  1.934 ms  1.612 ms  1.392 ms
    5  10.64.2.68 (10.64.2.68)  2.958 ms  2.699 ms  2.687 ms
    6  137.71.25.8 (137.71.25.8)  -2.119 ms  -2.244 ms  3.53 ms

    Note: traceroute uses IMCP (ping), so things that block ping (like firewalls), will stop traceroute from working, and you will end up with something like:

    root:~> traceroute www.google.com
    traceroute to www.l.google.com (216.239.37.99), 30 hops max, 40 byte packets
    1  10.64.204.1 (10.64.204.1)  1.808 ms  -4.478 ms  1.251 ms
    2  10.64.1.77 (10.64.1.77)  1.679 ms  1.369 ms  -4.592 ms
    3  10.64.1.45 (10.64.1.45)  2.114 ms  1.678 ms  1.34 ms
    4  10.64.2.81 (10.64.2.81)  1.752 ms  1.592 ms  1.41 ms
    5  * * *
    6  * * *
    7  * * *
  • try wget
    root:~> wget http://www.google.com/index.html
    Connecting to www.google.com[216.239.37.99]:80
    index.html          100% |*****************************|  2445      00:00 ETA

    If this works - you are pretty much set.

Host issues

Many host issues can be resolved to something not be installed on the host, or if a host firewall is turned on.

  • Can you ping the target from the host?
    rgetz@home:~> ping 192.168.0.3
    PING 192.168.0.3 (192.168.0.3) 56(84) bytes of data.
    64 bytes from 192.168.0.3: icmp_seq=1 ttl=64 time=0.207 ms
    64 bytes from 192.168.0.3: icmp_seq=2 ttl=64 time=0.147 ms
    64 bytes from 192.168.0.3: icmp_seq=3 ttl=64 time=0.156 ms
    64 bytes from 192.168.0.3: icmp_seq=4 ttl=64 time=0.143 ms
    
    --- 192.168.0.3 ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 3000ms
    rtt min/avg/max/mdev = 0.143/0.163/0.207/0.027 ms
  • Can you ping the host from the target?
    root:~> uname -a
    Linux blackfin 2.6.16.11-ADI-2006R1 #1 Sun Aug 20 22:18:44 EDT 2006 blackfin unknown
    root:~> ping 192.168.0.4
    PING 192.168.0.4 (192.168.0.4): 56 data bytes
    64 bytes from 192.168.0.4: icmp_seq=0 ttl=64 time=0.3 ms
    64 bytes from 192.168.0.4: icmp_seq=1 ttl=64 time=0.2 ms
    64 bytes from 192.168.0.4: icmp_seq=2 ttl=64 time=0.2 ms
    64 bytes from 192.168.0.4: icmp_seq=3 ttl=64 time=0.2 ms
    
    --- 192.168.0.4 ping statistics ---
    4 packets transmitted, 4 packets received, 0% packet loss
    round-trip min/avg/max = 0.2/0.2/0.3 ms
  • See if you can telnet from the host to the target. First check everything is installed properly on the target:
    root:~> cat /etc/inetd.conf
    shell   stream tcp nowait root /bin/rshd
    ftp     stream tcp nowait root /bin/ftpd -l
    telnet  stream tcp nowait root /bin/telnetd
    root:~> ps | grep inetd
       23 root         68 S   inetd
       52 root        516 S   grep inetd
    root:~> ls -l /bin/telnetd
    -rwxr--r--    1 1000     100         38904 /bin/telnetd
    root:~> ifconfig eth0
    eth0      Link encap:Ethernet  HWaddr 00:E0:22:FE:42:7A
              inet addr:192.168.0.3  Bcast:192.168.0.255  Mask:255.255.255.0
              UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:63746 errors:0 dropped:0 overruns:0 frame:0
              TX packets:28053 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
    root:~>

    Here we can see telnet is (1) installed, (2) set up to run from inetd, and (3) networking is configured. Now we can check to see if we can telnet from the host.

    rgetz@home:~> telnet 192.168.0.3
    Trying 192.168.0.3...
    Connected to 192.168.0.3.
    Escape character is '^]'.
    
    
    BusyBox v1.00 (2006.08.21-02:05+0000) Built-in shell (msh)
    Enter 'help' for a list of built-in commands.
    
    root:~> uname -a
    Linux blackfin 2.6.16.11-ADI-2006R1 #1 Sun Aug 20 22:18:44 EDT 2006 blackfin unknown
    root:~>

    Seems to work!

  • See if you can telnet from the target to the host:
    root:~> telnet 192.168.0.4
    Trying 192.168.0.4(5888)...
    telnet: Unable to connect to remote host: Connection refused
    root:~>

    This does not work, becuase telnet is turned off on the host (like it should be).

Normally, host ↔ target issues can be resolved to issues on the host, since the target is well tested, and most Linux distributions “lock” the networking down for security purposes.

More information

Complete Table of Contents/Topics