Embedded Freaks..

December 9, 2008

Setting Host Infrastructure for Embedded Linux Development

Filed under: embedded-linux — Tags: — kunilkuda @ 1:37 pm

What will you need for embedded linux development ?

  • TFTP server: To store and retrieve the kernel from the board
  • NFS server: To store and retrieve the root file system. Actually you can burn the root FS inside the Flash, SD-CARD, CF, or anything else, but I found out that I did a lot of mistake when doing that (eg. the driver for the device/filesystem is not included in kernel/initramfs).Besides, I’m too lazy to move the SD-CARD/Flash around my PC and the board all day long.
  • DHCP server. At first, I thought DHCP server is not needed, or can be deployed in other PC (or ADSL router). But my TS-7260 seems like asking NFS service from DHCP server. I cannot redirect it to ask NFS service from other IP, except for the IP of the DHCP server.

Checking the NICs (Network Interface Cards)

My plan is to use two NICs: one to be connected to the board, one for internet. By that way, I can still googling for answers if I get errors from the board. In SuSE Enterprise Linux Desktop 10, my previous distro, I cannot turn on both NICs at the same time. Therefore, I reformat my laptop into Ubuntu (I’m using Ubuntu 8.10 now).

My deployment scheme will be as follows:

  • eth0 (PCI-ethernet): Connected to the board, using static IP and act as DHCP/NFS/TFTP server interface for the board
  • wlan0 (ipw3945): Connected to the internet, using DHCP IP from the ADSL router.

To set the static IP, right click the NetworkManager applet -> Edit Connections -> Wired tab. Choose to add new profile. Then at IPv4 Settings tab, fill up the IP/Netmask/Gateway IP. Since we’re not going to route request from eth0 to wlan0, we can fill any value for the IPs. I’m using 192.168.0.1/24 as my eth0 IP, and 0.0.0.0 as default gateway for eth0. I didn’t fill the DNS since it’s not needed.

static_ip_settings
Once the new profile is saved, activate it. Then check the system’s default gateway.

Open a terminal and type:

# route

If your default gateway is directed to the correct NIC, then it’s done.

# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.100.0 * 255.255.255.0 U 2 0 0 wlan0
192.168.0.0 * 255.255.255.0 U 1 0 0 eth0
link-local * 255.255.0.0 U 1000 0 0 wlan0
default 192.168.100.1 0.0.0.0 UG 0 0 0 wlan0

Otherwise, you need to redirect it into the correct NIC.

# sudo route add default gw 192.168.100.206

Note that 192.168.100.206 is my wlan0 IP, which is given by the ADSL router.

Now, plug the ethernet cable to the board, activate the wired profile, and try to browse the internet. It should work.

Installing DHCP Server

Installing DHCP server is easy. I followed this link, with a bit of modification. I changed the subnet into:

subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.2 192.168.0.254;
option routers 192.168.0.1;
option broadcast-address 192.168.0.255;
}

It is important to match the subnet with the network address of eth0 static IP. Otherwise, the DHCP server will not running.
Once you’re done, start the dhcp server with:

# sudo /etc/init.d/dhcp3-server restart

Note: Make sure the eth0 is up while starting the DHCP server. Otherwise, it won’t start.

Installing TFTP Server

# sudo apt-get install atftp atftpd
# sudo mkdir /tftpboot
# sudo chown nobody: /tftpboot
# sudo chmod 777 /tftpboot

Then modify the atftpd configuration as follows:

# sudo cp /etc/default/atftpd /etc/default/atftpd.backup
# sudo vi /etc/default/atftpd
USE_INETD=false
OPTIONS=”–daemon –port 69 –tftpd-timeout 300 –retry-timeout 5 –maxthread 100 –verbose=5 /tftpboot”
:wq
# sudo vi /etc/init.d/atftpd
## Comment this line
## #USE_INETD=true
:wq

Then, restart the server

# sudo /etc/init.d/atftpd restart

Note that in Ubuntu 8.10, atftpd by default is run by inetd. In such case, atftpd will need the inetd service to be terminated. Edit /etc/inetd.conf, and erase the “tftpd” line. Then stop the inetd.

# sudo /etc/init.d/openbsd-inetd stop

Installing NFS Server

# sudo apt-get install portmap nfs-kernel-server

Then create a directory to share

# sudo mkdir /nfs
# sudo chmod 777 /nfs

Share the directory with:

# sudo vi /etc/exports
/nfs *(rw,no_root_squash)
:wq

Last step, start the server

# sudo /etc/init.d/portmap restart
# sudo /etc/init.d/nfs-kernel-server restart

That’s it. Your host is now ready for embedded linux deployment.

3 Comments »

  1. [...] on December 9, 2008. Filed under: Uncategorized | Done with setup, now we’re heading for the [...]

    Pingback by Testing The Host Infrastructure « Embedded Freaks.. — December 9, 2008 @ 6:23 pm

  2. Hi Kunilkuda,
    This is very useful info here. I have a question – can you talk about serial ports on the laptop? I am researching what kind of laptop to build/buy/setup for doing embedded linux dev work and the board I have needs a serial port for the console….

    Comment by Paul Simon — August 12, 2009 @ 8:21 pm

  3. Hi Paul,

    I’m not sure why serial port on laptop would be a problem ? All that I know is most of USB-serial port converter can run on Linux/Windows without any issue. I’m even using USB modem, which actually using USB-serial port converter inside (so it’s seen as serial port on my linux laptop), and it runs without any additional driver.

    Comment by kunilkuda — August 12, 2009 @ 10:06 pm


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.