Sorry, you need to enable JavaScript to visit this website.

Zedboard - Network bring up

For reference on bringing your Zedboard up check out my other post here: http://zedboard.org/content/zedboard-bring

So you want to do some networking hu?  Let's try and use the wget command to pull down the google homepage:

zynq> wget http://www.google.com
wget: bad address 'www.google.com'

Well that's not good ... Let's see if we can fix this :D
 

View Settings

Ok, now that we have our board booted we can get into some cool Linux stuff.  First things first, default settings.  Here is our ifconfig output:

zynq> ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0A:35:00:01:22          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.255.0          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:20 errors:0 dropped:0 overruns:0 frame:0          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000          RX bytes:15720 (15.3 KiB)  TX bytes:1409 (1.3 KiB)          Interrupt:54 Base address:0xb000

 And our route table output:

zynq> route
Kernel IP routing table
Destination    Gateway    Genmask         Flags Metric Ref    Use Iface
192.168.1.0    *          255.255.255.0   U     0      0        0 eth0

Ok, so for some setups this might be just fine - specifically if you aren't going to be doing much (read: any) networking past a Zedboard <-> Laptop setup.  In my case, I would like to get into some serious Linux based networking so I need a bit more control over how the board talks over Ethernet.
 

DNS Server Setup

First we need to learn about two files that the Linux networking sub-system uses to do it's job.

The first is resolv.conf.  The resolv.conf file has a list of all the DNS servers Linux should use to do name look-up.  That is, when you type in google.com, your system is going out and actually resolving that to an IP address, which it then connects to.  You can not make connections to sites via their name, just their IP.  But 207.217.77.82 is a lot harder to remember than a nice site name.

The resolv.conf lives in the /etc directory.  So lets go there!

zynq> cd /etc
zynq> ls
dropbear      init.d        inittab.orig  passwd
fstab         inittab       mtab          profile

Well it looks like Digilent didn't include that file in their base Linux system, so we will have to create it!

zynq> cd /etczynq> touch resolv.confzynq> vi resolv.conf

Now, if you don't know how to use vi, it's okay.  It is a very powerful editor but we are only going to use it for a little bit of text entry.  First we need to enter edit mode by hitting the key.  Now we can add text.  We are going to add the following text:

nameserver 192.168.1.1

Once you do that hit the key and then +: (that's the shift key, plus the colon key).  You will see a little colon shows up at the bottom left of the screen.  We want to write the contents to the disk, and then exist so we are going to type in "qw!" (the ! point just does it rather than asking you if you are sure - I'm impatient ..).  Your screen should look like this:
 

Ok, now that we have our nameserver entered into the resolv.conf file our networking sub-system within the Linux kernel now knows where to look to resolve our website names (cool!).

Note:  If you are not on a 192.168.1.x network, then you are going to want to set this value to the appropriate value for your DNS server.  In almost all cases with home router setups the DNS server will be the same address as your router.  If you are setting this up in an enviornment where you do not know your DNS server, then you can use Google's free DNS server located at 8.8.8.8 ... so instead of "nameserver 192.168.1.1", you would have "nameserver 8.8.8.8".

We can see if we were successful by trying to ping google.com:

zynq> ping google.com
PING google.com (74.125.228.103): 56 data bytes
ping: sendto: Network is unreachable

Now, our ping failed, but we were able to resolve the address!  Now we need to setup a route so our Zedboard knows how to get to the outside world.
 

Setup Routes

Now that we have our DNS server loaded correctly, we now need to setup our route table.  Now, route tables can get quite tricky, and WAY advanced.  I am just going to touch on what needs to be added to get you up and running to talk to your local network and the outside world.
 
I am going to assume that if you are happy with your 192.168.1.10 address (Note: DHCP howto coming soon!), that you are on a 192.168.1.x network and that your router is * probably* at 192.168.1.1.  With all that said, we just need to run a single command to add the correct route:

zynq> route add default gw 192.168.1.1 eth0

 
Now you can run the route command do display the new route table

zynq> route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use 
Ifacedefault    192.168.1.1     0.0.0.0         UG    0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0

 
Now we can connect to the outside world! woohoo!  Let's put down the google home page source code as our first example:

zynq> wget http://www.google.comConnecting to www.google.com (173.194.73.104:80)index.html           100% |*******************************| 13316  --:--:-- ETA
zynq> ls
dropbear      index.html    inittab       mtab          profile
fstab         init.d        inittab.orig  passwd        resolv.conf
zynq> cat index.html

 
The screen will scroll out all of hte HTML that it downloaded from google that is sitting in the index.html file. We'll that's it!  Now you have a board that can talk to the outside world.  What will you do next?  SSH?  FTP?  HTTP?  They are all already running on your zedboard - give it a shot!

 

Comments

Note: DHCP howto coming soon!

How soon?

Thanks for the hints, they were really useful to me!
Considering the other one about "modifying your ramdisk image", I decided to put some more convenience into my zedboard and permanently store it in the bootup scripts.

If you like, add to:

/etc/init.de/rcS

echo "++ Configure static IP"
ifconfig eth0 down
ifconfig eth0 aaa.bbb.ccc.ddd broadcast aaa.bbb.ccc.255 netmask 255.255.255.0
route add default gw aaa.bbb.ccc.1

echo "++ setting up system time via network ++"
ntpd -p 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org

echo "++ setting up hostname ++"
hostname zedboard

DNS resolution was mentioned before, but I like short hostnames without the domainname appendix as well:
/etc/resolv.conf

nameserver aaa.bbb.ccc.ddd
search mydomain.com

In order to have a more convenient bash prompt, modify
/etc/profile

# prompt
export PS1="\u@\h> "

# set timezone
export TZ=UTC-1

And finally, if the zedboard is on the network permanently, we should change the root password.

> more /etc/passwd

will show you the hash for the current password. Change it to something new:

> passwd

Now have a second look at the hash:

> more /etc/passwd

The line should have changed. Mount the SD-Card and the boot image, copy /etc/passwd over to /mnt/etc/passwd and store the modified boot image back again on the SD-Card. Done. OF COURSE make sure that you have a backup of the old boot-image at hand so that you can recover from any problems...

Cheers, Joachim

PS: I'm working on passwordless SSH but it's not working yet. Just a matter of time ;-)

Working on this now - sorry for the delay!

I think it should be :wq! in VI.

Hi, really nice work so far!
I'm trying to set up DHCP on my board, but I don't know how to get it running. I tried the following:

zynq> udhcpc eth0
udhcpc (v1.18.4) started
Sending discover...
Sending discover...
Sending select for 134.93.128.232...
Lease of 134.93.128.232 obtained, lease time 86400

but when I check the ifconfig, nothing has changed..

zynq> ifconfig
eth0 Link encap:Ethernet HWaddr 00:0A:35:00:01:22
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:20917 errors:0 dropped:835 overruns:0 frame:0
TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1846584 (1.7 MiB) TX bytes:3602 (3.5 KiB)
Interrupt:54 Base address:0xb000

Do you know how to get it working?

Well we solved the problem now. First we had to install a new default.script and make it executable. Than run it via "udhcpc -s (path)/default.script eth0".

I have followed every single instruction noted above but still no luck.

1. Do I need any specific settings on my Win7-64 laptop?
2. I tried to turn off "Windows Firewall", still no luck
Any other suggestions? I am not a network expert which makes it a little harder.

Please help!!!

despite setting the nameserver 192.168.1.10 or 8.8.8.8 using minicom i still have problem ping google.com.

I am using ubuntu 12.04 64bit on VMware.

Hi,
Thank your for your nice tutorial. I tried to follow your tutorial to setup for my QEMU but it didn't work.
This is my situtiation. I am using Windows as a host. Then, I install Linux Ubuntu 16.4 on the virtual box as a guest machine. I use NAT as network setting between two machine. In the virtual box, I install the QEMU and it runs successfully.
Now how can I setup a internet connection in the QEMU? This is the command line with option to run the QEMU:

./arm-softmmu/qemu-system-arm -M xilinx-zynq-a9 -m 1024 -serial null -serial mon:stdio -kern-dtb ./xilinx_zynq.dtb -smp 2 -nographic -kernel kernel/zImage -initrd filesystem/ramdisk.img -net nic,model=cadence_gem -net user -tftp ~/ -redir tcp:10023::23 -redir tcp:10080::80 -redir tcp:10022::22 -redir tcp:10021::21 -redir tcp:1234::1234

When I check the IP address of QEMU. It is same with Ubuntu OS's IP address as follow:
IP address: 10.0.2.15
Bcast: 10.0.2.255
Mask: 255.255.255.0
This is information when I use the route command
Destination     Gateway     Genmask          Flags  Metric  Ref  Use   Iface
default             10.0.2.2       0.0.0.0              UG      0          0           0  eth0
10.0.2.0           *                   255.255.255.0 U         0          0           0  eth0
 
 

Thanks for posting this amazing guideline. I guess now I need to navigate to this website for better use of content. I have always faced problems with networks, but after reading this post, I hope I get better at it.

Zedboard network is going well right now, and I hope it keeps going well. If it stops in the next few months due to the i don't want to write my essay, then it will real sad to see that. I support this network.