Search This Blog

Wednesday, October 9, 2013

Developing Linux OS for ARM - Part III

Hello. I am back. Its really very long time to pen down where I have stop. I will continue with PART III of developing Linus OS for ARM.

As we already configure primary bootloader AR91Bootstrap in PART II. Its time to configure a secondary bootloader.

In most cases, U­Boot is the secondary bootloader, which is in charge of downloading kernel binaries from FLASH, SD/MMC, USB or ethernet and starting the kernel.

Download the secondary bootloader (U­boot). It can be downloaded
from the following link:

ftp://ftp.denx.de/pub/u-boot/


we will download the u­boot­1.3.4.tar.bz2 at the following path:

/home/sanket/Download/Embedded_Linux_Complete/Sources/u­boot.

Extract the same in the current directory.

Download u­boot patch provided by the AT91 community from the below mentioned link:

ftp://www.linux4sam.org/pub/uboot/u-boot-1.3.4-exp/u-boot-1.3.4-exp.diff

 
Creating a patch is a standard way of adding newly generated code to a large existing code base. It is created by comparing the updated code with the code base for which the patch is to be generated.

Save this to the ~/Embedded_Linux_Complete/Sources/u­boot/u­boot­1.3.4.

/u-boot-1.3.4$ ls

Apply it (patch) on top of the original u­boot in the following way:

/u-boot-1.3.4$ cat u-boot-1.3.4-exp.diff | patch -p1

Once the AT91 u­boot sources  are available, cross­compiling u­boot can be done in two steps : configuration and compiling. Note that both arm­elf­ and arm­linux­ ARM GCC cross­compiler types are suitable for u­boot building. We will use arm­none­-linux­-gnueabi­-gcc.

Here are the building steps for the AT91SAM9260EK board:

/u-boot-1.3.4$ make CROSS_COMPILE=/home/sanket/Download/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin/arm-none-linux-gnueabi- distclean

distclean command removes the binaries and object files files that 'configure' created. Distclean is like make clean with the exception that make clean removes all the files created by make, where as distclean removes all files that are created by make config.

The U­boot can be made to reside on any of the following storage media: Data flash/NAND flash/NOR flash. In our case we are using the dataflash, but NAND flash can also be used since AT91Bootstap supports both. The AT91Bootstrap will pass the environment variables to U­boot while it tries to bring U­boot up.

So while we compile U­boot we will configure it for Dataflash.

/u-boot-1.3.4$ make CROSS_COMPILE=/home/sanket/Download/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin/arm-none-linux-gnueabi- at91sam9260ek_dataflash_cs1_config

These environment variables includes the IP address setting of the host, the server from which U­boot would tftp to retrieve some packages and more. When U­boot is up and running on our board we will try and view all these environment variables.

NOTE: In our case, the software packages have been made to reside in the dataflash. In some cases, they might reside in NAND Flash or NOR flash. While compiling u­boot the environment variable location needs to be choosen accordingly. 

To compile u­boot after configuration,

/u-boot-1.3.4$ make CROSS_COMPILE=/home/sanket/Download/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin/arm-none-linux-gnueabi- 

If the compilation goes well, a uboot.bin file would be generated in your current directory which would be ultimately flashed to the dataflash using a software utility called SAM­BA (Burning Application for SAM controllers).

Once the bootloader is in place, next step would be to build a kernel image. That we would be discussing in my next post.


continue................





2 comments:

  1. Welcome back...good to hear from you after long time

    ReplyDelete
  2. Hey hii... Nice blog....
    Nice to know its possible and easy too... :)

    ReplyDelete