<<

Ricardo Kekki, Tuomas Kulve, Valtteri Rahkonen, Markku Ursin [email protected] 8th March 2004

Copyright Movial Contents

1 Introduction 1

2 Test Environment 1 2.1 MontaVista ...... 1 2.2 BDI2000 ...... 1

3 Setting Up 2 3.1 Setup TFTP and DHCP Servers ...... 2 3.2 Setup BDI2000 ...... 3 3.3 Setup the Innovator and the Workstation ...... 3 3.4 TesttheSetup ...... 3

4 Compiling the U-Boot and Flashing to the Innovator 3 4.1 Compiling...... 4 4.2 Flashing...... 4

5 Compiling a for the Innovator 5 5.1 Compiling Linux kernel 2.4.21 ...... 5 5.2 Compiling Linux Kernel 2.6.3 ...... 6 5.3 Compiling the MontaVista Kernel ...... 7 5.4 Converting the Kernel to U-Boot’s Format ...... 7

6 Linux Installation 8 6.1 Setup MontaVista Linux in the NFS server ...... 8 6.2 Flash and Start the Kernel ...... 8

7 Conclusion 10

A OMAP BDI2000 Configuration File 12

B BDI2000 to JTAG Cable Pinout 14

C Flash Memory Map 14 1 Introduction

This document describes how to get MontaVista r Linux r running on the Innovator Development board for the Texas Instruments OMAP platform. The purpose is to get a bootloader and a Linux kernel flashed to the Innovator board and get the kernel to use a root file system over NFS. In this document we describe the use of Universal Bootloader(U-Boot)[12]. We used Linux kernel versions 2.4.21 and 2.6.3 in addition to MontaVista Linux’s kernel 2.4.21.

2 Test Environment

This document was done with the following hardware and :

• Innovator Development kit with a breakout board • Abatron BDI2000 with bdiGDB for ARM7/9TDMI targets • PC with (unstable) OS as the workstation • PC with Red Hat OS as the TFTPD/NFS server • MontaVista Linux CEE3.0 • U-Boot bootloader • Minicom[10] serial line communication software • Trivial file transfer protocol daemon (tftpd) [11]

With Debian you can get and install minicom and tftpd by typing apt-get install [package’s name ] With Red Hat you can install the packages after downloading them by typing rpm -i [package’s name ].rpm U-Boot can be downloaded from its project page[12] at sourceforge. MontaVista Linux requires Red Hat 7.2 or 7.3, otherwise it won’t install. We used Red Hat 91 with a little hack described in section 6.1. Excluding the MontaVista Linux there should be no specific requirements to get the Linux into the Innovator.

2.1 MontaVista Linux

MontaVista Linux can be found in the MontaVista Zone[1], which requires an user account. MontaVista Linux can be downloaded in the ISO-images named arm_v4t_le-mvlcee300_innovator.img and host-mvlcee300_innovator.img.

2.2 BDI2000

We chose Abatron’s JTAG emulator BDI2000, because it works well in Linux environment. The BDI2000 has GDB support and ethernet connection to the local LAN.

1Maybe this works with a Debian with Red Hat’s RPM -package tools installed too?

Copyright Movial 1 / 14 3 Setting Up

The network topology used in our tests is shown in Figure 1.

Figure 1: Test environment

3.1 Setup TFTP and DHCP Servers

We had separate computers for the workstation and TFTP and DHCP daemons but there should be no reason why the workstation and these servers couldn’t be the same computer.

TFTP

In our test we used /tmp as the TFTP directory because it eases the use. Configuring TFTPD on a Red Hat computer is done by modifying /etc/xinetd.d/tftp file. It should look like this:

service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -c -s /tmp disable = no per_source = 11 cps = 100 2 flags = IPv4 }

For the changes to take effect the xinetd must be informed about the changed configuration file by typing /etc/init.d/xinetd reload Configuring TFTPD on a Debian computer is done by adding the line

tftp dgram udp wait root /usr/sbin/in.tftpd tftpd /tmp

to /etc/inetd.conf and reloading inetd configuration by typing /etc/init.d/inetd reload

Copyright Movial 2 / 14 DHCP

Make your DHCP server to give the Innovator an IP Address.

3.2 Setup BDI2000

You need to have the correct firmware and settings loaded to the BDI2000. The firmware should be bdiGDB for ARM. The settings should have at least the BDI2000’s IP, your TFTP server’s IP and the configuration file name. The configuration might look like this:

BDI Type : BDI2000 Rev.C (SN: 95528830) Loader : V1.05 Firmware : V1.11 bdiGDB for ARM Logic : V1.05 ARM MAC : 00-0c-01-95-52-88 IP Addr : 172.16.6.53 Subnet : 255.255.255.255 Gateway : 255.255.255.255 Host IP : 172.16.6.63 Config : omap.conf

See the BDI2000 manual for setting the configurations. The configuration file can be found in the Appendix A. Copy the configuration file named as omap.conf to the TFTP directory. Copy also the reg925t.def file, which came with the BDI2000.

3.3 Setup the Innovator and the Workstation

Use a null-modem cable to connect the Innovator’s serial port labelled COM1 to the workstation’s serial port. Connect the BDI2000 to the Innovator breakout board with the MultiICE cable. Launch minicom on the workstation. Check that it is configured as follows:

Serial Device : /dev/ttyS0 (ttyS0 is normally the port 1) Bps/Par/Bits : 115200 8N1 Hardware Flow Control : No Software Flow Control : No

3.4 Test the Setup

Connect to BDI2000 with telnet to test the settings: telnet 172.16.6.53 If the configuration file gets loaded then the setup was successful.

4 Compiling the U-Boot and Flashing to the Innovator

In this section we describe how to compile the U-Boot bootloader and how to flash it to the Innovator’s bootflash.

Copyright Movial 3 / 14 4.1 Compiling

Compilation of the U-Boot is very straightforward procedure. First extract the archive and type the following commands in the U-Boot’s source directory: omap1510inn_config make all Now you should have u-boot, u-boot.bin, u-boot.srec and u-boot.map in the current directory and mkimage in the tools directory.

4.2 Flashing

Here we explain how to load and flash the U-Boot using mainly itself to do the job. After the U-Boot is flashed it should start automatically after powering up the Innovator. Set the Innovator’s Memory Configuration Switch (SW2) (see development kit’s user’s guide[4] Figures 2-2 and 3-3 and Table 3-1) to boot flash: S1 on, S2-4 off and restart the Innovator. First copy the u.boot and u.boot.bin to your TFTP -directory. Then unlock and erase the bootloader area with BDI:

Code#0>unlock 0 1 2 Core#0>erase 0 Erasing flash at 0x00000000 Erasing flash passed

Then load both the ELF and BIN formatted U-Boot images to Innovator’s memory:

Core#0>load u-boot elf Loading u-boot , please wait .... - File offset 0x00008000 to address 0x11000000 size 87548 Loading program file passed Core#0>load 0x10000000 u-boot.bin bin Loading u-boot.bin , please wait .... Loading program file passed

You can check with the RD -command that the PC points to the area where the ELF U-Boot image was loaded. Start the U-Boot by typing GO. If the PC is invalid, you can give the correct memory pointer as a parameter for GO -command.

Core#0>rd GPR00: fffb0000 00000020 1101172d 00000060 GPR04: 11011718 00000004 00000015 11017b60 GPR08: 11039020 ffffffff 00000001 11038f30 GPR12: 11038f34 11038f24 11003b00 11000000 PC : 11000000 CPSR: 400000d3 Core#0>go

Now you should see the Innovator’s prompt at minicom. Using the U-Boot unlock again the bootloader flash area and copy the BIN formatted U-Boot image there with CP -command.

Copyright Movial 4 / 14 OMAP1510 Innovator # protect off 1:0-1 Un-Protect Flash Sectors 0-1 in Bank # 1 OMAP1510 Innovator # cp 0x10000000 0 0x55aa Copy to Flash...-done

The first and second parameters of the CP -command are source and destination addresses. The last parameter tells how many words (32bit) should be copied.

5 Compiling a Linux Kernel for the Innovator

This section describes how to compile a kernel for the Innovator. We compiled both 2.4 and 2.6 series kernel. Compiling the kernel in a normal PC platform for Innovator requires cross compilation environ- ment where the kernel can be compiled directly for the target platform. We used both Scratchbox [6] and Embedded Linux Development Kit (ELDK) [5] as our compiling environment. The kernel can be compiled also in MontaVista SDK that comes with already patched version of kernel.

5.1 Compiling Linux kernel 2.4.21

First thing needed is to obtain sources for kernel 2.4.21. Sources can be found at The Linux Kernel Archives [7] or at one of its mirrors. Linux vanilla kernel needs to be patched with ARM and OMAP patches. The ARM can be found from The ARM Linux Project [8] and the OMAP patch can be obtained from MontaVista [9].

Extracting and Patching the Kernels

Before the kernel can be compiled it must be extracted and patched with the ARM and OMAP patches. The kernel archive can be extracted with the command: tar jxf linux-2.4.21.tar.bz2 Following patch -commands are assumed to be executed in the kernel source tree’s root directory. gzip -cd patch-2.4.21-rmk1.gz | patch -p1 bzip2 -cd patch-2.4.21-rmk1-omap1.bz2 | patch -p1

Preparing the Kernel for Compiling Environment

After the kernel is extracted and patches applied it must be prepared for cross compiling. If ELDK is used for cross compiling the kernel the target platform must be specified in the main makefile (ARCH := arm) and the compiler as the ELDK’s compiler (CROSS_COMPILE = arm-linux-). With ELDK there is also need to add ELDK’s include directories to ARM targets makefile: add CFLAGS := -Uarm -fno-common -pipe -I[path to ELDK]/usr/lib/gcc-lib/arm-linux/2.95.4/include/ to arch/arm/Makefile. If Scratchbox is used and the ARM target was created with gcc version 2.95 there is no need for additional changes. However, if Scratchbox uses e.g. gcc version 3.3 by default, the version 2.95 must be specified in main makefile as CROSS_COMPILER. Version 3.3 should not be used to compile a 2.4 series kernel, otherwise the kernel needs additional patching.

Copyright Movial 5 / 14 Compiling the Kernel

After preparations the kernel can be configured and compiled. We used the default Innovator config- uration that comes with the OMAP patch. This default configuration can be applied to the kernel configuration with the following commands: make innovator_config make oldconfig The actual compilation can be done with by typing: make dep make vmlinux make modules Because we are using a cross compilation environment we cannot install modules to their normal install path. Therefore we must specify an alternative location to store the modules. After the modules are compiled they need to be copied to MontaVista Linux kernel module directory (see Section 6.1). make modules_install INSTALL_MOD_PATH=[MontaVista Linux root dir]

5.2 Compiling Linux Kernel 2.6.3

First thing needed is to obtain sources for the kernel 2.6.3. Sources can be found at The Linux Kernel Archives [7] or at one of its mirrors. One difference between 2.6 and 2.4 series kernel is that there is no need to apply the ARM patch to vanilla 2.6 kernel. However vanilla Linux kernel needs to be patched with the OMAP patch. The OMAP patch for 2.6 series kernel can be obtained from Linux OMAP project pages [14]. When we compiled the 2.6.3 kernel we did not managed to compile it easily in the ELDK. This could be related to gcc 2.95 used by the ELDK.

Extracting and Patching the Kernel

Before the kernel can be compiled it must be extracted and patched with the OMAP patch. The kernel archive can be extracted with the command: tar jxf linux-2.6.3.tar.bz2 The following patch command is assumed to be executed in the kernel source tree’s root directory. bzip2 -cd patch-2.6.3-omap1.bz2 | patch -p1

Preparing the Kernel for Cross Compiling Environment

When using Scratchbox to compile the kernel there is need to modify the kernel’s main makefile. HOST_GCC compiler flag should be pointing to host-gcc instead of gcc compiler.

Compiling the Kernel

After the preparations the kernel can be configured and compiled. We used the default Innovator con- figuration that comes with OMAP patch. This default configuration can be applied to the kernel con- figuration with the following commands:

Copyright Movial 6 / 14 make innovator_1510_defconfig make oldconfig The default configuration needs a little bit fine tuning. CONFIG_ROOT_NFS kernel option should be added to kernel compile options so that the kernel can mount an NFS partition as the root fs. After the configuration the kernel can be compiled with the following commands: make vmlinux make modules Because we are using a cross compilation environment we cannot install the modules to their normal install path. So we must specify an alternative location to store the modules. After the modules are compiled they need to be copied to the MontaVista Linux kernel module directory (see section 6.1). make modules_install INSTALL_MOD_PATH=[MontaVista Linux root dir]

5.3 Compiling the MontaVista Kernel

MontaVista comes with an already patched version of the Linux kernel 2.4.20.

Compiling kernel

Go to the MontaVista kernel directory. MontaVista’s kernel is already patched so there is no need to apply any kernel patches. Default OMAP configuration can be applied to kernel with following command: make oldconfig make dep make vmlinux make modules make modules_install

5.4 Converting the Kernel to U-Boot’s Format

This section describes how to convert the compiled kernel image to U-Boot’s tagged binary format format. The upload and actual flashing to the Innovator is described later. For the conversion an ARM version of objcopy program is needed. In Scratchbox we can use its version of objcopy and in ELDK we must use ELDK’s version of objcopy. First thing to do is to convert the kernel image to a binary format and strip it with the following command: objcopy -O binary -R .note -R .comment -S vmlinux linux.bin Actual conversion to the U-Boot’s format was made with U-Boot’s mkimage command with as follows: mkimage -A arm -O linux -T kernel -C none -a 0x10008000 \ -e 0x10008000 -n "Linux Kernel Image" -d linux.bin uImage

Resulting uImage is in the U-Boot’s tagged binary format. According to U-Boot’s README it can be used if the kernel is loaded to the Innovator using the TFTP protocol but if it is loaded over the serial cable the kernel should be first converted to SREC format with the following command: objcopy -I binary -O srec uImage uImage.srec

Copyright Movial 7 / 14 6 Linux Installation

In the following sections we describe how to upload and flash the kernel to the Innovator’s flash memory. Before flashing the kernel change the settings of the memory configuration switch so that S3 is on and S1, 2, and 4 are off and then restart the Innovator.

6.1 Setup MontaVista Linux in the NFS server

Now you have to install the MontaVista linux environment. See the Cross-Development Quick Start Guide[2] for the instructions. MontaVista Linux requires Red Hat 7.2 or 7.3, but we had a RedHat 9 in the NFS server and we didn’t want to downgrade it to 7.2 or 7.3 so we edited the /etc/redhat-release file to look like: ”Red Hat Linux release 7.2 (Shrike)”. Create the /tftpboot directory. Make a symbolic link to the filesystem root directory. Name the link as the IP address of the Innovator. ln -s /tftpboot/172.16.6.52 /usr/mvlcee/devkit/arm/v4t_le/target/ On the NFS server edit the /etc/exports file. Add the following row:

/tftpboot/172.16.6.52 *(rw,no_root_squash,no_all_squash)

Restart the NFS server: /etc/init.d/nfs restart

6.2 Flash and Start the Kernel

Set the environment variables in the Innovator. The ethaddr is the MAC address of the Innovator board, serverip is the IP address of the NFS server and bootargs and arguments passed to the kernel.

OMAP1510 Innovator # setenv ethaddr 00:0b:36:00:04:23 OMAP1510 Innovator # setenv serverip 172.16.6.63 OMAP1510 Innovator # setenv bootargs console=ttyS0,115200n8 noinitrd root=/dev/nfs ip=bootp nfsroot=172.16.6.63

Using the printenv -command you can check that the environment variables look correct. Use the saveenv -command to save the variables in to the flash memory:

OMAP1510 Innovator # saveenv Saving Environment to Flash... Un-Protected 1 sectors Erasing Flash... Erasing sector 1 ... done Erased 1 sectors Writing to Flash...\done Protected 1 sectors

Erase enough flash memory for the kernel starting at the beginning of the userflash 0 (0x260000, sector 19) with the erase -command:

Copyright Movial 8 / 14 OMAP1510 Innovator # erase 1:19-40 Erase Flash Sectors 19-40 in Bank # 1 Erasing sector 19 ... done [...] Erasing sector 40 ... done

With the U-Boot you have to possibilities for transferring the kernel to the Innovator: over serial line or over ethernet. To use serial line start the receive operation at the Innovator with the loads -command:

OMAP1510 Innovator # loads 0x260000 ## Ready for S-Record download ...... and cat the SREC formatted kernel image to the serial port: cat uImage.srec > /dev/ttyS0 To transfer the kernel over ethernet, you have to copy the U-Boot binary formatted kernel image to the TFTP directory and the copy it to Innovator’s RAM with tftpboot -command and the flash it with CP -command:

OMAP1510 Innovator # tftpboot 0x10008000 uImage TFTP from server 172.16.6.63; our IP address is 172.16.6.52 Filename ’uImage’. Load address: 0x10008000 Loading: ################################################################# [...] ############################################# done Bytes transferred = 2222512 (21e9b0 hex) OMAP1510 Innovator # cp 0x10008000 0x260000 [size of the kernel in words] Copy to Flash.../done

For the U-Boot to start the kernel automatically after a delay set the boot command by typing:

OMAP1510 Innovator # setenv bootcmd bootm 0x260000 OMAP1510 Innovator # saveenv

To boot the kernel manually from the U-Boot’s command line type the same boot command:

OMAP1510 Innovator # setenv bootcmd bootm 0x260000

Copyright Movial 9 / 14 7 Conclusion

Getting the MontaVista Linux running on the Innovator development board should be relatively easy. The reality, however, can be a bit different, since there are many different components involved whose interoperability has not been very well documented as of yet, even if the components themselves would be. This is understandable, since there are numerous settings that can be misconfigured. To make it more challenging, there are generally no useful error messages if something goes wrong. We had some problems with rrload bootloader, we did not always manage to boot it in the Innovator. The U-Boot seems to work better and this is one reason why we recommend using it. It does not have a menu interface, but the command line interface is more handy, once you get use to it. Compiling and flashing a kernel was a simple procedure. After the compilation of the patched kernel, it had to be converted to bootloader’s format, transferred to the Innovator and flashed to the Innovator’s user flash. We managed to flash both the 2.4 and 2.6 series kernel.

Movial Tietokuja 2, FIN-00330 HELSINKI tel. +358 9 8567 6400, fax. +358 9 8567 6401 www.movial.fi [email protected]

Copyright Movial 10 / 14 References

[1] MontaVista Zone. http://support.mvista.com. Last checked 16.02.2004. [2] MontaVistaTM Linux r Consumer Electronics Edition for the Texas Instruments InnovatorTM Development Kit for the OMAPTM 1510 & OMAPTM 5910. Cross-Development Quick Start Guide, v3.0, May 2003.

[3] MontaVistaTM Linux r Consumer Electronics Edition. User’s Guide, v3.0, April 2003. [4] Innovator Development Kit for the OMAP Platform. User’s Guide, SPRU667, July 2003. [5] Embedded Linux Development Kit, DENX Software Engineering. http://www.denx.de/. Last checked 20.02.2004. [6] Scratchbox. http://www.scratchbox.org/. Last checked 20.02.2004. [7] The Linux Kernel Archives. http://www.kernel.org/. Last checked 20.02.2004. [8] The ARM Linux Project. ftp://ftp.arm.linux.org.uk/pub/armlinux/kernel/v2.4/. Last checked 20.02.2004. [9] MontaVista kernel patches. ftp://source.mvista.com/pub/omap/2.4. Last checked 20.02.2004. [10] Minicom. http://alioth.debian.org/projects/minicom/. Last checked 20.02.2004. [11] K. Sollins, The TFTP Protocol. Massachusetts Institute of Technology, IEN 133, January 1980. [12] Universal Bootloader. http://sourceforge.net/projects/u-boot. Last checked 20.02.2004. [14] Linux kernel tree for ARM based OMAP processors from TI. http://linux-omap.bkbits.net/. Last checked 20.02.2004.

Copyright Movial 11 / 14 A OMAP BDI2000 Configuration File

; bdiGDB configuration for TI Innovator/OMAP1510 EVM ; ------; [INIT] ; WREG CPSR 0x000000d3 ;set superviser mode WGPR 15 0x00000000 ;set PC = 0 WCP15 1 0x00000070 ;CP15 Control : disable caches ; WM16 0xfffec808 0x00F5 ;Disable Watchdog Timer WM16 0xfffec808 0x00A0 ; ; ;MMAP 0x00000000 0x01ffffff ;enable access to CS0 ;MMAP 0x04000000 0x05ffffff ;enable access to CS1 ;MMAP 0x08000000 0x09ffffff ;enable access to CS2 ;MMAP 0x0c000000 0x0dffffff ;enable access to CS3 ;MMAP 0x10000000 0x1fffffff ;enable access to SDRAM ;MMAP 0x20000000 0x2007ffff ;enable access to internal RAM ;MMAP 0xfffb0000 0xfffeffff ;enable access to peripheral ; WM16 0xfffecf00 0x0010 ; WM32 0xfffecc10 0x002130b0 ;EMIFS CS0 configuration WM32 0xfffecc14 0x0000f559 ;EMIFS CS1 configuration WM32 0xfffecc18 0x000055f0 ;EMIFS CS2 configuration WM32 0xfffecc1c 0x00003331 ;EMIFS CS3 configuration WM32 0xfffecc20 0x0101b6fc ;EMIFF SDRAM configuration WM32 0xfffecc24 0x00000027 ;EMIFF SDRAM MRS ; WM16 0xfffece10 0x0002 ;release Megastar3 reset ; WM32 0xfffecc0c 0x00000001 ;Disable flash WP ;

[TARGET] CPUTYPE TI925T CLOCK 4 ; JTAG clock (0=Adaptive, 1=8MHz, 2=4MHz,...) SCANPRED 1 8 ; JTAG devices connected before this core SCANSUCC 1 38 ; JTAG devices connected after this core ;RESET NONE ; NONE | HARD (ms) TRST PUSHPULL ; TRST driver type (OPENDRAIN | PUSHPULL) ENDIAN LITTLE ; memory model (LITTLE | BIG) ;VECTOR CATCH 0x1f ; catch D_Abort, P_Abort, SWI, Undef and Reset VECTOR CATCH 0x01 ; catch Reset ;BREAKMODE SOFT 0xDFFFDFFF ; SOFT or HARD, ARM / Thumb break code BREAKMODE HARD ; SOFT or HARD, ARM / Thumb break code STARTUP RESET ; RESET | RUN | STOP [runtime (mSecs)] BDIMODE AGENT ; LOADONLY | AGENT

[HOST] IP 172.16.6.63

Copyright Movial 12 / 14 FILE u-boot FORMAT BIN LOAD MANUAL

[FLASH] WORKSPACE 0x20000000 ;workspace in target RAM for fast programming algorithm CHIPTYPE STRATAX16 ; AM29F | AM29BX8 | AM29BX16 | I28BX8 | I28BX16 CHIPSIZE 0x02000000 ; CHIPTYPE AM29BX16 ; AM29F | AM29BX8 | AM29BX16 | I28BX8 | I28BX16 ; CHIPSIZE 0x02000000 BUSWIDTH 16 FILE u-boot.bin FORMAT BIN

[REGS] FILE reg925t.def

Copyright Movial 13 / 14 B BDI2000 to JTAG Cable Pinout

If you need to use the Innotavator JTAG debug connector you can do your own cable with the following connectionis. BDI Side TI JTAG 1 N/C 2 N/C 3 N/C 4 2 5 8 6 11 7 10 8 1 9 N/C 10 3 11 5 12 7 13 N/C 14 N/C

C Flash Memory Map

Flash Memory Map Useage Start Size bytes Device Bootloader 0x00000000 0x00020000 128 Kb mtd0 Parameters 0x00020000 0x00040000 256 Kb mtd1 Kernel 0x00060000 0x00200000 2 Mb mtd2 User0 0x00260000 0x00DA0000 13.625 Mb mtd3 User1 0x01000000 0x01000000 16 Mb mtd4

Copyright Movial 14 / 14