How to configure Linux for EM2440/MINI2440 board with S3C2440 processor.     


Step by step how to configure and compile Linux kernel for EM2440/MINI2440 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, uboot source for the board and the toolchain.


Type in the Linux terminal :

$ cd /opt
$ mkdir mini2440
$ cd mini2440
$ mkdir uboot
$ mkdir kernel-src
$ cd kernel-src
$ git clone git://repo.or.cz/linux-2.6/mini2440.git
$ cd ..
$ cd uboot
$ git clone git://repo.or.cz/u-boot-openmoko/mini2440.git
$ cd ..
$ wget http://www.codesourcery.com/sgpp/lite/arm/portal/package3696/public/arm-...
$ tar xjf arm-2008q3-72-arm-none-linux-gnueabi-i686-pc-linuxgnu.tar.bz2

Create a TFTP server directory

$ mkdir /tftpboot

Now we build the uboot and Linux Kernel.


$ export CROSS_COMPILE=arm-none-linux-gnueabi-
$ export CC=${CROSS_COMPILE}"gcc -march=armv4t -mtune=arm920t"
$ export PATH=$PATH:/opt/mini2440/arm-2008q3/bin
$ export ARCH=arm
$ cd uboot/mini2440
$ make mini2440_config
$ cd /opt/mini2440
$ cd /opt/mini2440/kernel-src/mini2440
$ make mrproper
$ cp /opt/mini2440/kernel-src/mini2440/arch/arm/configs/mini2440_defconfig /opt/mini2440/kernel- src/mini2440/.config
$ make menuconfig

At this point should show a Linux configuration screen.


You can add additional functions to the kernel.



Make the kernel image

$ make -j4
$ make ARCH=arm -j4 modules modules_install

Convert the zImage to uImage and put into the TFTP server directory.

$ cd /opt/mini2440
$ ./uboot/mini2440/tools/mkimage -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 -d kernel-src/mini2440/arch/arm/boot/zImage /tftpboot/uImage

Download the script to create the kernel and uboot.

Download configuration file for uboot.

Now we can download the kernel image to the EM2440/MINI2440 board.


Step by step how to download kernel to EM2440/MINI2440 board


OK. We have the kernel image created. Now 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

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

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 : 115200
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 :
U-Boot 1.3.2-mini2440 (Nov 25 2009 - 11:22:39)          
I2C: ready                                              
DRAM: 64 MB                                             
Flash: 2 MB                                             
NAND: 64 MiB                                            
Found Environment offset in OOB..                       
USB: S3C2410 USB Deviced                                
In: serial                                              
Out: serial                                             
Err: serial                                             
MAC: 08:08:11:18:12:27                                  
Hit any key to stop autoboot: 0

When power on, after 5 seconds, the default script will be runned.
Press any key to stop this procedure.
We set-up the environment variables by following commands:
MINI2440 # setenv serverip
MINI2440 # setenv ipaddr
MINI2440 # setenv bootfile uImage
MINI2440 # setenv loadaddr 0x32000000
The serverip is the IP address of the TFTP server, the ipaddr is static address for the board.
Save the configuration in flash :
MINI2440 # saveenv
Now we can download the kernel image from TFTP server :
MINI2440 # tftp
Start the boot from memory :
MINI2440 # bootm
If everything is okay you should see in minicom text similar to that : 
## Booting kernel from Legacy Image at 32000000 ...
Image Name:
Created: 2009-12-28 18:01:54 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
1f01 128 mtdblock1 (driver?)
1f02 5120 mtdblock2 (driver?)
1f03 60032 mtdblock3 (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.
   Step by step how to build a root file system for EM2440/MINI2440 board    
Now bootstrap an armel 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=armel --foreign lenny grip/ http://www.emdebian.org/grip/
$cd grip
$tar jcf ../emdebian-grip.tar.bz2 .
SD card preparation
I'm using the micro microSD card with USB reader, but you can use any SD card 1GB -4GB.
Insert your SD in the host.
You can detect what device name it is mapped on by typing :
$fdisk -l
In the example the SD 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)

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# 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
$mkdir boot
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 "EM2440" >etc/hostname $mknod dev/console c 5 1
$mknod dev/ttySAC0 c 204 64
$echo 'http://www.emdebian.org/grip/ lenny main' >>etc/apt/sources.list
$cp /tftpboot/uImage /mnt/arm/boot
Now we can boot the system Insert the SD card in the MMC slot at EM2440/MINI2440 board.
Restart the board and set new configuration
MINI2440 # setenv "bootcmd=mmcinit;ext2load mmc 1:1 0x32000000 /boot/uImage;bootm"
MINI2440 # setenv "bootargs=console=ttySAC0,115200 noinitrd root=/dev/mmcblk0p1 ip=dhcp init=/bin/sh rootwait=5"
MINI2440 # saveenv
Restart the board 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_armel.deb
End stage install
In minicom type
sh-3.2# echo ttySAC0 >>etc/securetty
sh-3.2# printf "T0:123:respawn:/sbin/getty 115200 ttySAC0\n" >>etc/inittab and for DHCP configuration
sh-3.2# printf "auto eth0\niface eth0 inet dhcp\n" >>etc/network/interfaces
Restart the EM2440/MINI2440 board, stop the boot script.
MINI2440# setenv "bootargs=console=ttySAC0,115200 noinitrd root=/dev/mmcblk0p1 ip=dhcp rootwait=5"
MINI2440# saveenv
Restart the board Log to the system as root (from minicom window) and set new password.
Update the system :
MINI2440:~# apt-get update
MINI2440:~# apt-get upgrade
Now we have working Linux on EM2440/MINI2440 board !!!