How to Use the Top-Level Makefile (Axis 82)


Description

This document describes how to use the top-level Makefile to build the devboard_82 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 82 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_82 software is built using GNU make. The top-level Makefile 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_82 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 Makefile file contains the paths to all applications, libraries, packages and files that the devboard_82 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_82

Building tools

The first thing that needs to be built are the applications in the tools/build directory. These are used through out the reset of the installation. Simply type:

make tools
 

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_82/os/linux
make xconfig                     (or "make menuconfig")

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

cd ~/axis/devboard_82
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_82
make kernel
make images

Adding an application

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

cd ~/axis/devboard_82
make cris-axis-linux-gnu
make install
make images

Modifying an application

If you have modified the source of an application (for example devboard_82/apps/my_app) you just need to install that application separately before building new images:
cd ~/axis/devboard_82
. ./init_env			(or "source ./init_env")
cd ~/axis/devboard_82/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_82
make images

Removing an application

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

Adding a file

To add a single file you must both add it in the proper directory in the devboard_82/files directory and add it to the Makefile 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_82/files/usr/html and add the following line under the "LOCALS" section of the Makefile file:
"files/usr/html/my_file.html 0644"

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

cd ~/axis/devboard_82
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_82/files directory, then run:
cd ~/axis/devboard_82
make files
make images

Removing a file

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

The install target removes the entire target/cris-axis-linux-gnu directory before installing everything listed in the Makefile 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_82
(set the board in boot mode)
./ktest

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

cd ~/axis/devboard_82
(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_82
(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_82/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: 2003/04/02 12:03:20 $
$Revision: 1.1 $

Axis Communications, Technology Division