How to Use the Top-Level Makefile


Description

This document describes how to use the top-level Makefile to build the devboard_lx software.

Requirements

Before you read this document you need to have the following installed:

The above is described in the document How to Install the Developer Board LX Software. Examples in this document assumes that you have installed the source code tree in a directory called axis in your home directory. If this is not the case, just keep it in mind and use your own installation directory instead of ~/axis in the examples.

Theory

The devboard_lx software is built using GNU make. The top-level Makefile, makespec and ptablespec files are used to provide information about how the product should be built. The Makefile contains several targets that can be built by typing:

make target
at the shell prompt in the devboard_lx directory. By using several targets (instead of just one do-it-all target) you can make a faster rebuild after changing the source code. The most frequently used targets are kernel (builds the Linux kernel), install (builds and installs libraries, applications and packages) and images (builds the images for network booting the developer board). The most frequently performed task during development are:

You will use different targets depending on what you want to do.

The makespec file contains the paths to all applications, libraries, packages and files that the devboard_lx product consists of.

The ptablespec file contains information about locations and sizes of the flash partitions.

Process

Change working directory to the product directory in your source code tree:

cd ~/axis/devboard_lx

Reconfiguring the Linux kernel

The Linux kernel is configured using the menuconfig or xconfig targets of the Makefile in the Linux source code directory:

cd ~/axis/devboard_lx/os/linux
make xconfig                     (or "make menuconfig")

Then use the top-level Makefile to build the kernel and images:

cd ~/axis/devboard_lx
make kernel
make images

Modifying the Linux kernel

When you have modified source code in the Linux kernel that does not require reconfiguring the kernel you just have to rebuild it like this:

cd ~/axis/devboard_lx
make kernel
make images

Adding an application

To add an application put the source code directory in the devboard_lx/apps directory and add it to the subdirs section in the makespec file (see How to Write and Build Applications for Linux for details). Then build it like this:

cd ~/axis/devboard_lx
make clinux
make install
make images

Modifying an application

If you have modified the source of an application (for example devboard_lx/apps/my_app) you just need to install that application separately before building new images:
cd ~/axis/devboard_lx
. ./init_env			(or "source ./init_env")
cd ~/axis/devboard_lx/my_app
make install

Note that you must source the init_env files to do this. Then use the top-level Makefile to build the kernel and images:

cd ~/axis/devboard_lx
make images

Removing an application

To remove an application just remove it (or comment it out) from the makespec file and run:
cd ~/axis/devboard_lx
make install
make images

Adding a file

To add a single file you must both add it in the proper directory in the devboard_lx/files directory and add it to the makespec file (not in the subdirs section). If you, for example, want to add the file my_file.html to the directory /usr/html on the developer board, put it in the directory ~/axis/devboard_lx/files/usr/html and add the following line at the end of the makespec file:
files/usr/html/my_file.html -m 0644

The option -m 0644 means file access permission 0644 (i.e. rw-r--r--). Then run:

cd ~/axis/devboard_lx
make files
make images
You can run make install instead of make files but you don't have to (make install also does a make files among other things).

Modifying a file

If you have modified a file under the devboard_lx/files directory, then run:
cd ~/axis/devboard_lx
make files
make images

Removing a file

If you have removed a file under the devboard_lx/files directory and/or in the makespec file, you cannot use the files target because it just adds files. Use the install target instead:
cd ~/axis/devboard_lx
make install
make images

The install target removes the entire eroot directory before installing everything listed in makespec again.

What's next?

All of the tasks above result in two images: kimage and fimage. The kimage contains the linux kernel and the read-only root partition (cramfs). The fimage contains a complete flash image (rescue partition, partition table, decompressor, compressed kernel, read-only root partition and JFFS partition). They can be transfered to the board using one of four scripts:

Before you run any of these scripts you should first put your devboard in boot mode by pressing the boot button, pressing and releasing the reset button and then releasing the boot button (i.e. the boot button must be kept down while resetting the developer board). The ktest and flashit scripts are the most useful. The rescue partition contains the serial number which is used as the ethernet address, so you probably do not want to overwrite that, i.e. don't use the flashitall script unless you really want to overwrite the rescue partition. To test a new kernel type:

cd ~/axis/devboard_lx
(set the board in boot mode)
./ktest

To flash a new fimage (except the rescue partition) type:

cd ~/axis/devboard_lx
(set the board in boot mode)
./flashit

If your ethernet interface (on your PC) is not eth0 the use the -d option to the scripts. For example run flashit on eth1 like this:

cd ~/axis/devboard_lx
(set the board in boot mode)
./flashit -d eth1

Notes

Sourcing init_env

Since having to source init_env everytime you start a new shell can be very annoying, it is recommended that you put the following in the rc-file of your shell (i.e. ~/.bashrc if you are using bash):

# Set INITENV to the file name of your init_env file.
INITENV=~/axis/devboard_lx/init_env

if test -f $INITENV ; then
	. $INITENV
fi
That way the environment variables will be set in all shells you start. Note that you may not want to do this if you are working on multiple products, since you then may mistakenly use the wrong environment variables.

Other make targets

There are other, less frequently used targets in the Makefile. Run make help to get a detailed list.

Common Mistakes




$Date: 2001/05/17 09:05:23 $
$Revision: 1.3 $
Please send feedback on how to improve this document to technology@axis.com.
Axis Communications, Technology Division