tag:blogger.com,1999:blog-45729088310841572012023-11-15T21:30:33.533+05:30Friendly ARMsankethttp://www.blogger.com/profile/09117237296761407879noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-4572908831084157201.post-16231794713767278422013-10-09T15:56:00.003+05:302013-10-09T15:56:17.970+05:30Developing Linux OS for ARM - Part IV<div dir="ltr" style="text-align: left;" trbidi="on">
<br />Bootstrap is in place ------- > Yes<br />
<br />
U-boot is in place -------> Yes<br />
<br />
Now its time to build kernel image, which will takeover control of the hardware.<br />
We would be discussing the procedure for booting the Linux operating system on board. However, AT91SAM9260 also supports other popular operating systems like WinCE, FreeRTOS, uC/OSII, eCOS etc. Refer to <a href="http://at91.com/">http://at91.com/</a> for more information on the same.<br />
<br />
The primary site for the Linux kernel source is <a href="http://www.kernel.org/">http://www.kernel.org</a>.<br />
<br />
we will download the kernel source at the following path:<br />
<br />
<a href="http://www.kernel.org/pub/linux/kernel/v2.6/linux%C2%AD-2.6.27.tar.bz2"> http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.27.tar.bz2</a><br />
<br />
Download it to the following path: <b>/Embedded_Linux_Complete/Sources/Linux_kernel/</b> . A copy of the source is also present in the archives under the following path: <br />
<br /><b>~/Embedded_Linux_Complete/Sources/Linux_kernel</b><br />
<br />
Extract the contents in the current directory.<br />
<br />
<b>/Embedded_Linux_Complete/Sources/Linux_kernel$ ls<br />linux-2.6.27 <span style="color: red;">linux-2.6.27.tar.bz2</span></b><br />
<br />
<br />
Next step would be to download the AT91 maintainers patch, which is the stable patch for AT91. This can be downloaded from:<br />
<br />
<a href="http://maxim.org.za/AT91RM9200/2.6/2.6.27-at91.patch.gz">http://maxim.org.za/AT91RM9200/2.6/2.6.27-at91.patch.gz</a><br />
<br />
Download/Copy this to the following path: <br /><b>/Embedded_Linux_Complete/Sources/Linux_kernel/linux2.6.27</b><br />
<b> </b><br />
After downloading the maintainer's patch apply it on top of the Linux kernel as shown:<br />
<b> </b><br />
<b>/Embedded_Linux_Complete/Sources/Linux_kernel/linux-2.6.27$ </b><br />
<b> zcat 2.6.27-at91.patch.gz | patch -p1</b><br />
<br />
Next you can also take the experimental patchset <br />
<a href="http://www.blogger.com/goog_1412230672"><br /></a>
<a href="ftp://www.linux4sam.org/pub/linux/2.6.27-at91/2.6.27-at91-exp.2.patch.gz">ftp://www.linux4sam.org/pub/linux/2.6.27-at91/2.6.27-at91-exp.2.patch.gz</a><br />
<br />
to the same location and apply it on top of the AT91 one as shown:<br />
<br />
<b>/Embedded_Linux_Complete/Sources/Linux_kernel/linux-2.6.27$ zcat 2.6.27-at91-exp.2.patch.gz | patch -p1</b><br />
<br />
Now you have to configure the Linux kernel according to your hardware. First identify your kernel revision, your board and then, download the corresponding configuration file. In our case, for AT91SAM9260, the configuration file can be downloaded from<br />
<br />
<a href="ftp://www.linux4sam.org/pub/linux/2.6.27-at91/at91sam9260ek_defconfig">ftp://www.linux4sam.org/pub/linux/2.6.27-at91/at91sam9260ek_defconfig</a><br />
<br />
Download the configuration file in<br />
<br />
<b>/Embedded_Linux_Complete/Sources/Linux_kernel/linux2.6.27</b><br />
<br />
Follow the below mentioned steps to configure the build process:<br />
<br />
<b>~/linux-2.6.27$ cp at91sam9260ek_defconfig .config</b><br />
<b><br /></b>
<b>~/linux-2.6.27$ make CROSS_COMPILE=/home/sanket/Download/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin/arm-none-linux-gnueabi- ARCH=arm oldconfig</b><br />
<b><br /></b>
In the above case, the default config that was stored in <b>~/Linux_kernel/linux-2.6.27/arch/arm/configs </b>will be used based on the target controller that you have specified.<b><br /></b><br />
<br />
In case you want to make your own customised kernel, you can configure all options individually using a menu based configuration interface. This can be done using:<br />
<br />
<br />
<b>~/linux-2.6.27$ make
CROSS_COMPILE=/home/sanket/Download/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin/arm-none-linux-gnueabi- </b><b>ARCH=arm menuconfig</b><br />
<b><br /></b>
But before that, for kernel compilation and buildroot, you need to have the some software packages installed on the the host machine. The folliwing is the list of softwares required: <br />
<br />
• GNU C/C++ <br />• GNU make <br />• wget <br />• sed <br />• flex <br />• bison <br />• m4 <br />• patch <br />• gettext <br />• libtool • texinfo <br />• autoconf <br />• automake <br />• ncurses library (development install) <br />• zlib library (development install) <br />• libacl library (development install) <br />
• lzo2 library (development install) <br />• glib library (development install) if some packages selected <b><br /></b><br />
<br />
On ubuntu, one can install all of these packages simultaneously in the following way:<br />
<br />
<b>~/linux-2.6.27$ sudo apt-get install make flex bison m4 ncurses-dev gettext texi2html texinfo zlib1g zlib1g-dev liblzo2-2 liblzo2-dev libacl1 libacl1-dev libglib2.0-dev autoconf automake libtool</b><br />
<br />
Once these packages have been correctly installed , we would be able to have a menu based configuration as shown below:<br />
<br />
<b>~/linux-2.6.27$ make
CROSS_COMPILE=/home/sanket/Download/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin/arm-none-linux-gnueabi- </b><b>ARCH=arm menuconfig</b><br />
<br />
On typing the above command you would see a menu based configuration utility<br />
<br />
Each of the categories shown above will further have kernel modules which can be either retained or removed. Linux supports the concept of loadable kernel modules, which means that many of these kernel modules can also be dynamically loaded/unloaded after the kernel has booted on the target hardware instead of including them at compile time.<br />
<br />Typically, [*] or <Y> symbolises that the corresponding modules are to be retained in the kernel image at the time of compilation, [ ] or <N> symbolises that the corresponding modules are not to be included in the kernel during the compilation, while <M> symbolises that the corresponding modules will not be loaded during the compile time but the kernel will include modules that would support the dynamic loading of these modules.<br />
<br />
There are two options available while doing this:<br />
<br /> 1. Load a default configuration: We have a default configuration file called <br />at91sam9260ek_defconfig, which we can load using the <b>“Load an Alternate <br />configuration file”</b> option.<br />
<br /> 2. Make your own configuration: If we want to prepare a new configuration altogether, we can select the appropriate options.<br />
<br />
Once these steps have been performed we can then save the required configuration using the <b>“Save an Alternate configuration file” </b>option. You will get a .config file generated within your current directory. Also, if there was a previous .config file existing within your current directory, a .config.old would be generated so that you can load it at some time in future if required again.<br />
<br />
We will go with the default configuration file supplied to us by the AT91 maintainers. Once this is done, you can ensure that the .config file has been generated in the following way:<br />
<br />
<b>/linux-2.6.27$ ls -al| grep "config"</b><br />
<br />
Finally , we arrive to the point where we are ready to build the kernel image:<br />
<b><br /></b>
<b>/linux-2.6.27$ make
CROSS_COMPILE=/home/sanket/Download/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin/arm-none-linux-gnueabi- </b><b>ARCH=arm</b><br />
<br />
At the end of the compilation process, a zImage and Image file would be generated under the following path:<b> /Linux_kernel/linux2.6.27/arch/arm/boot.</b><br />
<br />
UBoot does not support normal linux kernel images like zImage or Image (arch/arm/boot/), so you have to create an uImage file with the mkimage tool which encapsulates kernel image with header information, CRC32 checksum, etc. Download mkimage using:<br />
<br />
<b>/linux-2.6.27$ sudo apt-get install uboot-mkimage</b><br />
<b> </b><br />
Once mkimage is available run the following command to generate an uncompressed uImage file:<br />
<br />
<b>/linux-2.6.27$ mkimage -A arm -O linux -C none -T kernel -a 20008000 -e</b> <b>20008000 -n linux-2.6 -d arch/arm/boot/Image uImage</b><br />
<br />
Once the above steps are performed you will get a uImage file generated in your current directory, which would be used as the kernel image for booting Linux on your ARM platform.<br />
<br />
Next step would be to build a rootfs image. That we would be continuing in my next post.<br />
<br />
<br />
<br />
continue....... <br />
<br />
<br />
<br />
<br /></div>
sankethttp://www.blogger.com/profile/09117237296761407879noreply@blogger.com0tag:blogger.com,1999:blog-4572908831084157201.post-41771543248349936292013-10-09T11:51:00.006+05:302013-10-09T14:20:51.420+05:30Developing Linux OS for ARM - Part III<div dir="ltr" style="text-align: left;" trbidi="on">
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.<br />
<br />
As we already configure primary bootloader AR91Bootstrap in PART II. Its time to configure a secondary bootloader.<br />
<br />
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.<br />
<br />
Download the secondary bootloader (Uboot). It can be downloaded <br />
from the following link:<br />
<a href="http://www.blogger.com/goog_1635673431"><br /></a>
<a href="ftp://ftp.denx.de/pub/u-boot/">ftp://ftp.denx.de/pub/u-boot/</a><br /> <br />
<br />
we will download the uboot1.3.4.tar.bz2 at the following path: <br />
<br />
/home/sanket/Download/Embedded_Linux_Complete/Sources/uboot.<br />
<br />
Extract the same in the current directory.<br />
<br />
Download uboot patch provided by the AT91 community from the below mentioned link:<br />
<br />
<a href="ftp://www.linux4sam.org/pub/uboot/u%C2%ADboot%C2%AD1.3.4%C2%ADexp/u%C2%ADboot%C2%AD1.3.4%C2%ADexp.diff">ftp://www.linux4sam.org/pub/uboot/u-boot-1.3.4-exp/u-boot-1.3.4-exp.diff</a><br />
<br />
<br />
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.<br />
<br />
Save this to the ~/Embedded_Linux_Complete/Sources/uboot/uboot1.3.4.<br />
<br />
<b>/u-boot-1.3.4$ ls</b><br />
<br />
Apply it (patch) on top of the original uboot in the following way:<br />
<br />
<b>/u-boot-1.3.4$ cat u-boot-1.3.4-exp.diff | patch -p1</b><br />
<br />
Once the AT91 uboot sources are available, crosscompiling uboot can be done in two steps : configuration and compiling. Note that both armelf and armlinux ARM GCC crosscompiler types are suitable for uboot building. We will use armnone-linux-gnueabi-gcc.<br />
<br />
Here are the building steps for the AT91SAM9260EK board:<br />
<br />
<b>/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</b><br />
<br />
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.<br />
<br />
The Uboot 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 Uboot while it tries to bring Uboot up.<br />
<br />
So while we compile Uboot we will configure it for Dataflash.<br />
<br />
<b>/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</b><br />
<br />
These environment variables includes the IP address setting of the host, the server from which Uboot would tftp to retrieve some packages and more. When Uboot is up and running on our board we will try and view all these environment variables.<br />
<br />
<span style="color: red;">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 uboot the environment variable location needs to be choosen accordingly. </span><br />
<br />
To compile uboot after configuration,<br />
<br />
<b>/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- </b><br />
<br />
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 SAMBA (Burning Application for SAM controllers). <br />
<br />
Once the bootloader is in place, next step would be to build a kernel image. That we would be discussing in my next post.<br />
<br />
<br />
continue................<br />
<br />
<br />
<br />
<br />
<br /></div>
sankethttp://www.blogger.com/profile/09117237296761407879noreply@blogger.com2tag:blogger.com,1999:blog-4572908831084157201.post-5034006674422402092011-03-26T20:22:00.000+05:302011-03-26T20:22:02.710+05:30Developing Linux OS for ARM - Part II<div dir="ltr" style="text-align: left;" trbidi="on">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:<br />
<br />
<b>http://www.codesourcery.com/public/gnu_toolchain/arm-none-linux-gnueabi/arm-2007q1-10-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2</b><br />
<br />
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).<br />
<br />
<br />
Download the AT91Bootstrap source from the following link:<br />
<b>ftp://www.linux4sam.org/pub/at91bootstrap</b><br />
<br />
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.<br />
Extract the AT91Bootstrap source, change to the board directory as shown below:<br />
<br />
<b>$cd AT91Bootstrap/Bootstrap-v1.10/board/</b><br />
<b>$ls</b><br />
<br />
<b><span style="color: blue;">at91cap9adk</span> <span style="color: blue;">at91sam9261ek</span> <span style="color: blue;">at91sam9g20ek</span> <span style="color: blue;">at91sam9xeek</span></b><br />
<b><span style="color: blue;">at91sam9260ek</span> <span style="color: blue;">at91sam9263ek </span> <span style="color: blue;">at91sam9rlek</span></b><br />
<br />
Select your board by going into the corresponding board directory.<br />
<b><br />
/board$ cd at91sam9260ek/<br />
/board/at91sam9260ek$ ls</b><br />
<br />
<b>at91sam9260ek.c <span style="color: blue;">dataflash</span> <span style="color: blue;">nandflash</span></b><br />
<br />
Select your media by going into the corresponding directory. In our case the media for the secondary bootloader would be dataflash. <br />
<br />
<div style="background-color: white;"><b>/at91sam9260ek$ cd dataflash/</b></div><div style="background-color: white;"><b>at91sam9260ek/dataflash$ ls</b></div><div style="background-color: white;"><br />
</div><div style="background-color: white;"><b>at91sam9260ek.h dataflash_at91sam9260ek.elf Makefile</b></div><b><span style="background-color: white;">dataflash_at91sam9260ek.bin dataflash_at91sam9260ek.map</span></b><br />
<br />
<b>dataflash$ make clean</b><br />
<br />
<b>rm -f *.o *.bin *.elf *.map</b><br />
<br />
Before building the sources, check out the location of your compiler toolchain. In<br />
my case, it is<br />
<br />
<b>/home/sanket/Downloads/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin</b><br />
<b></b><br />
<b><br />
</b>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:<br />
<br />
<b>/dataflash$ make CROSS_COMPILE=/home/sanket/Downloads/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin/arm-none-linux-gnueabi-</b><br />
<br />
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.<br />
<br />
<br />
<b>/dataflash$ ls</b><br />
<br />
<b>at91sam9260ek.h crt0_gnu.o <span style="color: blue;">dataflash_at91sam9260ek.elf</span></b><br />
<b>dataflash.o div0.o main.o pmc.o string.o _udivsi3.o<br />
at91sam9260ek.o <span style="color: blue;"> dataflash_at91sam9260ek.bin </span> </b><br />
<b>dataflash_at91sam9260ek.map debug.o gpio.o Makefile </b><br />
<b>sdramc.o udiv.o _umodsi3.o</b><br />
<br />
<br />
<b>continue ...................................... </b><br />
</div>sankethttp://www.blogger.com/profile/09117237296761407879noreply@blogger.com1tag:blogger.com,1999:blog-4572908831084157201.post-25418514157336599702011-02-12T15:01:00.000+05:302011-02-12T15:01:28.398+05:30Developing Linux OS for ARM - Part I<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: small;">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.</span><br />
<br />
<span style="font-size: small;">The following would be the software components required to get Linux running on the target system : </span><br />
<span style="font-size: small;"><br />
Root filesystem</span><br />
<span style="font-size: small;">Linux Kernel</span><br />
<span style="font-size: small;">Bootloader</span><br />
<span style="font-size: small;">Hardware (MCU)</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"><b>Bootloader :</b></span><br />
<br />
The bootloader can be further classified into:<br />
<br />
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.<br />
<br />
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.<br />
<br />
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<br />
<br />
<br />
<b>continue ...................................... </b><br />
<br />
<br />
<br />
<span style="font-size: small;"><br />
</span></div>sankethttp://www.blogger.com/profile/09117237296761407879noreply@blogger.com1tag:blogger.com,1999:blog-4572908831084157201.post-7821104467374266292011-01-15T22:08:00.000+05:302011-01-15T22:08:38.582+05:30Difference between ARM and Intel ProcessorThe 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.<br />
<br />
The biggest difference between these platforms is the design dogma they follow. The x86 is a CISC architecture: <strong>Complex Instruction Set Computer</strong>. The ARM is a RISC-based designs: <strong>Reduced Instruction Set Computer.</strong><br />
<br />
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.<br />
<br />
<br />
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.<br />
<br />
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.<br />
<br />
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.<br />
<br />
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 devicesankethttp://www.blogger.com/profile/09117237296761407879noreply@blogger.com3tag:blogger.com,1999:blog-4572908831084157201.post-59016242779142542042010-12-31T21:05:00.000+05:302010-12-31T21:05:06.797+05:30Basic Operating System OverviewOne killer application of Linux is to be used as the operating system of an embedded system. ARM-based CPUs are killer partners of embedded Linux. Operating system consist of three main parts:<br />
<ul><li>Bootloader</li>
<li>Kernel and</li>
<li>Filesystem</li>
</ul><br />
<br />
<b>Bootloader :</b><br />
<br />
Unlike regular computer, most embedded systems don't have a firmware out-of-box like CMOS, Openfirmware or EFI, etc. Instead, you need to install the bootloader yourself or it is burned onto the board already. Generally, to a naked system, people use JTAG protocol to burn a bootloader. A bootloader can provide a interface for users to control the system as well as basic system tools, such as writing data into flash or transferring files from the host machine.<br />
<h1 class="firstHeading" id="firstHeading"><span style="font-size: small;"> </span></h1><h1 class="firstHeading" id="firstHeading"><span style="font-size: small;">Kernel :</span></h1><br />
In computing, the <b>kernel</b> is the central component of most computer operating system; it is a bridge between applications and the actual data processing done at the hardware level. The kernel's responsibilities include managing the system's resources (the communication between hardware and software components).<sup class="reference" id="cite_ref-Wulf74_0-0"><a href="http://en.wikipedia.org/wiki/Kernel_%28computing%29#cite_note-Wulf74-0"><span></span><span></span></a></sup> Usually as a basic component of an operating system, a kernel can provide the lowest-level abstraction layer for the resources (especially processors and I/O devices) that application software must control to perform its function. It typically makes these facilities available to application processes through inter-process communication mechanisms and system calls.<br />
The <b>Linux kernel</b> is an operating system kernel used by the Linux family of Unix-Like Operating system.<sup class="reference" id="cite_ref-README_5-0"><a href="http://en.wikipedia.org/wiki/Linux_kernel#cite_note-README-5"><span></span><span></span></a></sup> It is one of the most prominent examples of free and open source software<a href="http://en.wikipedia.org/wiki/Free_and_open_source_software" title="Free and open source software"></a>.<b> </b><br />
<br />
<br />
<b>The Root Filesystem </b>:<br />
<br />
Other than the Linux kernel, most embedded Linux system contain things such as a graphic environment as on most PDAs. The collection of all those files is called the Root Filesystem. It generally is stored in the flash partition called root. Attention, here "Root" is not equal to the /root directory and here "filesystem" is not a software to manager files on storage devices. The Root Filesystem is in the form of an image to be written into the flash memory.sankethttp://www.blogger.com/profile/09117237296761407879noreply@blogger.com0tag:blogger.com,1999:blog-4572908831084157201.post-18503132626533375542010-12-26T10:46:00.001+05:302010-12-31T22:19:26.093+05:30Deploying u-boot, Linux kernel and GPE onto Mini2440<h2> </h2>Before you start, you will need <br />
<ol><li>A mini2440 development board, with or without a 3.5"/7" LCD. </li>
<li>A software called minicom on your PC</li>
<li>The u-boot image, Linux kernel image, and GPE image, as well as the USB-downloader program to transfer files from your Linux PC to the NAND flash on mini2440 via a USB cable.</li>
<li value="4">A non-cross RS232 cable (both female heads) and a USB type-A-to-type-B cable (one head is the regular USB head as on your USB flash/thumb drive, and the other one is the little square one, like the one to connect your printer.) </li>
</ol><h2><span style="font-size: large;">Step 1: Setting up the minicom</span></h2><div class="content clear-block"><br />
<li><span style="font-size: small;">Install <code style="color: #45818e;">minicom</code>(for example, via command <span style="color: #45818e;">"</span><code style="color: #45818e;">sudo apt-get install minicom</code><span style="color: #45818e;">"</span>)</span><span style="font-size: small;"> </span></li><br />
<li><span style="font-size: small;">On a shell prompt, type <span style="color: #45818e;">"</span><code style="color: #45818e;">minicom -s</code><span style="color: #45818e;">"</span></span><span style="font-size: small;"> </span></li><br />
<li><span style="font-size: small;">Use up and down arrow to select "Serial port setup".</span> </li><br />
<li>If you wanna setup something, press the button corresponding to that item. After you finished, press Enter to exit. Besure to configure "Bps/Par/Bits" and "Hardware Flow Control" as same as the snapshot. You can save this configuration as default so that you don't need to set it again next time.</li><br />
<li>Then select "Exit" and press Enter. Don't select "Exit from Minicom", otherwise you are out of minicom.</li><br />
</div><div class="content clear-block"><br />
<br />
<b>Please note that your serial port does NOT have to be /dev/ttyUSB0, since I used a USB-to-RS2323 converter. It is only my case. In your case, it could be /dev/ttyS1 or /dev/ttyS0. But make sure set all the reset parameters as I did. </b></div><div class="content clear-block"><br />
<br />
<h2><span style="font-size: large;">Step 2: Replacing vivi by u-boot </span></h2><h2><span style="font-size: large;"> </span></h2>The mini2440 comes with two flashes, the NOR flash and the NAND flash. The NOR flash stores vivi by default. So I am NOT gonna overwrite it, in case I need it. I am gonna overwrite the NAND flash by u-boot, Linux kernel 2.6.31 and GPE. <br />
I will boot the board from NOR flash, using vivi in it to write u-boot into NAND flash. And then, I will reboot the board from NAND flash, and use u-boot to finish all the rest.<br />
Turn the boot selection switch to NOR flash on the board. Connect mini2440 with PC using minicom via RS232. Power on the board and you shall see this boot-up menu:<br />
<div style="background-color: white;"><br />
</div><pre style="color: #45818e;"><span style="background-color: white;">##### FriendlyARM BIOS for 2440 #####
[x] bon part 0 320k 2368k
[v] Download vivi </span>
[k] Download linux kernel
[y] Download root_yaffs image
[c] Download root_cramfs image
[a] Absolute User Application
[n] Download Nboot
[e] Download Eboot
[i] Download WinCE NK.nb0
[w] Download WinCE NK.bin
[d] Download & Run
[f] Format the nand flash
[p] Partition for Linux
[b] Boot the system
[s] Set the boot parameters
[t] Print the TOC struct of wince
[u] Backup NAND Flash to HOST through USB(upload)
[r] Restore NAND Flash from HOST through USB
[q] Goto shell of vivi
Enter your selection: q</pre><pre> </pre>Press q and Enter at the prompt and switch to vivi promp. <br />
Now connect PC with mini2440's USB device port, via a USB cable. Make the compiled u-boot image handy. Tell vivi that you need 239016 Bytes space in the RAM to load something from the USB, starting at 0x31000000<br />
<br />
<br />
<pre style="color: #45818e;">Supervivi> load ram 0x31000000 239016 u
USB host is connected. Waiting a download. </pre><pre> </pre><pre></pre><pre></pre>On another shell window, use following command to download u-boot into the RAM of mini2440<br />
<br />
<pre style="color: #45818e;">$ sudo ./s3c2410_boot_usb u-boot.bin </pre><pre> </pre>Enter root password when prompted, and you shall see this output on the shell<br />
<br />
<pre style="color: #45818e;">csum = 0xd542
send_file: addr = 0x33f80000, len = 0x0003a5a8
Error downloading program</pre><pre> </pre>Please ignore the error.<br />
<br />
<br />
Now go back to vivi. You shall see follows<br />
<br />
<pre style="color: #45818e;">Now, Downloading [ADDRESS:31000000h,TOTAL:239026]
RECEIVED FILE SIZE: 239026 (233KB/S, 1S)
Downloaded file at 0x31000000, size = 239016 bytes</pre><pre> </pre>Now we are ready to write u-boot from the RAM to NAND flash. Execute the code starting at RAM location 0x31000000:<br />
<br />
<pre><span style="color: #45818e;">Supervivi> go 0x31000000
go to 0x31000000
argument 0 = 0x00000000
argument 1 = 0x00000000
argument 2 = 0x00000000
argument 3 = 0x00000000
U-Boot 1.3.2-dirty-moko12 (Apr 16 2009 - 18:14:52)</span>
<span style="color: #45818e;">I2C: ready</span>
<span style="color: #45818e;">DRAM: 64 MB</span>
<span style="color: #45818e;">Flash: 2 MB</span>
<span style="color: #45818e;">NAND: Bad block table not found for chip 0</span>
<span style="color: #45818e;">Bad block table not found for chip 0</span>
<span style="color: #45818e;">64 MiB</span>
<span style="color: #45818e;">Found Environment offset in OOB..</span>
<span style="color: #45818e;">USB: S3C2410 USB Deviced</span>
<span style="color: #45818e;">In: serial</span>
<span style="color: #45818e;">Out: serial</span>
<span style="color: #45818e;">Err: serial</span>
<span style="color: #45818e;">MAC: 08:08:11:18:12:27</span>
<span style="color: #45818e;">Hit any key to stop autoboot: 0</span></pre><pre> </pre>When seeing "Hit any key to stop autoboot," press any key on the keyboard. The prompt shall change from <code style="color: #45818e;">Supervivi></code><span style="color: #45818e;"> to </span><code style="color: #45818e;">MINI2440 #</code>. Get the information about the NAND flash:<br />
<div style="color: #45818e;"><br />
</div><pre><span style="color: #45818e;">MINI2440 # nand info
Device 0: NAND 64MiB 3,3V 8-bit, page size 512, sector size 16 KiB </span></pre>Erase everything on the NAND flash:<br />
<br />
<br />
<pre style="color: #45818e;">MINI2440 # nand scrub
NAND scrub: device 0 whole chip
Warning: scrub option will erase all factory set bad blocks!
There is no reliable way to recover them.
Use this command only for testing purposes if you
are sure of what you are doing!
Really scrub this NAND flash? <y/N>
Erasing at 0x3ffc000 -- 100% complete.
Bad block table not found for chip 0
Bad block table not found for chip 0
OK</pre><pre style="color: #45818e;"> </pre><pre style="color: #45818e;"> </pre><pre></pre><pre></pre>Please enter a lower case y and press Enter when prompted. <br />
Now create a new partition table<br />
<br />
<pre><span style="color: #45818e;">MINI2440 # nand createbbt
Create BBT and erase everything ? </span><y n="">
<span style="color: #45818e;">Skipping bad block at 0x03ff0000
Skipping bad block at 0x03ff4000
Skipping bad block at 0x03ff8000
Skipping bad block at 0x03ffc000
Creating BBT. Please wait ...Bad block table not found for chip 0
Bad block table not found for chip 0
Bad block table written to 0x03ffc000, version 0x01
Bad block table written to 0x03ff8000, version 0x01</span></y></pre><pre><y n="">
</y></pre>and partition the NAND flash using u-boot default configuration. Each partition shall be given a name.<br />
<br />
<pre><span style="color: #45818e;">MINI2440 # mtdparts
device nand0 <mini2440-nand>, # parts = 4
#: name size offset mask_flags
0: u-boot 0x00040000 0x00000000 0
1: env 0x00020000 0x00040000 0
2: kernel 0x00500000 0x00060000 0
3: root 0x03aa0000 0x00560000 0
active partition: nand0,0 - (u-boot) 0x00040000 @ 0x00000000
defaults:</span>
<span style="color: #45818e;">mtdids : nand0=mini2440-nand</span>
<span style="color: #45818e;">mtdparts: <NULL></span></pre><pre> </pre>Now write u-boot to NAND flash<br />
<br />
<pre style="color: #45818e;">MINI2440 # nand write 0x31000000 u-boot
NAND write: device 0 offset 0x0, size 0x40000
262144 bytes written: OK </pre><pre style="color: #45818e;"> </pre><pre></pre><pre></pre>Reset the on-board switch to NAND flash and reboot mini2440<br />
<br />
<h2><span style="font-size: large;">Step 3: Downloading Linux Kernel</span> </h2><br />
Now you shall see all u-boot informations on the minicom window. Hit any key when you see the promption "Hit any key to stop autoboot."<br />
Now set a NAND flash offset since later you won't want to write stuffs on the area that contains u-boot.<br />
<br />
<pre style="color: #45818e;">MINI2440 # dynenv set 40000
device 0 offset 0x40000, size 0x3fc0000
45 4e 56 30 - 00 00 04 00
MINI2440 # nand erase kernel
NAND erase: device 0 offset 0x60000, size 0x500000
Erasing at 0x55c000 -- 100% complete.
OK</pre><pre style="color: #45818e;"></pre><pre style="color: #45818e;"> </pre><pre></pre><pre></pre>Copy the Linux kernel image onto an SD card and insert the SD card to the card reader of mini2440. Now initialize the SD card.<br />
<br />
<pre style="color: #45818e;">MINI2440 # mmcinit
trying to detect SD Card...
Manufacturer: 0x02, OEM "TM"
Product name: "SD01G", revision 2.3
Serial number: 2486075243
Manufacturing date: 1/2002
CRC: 0x72, b0 = 1
READ_BL_LEN=15, C_SIZE_MULT=7, C_SIZE=365
size = 1642070016</pre><pre style="color: #45818e;"></pre><pre></pre><pre></pre>Suppose the Linux kernel image has the filename "uImage." Now load it to the RAM first.<br />
<br />
<br />
<pre style="color: #45818e;">MINI2440 # fatload mmc 0:1 0x31000000 uImage
reading uImage
1945804 bytes read</pre><pre> </pre>Write the Linux kernel from RAM to the NAND flash partition called "kernel."<br />
<br />
<pre style="color: #45818e;">MINI2440 # nand write 0x31000000 kernel
NAND write: device 0 offset 0x60000, size 0x500000
5242880 bytes written: OK</pre><pre></pre><pre></pre><h2><span style="font-size: large;">Step 4: Downloading GPE Embedded Graphic Environment</span></h2><h2></h2>Well, at this step, you have plenty of choices. You can try Qtopia, etc. But I prefer GPE, which is GPL'ed and small. Things like GPE are called Root Filesystems. You can follow the same steps that you did for downloading Linux kernel. Just write to NAND partition "root" instead of "kernel."<br />
Initialize SD card<br />
<br />
<br />
<pre><span style="color: #45818e;">MINI2440 # nand erase root
MINI2440 # mmcinit
trying to detect SD Card...
Manufacturer: 0x02, OEM "TM"
Product name: "SD01G", revision 2.3
Serial number: 2486075243
Manufacturing date: 1/2002
CRC: 0x72, b0 = 1
READ_BL_LEN=15, C_SIZE_MULT=7, C_SIZE=365
size = 1642070016</span> </pre>Load GPE image to RAM, supposing the filename is gpe-image-micro2440.jffs2.<br />
<pre style="color: #45818e;">MINI2440 # fatload mmc 0:1 0x31000000 gpe-image-micro2440.jffs2
reading gpe-image-micro2440.jffs2
39239680 bytes read</pre><pre> </pre>Since the GPE image is compiled in JFFS2 filesystem, you need to write it as a JFFS2 image.<br />
<br />
<br />
<pre style="color: #45818e;">MINI2440 # nand write.jffs2 0x31000000 root ${filesize}
NAND write: device 0 offset 0x560000, size 0x256c000
Writing data at 0x2acbe00 -- 100% complete.
39239680 bytes written: OK</pre><h2><span style="font-size: large;">Finalization</span></h2>Now you are pretty much done. Just do the two last things as follows<br />
<br />
<pre style="color: #45818e;">MINI2440 # setenv bootcmd nboot.e kernel \; bootm
MINI2440 # saveenv
Saving Environment to NAND...
Erasing Nand...Writing to Nand... done</pre><pre> </pre>Now reset your mini2440 and enjoy!</div>sankethttp://www.blogger.com/profile/09117237296761407879noreply@blogger.com1