Saturday 8 February 2014

Bootloader for Embedded Linux !!

Hi all...

I hope you all are doing well. Today I'll discus about boot loader in general, we will discuss how boot loader works.. and also we'll try to build boot loader for our board(I am using beagle bone black... ).


BOOTLOADER In my uClinux posts(January's posts) we already have discussed about basic information of boot loader. New viewers click here to know about an introduction of boot loader.
 

Building U-boot for our target :  My target board is Beagle Bone black and i am building u-boot loader for this board. Below are the steps to build u-boot image for our target. In case you have other development board the steps will be same but at the time of configuration we have to build config file according to our board which i'll specify at that time. So lets begin... :)

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

1)Download all these packages:
 -u-boot-2013.10 Its a u-boot source code for latest version
 -0001-arm-omap-i2c-don-t-zero-cnt-in-i2c_write.patch This is a patch file for Beagle bone board. In case you are using other board you have to search for patch specific to your board.

2) Go where you downloaded all u-boot tar packages
   $ cd /home/<user>/download 

3) untar U-boot package in the same folder
   $ tar –xjvf  u-boot-2013.10.tar.bz2

4) Change directory to the u-boot directory.
   $ cd u-boot-2013.10

5) Apply the u-boot patch
   $ cat   ../0001-arm-omap-i2c-don-t-zero-cnt-in-i2c_write.patch | patch –p1

6) Set ARCH and CROSS_COMPILE variable to your current terminal...
  $ export ARCH=arm
  $ export CROSS_COMPILE=arm-linux-

7) Select board configuration. In this example I am selecting the configuration for the Beagle bone board.
   $ make omap3_beagle_config 


In case you have different board,  first see on to the kernel Is there any config file is present or not which  matches to your board :)

For seeing config file present in kernel type..

$ make help


It'll give you all pre-configured architecture if it matches to your board then select it :)


8) Now it is time to compile the u-boot.
   $ make

9) When the build has finished successfully a binary file named u-boot.bin will be
available in the u-boot-1.1.6 directory.

10) Convert the bin file to a hex file.
   $ arm-linux-objcopy –I binary –O ihex u-boot.bin u-boot.hex

This u-boot.hex is a final image of u-boot loader... yes we got it !!

In my next post i'll show you how to flash this u-boot.hex file into your target machine and how to run....

That's all... njoy!!

Abhishek Mourya

7 comments:

  1. Hi Abhi,
    Do u have any idea about Redboot sequence and how it will works,please let me know i have few questions on this.

    Thanks,
    Ravindar

    ReplyDelete
    Replies
    1. Hello Ravin, I will update very soon about red boot sequence :)

      Delete
  2. Nice work dude... keep going. :)

    ReplyDelete
  3. Compiling is very easy but writing config code according to requirement and board is equally hard so kindly help me to config code and also to write my custom memory testing code during boot

    ReplyDelete
    Replies
    1. ya Akhilesh compiling is quite easy.... I am very new in device drivers n so many frnz who r well familiar with UNIX and UNIX system programing but dont know the concept of kernel compiling... this info is very useful.
      n we will keep trying :)
      n i hope in few days we will try to write our own config for custom board.... so keep trying n keep in touch :)

      Delete
  4. This comment has been removed by the author.

    ReplyDelete