Running Linux on ARM Platforms July 2006
Abstract This document describes stages to set-up and run Linux on ARM based platforms, from installing a boot loader, kernel and file system image. This is not intended as an exhaustive guide on developing or building Linux system. There is already considerable information available in the open source community for this. Open source discussion forums also provide a good source of information. Please refer to the ARM Linux Wiki site (www.linuxarm.org) or www.arm.com/linux for additional information.
-1-
Copyright © 2005, ARM Ltd.
INDEX 1. INSTALLING PRE-BUILT IMAGES........................................................................................................................ 3 2. BOOT LOADER........................................................................................................................................................... 3 3. LINUX KERNEL........................................................................................................................................................... 5 4. FILESYSTEM................................................................................................................................................................ 5 5. COMPILATION TOOLS............................................................................................................................................. 5 5.1. CROSS-COMPILATION..................................................................................................................................................... 5 5.2. ABI COMPATIBILITY.................................................................................................................................................... 6 6. ADDITIONAL NOTES................................................................................................................................................. 6
-2-
Copyright © 2005, ARM Ltd.
1. Installing pre-built images Images can be installed into flash using a debugger connected to the board via a JTAG run control device, such ARM RealView ICE units. • ARM RealView Integrator boards: use ARM Flash Utility (provided with the board) to program images (e.g. AFU.axf), running the utility from the debugger: AFU> program 1 u-boot c:/tmp/u-boot.bin Lowest available flash at location 0x24440000 block B30 Programming Block B30 ...
• ARM RealView Versatile/(PB, AB)926EJ-S: run the BootMonitor.axf program supplied with the board from the debugger to program images. There is a Flash menu with some options to program ELF or binary images. To run from flash you should program the ELF image into flash as: FLASH> write image c:/tmp/u-boot.axf NAME u-boot An additional flash programming utility is provided with RealView Versatile boards called ‘Network Flash Utility’ (NFU). This program enables programming of images into flash through an Ethernet connection. Please, refer to documentation on the RealView Versatile Family CD for more information. A similar process can be used to program other images (kernel and cramfs) into Flash. These should be programmed as binary files as they are not ELF images. For more information, please refer to the Firmware documentation supplied with the board.
2. Boot Loader U-Boot is used as boot loader for RealView Integrator and Versatile platforms. The source code and documentation are available at the following location: http://sourceforge.net/projects/u-boot/ U-Boot is expected to run from 0x01000000 in memory on ARM boards. The supplied images can be loaded and run from a debugger at this address. • RealView Integrator: raw binaries (or ELF files) can be placed at the beginning of flash and executed as default image. • RealView Versatile: you should use the ELF file to execute directly from flash or load and run the raw binary from memory. To compile U-Boot, download source distribution from the above site. RealView Integrator and Versatile support has been added in U-Boot CVS/GIT repository. Additional patches may have been submitted at the time of writing this document, if any, these should have been posted on the public mailing list. Once you have unpacked/retrieved the sources, you need to configure and build the boot loader. You can consult the full list of targets from the top Makefile. To configure and compile the boot loader, you should execute the following commands: • RealView Integrator/CP: make integratorcp_config make
-3-
Copyright © 2005, ARM Ltd.
• RealView Versatile: make versatileab_config make Resulting executables files (binary and ELF) are located in the top level directory. Some macros are used to encode default command line passed to a Linux kernel, default boot sequence of the boot loader (i.e. dhcp/bootp, flash etc.). Some of these definitions can be changed interactively from the U-Boot command line using the set command. Parameters used for ARM RealView Versatile board can be found in the respective configuration file in the include/configs directory with macro definitions such as CONFIG_COMMANDS, CONFIG_BOOTARGS and CONFIG_BOOTCOMMAND. The Linux kernel is usually loaded at the address specified by CFG_LOAD_ADDR (0x7c0) and then executed from 0x8000 for an uncompressed Linux kernel image. These parameters are specified by the u-boot mkimage utility when converting a raw Linux kernel binary image to be loaded by u-boot. The mkimage utility is built when compiling u-boot. Note that when downloading a kernel image via Ethernet, you should configure your server to recognise the MAC address of your platform and the location of the image to download. Booting from images in flash When adding the u-boot header to the Linux kernel binary image, ensure that the load and execute addresses are both set to 0x8000. The boot command should be: –
Integrator/CP # bootm 0x
You can also use the ‘help’ command with U-Boot to see the exact syntax of each command. The command line The Linux kernel CMDLINE can be set from the U-Boot prompt using the ‘set’ command. The ‘printenv’ command can be used to list the current environment variables. When executing the Linux kernel from a boot loader, the kernel will use the command line which is pointed at by , instead of any default built-in command line. The images provided allow you to save the environment into Flash memory. This can be done using the saveenv command. The U-Boot images available for download at http://www.arm.com/linux contain the command line used with the supplied U-Boot, kernel and filesystem images saved into flash, in that order, starting at the bottom of flash.
3.Linux kernel Sources for the kernel can be obtained and downloaded from www.kernel.org. Any additional patch should be applied to the base kernel source tree as follows: $ cd linux-2.6.17/ $ patch –p 1 < patch-2.6.17-
Configuration files are provided for each platform and pre-built images. The relevant configuration file should be copied into the kernel tree as .config, the kernel can then be configured running ‘make xconfig’ or equivalent command. The following sequence of commands can be used to build the kernel: $ make xconfig $ make Image
produces a raw binary Image in arch/arm/boot/
-4-
Copyright © 2005, ARM Ltd.
A vmlinux file is also generated which contains debugging information associated to the kernel image which can be loaded by a debugger (assuming the kernel is compiled with '-g' flag). The boot loader also determines the platform identification. This information is stored in register . The platform number is needed by the kernel before starting its execution. When starting the kernel directly from a debugger, this register value needs to be set from within the debugger.
4.Filesystem Pre-built filesystem images provided on this page can be use with ARM RealView Integrator and Versatile platforms. The platform type is detected at run-time with a script to create a symbolic link to the appropriate serial device (/dev/tty…). These images contain a subset of system utilities, commands and applications. To configure a compressed filesystem image, the ARM_Embedded_Linux_2.2.0.tar.gz file needs to be unpacked. The build instructions written in the top-level README file list the various steps needed to generate a compressed filesystem image. A copy of the source of packages used to produce applications used in this file system (e.g. cramfs) are available in source format from ARM upon request. The filesystem can either be mounted via NFS or placed into Flash, depending on the platform settings and the command line passed to the kernel at boot time. In any case, the location of the filesystem should be specified in the kernel command line by the “root =…” option, either root=/dev/mtdblocki or root=/dev/nfs, where i is to be replaced by the appropriate partition number. On RealView Versatile platform, the mtdpart option needs to be defined to indicate where images are located in flash. This is documented in the kernel driver/mtd/ sources and an example is in the configuration file associated with the RealView Versatile binary image.
5.Compilation Tools 5.1.Cross-compilation An ARM cross-compilation tool chain need to be installed on the host system to produce Linux kernels or applications. By default, this document assumes a Linux based host development platform. Note that the pre-compiled tool chain which is available for download assumes that you have a version of Glibc library ≥ 2.3 installed on your system. Perform the following steps as root to unpack and install the pre-built tool chain on your system: $ mkdir /usr/local/arm/gnu/release4.1-6 $ cd /usr/local/arm/gnu/release4.1-6 $ tar xvfz sourceryg++-4.1-6-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.gz $ ln –s /usr/local/arm/gnu/release-4.1-6 /usr/local/arm/gnu/release
Sources used to build the GCC tools can be downloaded from www.codesourcery.com or from the main GCC CVS repository. Discussion groups are also available on this site to discuss technical issues related to ARM GNU tools. Multiple targets can be built for the compiler: -
arm-elf produces a flat or standalone binaries which are not tied to any operating system. arm-elf selects ELF support which shares much of its code with arm-linux.
-5-
Copyright © 2005, ARM Ltd.
-
arm-none-linux-gnueabi is the target you need for Linux and generates ELF support for Linux/ARM.
The pre-built tool chain is produced using the arm-linux option and is produced against 2.3.6 version of Glibc.
5.2. ABI compatibility The version of GCC used with this release (i.e. GCC 4.1) defaults to the new ABI for the ARM Architecture. Linux kernel version 2.6.17 can be configured to support both, the new ABI for the ARM Architecture and old ABI. Since packages provided with filesystem version 2.2.0 were built for the new ABI, you should ensure that Linux kernel is configured to support this version of the ABI (Kernel Features:: CONFIG_AEABI). Older version of the ABI for the ARM Architecture can be used with Kernel Features:: CONFIG_OABI_COMPAT, however, this should be used in conjunction with a file system with binaries built for the old ABI (i.e. AEL 2.1.0). This is particularly important when using data structures such as those passed through ioctl() calls where types and alignment must be exactly the same from the kernel view as from the user view.
6.Additional notes Notes and Linux packages provided on this page are intended as starting point for evaluation and validation with ARM development platforms. Please contact Linux distributors for complete Linux distributions. Some additional discussion forums are also available on public websites, Linux kernel mailing lists and GNU mailing lists. Other communities such as www.debian.org, www.openembedded.org, www.handhelds.org and http://www.celinuxforum.org/ also provide good resources which can be used with ARM platforms.
-6-
Copyright © 2005, ARM Ltd.