Monday, 13 January 2014

Compiling uClinux with kernel linux-2.6.21

Hello everybody!

In my previous post i mentioned that we need LINUX platform or Linux in Vmware to compile and build uClinux kernel and i suggested u to use Vmware coz sometime we need flashmagic software to flash u-boot...(which runs on windows)
So, its ur choice....

I'm following some instructions from Embedded Artists to build my own toolchain, compile and upgrade board's u-boot. I'm working with Ubuntu 12.04(as i told its ur choice..).

Today I'll show you what I did to compile the kernel.. First of all I'm       assuming that you have already read Getting started with uClinux.
                                                     Now let's begin the hard work! =D


Steps:Follow these steps on linux platform, I m doing these on Ubuntu 12.04

1) Download all these packages:      
  - uClinux-dist-20070130.tar.gz                      
  - ea-uClinux-081020.diff.gz                       
  - ea-v3_1_incr1.diff.gz
  - linux-2.6.21.tar.gz
  - arm-linux-tools-20061213.tar.gz
  - arm-elf-tools-20040427.sh
  - mkimage (used to generate uLinux.bin)

or

 You can download all  above packages in one shot..
  click                  -EADevEnv_v3_1
  after downloading unzip this package....


2) untar toolchain 1. (It will untar in the same directory where you download it. I add this path to the $PATH)



1. tar -zxvf arm-linux-tools-20061213.tar.gz

2. export PATH=$PATH:path-to-the-download-directory/usr/local/bin

Note: You can either move this directory to a directory in the PATH or add the path into the $PATH in your /home/user/.bashrc. In this way you don't have to export everytime you open a new console.

install toolchain 2.


./arm-elf-tools-20040427.sh 

I had a problem when installing this toolchain. If you get an error too, edit this file and try changing:


tail +${SKIP} ${SCRIPT} | gunzip | tar xvf -

by



tail -n +43 ${SCRIPT} | gunzip | tar xvf - 


Copy mkimage to /usr/local/bin and set it as executable



sudo chmod +x /usr/local/bin/mkimage


3) untar uClinux and then remove old kernel






1. tar -zxvf uClinux-dist-20070130.tar.gz

2. rm -r ./uClinux-dist/linux-2.*


4) untar linux-2.6.21 and move it to uClinux-dist


1. tar -zxvf linux-2.6.21

2. mv ./linux-2.6.21 ./uClinux-dist/linux-2.6.x


5) apply both patchs


1. cd ./uClinux-dist

2. gunzip -c ../ea-uClinux-081029.diff.gz | patch –p1

3. gunzip -c ../ea-v3_1_incr1.diff.gz | patch –p1


6) Configure & Compile.

a) Choose vendor Embedded Artists and board LPC2468
b) Disable i2c in device drivers > I2C support > <> I2C support


1. make menuconfig

 
- Change vendor to Embedded Artists (“Select the Vendor you wish to target”).
    Vendor/Product Selection -->Vendor--> EmbeddedArtists
- Select your board configuration (“Select the Product you wish to target”).
  
- Click Exit followed by Exit once more and then click the Yes button when asked to save the kernel         configuration.
 - Now it is time to build μClinux

2. make ARCH=arm CROSS_COMPILE=arm-elf- 

After make, you will get an error. You must include <linux/limits.h>  in the file ./linux-2.6.x/scripts/mod/sumversion.c. Make again and go take a coffee...
The images will be in the folder ./images
When the build has finished successfully the kernel and file system images will be available in the uClinux-dist/images directory.


-rw-r--r--  1 user user 1012K 2011-06-14 14:13 cramfs.img
-rw-r--r--  1 user user  4.2M 2011-06-14 14:13 image.bin
-rw-r--r--  1 user user     0 2011-06-14 14:13 jffs2.img
-rwxr-xr-x  1 user user  162K 2011-06-14 14:13 linux.data
-rw-r--r--  1 user user  1.1M 2011-06-14 14:13 linux.gz
-rwxr-xr-x  1 user user  2.1M 2011-06-14 14:13 linux.text
-rw-r--r--  1 user user  1.9M 2011-06-14 14:13 romfs.img
-rw-r--r--  1 user user  1.1M 2011-06-14 14:13 uLinux.bin

It's weird that we need 2 toolchain... I don't know why, but arm-linux- is used to compile the kernel (actually the kernel complains that the toolchain arm-elf is too old). It has been forced to, even if you set CROSS_COMPILE=arm-elf-. The rest is compiled with arm-elf-, so, be sure that both toolchain is in the path.

Until today, jffs2 file system can't be generated following these instructions. I'll check later! =D

Next post we'll update u-boot and boot the kernel! Wait and you'll see! =D
That's all !!
Abhishek Mourya

2 comments:

  1. hi Abhishesk ,
    Am struck in executing the shell script ,

    ./arm-elf-tools-20040427.sh
    initially i got error as you have mentioned.
    But as per your steps i changed line 40 of script to the
    tail -n +43 ${SCRIPT} | gunzip | tar xvf -
    but i see below errors now .


    ./usr/local/arm-elf/

    > ./usr/local/arm-elf/bin/

    > ./usr/local/arm-elf/bin/nm

    > ./usr/local/arm-elf/bin/strip

    > tar: Skipping to next header

    > gunzip: stdin: invalid compressed data--format violated

    > tar: Error exit delayed from previous errors

    let me know if you have any workarounds for the situation.

    Thanks in advance
    Sachin


    ReplyDelete
    Replies
    1. Hello Sachin,
      Sorry for replying late :| I was on vacation.

      I think your download arm-toolchain tar file is corrupted.
      Try to download again.

      Let me know if u r finding any difficulties.

      Regards,
      Abhishek Mourya

      Delete