Wednesday, May 27, 2009

Porting Linux 2.6.13 on LN2410

















Introduction

There are many blog on net which are introducing porting Linux on LN2410,I tried their way,I was able to boot linux and filesystem, however I was not sucessfull in enabling the touch screen driver on the board.This is an attempt to fill those gap.

Before we start with setting the enviroment we need to ensure that we have all the necessary source code and bineries required to set up the host enviroment are availble on the system.

Download Files
Cross compiler
gnu-arm-2005QIB-arm-none-linux-gnueabi-i686-pc-linux-gnu-1.tar.bz2
cross-2.95.3.tar.bz2

Linux Source code:
linux-2.6.13.2.tar.bz2


Patch for LN2410
patch-2.6.13.2-ln2410sbc-0.6.gz


We need to one more patch to enable the touch screen funtionality,this is created by Mr. Ragrot and can be downloaded from below link
Patch for LN2410 by Mr. Ragrot
ln2410sbc-lc6-patch-rag-04-28-07.bz2

UBoot source
uboot-1.1.1-ln2410sbc-0.3.tar.gz


Microwindows
a. microwindows-0.90.tar.gz
b. microwindows-fonts-0.90.tar.gz
c. patch-0.90-lc1.gz


Root file system
LN2410disk.gz


The kernel compilation steps :
a. Environment.
b. Compilation.
c. Flashing to Memory.

a. Environment
extract 'gnu-arm-2005QIB-arm-none-linux-gnueabi-i686-pc-linux-gnu-1.tar.bz2' to /usr/local/arm/release-3.4.3
$setenv GCC_ARM_HOME /usr/local/arm/release-3.4.3
$set path=($GCC_ARM_HOME/bin:/$path)
b. Compilation
Extract the kernel and apply above two patches
# bunzip2 -dc linux-2.6.13.2.tar.bz2 | tar xvf -
# gzip -dc patch-2.6.13.2-ln2410sbc-0.5.gz | (cd linux-2.6.13.2;patch -p1)
# bunzip2 -dc ln2410sbc-lc6-patch-rag-04-28-07.bz2 | (cd linux-2.6.13.2;patch -p1)
# cd linux-2.6.13
# make menuconfig
# make
If it is a successful compilation you will have zImage file in arch/arm/boot directory.
extract the uboot source
# cd uboot-1.1.1
# cd tools
#./mkimage -A arm -T kernel -O linux -a 0x30f00000 -e 0x30f00000 -n "Linux 2.6.13" -d /path/to/zImage /path/to/zImage.bin
c. Flashing it to memory
LN2410 To Download zImage.bin onboard DRAM through serial port.
Go to terminal type 'kermit' to now to get the uboot command line type 'connect'
I assume that you have installed the kermit and configured it.
To return to kermit prompt by pressing 'Ctrl + \' and 'u'
To send a file from kermit prompt type send /zImage.bin
LN2410SBC # loadb 0x31000000
transfer the file with Kermit, it takes a few minutes.
now return to uboot prompt and type
LN2410SBC # erase 1:7-33
This erase the sectors from 7 to 33
Copying zImage from DRAM to Flash:
LN2410SBC # cp.b 0x31000000 0x40000 /* source, destination, size */

The File system compilation steps :
a. Environment.
b. Microwindows Compilation.
c. Copy the root filesystem to host

a. Environment

extract 'cross-2.95.3.tar.bz2' on /usr/local/arm/2.95.3
$setenv GCC_ARM_HOME /usr/local/arm/2.95.3
$set path=($GCC_ARM_HOME/bin:/$path)
b. Microwindows Compilation
i. Install microwindows-0.90, fonts and patch
$ tar xvfz microwindows-0.90.tar.gz
$ cd microwindows-0.90 /src
$ tar xvfz ../../microwindows-fonts-0.90.tar.gz
$ cd ../..
$ gzip -cd patch-0.90-lc1.gz | (cd microwindows-0.90; patch -p1)
ii. Build and install binaries
$ cd microwindows-0.90/src
In config file do the following changes
ARMTOOLSPREFIX = arm-linux-
In Mouse driver section
NOMOUSE =N
IPAQMOUSE =Y
For PCF font error:
Modify: HAVE_PCF_SUPPORT = N
HAVE_PCFGZ_SUPPORT = N
PCF_FONT_DIR = “fonts/pcf”.
$ which arm-linux-gcc /* make sure tool is available */
/usr/local/arm/2.95.3/bin/arm-linux-gcc
$ make
$ mkdir ../install
$ make INSTALL_PREFIX=../install install
iii. Create new file system
Copy files from RAMdisk image to new disk image
$ unzip LN2410disk.gz
$ mount -o loop LN2410disk olddisk
$ mkdir newdisk
$ copy -a olddisk/* newdisk
iv. Copy Microwindows binary files to new disk
$ copy -a microwindows-0.90/install/* newdisk
c. Root filesystem on host(SD MMC card or USB drive)
See me blog on 'Root file system on SD-MMC card' for details


Boot kernel:
LN2410SBC # bootm 0x40000


Running NANO-X/Micro-windows
On BusyBox shell window,type following commands to start Nano-X
$ mknod /dev/null c 1 3
$ mknod -m 660 /dev/h3600_ts c 13 128
$ mknod -m 666 /dev/h3600_tsraw c 13 144
$ nano-X & /* start nano-X server */
$ nanowm & /* Window manager */
$ nxcal & /* touch screen calibration tool */
$ ntetris & /* play tetris! */

Saturday, May 2, 2009

Porting cURL Library on LN2410

Introduction
cURL library allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP's ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.
In this section is about how to compile curl in the host
environment and put it them on target machine.

Configuration and Installation
Download and unpack the
cURL package.
Source code of cURL can be obtained from http://curl.haxx.se/download.html
'
cd' to the new directory. (e.g. cd curl-7.12.3)

Now call the configuration script,Be sure and specify the '--host' and
'--build' parameters at configuration time.
The following script is cross-compiling for ARM9 processor using the
cross tool chain 'cross-2.95.3.tar.bz2' on
RedHat Linux.
(Other tool chains has library linking issues)

./configure --prefix=/root/curl --build=i686-pc-linux-gnu --host=arm-linux --target=arm-linux CC=/usr/local/arm/2.95.3/bin/arm-linux-gcc
The '--prefix' parameter
specifies where
cURL will be installed.
CC parameter is the cross compiler toolchain path.
If 'configure' completes
successfully, do 'make' and 'make install' as usual.


Copying the binaries and libraries to root file system
Once the make install is sucessfull,copy the binaries and libraries in curl folder to bin and lib folder respectively on root file system.
now test the libary on the commad line by typing 'curl url'
I got html page as a response when I typed 'curl http://192.168.1.1' on the shell.

[root@test Linux]# curl http://192.168.1.1
401 Unauthorized401 Unauthorized401 Unauthorized401 Unauthorized







Sunday, April 19, 2009

Root filesystem on SD MMC card


Introduction :
Hacking Linux kernel for LN2410 Single board computer

Here I would like to share my experience in porting root File system on the SD MMC card,and configuring the kernel to use it

I have done it in following steps
1. Setting up the environment
2. Kernel compilation and loading it to NOR flash
3. preparing the SD MMC card and File system.
4. Copying the rootfs to SD MMC Card


Requirements :
Toolchain :
gnu-arm-2005QIB-arm-none-linux-gnueabi-i686-pc-linux-gnu-1.tar.bz2
Kernel:
linux-2.6.13.2-lc6.tar.gz
File system:
LN2410disk.gz (provided by vendor)

Setting up the environment:
-Extract the tool chain and update the environment.
Please follow these steps
create an arm folder in "/usr/local" and extract the binaries in this folder
#mkdir /usr/local/arm
#cd /usr/local/arm
#tar –jxvf gnu-arm-2005QIB-arm-none-linux-gnueabi-i686-pc-linux-gnu-1.tar.bz2
update the shell environment by adding the following in .bashrc file
export PATH=$PATH:/usr/local/arm/bin


Kernel compilation and loading it to NOR flash

a. Extract the kernel source and compile it using the menuconfig option.
# tar xvzf linux-2.6.13.2-lc6.tar.gz
#make menuconfig -------- for configuring kernel
CONFIG_CMDLINE="root=/dev/mmcblk0p1 rootfstype=ext2 console=ttySAC0 rw"(kernel command line we used)
In the Kernel command line we convey in command line the type of filesystem, the partition on which the root file system is available
Under character device driver section do select the
<*> MMC support
[ ] MMC debugging
<*> MMC block device driver
< > Winbond W83L51xD SD/MMC Card Interface support
<*> Samsung S3C2410 Multimedia Card Interface support
#make ---------- u will get zimage in (./arch/arm/boot/zimage)
Once the Image is ready copy this image using the following commands.
LN2410SBC # loadb 0x31000000 (Using Kermit send the zimage.bin )
Once the image is copied the size of byte is indicated in the terminal
LN2410SBC # erase 1:7-33
LN2410SBC # cp.b 0x31000000 0x40000 size

preparing the SD MMC card and File system.

# fdisk /dev/sda
To create a new partition that will use up the whole free space, use the command sequence
like this:
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1011, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1011, default 1011):
Using default value 1011

prepare /dev/sda1 for ext2 filesystem
mkfs.ext2 /dev/sda1



Changes in the kernel command line argument
#make menuconfig -------- for configuring kernel
and in CONFIG_CMDLINE="root=/dev/sda1 rootfstype=ext2 rootdelay=10 init=/linuxrc rw"

Coping the rootfs to SD MMC Card

#gzip -dc LN2410disk.gz
#mkdir olddisk
#mount -o loop LN2410disk olddisk
Now mount the newly created partition on SD MMc card on /mnt
#mount /dev/sda1 /mnt
#cp -rf olddisk/* /mnt
Now connect SD MMC card on LN2410 board.

Restart the board and type loadm 0x40000 on shell prompt.

Now the Kernel will mount the file system from SD MMC card!!