OLIMEX CS-E9302

OLIMEX CS-E9302

How to configure Linux for OLIMEX CS-E9302 board with EP9302 processor

 
Step by step how to configure and compile Linux kernel for OLIMEX CS-E9302 board
 
 
 
 
!!! Remember the procedure works for me, but if your cat will change in an elk, do not blame me for it.
You use information from this site at your own risk.!!!
 
 
First we need download Linux kernel (linux-2.6.24.7.tar.gz)
 
Type in the Linux terminal :
 
$ mkdir EP9302
$ cd EP9302
$ tar -zxf linux-2.6.24.7.tar.gz $ cd linux-2.6.24.7
$ zcat ../linux-2.6.24-rc8_ep93xx_mmc.patch.gz | patch -p1
$ cp cs-e9302_kernel_config .config
 
For ARM cross compiler,we use ELDK toolkit.
 
You can download the ELDK for ARM ver 4.2 from ftp://ftp.denx.de/pub/eldk/4.2/arm-linux-x86/
 
Install the ELDK e.g. in /opt/ELDK
Edit the file Makefile from linux-2.6.24.7 folder and replace
 
ARCH ?= $(SUBARCH) with ARCH ?= arm 
CROSS_COMPILE ?= with CROSS_COMPILE = arm-linux-
 
Now we can configure and build the kernel.
 
It is good to create a script which set the environment properly and clean the previous compilation.

#!/bin/bash
#set the environment
export CROSS_COMPILE=arm-linux-
export PATH=/opt/eldk/usr/bin:/opt/eldk/bin:$PATH
export ARCH=arm
cd linux-2.6.24.7
#clean the previous compilation
make  mrproper
#copy the config for CS9302
cp cs-e9302_kernel_config .config
#run the configuration
make   menuconfig
#make the kernel
make
  

Save the script as make-kernel.sh in EP9302 folder.

From terminal run the script (./make-kernel.sh), after a while you will get the configuration window.

Using the configurator, you can modify the properties of the kernel.

For example you can add support for NFS server.

After succesfully compiling the zImage (Linux kernel image) file will be created in the directory "/linux-2.6.247/arch/arm/boot"

Now we can download the kernel image to the CS-E9302 board.

How to download the kernel to the CS-E9302 board ?

OK. We have the kernel image created.

Now we want to download it to the board.

We need the RS232 cable for communicate with the board, minicom and tftp server installed.

The cable for connection the board to RS232 port in computer     

TD  3 ------------------------> 2 RD     
RD  2 <------------------------ 3 TD     
RTS 7 ----,              ,----- 7 RTS    
CTS 8 <---'              '----> 8 CTS    
DSR 6 <---,              ,----> 6 DSR    
DCD 1 <---|              |----> 1 DCD    
DTR 4 ----'              '----- 4 DTR    
SG  5 ------------------------- 5 SG     

Then you need to install a tftp server - the module will download the kernel image from the server.

How to install tftp in Debian?

Open a terminal window and type

$aptitude install tftpd
$aptitude install tftp
$mkdir /tftpboot
$chmod 777 /tftpboot

Edit the  /etc/inetd.conf file and change the location of director from /srv/tftp to /tftpboot

tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot

Restart the tftpd.
$cd /etc/init.d
$./openbsd-inetd restart

You can edit /etc/hosts.allow and /etc/hosts.deny for restriction.

 

Then you need install the Minicom program.

Minicom is a text-based modem control and terminal emulation program for Unix-like operating systems.

To install Minicom open a terminal window and type

$aptitude install minicom

Now we need to configure minicom.

Open a terminal window and type

$minicom

Press CTRL+Z then A .

Window will appear to configure the program.

Press P to configure comm and set the parameters :

Speed : 57600
Parity : None
Data : 8
Stopbits :1

Connect the board to the computer using the RS232 cable.

Power the system.

In minicom window you can see :

+Ethernet eth0: MAC address 00:00:00:00:54:33                       
IP: 192.168.1.10/255.255.255.0, Gateway: 192.168.1.1                
Default server: 192.168.1.100, DNS server IP: 208.67.222.222        
RedBoot(tm) bootstrap and debug environment [ROMRAM]                
Non-certified release, version v2_0 - built 08:14:43, Aug 22 2006   
Platform: Cirrus Logic EDB9302 Board (ARM920T)                      
Rev A Copyright (C) 2000, 2001, 2002, Red Hat, Inc.                 
RAM: 0x00000000-0x02000000, 0x00041e68-0x01fdd000 available         
FLASH: 0x60000000 - 0x61000000, 128 blocks of 0x00020000 bytes each.
== Executing boot script in 5.000 seconds - enter ^C to abort       

When power on, after 5 seconds, the default script will be runned.
Stop this timer and reconfigure the environment variables by pressing CTR-C.
We set-up the environent variables by following command:
 
RedBoot> fconfig
 
Set the variables for your system Enter script, terminate with empty line
 
Enter script, terminate with empty line
>> fis load zImage
>> exec -c "console=ttyAM root=dev/sda1 rootdelay=5"
>>
Boot script timeout (1000ms resolution): 5
Use BOOTP for network configuration: false
Gateway IP address: 192.168.1.1
Local IP address: 192.168.1.10
Local IP address mask: 255.255.255.0
Default server IP address: 192.168.1.100
DNS server IP address: 208.67.222.222
Set eth0 network hardware address [MAC]: true
eth0 network hardware address [MAC]: 0x00:0x00:0x00:0x00:0x54:0x33
GDB connection port: 9000
Force console for special debug messages: false
Network debug at boot time: false
Update RedBoot non-volatile configuration - continue (y/n)?

Where

Boot script - input Linux kernel command line here
 
fis load zImage
exec -c "console=ttyAM root=dev/sda1 rootdelay=5"
 
the boot script loads the kernel image from flash, set-ups the serial port as Linux console,
and attaches the pendrive connected tu USB port1 as root system file.
 
Boot script timeout 5 after 5s - RedBoot will run script configuration variable
Use BOOTP for network configuration - Boot using BOOTP protocol
Gateway IP address - your network Getway IP Address
Local IP address - CS-E9302's static IP address in your network Local IP
address mask - IP address mask in your nrtwork
Default server IP address - the IP address of your computer with TFTP server
DNS server IP address - DNS server's IP address
eth0 network hardware address - MAC address
GDB connection port - GDB debug server port number
Force console for special debug messages - enable special debug message console
Network debug at boot time - network debug supporting
 
Manually boot the Linux kernel
 
Copy the kernel image (zImage) from /linux-2.6.247/arch/arm/boot" to /tftpboot.
Connect the CS-E9302 to the LAN
On the RedBoot command promt (minicom), enter load command
 
+RedBoot> load -r -v -b 0x80000 zImage
 
You will see the spining wheel "/" on the left corner of the minicom window.
RedBoot will load the zImage from TFTP server.
Now we start booting the kernel, type the command and press enter in minicom
 
+RedBoot> exec -c "console=ttyAM root=/dev/sda1 rootdelay=5"
 
If everything is okay you should see in minicom text similar to that :
 
Uncompressing Linux...................................................................................................... done, booting the kernel.
Linux version 2.6.24.7 (
root@modbus-debian) (gcc version 4.2.2) #1 PREEMPT Thu Dec 24 16:18:30 CET 2009
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
.
.
.
Root-NFS: No NFS server available, giving up.
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "sda1" or unknown-block(2,0)
Please append a correct "root=" boot option; here are the available partitions:
1f00      16384 mtdblock0 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0
)

 
 
At the end of a message is displayed
 
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
 
This means that Linux can not find the root file system .
We must now create a root file system
 
How to build a root file system ?
 
Step by step how to build a root file system for OLIMEX CS-E9302 board.
 
Now bootstrap an arm emdebian "grip" file system for the CS-E9302 board.
 
Debootstrap phase 1
Create a debootstrap with emdebian base minimum system.
Open a terminal window and type
 
$mkdir debootstrap
$cd debootstrap
$sudo debootstrap --arch=arm --foreign lenny grip/ http://www.emdebian.org/grip/
$cd grip
$tar jcf ../emdebian-grip.tar.bz2 .
 
Pendrive preparation
 
I'm using the micro SD card with USB reader, but you can use any pendrive 1GB -4GB.
Insert your pendrive in the host.
You can detect what device name it is mapped on by typing :
$fdisk -l
In the example the pendrive name is /dev/sdd, you must use your configuration (if not you can damage your Linux OS)
Now we configure the ext3 file system on the pendrive .
Open a terminal window and type
 
modbus-debian:/home/andrzej# fdisk /dev/sdd

Command (m for help): o
 
Building a new DOS disklabel with disk identifier 0xa5017fba.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

 
Command (m for help): p
Disk /dev/sdd: 990 MB, 990904320 bytes
32 heads, 63 sectors/track, 960 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes
Disk identifier: 0xa5017fba
Device Boot Start End Blocks Id System

 
Command (m for help): n
 
Command action
e extended
p primary partition (1-4)
p

 
Partition number (1-4): 1
First cylinder (1-960, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-960, default 960):
Using default value 960
Command (m for help): p
Disk /dev/sdd: 990 MB, 990904320 bytes
32 heads, 63 sectors/track, 960 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes
Disk identifier: 0xa5017fba
Device Boot Start End Blocks Id System
/dev/sdd1 1 960 967648+ 83 Linux

 
Command (m for help): w
 
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
modbus-debian:/home/andrzej#
modbus-debian:/home/andrzej# mkfs.ext3 /dev/sdd1
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
60544 inodes, 241912 blocks
12095 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=251658240
8 block groups
32768 blocks per group, 32768 fragments per group
7568 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
 
Mount new partitions
 
$sudo mkdir /mnt/arm
$sudo mount /dev/sdd1 /mnt/arm
 
Install debootstrap
 
This will uncompress the archive into the new ext3 partition on the pendrive
 
$cd /mnt/arm
$sudo tar zxf /opt/debootstrap/emdebian-grip.tar.bz2
$sync
 
 
Finishing the phase 1
 
The file system needs to be configured , so we do that with a root shell into the target directory.
Be VERY careful not to use any leafing / in your paths!!
 
$cd /mnt/arm
$echo "proc /proc proc none 0 0" >>etc/fstab
$echo "EP9302" >etc/hostname
$mknod dev/console c 5 1
$mknod dev/ttyAM0 c 204 16
$echo 'http://www.emdebian.org/grip/ lenny main' >>etc/apt/sources.list
 
Now we can boot the system Insert the pendrive in USB1 slot at CS-E9302 board.
In minicom window type :
 
RedBoot> load -r -v -b 0x80000 zImage                                                                    
RedBoot> exec -c "console=ttyAM root=/dev/sda1 init=/bin/sh rootdelay=5"
 
Eventualy, you should arrive at a naked shell prompt -
 
sh-3.2#                                                                                                                               
 
Second Stage Install
 
Do this to finish the debian install.
It will take a rather long time, so be patient !
 
sh-3.2# mount /proc /proc -t proc                                                                                 
sh-3.2# export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
sh-3.2# /debootstrap/debootstrap --second-stage                                                  
 
Wait (long time)
 
Warning - udev might give you some warnings, in which case you might have to reinstall it by command :
 
sh-3.2# dpkg -i /var/cache/apt/archives/udev_0.125-7em1_arm.deb
 
End stage install
 
In minicom type
 
sh-3.2# echo ttyAM0 >>etc/securetty
sh-3.2# printf "T0:123:respawn:/sbin/getty 57600 ttyAM0\n" >>etc/inittab
 
and for DHCP configuration
 
sh-3.2# printf "auto eth0\niface eth0 inet dhcp\n" >>etc/network/interfaces
 
Restart the CS-E9302 board.
Stop the RedBoot script and type
 
RedBoot> fis load zImage RedBoot> exec -c "console=ttyAM root=dev/sda1 rootdelay=5"
 
Log to the system as root (from minicom window) and set new password.
Update the system :
EP9302:~# apt-get update
EP9302:~# apt-get upgrade
 
If the kernel is stable, and we want to boot up the kernel when power on, we must write the zImge to Flash memmory.
 
Restart the CS-E9302 board.
Stop the RedBoot script and type
 
RedBoot> fis delete zImage RedBoot> load -r -v -b 0x80000 zImage
RedBoot> fis create -b 0x80000 -l 0xXXXXXX zImage
 
Where 0xXXXXX is the value of the zImage lenght.
 
Now we have working Linux on CS-E9302 board.