Embedded Freaks..

December 9, 2008

Setting Host Infrastructure for Embedded Linux Development

Filed under: ARM9, 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. Also can be used to transfer JFFS2 image to the SDRAM, before burning it into the NAND Flash
  • NFS server: To store and retrieve the root file system in target board. It’s the recommended method to do embedded linux development because it’ll be much easier to develop (no need to reboot and move around files from SD-Card or burning to Flash).
  • DHCP server: To make your life easier. Otherwise, there’ll be so many things to type during boot up.

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.

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.1.21/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.


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.1.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.1.0 netmask 255.255.255.0 {
  range 192.168.1.2 192.168.1.20;
  option routers 192.168.1.21;
  option broadcast-address 192.168.1.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 tftpd-hpa
# sudo mkdir /home/kunil/workspace/tftpboot

Then modify the TFTPD-HPA configuration as follows:

# sudo cp /etc/default/tftpd-hpa /etc/default/tftpd-hpa.backup
# sudo vi /etc/default/tftpd-hpa
TFTP_USERNAME="kunil"
TFTP_DIRECTORY="/home/kunil/workspace/tftpboot"
TFTP_ADDRESS=""
TFTP_OPTIONS=""
:wq
# sudo vi /etc/init/tftpd-hpa.conf
description     "tftp-hpa server"
author          "Chuck Short <zulcss@ubuntu.com>"
#start on (filesystem
#       and net-device-up IFACE!=lo)
#stop on runlevel [!2345]

console output
expect fork
#respawn

env PIDFILE="/var/run/tftpd-hpa.pid"
env DEFAULTS="/etc/default/tftpd-hpa"

script
    if [ -f ${DEFAULTS} ]; then
        . ${DEFAULTS}
    fi
    if [ ! -d "${TFTP_DIRECTORY}" ]; then
        echo "${TFTP_DIRECTORY} missing, aborting."
        exit 1
    fi
    #exec /usr/sbin/in.tftpd --listen  --user ${TFTP_USERNAME} --address ${TFTP_ADDRESS} ${TFTP_OPTIONS} ${TFTP_DIRECTORY}
    exec /usr/sbin/in.tftpd --listen --user ${TFTP_USERNAME} ${TFTP_DIRECTORY}
end script
:wq

Then, restart the server

# sudo stop tftpd-hpa
# sudo start tftpd-hpa

Installing NFS Server

# sudo apt-get install nfs-kernel-server

To disable automatic NFS server activation during boot up:

# sudo update-rc.d -f nfs-kernel-server remove
 Removing any system startup links for /etc/init.d/nfs-kernel-server ...
    /etc/rc0.d/K80nfs-kernel-server
    /etc/rc1.d/K80nfs-kernel-server
    /etc/rc2.d/S20nfs-kernel-server
    /etc/rc3.d/S20nfs-kernel-server
    /etc/rc4.d/S20nfs-kernel-server
    /etc/rc5.d/S20nfs-kernel-server
    /etc/rc6.d/K80nfs-kernel-server
# sudo vi /etc/init/statd.conf
.....
description     "NSM status monitor"
author          "Steve Langasek <steve.langasek@canonical.com>"

#start on (started portmap or mounting TYPE=nfs)
#stop on stopping portmap
.....
# sudo vi /etc/init/gssd.conf
.....
description     "rpcsec_gss daemon"
author          "Steve Langasek <steve.langasek@canonical.com>"

#start on (started portmap
#          or mounting TYPE=nfs4 OPTIONS=*sec*krb5*)
#stop on (stopping portmap or runlevel [06])
.....
# sudo vi /etc/init/idmapd.conf
....
description     "NFSv4 id <-> name mapper"
author          "Steve Langasek <steve.langasek@canonical.com>"
#start on (local-filesystems or mounting TYPE=nfs4)
#stop on runlevel [06]
......
:wq
# sudo vi /etc/init/portmap.conf
......
description     "RPC port mapper"
author          "Steve Langasek <steve.langasek@canonical.com>"

#start on (virtual-filesystems
#          and net-device-up IFACE=lo)
......
:wq

Then create a directory to share

# sudo mkdir /home/kunil/workspace/nfsroot

Share the directory with:

# sudo vi /etc/exports
/home/kunil/workspace/nfsroot   192.168.0.0/16(rw,no_subtree_check,no_root_squash,nohide)
:wq

Last step, start the server

# sudo service portmap restart
# sudo service nfs-kernel-server restart

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

Advertisements

5 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

  4. […] filesystem while debugging the Disko application is quite a troublesome if you use SD-Card (see my last post for it). However, just to run this demo, you can download your root filesystem into SD-Card and […]

    Pingback by Testing ‘Disko-Demos’ in LPC3250 « Embedded Freaks.. — November 26, 2010 @ 4:48 pm

  5. Fix-101129: Update the contents to Ubuntu-10.4

    Comment by kunilkuda — November 29, 2010 @ 6:33 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: