This chapter describes how a kernel is built from source on the
NetWinder. The process is almost the same as the usual Linux kernel, with
two notable exceptions. (For the impatient, the two differences are: the
default configuration file must be copied from
arch/arm/def-configs/netwinder
to .config
before you
begin, and to build the kernel you must use make Image
or
zImage
and not bzImage
).
The mainsteam linux kernel includes some support for the ARM architecture (which the NetWinder belongs to), but it is far from complete. Russell King is the primary developer of the ARM-linux port (see http://www.arm.linux.org.uk) which includes many other ARM-based systems. Russell distributes patches that can be applied to the mainstream linux kernel, and these can be used as-is on the NetWinder.
The NetWinder-specific port was done by Pat Beirne, San Mehat, Woody Suwalski, and is being maintained now by Phil Blundel, Woody and myself. Our changes are filtered back to Russell and from there back up to the mainstream kernel. While it is not presently the case, the NetWinder specific code will eventally be merged in completely with Russell's code which in turn be merged in to the mainstream linux kernel.
For now, the best place to get NetWinder-specific kernels is from netwinder.org (either via FTP or CVS). Russell's kernel (patches applied against mainline) also work but are not tested as widely, and may lack some drivers. Work is in progress to merge the sources together so that in the future there will be only one arm-linux source.
The source code for the NetWinder kernel can be obtained by anonymous FTP
from
ftp://ftp.netwinder.org/pub/netwinder/kernel/. The
filenames are in the form linux-YYMMDD.tar.gz
(consult the
README
file in the same directory for more information).
Alternatively, you may also download a binary RPM containing the source code
(kernel-source-YYYYMMDD.armv4l.rpm
). If you chose that route,
you'll also need the corresponding kernel-headers
package from the
binaries directory. (There is also a kernel-YYMMDD.src
package;
this is only of use if you need to rebuild the kernel in RPM format and
redistribute the results. Ignore it).
The kernel source normally lives in /usr/src
but can really be
installed wherever you wish. You should ensure that the symbolic link
/usr/src/linux
points at the place where your kernel source is
located. The appropriate commands to unpack the source from tar.gz
form and to make the symlink are shown below.
tar zxvf linux-YYMMDD.tar.gz ln -sf /path/to/linux-YYMMDD /usr/src/linux cd linux-YYMMDD
If you install the kernel-source
and kernel-headers
RPM
packages, the source will be placed in /usr/src/linux-YYYMMMDD
and
the symbolic link will be set appropriately.
As there are many ARM platforms, of which NetWinder is but one, the usual
default configuration (arch/arm/defconfig
) is not optimal for the
NetWinder. In fact it might not even work. Instead, the default
configuration can be found at arch/arm/def-configs/netwinder
. If
you're building a kernel tree for the first time, you should always copy the
proper config file to the toplevel first:
cd <your-kernel-tree> cp arch/arm/def-configs/netwinder .config
Alternatively, you can use the `Load alternate configuration file' provided
by make menuconfig
or make xconfig
, instead of copying the
default configuration file as shown above.
The kernel must then be configured in one of the usual ways. The
recommended way is via make menuconfig
, but you can also use
make xconfig
, make config
or make oldconfig
(the
latter is useful if you don't want to change any settings). Note that the
xconfig
option was broken prior to the 19990121 release.
For the first build, you must run one of the config tools
(menuconfig
, xconfig
, etc) and answer "Yes" when it asks
if you wish to save your configuration changes - even if you didn't change
anything. Otherwise certain files will not be remade and the compile will
fail later on.
The default configuration includes a minimum number of devices `built in', and virtually everything that could be needed built as a module. For most cases, this should be sufficent. Of course, you can signficantly reduce the compile time by turning off options you won't need (for example, the whole SCSI subsystem, which is normally built as a module).
The bare-bones config for a NetWinder would normally include support for the
'553 disk controller (unless you have no disk), have an ext2
filesystem, and ethernet support for the ne2k
(for eth0) or
tulip
(for eth1). There is a config called netwinder-tc
intended for use on diskless NetWinders, which is pretty well stripped
down.
The char driver for ds1620
(thermometer) should always be included,
since it operates the speed control for the NetWinder's fan. Otherwise, the
fan might never turn on, and the NetWinder might overheat!
Kernel compilation takes about 10-15 minutes on a stock NetWinder.
For the 2.0.x kernels, the following commands should be executed.
make dep make clean make make modules
Subsequent builds from the same source directory can (and should) omit the
make dep
and make clean
stages.
The end result of this should be a kernel called vmlinux
and a
series of loadable modules in the modules
directory, all within the
build tree.
For the 2.2.x and beyond kernels, the following commands should be executed.
make dep make clean make Image make modules
Subsequent builds from the same source directory can (and should) omit the
make dep
and make clean
stages.
The end result of this should be a kernel called
arch/arm/boot/Image
and a series of loadable modules in the
modules
directory, all within the build tree.
Compressed kernels also work (I forget exactly when, sometime around Dec
1999). Substitute make zImage
instead of make Image
if
you wish it. The kernels are smaller, but take longer to decompress, so it
is really only worth it if you are booting via tftp or similar. The output
appears as arch/arm/boot/zImage
.
Note that bzImage
is not supported nor will it ever be! Contrary
to the popular belief, bzImage
does not mean a kernel compressed
with bzip
. It means `big zImage', which has repercussions on how
LILO loads the kernel on an x86 (with it's archaic 640k memory limit). The
Netwinder doesn't have such a limitation, so we don't need
bzImage
.
To install the kernel, you must be logged in as root
. It is a good
idea to back up your existing kernel and modules so that you can revert to
them later on, in case your new kernel doesn't work. To make the backups,
use the following commands, substituting for 2.X.Y
with the actual
version of your kernel.
cp /boot/vmlinux /boot/vmlinux.old mv /lib/modules/2.X.Y /lib/modules/2.X.Y-old
Now the new kernel and modules can be installed. Note that the file
/boot/vmlinux
is usually a symbolic link. We recommend you give
each kernel a unique name, and use the symbolic link to select which kernel
to boot. Supposing you select the extension `test' to identify your kernel,
the following commands could be used.
cp arch/arm/boot/Image /boot/vmlinux-test ln -sf vmlinux-test /boot/vmlinux cp System.map /boot/System.map-test ln -sf System.map /boot/System.map-test make modules_install
The example above renames the kernel file from Image
to
vmlinux-test
. This is not strictly necessary, all that counts is
that the symlink points to the real kernel. You could theoretically point
it into your build tree, but that would not be wise since a make
clean
would wipe it out (and then you'd be in trouble when you tried to
reboot...).
To test out the new kernel, you must reboot your machine. If you followed
the instructions as described previously, your new kernel will (most likely)
be booted automatically. This is because the default settings in the
firmware are to load the kernel from a file called
/boot/vmlinux
, and you created a symbolic link to the actual kernel
above.
If you used a different name for your kernel, or if your firmware settings have been changed from their default values, then you'll have to check and possibly modify the firmware settings. See the Firmware-HOWTO for more details about the firmware. In brief, you press a key when prompted while your machine boots. Then you issue the following commands at the firmware command prompt.
setenv kernfile /boot/YOUR-KERNEL-FILE save-all boot
Only specify the save-all
command if you wish to make the setting
permanent. Otherwise kernfile
will default back to whatever it was
before the setenv
command. See the Firmware-HOWTO for more
details.
If your new kernel won't boot, then you probably forgot some important
hardware support when you built it. To get back to a working system, you
simply have to set the kernfile
parameter in the firmware menu back
to the old kernel /boot/vmlinux.old
. What if you didn't make a
backup? Well luckily the kind creators of the NetWinder have anticipated
this need and provide a /boot/vmlinux.rescue
kernel for this
purpose. At least on the recent disk images.
If you can't determine why your new kernel won't boot, try using the default
configuration (stored in arch/arm/def-configs/netwinder
) when
building the kernel. If that doesn't work, you're either doing something
wrong, or using the wrong tools (compiler, binutils). All of the official
NetWinder kernels to 20000121 were natively built using gcc-2.8.1 on an
unmodified DM-13. (Future kernels will be built on dm-3.1-15 using
gcc-2.95.1).