Search

Cross Compiling linux for ARM

Cross compiling Linux 2.6.34 for arm (Innovate solutions ARM926 Kit).

1. Download the kernel from http://kernel.org/
2. untar the file to any location of your preference
3. Download and install the latest cross compiling tool chain from http://www.codesourcery.com/sgpp/lite/arm
4. Get the path to the directory where the "gcc" cross compiler is present.
    For Eg : Codesourcery by default installs it in
        /root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gcc
5. Go to the directory where you have untarred the kernel that you want to compile.
6. run the command
              make defconfig
7. This should generate a default ".config" file in your present directory, taking the configuration from your currently installed system.
8. To compile the kernel for arm, run make as follows
    make ARCH=arm CROSS_COMPILE=/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-
gnueabi-

Note that gcc has been omitted from the path to the cross compiler, that is because "gcc" would already have been set as the default compiler for the host.

9. This will generate a zImage in the arch/arm/boot folder.

10. In case you are using a U boot loader then you would need a uImage, to generate a uImage just add uImage when you run the make command i.e.

 make ARCH=arm CROSS_COMPILE=/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-
gnueabi- uImage.

This will generate a uImage for ARM, in arch/arm/boot. 

10. To make sure you have compiled the files for ARM, you can check any of the object files in the drivers folder with  command "file", for eg: 
file drivers/usb/storage/usb.o 
you should see output similar to the following. 

drivers/usb/storage/usb.o: ELF 32bit LSB Relocatable,ARM,Version 1,not stripped  

11. A uImage generated using the config file generated from make defconfig, would genreally be around 10MB. This is quite  a huge file in case you are planning to port it on to an ARM board. 

12. To reduce the size of the uImage you can run "make menuconfig" and disable all the drivers that you  feel are not needed. There will be a kernel and a .config file that would have come with your kit, you can refer to that to decide what config options are required. 
  In case make menuconfig is not working, the open the .config file in any text editor and comment out the config options that  you don't want to compile and then run the make command as shown above again.

13. In case you are adding your own driver module, than make sure to include it in the config file and the respective makefiles. 

Problem faced during the cross compilation of 2.6.34

You might get an error saying wrong value for __bad__udelay or some thing similar.

Workaround: 

In the files mentioned below, modify the value of all the udelay() greater than 200 to a value less than 2000. 1500 worked for me. 

atp870u.c in drivers/scsi
nsp32.c   in drivers/scsi
sungem.c  in drivers/net/



Follow by Email