Professional Documents
Culture Documents
3.2 Cross development tool chain The cross development tool chains based on
gcc-2.95.3 and gcc-3.0 are available as free downloads [3]. The tool chain needs to
be untared (tar xvjf/tar xvzf) in /usr/local/arm directory and the same has to be
appended to the PATH environment variable.
The files specific to ARM are in:
linux/arch/arm: the code.
linux/include/asm-arm: the header files Linux/arch/arm further contains the
following directories, among others:
kernel: core kernel code.
mm: memory management code.
lib: ARM specific internal library functions.
nwfpe and fastfpe: floating point implementations
boot: has the final compiled kernel.
tools: scripts for auto generating files.
def-configs: default configuration files
3.3 Machine registration The kernel tree identifies each device by a unique
machine ID. We need to get this ID from [4] and if the device is new, it has to be
first registered there in order to get its unique ID. This registration gives a unique
numerical identifier for the device, a configuration variable viz.
CONFIG_MACH_$MACHINE and provides for runtime machine checking. This file,
containing the ID has to be placed at linux/arch/arm /tools/mach-types. The script
linux/arch/arm/tools/gen-mach-types uses this file to generate linux/include /asm-
arch/mach-types.h, which in turn sets the various macros, to be used by the
source.
3.4 Configuration &Compilation For configuring and cross compiling the kernel,
the sequence given in Fig.2 has to be followed.
ARCH and CROSS_COMPILE variables in the top level Makefile have to be
edited with:
ARCH = arm
CROSS_COMPILE = <path_to_cross_compile_toolchain>
A new default config file (named <machinename>) has to be added in
linux/arch/arm/def-configs. Any old .config file should be deleted.
On executing
# make <machinename>_config (for2.6.xx kernel)
And
# make <machinename>_config
# make oldconfig (for 2.4.xx kernel)
The file <machinename> is copied from linux/arch/arm/ def-configs/ to
linux/.config.
To compile, execute:
# make clean
# make dep (optional for 2.6.xx kernel)
# make zImage (generates a compressed image)
#make modules
The compressed kernel image is compiled as arch/arm/boot/zImage [5].
4. The Boot Loader The ARM Linux needs a small amount of machine dependent
code to initialize the system. This code i.e. the bootloader, runs before the main
kernel, and without it the system cannot boot. Its equivalent to the BIOS for an X86
system. The minimum functionality required from the bootloader are: Initialize
the memory system. Initialize at least one serial console Obtain the ARM Linux
machine type. Place the kernel image at the correct memory address. Load the
Initrd (Initial RAM disk) Set up the boot parameters Jump to the kernel with
specific register values. Following changes have to be made to the configuration
files of the boot loader: a) In order to pass the physical memory layout to the
kernel, bootloader uses the ATAG parameters [6].
Fig.3, [6] depicts the ATAG structure as organized in the system memory.
base address
ATAG_CORE increasing
ATAG_MEMORY address
ATAG_NONE
e) The boot loader places the Initrd image, into the memory at a set location. It uses
the following parameters for this:
ATAG INITRD2:specifies the location of the compressed ramdisk image.
struct atag_initrd2
{
U32 start; /* physical start address */
U32 size; /* size of compressed ramdisk image in bytes */
};
ATAG RAMDISK:ensures that the ramdiskis large enoughfor the decompressed
Initrd image.
struct atag_ramdisk
{ U32 flags; /* bit 0 = load, bit 1 = prompt */
U32 size; /* decompressed ramdisk size in _kilo_ bytes */
U32 start; /* starting block of floppy-based RAM disk image */
}
f) The tagged list passed by the bootloader to the kernel has to conform to the
following constraints: The list has to be placed in RAM, where it cant be
overwritten. The recommended place is, start of RAM + 0x100. It must not extend
past 0x4000 boundary, as after that kernels TLB is created. It has to be word (32
bit) aligned. g) The boot loader calls the kernel image by jumping directly to the
first instruction of the kernel image. For both flash or RAM based, kernel
compressed image, following settings apply:
Processor registers
o r0 = 0
o r1 = machine ID
o r2 = address of the tagged list
Processor mode
o Disabled IRQs and FIQs.
o Processor has to be in supervisor mode (SVC).
In the present context, the GPL universal bootloader, U-Boot is reffered[8].
5. Kernel Customisation The following kernel files have to be edited for the ARM
platform
5.1 Entry Level Files
arch/arm/Makefile
It should have the proper macros to detect the machine name, e.g.
CONFIG_ARCH_xxx; here xxx refers to the specific machine names.
arch/arm/boot/Makefile
This should list the start address from where the kernel image has to be
decompressed, the targeted environment variable is, ZTEXTADDR. Its the same
physical address to where ARM Linux is placed in the bootloader code. Usually its
32KB inside the RAM.
include/asm/arch/uncompress.h
This is used to output the kernel decompression messages to the UART. It provides
following two functions to accomplish this:
1. arch_decomp_setup() : to setup the UART.
2. putstr() : to output a string to UART, it appends every \n with \r
arch/arm/kernel/debug-armv.s
or
arch/arm/kernel/debug.s
This file refers to assembly level debugging, for ARM 32 bit mode. The following
(assembly) functions implemented here communicate to a serial port, independent
of the kernel.
addruart rx: to obtain the address of the serial port in rx
senduart rd,rx: write the character at rd to rx (the serial port)
busyuart rd, rx : the wait function (transmit buffer empty)
waituartrd,rx: wait for handshake signal (clear to send)