Note: The examples below are taken from several architectures. Before using the instructions please tailor them to the required architecture (ST40, ST200 or ARM).
The ST Linux distribution contains pre-built kernels for the supported ST boards. If you wish to modify the kernel, reconfigure it, or port it to a new platform, it is necessary to rebuild the kernel.
The rpm program installs the kernel source tree in the /opt/STM/STLinux-X.X/devkit/sources/kernel/ directory. It is advisable to copy the kernel source tree to a work directory before building the kernel. This may be done using drag and drop in a GUI file manager, or using the Linux shell command line.
For example, assuming the work directory /home/STLinux has been created, using the GUI file manager, drag the ST Linux release folder (for example, the linux-sh4 symbolic link points to the latest kernel source tree) from /opt/STM/STLinux-X.X/devkit/sources/kernel/ to /home/STLinux/, or using the command line enter:
host% cd /home/STLinux host% cp -r /opt/STM/STLinux-X.X/devkit/sources/kernel/linux-sh4/ .
To carry out the build, cd to your copy of the kernel source tree:
host% cd /home/STLinux/linux-sh4 The Linux kernel comes with a complex and comprehensive build system based on Linux make. Within this build system the compiler and architecture options are left as the defaults (those appropriate to the host). To compile for the target, these options must be overridden at the command line. For example, to compile the Linux kernel binary (vmlinux) for an ST40 target:
host% make ARCH=sh CROSS_COMPILE=sh4-linux- vmlinux A number of additional options are supported by the 2.6 kernel build system. For a list of those relevant to a particular architecture run:
host% make ARCH=<architecture> helpreplacing <architecture> with the appropriate code (sh4, st200 or other). In particular make V=1 (turn on verbose mode) is useful to debug build problems, and make O=dir can be used to place object files in a different directory from the source. This is useful for building multiple kernels with different options from the same source tree.
Typical configurations for all supported boards are provided as part of the kernel source tree. One of these can be selected to initialize the kernel configuration by running make with one of the <boardname>_defconfig targets displayed by make help.
For example, to generate a kernel for an MB442 reference board, first run make help to find the name of the target:
host% make ARCH=sh CROSS_COMPILE=sh4-linux- help | grep ^mb
mb374_defconfig - Build for mb374
mb411_defconfig - Build for mb411
mb442_defconfig - Build for mb442
mb442se_defconfig - Build for mb442se
mb448_defconfig - Build for mb448
mb519_mb520_defconfig - Build for mb519_mb520
mb519se_mb520_defconfig - Build for mb519se_mb520
mb602_defconfig - Build for mb602
mb618_defconfig - Build for mb618
mb618se_defconfig - Build for mb618se
mb628_defconfig - Build for mb628
mb671se_defconfig - Build for mb671se
mb680_defconfig - Build for mb680This shows the required target is mb442_defconfig. Invoke make again, to set up the kernel configuration for this board:
host% make ARCH=sh CROSS_COMPILE=sh4-linux- mb442_defconfigTo view the default configuration, or to change any of the defaults, run make with one of the standard configuration targets, for example:
host% make ARCH=sh CROSS_COMPILE=sh4-linux- menuconfigFinally, to build the kernel enter:
host% make ARCH=sh CROSS_COMPILE=sh4-linux- vmlinux