Search This Blog

Saturday, March 26, 2011

Developing Linux OS for ARM - Part II

With the previous understanding of Part I, the first thing that you need to get is the toolchain. The toolchain might be available in source form as well as in the form of a binary. To avoid the effort of compiling the toolchain, we will start off with a binary. CodeSourcery provides regular, validated releases of the GNU Toolchain for arm processor. The version of the toolchain that we are using can be downloaded from the following link:

http://www.codesourcery.com/public/gnu_toolchain/arm-none-linux-gnueabi/arm-2007q1-10-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

After downloading this package, extract it to some location (In my case, I have pasted at the following path: /home/sanket/Downloads/Embedded_Linux_Complete/Packages/GNU_GCC_toolchain).


Download the AT91Bootstrap source from the following link:
ftp://www.linux4sam.org/pub/at91bootstrap

The AT91Bootstrap sources will differ based on the media where the secondary level bootloader is located. In our case, we want our secondary bootloader to be loaded in the dataflash and hence we will download the corresponding package. Alternate option for the secondary level bootloader would have been NAND flash.
Extract the AT91Bootstrap source, change to the board directory as shown below:

$cd AT91Bootstrap/Bootstrap-v1.10/board/
$ls

at91cap9adk     at91sam9261ek     at91sam9g20ek     at91sam9xeek
at91sam9260ek     at91sam9263ek     at91sam9rlek

Select your board by going into the corresponding board directory.

/board$ cd at91sam9260ek/
/board/at91sam9260ek$ ls


at91sam9260ek.c    dataflash    nandflash

Select your media by going into the corresponding directory. In our case the media for the secondary bootloader would be dataflash.

/at91sam9260ek$ cd dataflash/
at91sam9260ek/dataflash$ ls

at91sam9260ek.h       dataflash_at91sam9260ek.elf       Makefile
dataflash_at91sam9260ek.bin      dataflash_at91sam9260ek.map

dataflash$ make clean

rm -f *.o *.bin *.elf *.map

Before building the sources, check out the location of your compiler toolchain. In
my case, it is

/home/sanket/Downloads/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin


While running make we would be specifying the entire path. This is required if you have not installed the toolchain. In our case, instead of installing we have just extracted the tar ball image of the toolchain and hence we need to specify the path as shown below:

/dataflash$ make CROSS_COMPILE=/home/sanket/Downloads/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin/arm-none-linux-gnueabi-

If everything is fine (compiler path and bootstrap source) a binary file (dataflash_at91sam9260ek.bin) will be generated in the current directory at the end of the compilation process.


/dataflash$ ls

at91sam9260ek.h        crt0_gnu.o        dataflash_at91sam9260ek.elf
dataflash.o     div0.o    main.o    pmc.o    string.o _udivsi3.o
at91sam9260ek.o    dataflash_at91sam9260ek.bin  

dataflash_at91sam9260ek.map    debug.o     gpio.o    Makefile    
sdramc.o     udiv.o      _umodsi3.o


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

Saturday, February 12, 2011

Developing Linux OS for ARM - Part I

The first thing that you possibly need to do after getting your hardware ready is to install the necessary software packages and toolchain on the host system (PC).These packages would be required to compile and download/burn packages on to your target platform (ARM9/any embedded controller). We would be talking specifically about the AT91SAM9260 from ATMEL, which is an ARM9 based architecture giving 200MIPS at 180MHz. Although AT91SAM9260 would be our target controller, most of the software components that we discuss would apply to all target platforms. The lower level softwares like the primary level bootloader would be architecture specific. The AT91SAM9260, also known as Smart ARM based controllers (aka SAM) is based on the integration of an ARM926EJS processor with fast ROM and RAM memories and a wide range of peripherals. The AT91SAM9260 embeds an Ethernet MAC, one USB Device Port, and a USB Host controller. It also integrates several standard peripherals, such as the USART, SPI, TWI, Timer, Counters, Synchronous Serial Controller, ADC and MultiMedia Card Interface. Primarily for porting the conventional Linux, we would need MMU support in hardware. ARM9 based MCUs feature an MMU (unlike most ARM7 MCU) and hence we do not need to use some other stripped down Linux variants like uCLinux which can be ported to MMU less architectures.

The following would be the software components required to get Linux running on the target system : 

Root filesystem

Linux Kernel
Bootloader
Hardware (MCU)


Bootloader :

The bootloader can be further classified into:

1. Primary bootloader: This might typically reside onchip (internal flash). In case of AT91SAM9260, a component called ROMboot enables us to dump the primary bootloader to the on chip flash. The primary bootloader is called AT91Bootstrap. A primary bootloader is needed for configuration of CPU parameters like clock frequency, incharge of hardware configuration, download UBoot (secondary bootloader) from FLASH to SDRAM and start the bootloader.

2. Secondary bootloader: In most cases, UBoot is the secondary bootloader, which is in charge of downloading kernel binaries from FLASH, SD/MMC, USB or ethernet and starting the kernel.

Once the bootloader has loaded the kernel in the memory, the operating system kernel will then takeover control of the hardware. The kernel comprises of the scheduler and the device drivers. The other utilities provided by any standard OS distribution are not a part of the kernel space. The Root filesystem contains applications which are executed on the target, using the OS kernel services. It forms the user space. Its primarily an archive of utilities like cat, ftp, vi, gedit, ls etc


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




Saturday, January 15, 2011

Difference between ARM and Intel Processor

The world of CPUs is a dark, deadly, and dangerous place. After all, the CPU is said to be the literal “heart” of the PC – and as such, it’s the single most-heavily engineered component. Billions of dollars and manhours have gone into the design of these various chipsets and they’ve all been researched, optimized, fabricated, and sold in order to make your computer… better.

The biggest difference between these platforms is the design dogma they follow. The x86 is a CISC architecture: Complex Instruction Set Computer. The ARM is a RISC-based designs: Reduced Instruction Set Computer.

CISC architectures can have up to thousands of individual commands supported by the processor that can be used in machine code. Each of these assembly commands can range from a single operation to several hundred or more in length. On the other hand, RISC-based CPUs understand only a handful of different instructions, the minimum necessary to get the job done.


However, this in no way means that CISC is more powerful or that RISC is limited. The difference between the ARM and Intel can be explained with booting process of an OS.

In the Intel x86 architecture the bootloader is called from BIOS (Basic Input / output system). It then loads the kernel into RAM from the filesystem, & execute the kernel. At this point the kernel has control & accesses the filesystem. On an Intel architecture you need only to place the bootloader on the boot sector of the hard drive and have an accessible filesystem.

On the ARM, there is no BIOS, & no delay for the POST. There is also no hard drive. So the first thing to run is the bootloader, which then loads the kernel directly from flash (and not of a filesystem). The bootloader passes execution to the kernel. The kernel then accesses the filesystem & things are pretty similar to an x86 boot sequence from there.

The other important difference between the Intel world & the ARM world is that the bootloader is also used to transfer the OS image onto the flash device