Build and boot Linux (over network)

Why boot your board over network?  its easy……

I am taking some assumptions first.

  1. Your host is running Ubuntu 12.10
  2. Your target has a RS232 port
  3. Your target has U-boot flashed
  4. Your target has an Ethernet interface
  5. The target and the host are connected on ethernet interface and has no DHCP
  6. The target and the host are connected on RS232 and this console is used by U-boot

Step1: Building Linux

1. Download build root (from  and extract in a folder go into the main folder of buildroot (in my case /home/prajosh/Project/buildroot_sam9g20/buildroot-2013.05)

$ make at91sam9g20dfc_defconfig

Or any other default configs found in the configs folder. E.g choose mini2440_defconfig for friendly arm

2. I would like to add a few packages

$ make menuconfig

And select the drop bear for ssh and also I would select the root file system compressed as .tar file.

3. after the configurations type

$ make

And wait for the tool chain, Kernel, etc …. to be compiled and will generate rootfs  and kernel image

Step 2: Configure your tftp server

We need TFTP so U-Boot is able to retrieve our kernel over the network with the TFTP. I have configured the tftp as per the directions from David Sudjiman from his blog. (Special thanks to David) I have just copied it below

1. Install tftpd and related packages.

$ sudo apt-get install xinetd tftpd tftp

2. Create /etc/xinetd.d/tftp and put this entry:

$ sudo gedit  /etc/xinetd.d/tftp

And copy the text below

service tftp
protocol        = udp
port            = 69
socket_type     = dgram
wait            = yes
user            = nobody
server          = /usr/sbin/in.tftpd
server_args     = /tftpboot
disable         = no}

3. Make /tftpboot directory

$ sudo mkdir /tftpboot
$ sudo chmod -R 777 /tftpboot
$ sudo chown -R nobody /tftpboot

4. Start tftpd through xinetd

$ sudo /etc/init.d/xinetd start

5. copy the kernel into the tftp folder

$ cp buildroot-2013.05/output/images/uImage  /tftpboot/
$ chmod 777 /tftpboot/uImage

6. Testing. Tranfering file uImage from (Server using tftp) to (Client is assumed to be your host IP. Use ifconfig to set your ip accordingly

prajosh@test-box:~/Project/exp$ tftp
tftp> get uImage
Received 1887993 bytes in 0.2 seconds
tftp> quit

Step 3: Configure your nfs server

We need NFS to be able for the target to get the file system via the network from our development system

1. Install the NFS daemon nfsd

$sudo apt-get install nfs-kernel-server

2. Copy the entire filesystem generated using buildroot or with help of busy box etc… into the folder /nfs

$ sudo mkdir /nfs
$ sudo chown 1000:1000 /nfs

3. Edit the exports

$ sudo gedit /etc/exports

4. add this line to /etc/exports


save the changes

5. restart nfs server

$ sudo /etc/init.d/nfs-kernel-server restart

6. For testing the nfs server you will have to change the line in /etc/exports to /nfs,sync,no_root_squash)

Restart the server and do the following

$ sudo mkdir ~/nfs_test
$ sudo mount localhost:/nfs ~/nfs_test
$ sudo umount ~/nfs_test

And if there are no errors all is good

Step 4: Setting up your target

Power up the board and stop your board from booting with default parameters you will get some messages and a U-Boot prompt. I will give the target ip

U-Boot 1.3.4 (Mar  9 2010 - 19:35:35)
DRAM:  64 MB
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
Net:   macb0
macb0: Starting autonegotiation...
macb0: Autonegotiation complete
macb0: link up, 100Mbps full-duplex (lpa: 0xc5e1)
Hit any key to stop autoboot:  0

Set the following commands:

U-Boot>set serverip

The command set the ip for target

U-Boot>set ipaddr

Set ip for Host

$ sudo ifconfig eth0

Test the network by ping on each other you get something like this

U-Boot> ping
macb0: link up, 100Mbps full-duplex (lpa: 0xc5e1)
Using macb0 device
host is alive

This command tells the U-boot where to copy the uImage file or the os image. The Magic Number “0x22200000” is the location of the RAM and you have to find this in your board spec. I am using SAM9G20-EK

U-Boot>set bootcmd 'tftp 0x22200000 uImage; bootm 0x22200000'
U-Boot>set bootargs 'root=/dev/nfs nfsroot= ip= console=ttyS0,115200'

Use printenv command and verify all the commands are set as expected.


Use saveenv command to store the variables into non-volatile memory


Step 5: Booting your board
On the u-boot prompt type boot


And wait for the buildroot prompt…. 🙂


Leave a Reply

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

You are commenting using your 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