Taskit Portux 920t EU SW, Portux-MiniPC, Portux Panel-PC, Panel-Card, MoLUX Linux Guide

...
Linux Guide taskit GmbH
Linux Guide
for
Portux 920t EU + SW
Portux-MiniPC
Portux Panel-PC
Panel-Card
Stamp
Page 1 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH
taskit GmbH
Seelenbinderstr. 33
D-12555 Berlin
Germany
Tel. +49 (30) 611295-0
Fax +49 (30) 611295-10
http://www.taskit.de
© taskit GmbH, Berlin All rights reserved. This document and the products referred to herein are copyrighted works of taskit GmbH. Information in this document is subject to change without notice. No part of this document may be reproduced or transmitted in any form, without the express written permission of taskit GmbH. If however, your only means of access is electronic, permission to print one copy is hereby granted. Neither taskit GmbH nor taskit´s distributors assume any liability arising from the use of this manual/guide or any product described herein.
Page 2 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH
Table of contents
1. Introduction................................................................................................6
2. Supported products...................................................................................7
3. Mounting MMC or SD-cards......................................................................8
4. Using the bootloader „U-Boot“.................................................................9
4.1. Setting up a TFTP server under Linux...................................................................9
4.2. Description of the bootprocess..............................................................................9
4.3. Reading and writing memory and flash memory................................................10
4.4. Scripts with U-Boot................................................................................................10
4.5. Creating a bootscript..............................................................................................12
4.6. Updating U-Boot.....................................................................................................14
5. Compiling and debugging applications.................................................15
5.1. Setting up a development system........................................................................15
5.1.1. Installing the toolchain on Debian................................................................15
5.2. Mounting the working directory............................................................................16
5.3. Compiling the application sample........................................................................16
5.4. Starting the sample................................................................................................16
5.5. Debugging the sample...........................................................................................17
5.6. Downsizing the binary............................................................................................17
6. Compiling a new linux kernel..................................................................18
6.1. Configuring the kernel...........................................................................................18
6.2. Compiling the kernel..............................................................................................19
6.3. Preparing the kernel...............................................................................................20
6.4. Installing the kernel................................................................................................20
6.5. Resetting to the original state...............................................................................21
7. Creating a new root filesystem...............................................................22
7.1. Overview..................................................................................................................22
7.2. Installing the busybox............................................................................................22
7.3. Installing the MTD-utilities.....................................................................................23
7.4. Creating the initial ramdisk image........................................................................24
Page 3 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH
7.5. Testing the new root filesystem............................................................................25
7.6. Installing the new root filesystem permanently..................................................25
8. Creating a new user data partition.........................................................26
8.1. Overview..................................................................................................................26
8.2. Creating a new JFFS2 image.................................................................................26
8.3. Archiving the JFFS2 partition...............................................................................26
8.4. Restoring the JFFS2 partition...............................................................................27
8.5. Resetting to the original state...............................................................................27
9. The input driver........................................................................................28
9.1. Overview..................................................................................................................28
9.2. Un- / installing the drivers.....................................................................................28
9.3. Customizing the keymap of the matrix keyboard...............................................29
9.4. Customizing the keymap of the infrared interface (optional)............................32
9.5. Getting the input.....................................................................................................33
9.6. Using the touchscreen...........................................................................................33
9.6.1. Calibrating the touchscreen..........................................................................34
9.7. Using the knob........................................................................................................35
10. The display.............................................................................................36
10.1. Un- / Installing the driver.....................................................................................36
10.2. Text based applications.......................................................................................36
10.3. Graphical applications.........................................................................................36
11. Appendix.................................................................................................38
11.1. Memory map..........................................................................................................38
11.1.1. Portux 920t EU + SW, Portux-MiniPC, Portux Panel-PC, Panel-Card,
MoLUX and Stamp....................................................................................................38
11.2. Driversupport........................................................................................................39
11.2.1. Portux Panel-PC............................................................................................39
11.2.2. Panel-Card.....................................................................................................39
11.2.3. MoLUX............................................................................................................39
11.3. U-Boot environment variables............................................................................40
11.3.1. Environment variables for Portux 920t EU + SW, Portux-MiniPC, Portux
Panel-PC and Stamp.................................................................................................40
11.3.2. Environment variables for Panel-Card and MoLUX..................................41
11.4. Product specific kernel settings.........................................................................43
Page 4 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH
11.4.1. Portux 920t EU + SW, Portux-MiniPC.........................................................43
11.4.2. Portux Panel-PC............................................................................................43
11.4.3. Panel-Card.....................................................................................................43
11.4.4. MoLUX............................................................................................................44
11.4.5. Stamp.............................................................................................................45
11.5. Input driver reference...........................................................................................46
11.5.1. struct portuxinputevent................................................................................46
11.5.2. struct matrixentry..........................................................................................46
11.5.3. struct irentry..................................................................................................46
11.5.4. struct calibration...........................................................................................47
11.5.5. struct eeprom_t.............................................................................................47
11.5.6. Defines / Constants......................................................................................48
11.5.7. Ioctl functions................................................................................................49
11.6. U-Boot commands................................................................................................52
11.6.1. Read and write memory and flash memory..............................................53
11.6.2. Load programs and files via the serial interface or Ethernet..................58
11.6.3. Start programs and boot Linux..................................................................61
11.6.4. Set environment variables..........................................................................62
11.6.5. Additional commands.................................................................................63
11.7. Important linux shell commands........................................................................65
Page 5 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH

1. Introduction

Your product is delivered with an customized Linux and the bootloader U-Boot.
This document will describe how to install and customize the operation system and it will also describe how to handle the drivers for the input and output devices.
Furthermore it will describe how to setup an development system and you will be given small examples that demonstrate how to compile your own applications and how to use the input devices and the display in your applications.
Because of the wide variety of existing operating systems taskit can only give support for the Debian GNU/Linux operating system. Taskit is utilising the Linux-based operating system Debian (www.debian.org) as development system because it is one of the most reliable operating systems. Furthermore it is easy to install additional software on Debian because you only need the tool apt-get to automatically download software packages that are installed and configured automatically. Debian can be downloaded free from the internet and the installation is also very easy because you only need to download a portion (http://www.uk.debian.org/distrib/netinst) and the remaining parts will be automatically downloaded and installed from the internet.
A cross-platform toolchain for cross compiling on Debian can be found on the starterkit­CD. Developing on MS Windows is not supported by taskit.
Instructions for the first start-up are located in the QuickStartGuide. If you want to develop your own drivers or hardware extensions you will have to work the appropriate Technical Reference and Atmel manual for your product over.
Page 6 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH

2. Supported products

The specifications in this document apply to the following products:
Portux 920T EU / SW
Portux-MiniPC
Portux Panel-PC
Panel-Card
MoLUX
Stamp
All specifications concerning memory addresses are exemplary. The accurate memory address specifications for your product can be found in the appendix (memory map).
It is possible to skip some chapters of the document, depending on the configuration of your product. For instance if your product isn't equipped with a display, you can skip the chapter “The Display”.
Page 7 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH

3. Mounting MMC or SD-cards

An MMC- or SD-card can be used to save larger amounts of data. Before you can mount a card you have to create a directory as mountpoint: mkdir /data .
To map a card mounted in the MMC slot to a FAT file system, use the following command:
mount -t vfat /dev/mmc/blk0/part1 /data
If an ext2 file system is on the MMC card, the command is:
mount -t ext2 /dev/mmc/blk0/part1 /data
Nowadays some vendors deliver their cards without any partition. These cards can then be mounted by accessing the entire disc:
mount -t ext2 /dev/mmc/disc/part1 /data
When using MMC/SD-card have in mind that the driver doesn't support hotplugging. As a result it is necessary that the SD/MMC-card you want to use, has to be inserted before the operating system boots up. SD/MMC-cards inserted after the boot process, won't be detected. If an MMC/SD-card was inserted before the boot process and mounted, it can be removed after unmounting: umount /data. After that it is not possible to insert the same, or any other card, again.
If it is essential for you to have a removable mass storage device, the best solution is to use an USB memory stick. It can be inserted after the boot process and mounted (mount / dev/sda1 /data). After unmounting (unmount /data) it can be removed and another USB­stick can be inserted.
Page 8 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH

4. Using the bootloader „U-Boot“

U-Boot is an open-source boot loader for embedded systems. U-Boot is well-documented, customizable, and loaded with functions. The U-Boot boot loader has been ported to more than 100 platforms. Wolfgang Denk (www.denx.de) maintains this project at www.sourceforge.de. The README in the U-Boot source code contains very detailed documentation of U-Boot.
Before you can start customizing the bootloader you will have to know the flash addresses of the installed software and flash partition sizes belonging to your product. These informations can be found in the appendix (Memory map).

4.1. Setting up a TFTP server under Linux

To transfer customized firmware a protocol for transferring data without the use of the operating system is needed. The TFTP (Trivial File Transfer Protocol) implemented in the bootloader U-Boot is used for simple transfer of a Linux kernel image or a root file system image. A corresponding TFTP server must be set up on the development system for this purpose. Use apt-get to install the required tftpd demon under Debian: apt-get install tftpd . Usually tftpd is not started directly, but rather via the inetd Internet demon. An entry for TFTP must be on hand in the inetd configuration file after installation. Under Debian, the line tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot is automatically entered in the configuration file /etc/inetd.conf during packet installation. The server is given the base directory with /tftpboot. If no argument is given at start-up, the server uses /tftpboot as the base directory. This directory must exist, and must be readable by all users. mkdir /tftpboot
chmod 777 /tftpboot

4.2. Description of the bootprocess

After resetting or turning on the power supply, an internal boot loader is started on the AT91RM9200. It searches the peripherals for a bootable program, in the following order:
1. Dataflash on NPCS0
2. EEPROM on TWI
3. 8-bit memory on NSC0
A bootable program can be identified by the eight exception vectors at the beginning of the program. If no valid sector sequence is found, the internal uploader is started. The uploader initializes the serial debug port and loads a program via DBGU for USART0 or using DFU (Device Firmware Upgrade) for USB into internal SRAM. It then starts the newly-loaded program. If a valid vector sequence is found, the code is likewise loaded into the internal SRAM. (Information about the code length is stored in the sixth vector.) Then the remap command is carried out, and jumps to the first address of the internal SRAM.
Page 9 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH
The parallel flash is connected to NSC0 and is used as the boot medium. In the first phase of the boot process the Atmel controller starts the bootloader U-Boot. The U-Boot start code loads the boot loader at address 21 F00 000 (SDRAM). U-Boot then initializes the memory. In the second phase of the boot process the bootloader boots the Linux image found in flash memory. The Linux image is decompressed to SDRAM. At last the root filesystem image is decompressed by Linux and stored in SDRAM.
You can interrupt the boot process by pressing any key during the first phase of the boot process (within 3 seconds). Then the U-Boot command line appears.

4.3. Reading and writing memory and flash memory

The AT91 data bus for memory is 32-bit and for flash 16-bit wide. Therefore, we recommend using all variable memory commands with the .l, .w or .b option (long word, word or byte). Otherwise, side effects cannot be ruled out.
Example:
cmp - memory compare
cmp [.l, .w, .b] Addr1 Addr2 count
You can check the contents of two memory ranges with the cmp command. Extensions can be used to determine the size of the memory access:
cmp.l -> 32-bit long word (default), .w ->16-bit word or .b -> 8-bit byte. The comparison runs until the number of units indicated by count have been compared, or until the first difference is found. The size of the memory compared is calculated by count * (l,w,b).
All commands that read memory can be used for both flash and SDRAM. Commands that modify memory (with the exception of cp, which recognizes flash regions on its own) can be used only for SDRAM and are inappropriate for directly writing flash memory. Please note, when performing memory write operations, that the area containing the U­Boot code is not modified; this will generally crash the system. Before executing write operations on the flash memory you must ensure that the corresponding memory range has already been erased, using the erase command (described below). Note also that the memory area used for U-Boot and the environment variables is protected against accidental write operations. You can turn this write protection off and on using the protect command.
A complete list of all U-Boot commands can be found at the end of this document (chapter U-Boot commands).

4.4. Scripts with U-Boot

Some environment variables are used by U-Boot if they are set, such as IP parameters.
Page 10 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH
On the other hand, some are set by U-Boot, such as filesize and fileaddr when downloading a file.
Printenv outputs the current contents of the environment variables. To show specific variables, you can add their names as arguments.
printenv [name[ name[ ...]]]
During runtime, changes to variables or new variables are stored in RAM and not saved permanently in flash memory. Saving is done explicitly with the saveenv command.
saveenv
Sets the environment variable name to the value value. If the variable already exists, its current value is overwritten; if it does not yet exist, it is created. If no value is given, the variable is erased (if it exists).
setenv name value
setenv name
The run command runs the environment variable name as if it were a command. This makes it possible to store commands in environment variables and create simple boot scripts.
run name
Using the run command, which makes it possible to run saved variables as a command sequence, you can create simple scripts to automate regularly occurring processes. In U­Boot, the characters $() are used to reference variables, ; is for creating command sequences and \ is the escape character. U-Boot generally interprets numerical arguments as hex values. In other words, 10000000 is 0x1000 0000 Hex.
For example: U-Boot> echo $(filesize)
U-Boot> 171a4 Entering this command outputs the contents of the filesize environment variable. The same command without parentheses would be interpreted as a simple string:
U-Boot> echo $filesize U-Boot> $filesize
If the $ character from the first example is marked with the escape character, the argument is also interpreted as a string:
U-Boot> echo \$(filesize) U-Boot> $(filesize)
Similarly, you can use a semicolon to indicate a sequence of commands:
U-Boot> echo $(filesize); echo Hello U-Boot> 171a4 U-Boot> Hello
Escape the semicolon with the backslash escape character, and the argument will be interpreted as a string:
Page 11 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH
U-Boot> echo $(filesize)\; echo Hello U-Boot> 171a4; echo Hello
A list of all U-Boot environment variables can be found at the end of this document (chapter U-Boot environment variables).

4.5. Creating a bootscript

To demonstrate U-Boot's scripting capabilities, we will now describe the construction of a boot script step by step. This script loads a RAM-disk image from the network via TFTP and starts a kernel found in flash memory with the appropriate boot arguments for size and RAM-disk address. The following tasks must be carried out: The RAM-disk image needs to be loaded from the network via TFTP, the boot arguments need to be set, and the kernel needs to be booted. The assumption is made that the following prerequisites have been satisfied: a bootloader and kernel images are stored in flash memory at the correct address and the network environment is configured correctly.
In the first step, the boot arguments are divided into logical sections and the environment variable basicargs, which contains the static boot arguments, is defined.
U-Boot> setenv basicargs console=ttyS0,115200 mem=64M root=/dev/ram rw U-Boot> printenv basicargs U-Boot> basicargs=console=ttyS0,115200 mem=64M root=/dev/ram rw
Then the MTD (memory technology devices) partitions for the flash unit are defined in another variable: mtdparts. Be sure to note the backslash escape character (\) in front of the semicolon, which prevents the partitioning of the dataflash from being interpreted as a command.
U-Boot> setenv mtdparts mtdparts=physmap_flash.0:384k(boot)ro,
1664k(linux)ro,3072k(initrd)ro,10240(cfg),-(custom)
U-Boot> printenv mtdparts
mtdparts=mtdparts=phys_mapped_flash:384k(boot)ro,1664k(linux)ro,
3072k(initrd) ro,1024(cfg),-(custom) The size and address of the initrd can only be determined later, when the current image has been loaded from the network.
The address of the kernel is now stored in a variable and the environment variable bootcmd is created. bootcmd is automatically called by the boot/bootd command.
U-Boot> setenv kerneladdr 10060000 U-Boot> setenv bootcmd run ramboot U-Boot> printenv kerneladdr bootcmd
kerneladdr=10060000 bootcmd=run ramboot
In the variable ramboot, we will specify the actual command sequence necessary for booting the kernel.
U-Boot> setenv ramboot tftpboot 21400000 initrd.bin\;setenv bootargs
Page 12 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH
\$(basicargs) initrd=0x\$(fileaddr),0x\$(filesize) \$(mtdparts)\;bootm
\$(kerneladdr)
U-Boot> printenv ramboot
ramboot=tftpboot 21400000 initrd.bin;setenv bootargs $(basicargs) initrd=0x$(fileaddr),0x$(filesize) $(mtdparts);bootm $(kerneladdr)
Once again, note the escape characters before all special characters. Later, when ramboot is run, the variable names will be replaced with their contents. Here, however, when setting the variables, they need to be interpreted as strings.
The boot script is now almost done, but the new entries need to be saved by calling saveenv; otherwise everything needs to be entered again after the next boot.
U-Boot> saveenv
Saving Environment to Flash... Un-Protected 1 sectors Erasing Flash...flash_erase: first: 2 last: 2 . done Erased 1 sectors Writing to Flash... done Protected 1 sectors
Now we can test the script:
U-Boot> boot
TFTP from server 192.168.2.238; our IP address is 192.168.2.171 Filename 'initrd.bin'. Load address: 0x21100000 Loading:################################################### ############################# done Bytes transferred = 1478664 (169008 hex) ## Booting image at 10060000 ... Image Name: uImage Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 739208 Bytes = 721.9 kB Load Address: 21000000 Entry Point: 21000000 Verifying Checksum ... OK OK Starting kernel ... Uncompressing
Linux...................................... done, booting the kernel.
... Kernel command line: console=ttyS0,115200 mem=64M root=/dev/ram rw initrd=0x21000000,0x169008 mtdparts=physmap_flash.0:384k(boot)ro, 1664k(linux)ro,3072k(initrd)ro,10240k(cfg),-(custom)
Page 13 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH

4.6. Updating U-Boot

To load a new version of U-Boot, you just need to interrupt the boot process of U-Boot and use the U-Boot running in SDRAM to re-load the U-Boot flash memory area. Since the U-Boot flash range is write-protected, you must first remove the write protection. Then load the new image from the network via TFTP and copy it to flash.
The original U-Boot images can be found on the starterkit-CD in the directory /tftpboot:
u-boot.bin contains the bootloader
u-boot.img contains the bootloader inclusive all environment variables excepting
the MAC address, this address is worldwide unique and should be written down before updating U-Boot
U-Boot> tftpboot 21000000 u-boot.bin
TFTP from server 192.168.2.238; our IP address is 192.168.2.171 Filename 'u-boot.bin'. Load address: 0x21000000 Loading: ################### done Bytes transferred = 94632 (171a8 hex)
U-Boot> protect off 10000000 1005FFFF
Un-Protected 3 sectors
U-Boot> erase 10000000 1005FFFF
flash_erase: first: 0 last: 2 Erased 3 sectors
U-Boot> cp.b 21000000 10000000 171a8
Copy to Flash... done
U-Boot> protect on 10000000 1005FFFF
Protected 9 sectors
U-Boot> reset
Page 14 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH

5. Compiling and debugging applications

5.1. Setting up a development system

The development system described here assumes that your device is connected to a separate development computer, using either Ethernet or a serial cable. All transfers between the two systems occur exclusively over this connection. The development system does not have any particular hardware demands; a standard PC is in most cases sufficient. To operate a graphical interface under Linux, a minimum of 64MB RAM and a corresponding graphic card are necessary. A Linux workstation is normally used as a development computer for an embedded Linux device. A network card and serial interface are required for the connection
As a basis for such a host system, taskit recommends and supports the freely available Debian Linux distribution for development. Debian stands out for its stability and good packet management. Both the current stable version „woody“ and the forthcoming „sarge“ version may be used. Several ways to acquire Debian are described at
http://www.debian.org/distrib/. With a broadband Internet connection, you can download
the current installation CD images using the jigdo tool or a BitTorrent client. The procedure for using jigdo is described at http://www.debian.org/CD/jigdo-cd/. The first of the seven CDs in the distribution is sufficient for installing a basic system. If the development computer has a network connection, additional packages can be installed over the network. For complete installation instructions for the x86 architecture, see http://www.debian.org/releases/stable/i386/install. The following descriptions relate to such a Debian system.
You could also run a Linux system in a virtual environment using a virtual machine such as VMWare or VirtualPC. This solution, however, severely limits performance and usability.
If the development PC uses Windows 2000 or XP, you can use the cross-platform tool chain under the Cygwin environment (http://www.cygwin.com/). Taskit will not grant support for installing and developing on the Microsoft Windows platform.

5.1.1. Installing the toolchain on Debian

A toolchain for cross compiling is the most important element of the development system. Precompiled binaries for the i386 architecture are on the starterkit CD.
In the /toolchain directory on the started-kit CD an installation script can be found, this can only be done by the user root:
cd /dev/cdrom/toolchain ./install_toolchain.sh.
Now the toolchain with GCC 3.4.2 and glibc 2.2.5 is installed. Additionally you can also install the softfloat toolchain which is much faster when working with floating point numbers. It has is own install_toolchain.sh script and can be found on
Page 15 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH
in the folder \toolchain\gcc-3.4.1-glibc-2.3.3 of the starter-kit CD.
The compilation of a tool chain itself is labour intensive and will not be described here. The toolchain was made with Crosstools, which simplifies the compilation considerable. Have a look at http://kegel.com/crosstool/ for further information.
After the installation, corresponding version of binutils, gcc and c++ are available for crosscompiling. Type ls /usr/bin | grep arm-linux to get a list of all available tools.

5.2. Mounting the working directory

After installing the tool chain, you can compile your own software for the arm processor. In the early stages of development, it is convenient to mount the working directory on the development system with NFS (network file system), in order to make changes available quickly.
Installation of the NFS-server:
apt-get install nfs-common nfs-kernel-server
If an NFS server is already set up on the development system, you only need to add one line to the /etc/exports file:
/develop *.local.domain(ro). This line exports, for example, the /develop directory for all clients on the local domain with read access. If this folder does not exist it has to be created:
mkdir /develop
chmod 777 /develop
The exported directory can then be mapped to a directory on the ARM-board with the mount command.
mkdir /mnt/develop
mount -t nfs -o nolock nfs_servername:/develop /mnt/develop

5.3. Compiling the application sample

In the /examples directory on the starterkit-CD you will find the example1.c file, which contains C sourcecode for a simple program for entering and printing text. For editing, first copy the file to the /develop directory on the development computer. Then you can use the cross-compiler to compile example1.c:
arm-linux-3.4.2-gcc -Wall example1.c -o example1 .

5.4. Starting the sample

If the execution rights for the newly created binary are set correctly, the program can now be called:
cd /mnt/develop
./example1
Page 16 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH

5.5. Debugging the sample

The GNU debugger (GDB) is one of the most important debugging tools for Linux. To debug an embedded system, set up a gdb server with the gdb package. The gdbserver itself is a small application that carries out commands from the gdb, which runs on the development system. You will find the gdbserver in the Linux starter kit's root file system, in the /usr/bin directory. Before debugging a program, you must compile it with the appropriate flags (-g or -ggdb for more information).
cd /develop
arm-linux-3.4.2-gcc -g example1.c -o example1_debug
If you include in debugging information, the binary created is much larger. As long as you have the original version with the debugging information on the development system, however, you can simply copy the smaller, stripped-down version to the target system. You can strip down the debugger using the arm-linux-strip tool. For remote debugging, you can set up communication between the gdbserver on the taskit device and the gdb on the development system either over a serial null modem cable or over a TCP/IP connection. The connection via TCP/IP is described below. First you need to start the gdbserver on the taskit device, and then create the connection from the gdb on the development computer:
gdbserver development_computer_ip:2345 example1_debug
The development computer is entered as host. As port, choose any available port. All command line parameters for the program (in this case, led is an integer indicating the number of repetitions) must be given in this call. Then you can start the gdb on the other system and create the connection to your taskit device:
arm-linux-gdb example1_debug
(GDB) target remote_ip:2345 Now you are ready to start debugging with the usual gdb commands.

5.6. Downsizing the binary

After compiling the example the filesize of the binary can be noticeable reduce by removing unneeded informations generated by the compiler as well as debug informations (debugging wont be possible any more):
arm-linux-3.4.2-strip example1
Page 17 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH

6. Compiling a new linux kernel

If you work with Embedded Linux regularly, you will often face the need to create your own kernel. In most cases, this involves integrating new drivers, e.g. for USB devices, or additional file systems. Because memory space is limited on an embedded board, it does not make sense to set up a large number of drivers to start with (as is common for desktop PCs) unless you know for sure that you actually need them.
The kernel binaries and sources delivered with your product are made up of a standard kernel with ARM patches and some AT91-specific patches or drivers. The process for creating your own kernel is broken down into three steps – configuring, compiling and installing.

6.1. Configuring the kernel

The source codes for the Linux kernel are on the starterkit-CD in the tarred GZIP archive linux.tgz. The kernel sources are configured in delivery form. You just need to append the
drivers you want to use or deselect the drivers that you don't need. Before you can configure the kernel the tarred archive has to be extracted to your development folder:
cd /develop
tar -xzvf starterkit-CD/linux.tgz
Before you can change the kernel configuration and compile your new kernel, you will have to setup the kernel for your product:
ARCH=arm make PRODUCT_defconfig
Note: PRODUCT specifies the name of your product (the precise command for your product can be found in the appendix “Product specific kernel settings”).
Now the kernel is configured for your product which factory settings. Various tools can be used to change the kernel configuration; the most well-known is menuconfig. Menuconfig is a Text User Interface (TUI), it offers a text-based interface, which allows for easy configuration and can also be used in terminal emulation mode. In order to use it you have to install the curses development package:
apt-get install ncurses-dev . After that you can start the kernelconfiguration by typing:
ARCH=arm make menuconfig.
Page 18 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH
The options can now be selected or deselected in the individual levels. The basic selection consists of „empty“, „*“, „M“. Empty means that the driver will not be compiled with the
kernel. * means that the driver will be included in the kernel binary. M means that the driver is configured as a module; in other words, it can be dynamically activated and deactivated at runtime. When you have set the configuration as you like, finish the process with Exit and Save. The kernel is now ready to compile. The corresponding options for cross-compilation are already entered in the makefile.

6.2. Compiling the kernel

Compiling is simple: ARCH=arm CROSS_COMPILE=arm-linux-3.4.2- make zImage With “CROSS_COMPILE=arm-linux-3.4.2-” you “tell” the makefile to use the compiler from the cross-compiler toolchain of the starterkit-CD. If the compilation runs without errors, the compiled image is saved in arch/arm/boot. If you configured drivers as modules, you still need to create these:
ARCH=arm CROSS_COMPILE=arm-linux-3.4.2- make modules . The kernel makefile provides a target for installing the modules – modules_install. By default, the modules are installed in the /lib/modules directory. For cross-environment development, the modules must be installed in a different directory. The example gives a module directory within the Linux source folder. When entering the path to the module directory, ensure that no relative paths are given; since the script goes through the kernel directories, relative paths can change.
ARCH=arm make INSTALL_MOD_PATH=/develop/linux/modules modules_install
The modules are now copied to the /develop/linux/modules/lib/modules/modules/2.x.xx/
Page 19 of 65 Version 1.26 (2008-04-30)
Linux Guide taskit GmbH
directory.

6.3. Preparing the kernel

To install the new kernel on the taskit device, you now need to prepare the zipped kernel image for use by U-Boot. This is done using the mkimage tool. Mkimage is also included in the /scripts directory on the starter-kit CD. Enter the following 3 lines as one line separated by a space character:
mkimage -A arm -T kernel -O linux -C none
-a 21000000 -e 21000000 -n plinux
-d arch/arm/boot/zImage uImage
Result:
Image Name: plinux
Created: Tue Dec 14 19:12:23 2004
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 738972 Bytes = 721.65 kB = 0.70 MB
Load Address: 0x21000000
Entry Point: 0x21000000
This script packs a 64 Kb header around the zipped image. This gives U-Boot important information for booting the kernel correctly. Before you can install the kernel you need to copy the uImage into the tftp directory:
cp uImage /tftpboot
You can also carry out this process by running the simple shell script install_linux.sh, which you will find in the /scripts directory on the starterkit CD.

6.4. Installing the kernel

Finally, load the finished image in U-Boot, program it into flash memory and start it:
U-Boot> erase 10060000 101FFFFF
U-Boot> tftpboot 21000000 uImage
-> TFTP from server 192.168.2.238; our IP address is 192.168.2.171
Filename 'uImage'. Load address: 0x21000000 Loading: ################################################### ########################################################## ###############
done Bytes transferred = 739036 (b46dc hex)
The last step is to copy the kernelimage into flash. To do that the copy-command needs the filesize of the kernelimage. The filesize is displayed after the transfer from the remote PC (marked red) and is also stored in the environment variable filesize.
U-Boot> cp.b 21000000 10060000 $(filesize)
-> Copy to Flash... done
U-Boot> boot
Page 20 of 65 Version 1.26 (2008-04-30)
Loading...
+ 45 hidden pages