My Tech notes: July 2008
Subscribe

Unix Documentation

Free Online Unix Training Materials

Lists many links to free Unix training materials.

Pointers and Arrays Materials

Pointers and Arrays materials Explained for C beginners

C FAQ and General Questions C Interview Questions

Powered By

Free XML Skins for Blogger

Powered by Blogger

Thursday, July 31, 2008

Nobody's Copyright

Let’s see what some wise people, spiritual teachers, say about copyright. U. G. Krishnamurti, the controversial teacher/non-teacher, expressed it this way.

My teaching, if that is the word you want to use, has no copyright. You are free to reproduce, distribute, interpret, misinterpret, distort, garble, do what you like, even claim authorship, without my consent or the permission of anybody (U. G. Krishnamurti, The Mystique of Enlightenment, India. Dinesh Vaghela. Goa. 1982: http://www.well.com/user/jct/mystiq.htm)
clipped from www.indranet.org
The debate about copyright is one of the most heated on the Internet. Record labels, movie distributors, publishers, news agencies, bloggers and users are involved in a discussion which at times gets aggressive.
It seems that virtually everything on the Net is eventually copied, aggregated, cut, pasted and homogenized. There are various sites which aggregate articles by collecting everything being produced by blogs.
Every intellectual production is being absorbed by the collective sphere and somehow becomes depersonalized from the original author.
The hyperproduction of information and knowledge by hundreds of millions of people at the same time creates a whirl where individual identities and sources of information become out of focus and, like the rotation pinwheel of colors, creates a single white color from which it is difficult to trace the original color.
 blog it

Wednesday, July 30, 2008

Sending Data Other Process Signals

Sending Signals With payload.
1) we can send signal from one process to other along with data.
2) Data can be an int or pointer to some location.
3) For pointer both process should have access to that location, In case of integer,
data is part of the signal.
4) There is no provision to include the payload in signal which is sent from kernel.
Example:
file: first.c
#include
#include
void sighandler(int sig, siginfo_t *info, void *arg)
{
printf("In Handler value %d\n", info->si_value.sival_int);
}
main()
{
struct sigaction sa;
int ret;
sa.sa_sigaction = sighandler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART | SA_SIGINFO;
if((sigaction(SIGUSR1, &sa, NULL)) == -1) {
printf("Can't register handler\n");
}
for(;;) {
pause();
}
}
file second.c
#include
#include
#include
main(int argc, char *argv[])
{
sigval_t value;
int ret, pid;
if(argc < 2) {
printf("%s \n", argv[0]);
return;
}
pid = atoi(argv[1]);
value.sival_int = atoi(argv[2]);
ret = sigqueue(pid, SIGUSR1, value);
if(ret) {
perror("sigqueue\n");
}
}

Tuesday, July 29, 2008

Short Sweet C Functions

One of the short and sweet function which i have written in C language is dotted_decimal_to_string(). This function takes individual fields as inputs returns dotted decimal string. This is used in taking dotted decimal values of network parameters like IP address, IP netmask, IP gateway address, DNS server IP address etc, from the webpage, where these network parameters are individual inputs from a form.
Check out the function.

char *dotted_decimal_to_string(char *pad1, char *pad2, char *pad3, char *pad4)
{
char temp[40],*ret_string;

sprintf(temp,"%s.%s.%s.%s",pad1,pad2,pad3,pad4);

ret_string = (char*)malloc(strlen(temp) + 1);
strcpy(ret_string,temp);

return ret_string;
}
The return string is a dotted decimal value for a network parameter and is used to store in configuration file or to use for setting and configuring the Network parameters.
This function stuck to my mind while i was going to bed yesterday. That means, my back-office was working for me, and giving me such a cute solution.
Otherwise I dont keep solutions short, they are always complex for little task also. :-)

Sunday, July 27, 2008

Booting ARM Linux By Russell King

Booting ARM Linux
=================

Author: Russell King
Date : 18 May 2002

The following documentation is relevant to 2.4.18-rmk6 and beyond.

In order to boot ARM Linux, you require a boot loader, which is a small
program that runs before the main kernel. The boot loader is expected
to initialise various devices, and eventually call the Linux kernel,
passing information to the kernel.

Essentially, the boot loader should provide (as a minimum) the
following:

1. Setup and initialise the RAM.
2. Initialise one serial port.
3. Detect the machine type.
4. Setup the kernel tagged list.
5. Call the kernel image.


1. Setup and initialise RAM
---------------------------

Existing boot loaders: MANDATORY
New boot loaders: MANDATORY

The boot loader is expected to find and initialise all RAM that the
kernel will use for volatile data storage in the system. It performs
this in a machine dependent manner. (It may use internal algorithms
to automatically locate and size all RAM, or it may use knowledge of
the RAM in the machine, or any other method the boot loader designer
sees fit.)


2. Initialise one serial port
-----------------------------

Existing boot loaders: OPTIONAL, RECOMMENDED
New boot loaders: OPTIONAL, RECOMMENDED

The boot loader should initialise and enable one serial port on the
target. This allows the kernel serial driver to automatically detect
which serial port it should use for the kernel console (generally
used for debugging purposes, or communication with the target.)

As an alternative, the boot loader can pass the relevant 'console='
option to the kernel via the tagged lists specifying the port, and
serial format options as described in

Documentation/kernel-parameters.txt.


3. Detect the machine type
--------------------------

Existing boot loaders: OPTIONAL
New boot loaders: MANDATORY

The boot loader should detect the machine type its running on by some
method. Whether this is a hard coded value or some algorithm that
looks at the connected hardware is beyond the scope of this document.
The boot loader must ultimately be able to provide a MACH_TYPE_xxx
value to the kernel. (see linux/arch/arm/tools/mach-types).


4. Setup the kernel tagged list
-------------------------------

Existing boot loaders: OPTIONAL, HIGHLY RECOMMENDED
New boot loaders: MANDATORY

The boot loader must create and initialise the kernel tagged list.
A valid tagged list starts with ATAG_CORE and ends with ATAG_NONE.
The ATAG_CORE tag may or may not be empty. An empty ATAG_CORE tag
has the size field set to '2' (0x00000002). The ATAG_NONE must set
the size field to zero.

Any number of tags can be placed in the list. It is undefined
whether a repeated tag appends to the information carried by the
previous tag, or whether it replaces the information in its
entirety; some tags behave as the former, others the latter.

The boot loader must pass at a minimum the size and location of
the system memory, and root filesystem location. Therefore, the
minimum tagged list should look:

+-----------+
base -> | ATAG_CORE | |
+-----------+ |
| ATAG_MEM | | increasing address
+-----------+ |
| ATAG_NONE | |
+-----------+ v

The tagged list should be stored in system RAM.

The tagged list must be placed in a region of memory where neither
the kernel decompressor nor initrd 'bootp' program will overwrite
it. The recommended placement is in the first 16KiB of RAM.

5. Calling the kernel image
---------------------------

Existing boot loaders: MANDATORY
New boot loaders: MANDATORY

There are two options for calling the kernel zImage. If the zImage
is stored in flash, and is linked correctly to be run from flash,
then it is legal for the boot loader to call the zImage in flash
directly.

The zImage may also be placed in system RAM (at any location) and
called there. Note that the kernel uses 16K of RAM below the image
to store page tables. The recommended placement is 32KiB into RAM.

In either case, the following conditions must be met:

- Quiesce all DMA capable devices so that memory does not get
corrupted by bogus network packets or disk data. This will save
you many hours of debug.

- CPU register settings
r0 = 0,
r1 = machine type number discovered in (3) above.
r2 = physical address of tagged list in system RAM.

- CPU mode
All forms of interrupts must be disabled (IRQs and FIQs)
The CPU must be in SVC mode. (A special exception exists for Angel)

- Caches, MMUs
The MMU must be off.
Instruction cache may be on or off.
Data cache must be off.

- The boot loader is expected to call the kernel image by jumping
directly to the first instruction of the kernel image.
source

Saturday, July 26, 2008

Disney Fairies Pixie Hollow (www.PixieHollow.com) watch from youtube

Fairies Pixie Hollow, the new MMO

Warren Buckleitner previews the new MMO from Disney

Disney Fairies Pixie Hollow (www.PixieHollow.com) watch from youtube




Check out http://www.pixiehollow.com/

Friday, July 25, 2008

Use Of Mount - Accessing Windows Files From Linux

This is pretty good use of SMB protocol aka CIFS.
Windows system are default use SMB protocol to share files over network and with other systems.
In linux one has to run SMB server, one SMB server is running on linux system, one can access the windows file from Linux system using mount.

Use

$mount -t cifs //192.168.2.102/bhagwat/firmware /mnt/prolent -o user=bhagwat

Usages:
192.168.2.102 is windows machine IP address /bhagwat/firmware is the folder name on windows machine.
/mnt/prolent is the local mount point in linux system. If local mount point is not created, create it using,

$mkdir -p /mnt/prolent

-p option for creating dir /mnt/ if it is not there.

Then provide the usrename on for windows system ie user=bhagwat. press enter, this will ask for the password to enter to windows system. Enter the password and you are ready to use windows files or filesystem from linux.
go to $ cd /mnt/prolent you could see windows files on linux machine.

Thursday, July 24, 2008

MSBTE Summer 2008 Result at msbte.com

Maharashtra State Board of Technical Education Results 2008
नमष्कार मित्रानो आपला MSBTE चा नीकाल आनी अधिक माहिती एथे वाचा
MSBTE Summer 2008 Results for Mumbai, Pune and Nagpur
(Semester Pattern - C Scheme)

Direct link; msbte.com/msbte2008rs/

MSBTE Summer Results for 2008 -

The website has a MSBTE Results Search section where you can get your Summer results

http://www.msbte.com/site/index.php?option=com_wrapper&Itemid=52

Check out other source of information here

previous update




















msbte, msbte results, msbte summer 2008 result, msbt, msbte.com, result, msbte, msbte summer 2008 results, msbte.com, msbte summer 2008 result, msbte result, msbte, msbte result,

Wednesday, July 23, 2008

Rajasthan DIET Results Sikar

DIET Result of Rajasthan VIII Board Supp (Sikar) Exam Result

Check DIET Result

Tuesday, July 22, 2008

Lok Sabha TV Live from All News Channels for Trust Vote

Check latest updates and latest news on Lok Sabha TV Live from All News Channels for Trust Vote
1.ndtv
2.aajtak
3.trust vote
4.ndtv.com
5.ibn7
6.live news
7.parliament news
8.zee news
9.times now
10.ndtv news
11.www.ndtv.com
12.cnn ibn
13.loksabha
14.ddnews
15.star news
16.ndtv live
17.latest news
18.times of india
19.aajtak.com
20.india tv

Lok Sabha Speaker Somnath Chatterjee has fixed 6 pm as the time for voting on the confidence motion moved by Prime Minister Manmohan Singh

trust vote trust vote live, trust vote india, trust vote time

NDTV
ndtv.com/convergence/ndv

aajtak
aajtak.com

ibn7 live
ibn7 Live streaming

zee news
Visit Zee News for latest India news, get current news from India and all over the world.

watch lok sabha live
audio lok sabha live proceedings

Monday, July 21, 2008

Wigeon Baldpate

Wigeon are dabbling ducks in the genus Anas. There are three species: the Eurasian Wigeon (Anas penelope), the American Wigeon (A. americana) and the Chilöe Wigeon (A. sibilatrix). Widgeon is an alternative, though archaic, spelling; the American Wigeon has in the past been known as Baldpate.

three wigeon species hybridise in captivity,[1] and American and Eurasian Wigeons hybridise in the wild.[2] An American Wigeon × Mallard hybrid has also been recorded
The image “http://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Anas_americana_03828.JPG/180px-Anas_americana_03828.JPG” cannot be displayed, because it contains errors.
source
french vanilla, french vanilla ice cream, caucasus

5 easy ways to access your bookmarks anywhere

Having full access to your bookmarks wherever you are is now something that most users take for granted. Not so long ago, the only way to really ensure you had your bookmarks with you was to crudely send them to your e-mail account and access them from there. Nowadays, you’re almost spoiled for choice meaning it’s easy than ever to work on the move or check your favorite RSS feeds during a spare moment away from the home or office. And having a way to access your bookmarks from any location is a great way to avoid disaster if your hard drive fails and you lose everything. For desktop PC users, here are 5 of the best:
clipped from en.onsoftware.com
Having full access to your bookmarks wherever you are is now something that most users take for granted. Not so long ago, the only way to really ensure you had your bookmarks with you was to crudely send them to your e-mail account and access them from there. Nowadays, you’re almost spoiled for choice meaning it’s easy than ever to work on the move or check your favorite RSS feeds during a spare moment away from the home or office. And having a way to access your bookmarks from any location is a great way to avoid disaster if your hard drive fails and you lose everything. For desktop PC users, here are 5 of the best:

Foxmarks - The undisputed king for Firefox users - works seamlessly 24/7

Bookmarks Unifier - Export bookmarks to hard copy for Firefox, Internet Explorer and Opera

Mozmarks - An early predecessor to Foxmarks but with less synchronisation

Chipmark - Browser bookmarks plugin for both Internet Explorer and Firefox

Blinklist - Gives you access anywhere
 blog it

Sunday, July 20, 2008

Hai Naath Aab Too Aaisi Krupa Hoo..

Amma Bhagvan Bhajan
Hai Naath Aab Too Aaisi Krupa Hoo..

Listen from here,
Enjoy

Thank you amma Bhagvan



11 Ways to Build an Extraordinary Life

Have a vision for your future...
clipped from www.steve-olson.com

How can you build the life you want? The answer to that question is different for each of us. But it’s critical that you answer it, because in the answer you will find purpose and meaning. Many of us look for happiness in things, but happiness doesn’t come from things, it comes from how we relate to ourselves and our world.

Be True to Yourself
Have a Vision for Your Future
Avoid Debt
Save
Continue Your Education
Take Responsibility for Change
Learn from Mistakes -
Build Quality Relationships/Discard Destructive Ones
Love: Look for a partner who is on a similar journey as yours, who has similar goals and values, and build on your relationship by giving your love and encouragement
Friendship: Look for people with similar values, who give as much as they take, with which you can share interests and hobbies.
Do the Right Thing Even When it is Unpopular
Honor Your Commitments - Do not make commitments lightly
Be Charitable
 blog it

Saturday, July 19, 2008

Avatar 318 Torrent Youtube Collection | Avatar book 4 The Last Airbender

Season 3 of Avatar: The Last Airbender (also known as Book 3: Fire), which is an American animated television series, began airing September 21, 2007, and ended on July 19, 2008, with twenty-one episodes aired.

Avatar the last airbender: Book 3: Fire trailer


Avatar the Last Airbender: Book 3


Avatar Series Finale Trailer


another season with Aang is just logical, Aang and even Zuko deserve another season, but this time, Zuko will team up with Aang, trying to take back Ba Sing Sei. Or trying to capture Azula , before she unleash the ''devils'' spirits from the spirit world. Or something like that. Introducing new guys, like the spirit warrior, there are soo many ideas
avatar sozin s comet torrent, sozin s comet torrent, avatar, avatar torrent, avatar 318
Avatar Book 4

Friday, July 18, 2008

IN MEMORIAM STANLEY KAMEL Youtube Collection

The image “http://upload.wikimedia.org/wikipedia/en/thumb/d/d2/DrCharlesKroger.jpg/175px-DrCharlesKroger.jpg” cannot be displayed, because it contains errors.

Stanley Kamel (January 1, 1943[1] - April 8, 2008) was an American television actor best known for his role on the USA Network series Monk as Dr. Charles Kroger, Adrian Monk's psychiatrist.

Stanley Kamel in Bruce Almighty



IN MEMORIAM STANLEY KAMEL



Mr. Monk and the Dr. Kroger
IN MEMORIAM : CELEBRITY DEATHS IN 2007

Thursday, July 17, 2008

Peloponnesian War and Statue Of Liberty Island

Peloponnesian War
The Peloponnesian War (431–404 BC) was an Ancient Greek military conflict, fought by Athens and its empire against the Peloponnesian League, led by Sparta. Historians have traditionally divided the war into three phases. In the first, the Archidamian War, Sparta launched repeated invasions of Attica, while Athens took advantage of its naval supremacy to raid the coast of the Peloponnese attempting to suppress signs of unrest in its empire. This period of the war was concluded in 421 BC, with the signing of the Peace of Nicias.
Peloponnesian War
Liberty Enlightening the World commonly known as the Statue of Liberty presented to the United States by the people of France in 1886. It stands at Liberty Island as a welcome to all visitors, immigrants, and returning Americans. The copper -clad statue, dedicated on October 28, 1886, commemorates the centennial of the United States and is a gesture of friendship from France to the U.S.
http://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Statue_of_Liberty_frontal_2.jpg/200px-Statue_of_Liberty_frontal_2.jpg
Worldwide, the Statue of Liberty is one of the most recognizable icons of the United States,[2] and, more generally, represents liberty and escape from oppression. The Statue of Liberty was, from 1886 until the jet age, often one of the first glimpses of the United States for millions of immigrants after ocean voyages from Europe. Visually, the Statue of Liberty appears to draw inspiration from il Sancarlone or the Colossus of Rhodes.
source

Wednesday, July 16, 2008

TNPSC Results Tamil Nadu Public Service Commission | www.tnpsc.gov.in



The image “http://www.tnpsc.gov.in/images/tnpsc_txt.gif” cannot be displayed, because it contains errors.


tnpsc results, www.tnpsc.gov.in, tnpsc.org, rpsc, dopt
The image “http://www.tnpsc.gov.in/images/logo.gif” cannot be displayed, because it contains errors.


Results of recruitment exams can be seen at the links below. Please click on the exams you are interested in.

List of Register Numbers of Candidates who have been summoned for Verification of Original certificates and for obtaining order of preference to the POSTS INCLUDED IN GROUP-IV SERVICES (SPECIAL COMPETITIVE EXAMINATION) - 2007 based on written examination conducted by the Commission on 17.02.2008 (Published on 16.07.2008)

Marks obtained by the candidates in the Written Examination held on 17.02.2008 for the POSTS INCLUDED IN GROUP-IV SERVICES (SPECIAL COMPETITIVE EXAMINATION) - 2007 (Published on 16.07.2008)

List of Register Numbers of candidates selected provisionally for appointment by direct recruitment to the posts included in COMBINED SUBORDINATE SERVICES EXAMINATION - I, 2007 (Date of Written Examination:17.11.2007 - Dates of Oral Test : 17.03.2008 to 15.04.2008) (Published on 16.07.2008)



http://www.tnpsc.gov.in/recruitnresults.htm
about tnpsc
Tamil Nadu Public Service Commission has had a glorious past of 75 years. During 1923, the Lee Commission had recommended setting up of a Central Public Service Commission in India, but it did not give much thought to the need of establishing similar commissions in provinces. It was left largely to the discretion of provincial Governments to recruit and exercise control over their Services, as they thought proper. As a result of the discretionary powers left to provincial Government, the Government of Madras and Punjab proposed to set up their Public Service Commissions.
http://www.tnpsc.gov.in/Index.htm

Tuesday, July 15, 2008

Rajasthan Technical University, Kota Results RPET/RMAT/RMCAT

rpet 2008 results of Rajasthan Technical University, Kota:: RPET/RMAT/RMCAT
The image “http://www.rtu.ac.in/image_files/logo.JPG” cannot be displayed, because it contains errors.
RESULT RPET-2008

RESULT RMCAT-2008

RESULT RMAT-2008 -::- Online Counseling for RMAT -08

RMCAAT results

contact
Coordinator RPET 07442473900 07442473901 rpet2008@gmail.com
Coordinator RMAT 07442473908 07442473909
Coordinator RMCAAT 07442473907
Controller of Examination 0744-3297849,2473016 0744-2473016,2473931 (Telefax) examrtu@gmail.com

tags
rtu.ac.in, rpet 2008, rpet 2008 result, rpet result, rtu
Rajasthan Technical University (RTU), Kota is conducting RPET-2008, RMAT-2008 and RAMCAAT-2008.
source
http://www.rtu.ac.in/

Monday, July 14, 2008

VTU - Visvesvaraya Technological University Results 2008 Updated

The results of VTU - Visvesvaraya Technological University Results 2008 are declared

vtu 8th sem results (PROVISIONAL)

B.E / B.Tech VIII Semester results announced for Gulbarga & Belgaum Regions

B.E / B.Tech VIII semester Bangalore & Mysore region results will be announced on 15th & 16th July 2008 respectively


The image “http://results.vtu.ac.in/image/vishwere_sml2.GIF” cannot be displayed, because it contains errors.


Enter the University Seat No

The official site http://vtu.ac.in is coming slow, check above link for direct results.

All the best.

Sunday, July 13, 2008

Everything Related To Linux

Recently I came across yolinux.com its a huge collection of everything related to Linux.


Linux Installation and Getting Started
<http://www.tldp.org/LDP/gs/gs.html>by Matt Welsh

Contents <http://www.tldp.org/LDP/gs/node1.html>

Saturday, July 12, 2008

MCAER चा नीकाल आनी admission बधल माहिती | www.mcaer.mah.nic.in

नमष्कार मंडली आपला MCAER चा नीकाल आनी admission बधल माहिती एथे वाचा

Maharashtra Council Agricultural Education and Research - MCAER, Pune At www.mcaer.mah.nic.in The image “http://mcaer.mah.nic.in/Images/MCAERHead_r1_c1.gif” cannot be displayed, because it contains errors.

check information about programs, U.G, P.G, Ph.D courses, admissions & process,

CET. CET 2008 Results also available at www.mcaer.mah.nic.in

http://mcaer.mah.nic.in

http://admissions.mkcl.ws/agri/StaticPages/HomePage.aspx

The Maharashtra Council of Agricultural Education and Research (MCAER), Pune is a body which has been constituted under Section 12 of Maharashtra Agricultural Universities (Krishi Vidyapeeths) Act 1983. In exercise of the powers conferred upon MCAER vide provision in the proviso (g) of sub-section 3 of Section 12 of the Act, common regulations for admission to various degree programmes in State Agricultural Universities have been formulated.

http://mcaer.mah.nic.in/html/cet2008-result.pdf

Friday, July 11, 2008


Porting Linux


Booting Linux






Introduction 3

About boot loader 3

Known components of Hardware block 4

[ARM926ejs core] 4

[Cache] 4

[MMU/TLB] 4

Linux kernel 5

Basic understanding of kernel internal 5

Specific patches added in kernel 6

Specific adaptions and patches for MCS8140 6

Compiling and using Linux kernel 6

Debugging kernel 8

JTAG- 8

Porting Linux step by step 8

Step 1 Machine registration 8

Step 2 Firmware to kernel transition 8

Step 3 Early kernel init 9

Step 4 Mapping I/O devices 10

Step 5 IRQ setup 10

Step 6 system timer tick 10

Step 7 board level initialization 11

MCS8140 specific peripherals 12

Root file system 15

Creating a JFFS2 file system 15

/bin and /sbin 16

About busybox 16

/etc 16

About /init.d/rcS 17

/dev 17

/proc 17

/tmp 17

/var 17

/lib 17

/mnt 17

/modules 17

/usr 17

/sys 17

Introduction

This document contains basic information about what are steps involved in building Linux for MCS8140, this board uses internal boot loader called I-boot and external boot loader called U-boot.

Building embedded Linux system consists of three parts, the bootloader, the Linux kernel, and the graphical user interface (or GUI). Attempt is made here to present understanding of linux kernel.

About boot loader

The typical bootloader performs the following types of functions:

  • Initialize CPU speed

  • Initialize memory, which includes enabling memory banks, initializing memory configuration registers, and so on

  • Initialize serial port (if present on the target).

  • Enable instruction/data caches.

  • Set up stack pointer.

  • Set up parameter area and construct parameter structures and tags (this is an important step, as boot parameters are used by the kernel in identifying root device, page size, memory size and more).

  • Perform POST (Power On Self Test) to identify the devices present and to report any problems.

  • Provide support for suspend/resume for power management.

  • Jump to start of kernel.

Known components of Hardware block

[Brief about hardware components involved in; need to have understanding of processor core, cache, MMU/TLB, memory map ]


[ARM926ejs core]

[Cache]

[MMU/TLB]


Linux kernel

The Linux kernel we are using for MCS8140 is linux-2.6.15. This kernel has so many features in built; we are using the following kernel features for MCS8140.

1) Kernel module support added.

2) Enabled ARM926 processor support and thumb instruction set support.

3) MMU support enabled.

4) PCI host support and hot plug enabled.

5) IPV4 TCP/IP stack enabled

6) IEEE80211 wireless support enabled.

7) Incorporated the flash device driver for supporting flash memory.

8) Enabled char, block devices support.

9) Ramdisk support enabled.

10) Enabled SCSI support.

11) PROC file system support.

12) SATA support enabled.

13) Enabled network device support.

14) Generic serial console (8250) support enabled.

15) Enabled sound support in kernel.

16) USB EHCI, OHCI support.

17) USB dev,sys file system.

18) Enabled ext2,ext3, minix, VFAT, FAT,MSDOS,NTFS,RAMFS file systems.

19) Enabled JFFS2, NFS, SMB file system support.

The features added to kernel which are specific to MCS8140 are: (we can enable the options in kernel in menuconfig by adding the options in Kconfig files in their respective modules.)

1) Added on board Ethernet driver to the kernel.

2) Added List processor and TCP segmentation offloading support to Ethernet driver.

3) Added board specific serial driver.

4) Added board specific sound driver. (I2S codec)

5) Added USBIP application module.

Basic understanding of kernel internal

The kernel layout is divided into architecture-specific and architecture-independent parts. The architecture-specific part of the kernel executes first and sets up hardware registers, configures the memory map, performs architecture-specific initialization, and then transfers control to the architecture-independent part of the kernel. It is during this second phase that the rest of the system is initialized. The directory arch/ under the kernel tree consists of different subdirectories, each for a different architecture (MIPS, ARM, i386, SPARC, PPC, and so on). Each of these subdirectories includes kernel/ and mm/ subdirectories, which contain architecture-specific code to do things like initialize memory, set up IRQs, enable cache, set up kernel page tables, and so on. These functions are called first once the kernel is loaded and given control, then the rest of the system is initialized.

The kernel can be compiled either as vmlinux, Image, or zImage depending on the available system resources and the functionality of the bootloader. The main difference between vmlinux and zImage is that vmlinux is the real (uncompressed) executable, while zImage is a self-extracting compressed file containing more or less the same information.

Specific patches added in kernel

The wireless drivers which are not available directly in 2.6.15 kernel are downloaded and added to our CVS tree.

These include Broadcom driver, Ralink drivers. (Available in drivers/net/wireless folder)

Specific adaptions and patches for MCS8140

UART, Timer, Interrupt Controller are must for Linux (these will come into basic Linux kernel porting section).
PCI Host driver
USB Host driver
EHCI,OHCI drivers.
MAC Driver (Includes LP & TSO & Cipher)
Audio Drivers.

Compiling and using Linux kernel

Kernel linking and loading

The kernel executable consists of many object files linked together. The object files have many sections such as text, data, init data, bass, and so forth. These object files are linked and loaded by a file known as a linker script. The function of the linker script is to map the sections of the input object files into an output file; in other words, it links all the input object files into a single executable whose sections are loaded at specified addresses. vmlinux.lds is the kernel linker script present in the arch/<target>/ directory, and it is responsible for linking the various sections of the kernel and loading them at a particular offset in memory.

Parameter passing and kernel boot up

stext(from lds file) is the kernel entry point, which means that the code under this section is the first to execute when the kernel boots up. It is usually written in assembly, and is normally present under the arch/<target>/ kernel directory. The code sets up the kernel page directory, creates identity kernel mapping, identifies architecture and processor, and branches to start_kernel (the main routine whereby the system is initialized).

start_kernel calls setup_arch as the first step where the architecture-specific setup is done. This includes initializing hardware registers, identifying the root device and the amount of DRAM and flash available in the system, specifying the number of pages available in the system, the filesystem size, and so on. All this information is passed in parameter form from the bootloader to the kernel.

There are two ways to pass parameters from bootloader to kernel: parameter_structure and a tag list. Of these, param structure is deprecated as it imposes restrictions by specifying that each and every parameter has to be at a particular offset within param_struct in memory. Recent kernels expect parameters to be passed as a tag list and will convert parameters to a tagged format. param_struct is defined in include/asm/setup.h. Some of its important fields are:

struct param_struct {

unsigned long page_size; /* 0: Size of the page */

unsigned long nr_pages; /* 4: Number of pages in the system */

unsigned long ramdisk /* 8: ramdisk size */

unsigned long rootdev; /* 16: Number representing the root device */

unsigned long initrd_start; /* 64: starting address of initial ramdisk */

/* This can be either in flash/dram */

unsigned long initrd_size; /* 68: size of initial ramdisk */

}

Note that the numbers represent the offset within the param structure where the fields are to be defined. This means that if the bootloader places the parameter structure at address 0xc0000100, then the rootdev parameter is placed at 0xc0000100 + 16, initrd_start is placed at 0xc0000100 + 64, and so on -- otherwise, the kernel will encounter difficulties in interpreting the correct parameters.

In a tagged list, each tag consists of a tag_header that identifies the parameter passed, followed by values for the parameter. The general format for a tag in the tag list could be as follows:

The kernel identifies each tag by the <ATAG_TAGNAME> header.

#define <aTAG_TAGNAME> <Some Magic number>


struct <tag_tagname> {

u32 <tag_param>;

u32 <tag_param>;

};


/* Example tag for passing memory information */


#define ATAG_MEM 0x54410002 /* Magic number */


struct tag_mem32 {

u32 size; /* size of memory */

u32 start; /* physical start address of memory*/

};


The setup_arch also needs to perform any memory mappings for flash banks, system registers, and other specific devices. Once the architecture-specific setup is done, control returns to the start_kernel function where the rest of the system is initialized. These additional initialization tasks include:

  • Setting up traps

  • Initializing interrupts

  • Initializing timers

  • Initializing console

  • Calling mem_init, which calculates the number of pages in various zones, high memory, and so on

  • Initializing the slab allocator and creating slab caches for VFS, buffer cache, etc.

  • Setting up various filesystems like proc, ext2, JFFS2

  • Creating kernel_thread, which execs the init command in the filesystem and displays the lign prompt. If no init program is present in /bin, /sbin, or /etc, the kernel will execute the shell present in /bin of the filesystem.

Debugging kernel

JTAG-

Porting Linux step by step

Below steps provides brief explanation about porting linux to ARM; these steps are very general.

Step 1 Machine registration

Register the machine type. In arch/arm/tools/mach-types

# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number

scp ARCH_SCP SCP 900

This provides a unique numerical identifier for your machine, also provides configuration variable for your machine as CONFIG_MACH_$MACHINE.

Provides runtime machine-check (machine_is_xxx).

Step 2 Firmware to kernel transition

Requires boot loader to

● Initialize all memory controller and system RAM

● Initialize a single serial port for early boot messages

● Disable MMU

● Disable all caches

● Provide kernel parameter ATAG list

● Required registers:

– r0 = 0

– r1 = machine number

  • r2 = &(ATAG list)

We are using U-boot.

ATAG list is a data structure for providing machine details to kernel.

Usually located in first 16KB of RAM, most common is @RAM base + 0x0100.

ATAG list is defined in include/asm-arm/setup.h.

ATAG list consists of

ATAG_CORE- start of parameter list.

ATAG_MEM- memory size and location one per memory blocks.

ATAG_NONE- end of parameter list.

Directory file structure which need to be taken care while modifying,

arch/arm/

mm

● Cache/TLB/page fault/DMA handling

kernel

● core kernel setup, APIs, and syscall handling

lib

● low-level helper functions (mostly ASM)

common

● code shared across various machine types

arch-$MACHINE

● Machine-type specific code (arch-ixp425, -pxa, -omap, etc)

configs/$PLATFORM_defconfig

● Default configuration for $PLATFORM (lubbock, ipaq, etc)

include/asm-arm/arch-$MACHINE (include/asm/arch)

– Machine-specific headers

Step 3 Early kernel init

At this stage kernel starts decompression, calling arch_decomp_setup(), during this stage it initializes serial port(if any), to see the messages.

Need to detect the CPU before starts initialization,

Kernel contains table of CPUs it supports in

arch/arm/mm/proc-$CPUTYPE

include/asm-arm/procinfo.h

First thing kernel does is check CPUID with table of CPUs

– Table contains a mask and expected value

If (cpuid & cpu_mask) == cpu_val we are OK

Otherwise we can't run on this CPU

– If OK, call CPU's _setup function.

If CPU is detected OK

Check for the machine type

Each platform has a machine descriptor structure: like

MACHINE_START(IXDP425, "Intel IXDP425 Development Platform")

MAINTAINER("MontaVista Software, Inc.")

BOOT_MEM(PHYS_OFFSET,

IXP4XX_PERIPHERAL_BASE_PHYS,

IXP4XX_PERIPHERAL_BASE_VIRT)

MAPIO(ixdp425_map_io)

INITIRQ(ixp4xx_init_irq)

.timer = &ixp4xx_timer,

BOOT_PARAMS(0x0100)

INIT_MACHINE(ixdp425_init)

MACHINE_END

Machine name/number from can be obtained from arch/arm/tool/mach-types.

Step 4 Mapping I/O devices

Certain devices need to be mapped before VM is fully up and running.

Like interrupt controller

Timer tick

Also certain devices need large virtual memory area

Static mapping allows usage of 1MB sections.

ioremap() uses only 4K pages

Call mdesc->map_io()

Call create_mapping() with static I/O mappings.

ARM-Linux Memory Map

Step 5 IRQ setup

IRQ are defined in defined in include/asm-arm/arch/irqs.h; with macro NR_IRQS

IRQ numbering is upto developer.

First level IRQ decoding is done in

include/asm/arch-$MACHINE/entry-macro.S

get_irqnr_and_base irqnr, irqstat, base, tmp

Step 6 system timer tick

This is initialized after IRQ.

Load timer with LATCH,

● ((CLOCK_TICK_RATE + HZ/2) / HZ)

● CLOCK_TICK_RATE is HW clock freq.

Request timer interrupt.

Set SA_INTERRUPT

Timer ticks every (1/HZ)s

For getting timer interrupt, call first timer_tick() function.

gettimeoffset() function returns no of microseconds since last timer tick.

Step 7 board level initialization

Board_init() function is called; which adds platform devices such as flash, I2C etc. This is very board specific.


MCS8140 specific peripherals

[List out peripherals and write brief about what are file changes done in kernel source tree to support these peripherals]


Directory

Files changed

Purpose

Target related changes

Arch/arm/mach-scp

Added new dir



irq.c

Interrupt management on MCS8140 (clear_irq, mask_irq, unmask_irq) ,do_level_irq, pci , usb routines.

arch.c

Arch type and name mentioning, ,Configuring size and start of SDRAM

pci.c

PCI bus registration, memory, irq mappings, configuration space reading routines.

Arch/arm/boot/compressed

/head-scp.S

- mov r7, #MACH_TYPE_SCP

Arch/arm/boot/bootp

/init.S

Taking the param_struct out of "tag list" , "param_struct".

include/asm-arm/arch-scp

Added new dir




dma.h

DMA hardware details e.g DMA channels, Max. DMA addr.( No changes)

hardware.h

Hardware mapping and base addr for all blocks e.g. BASE addr, offsets for PCI, USB, MAC etc..

io.h

Macros to perform various read/write operations

irqs.h

IRQ's numbers. memory mapping , some definitions for IRQs.

keyboard.h

Minor change - File not required

memory.h

defines phys_to_virt and vice-versa

pch.h

packet cache manipulation functions ( not required)

param.h

reserved for future use

serial_reg.h

Definitions for serial port usage

system.h

Routines for cpu soft reset and cpu idle.

time.h

System timer initialization, routines for timer offset and it's interrupt.

uncompress.h

serial console putc and puts funtions

timex.h

clock tick rate

vmalloc.h

virtual memory allocation , start, offset, end definitions.

Arch/arm/kernel

/entry-armv.S

deals preempt changes


/fiq.c

__asm_volatile changes for fiq.

Arch/arm/boot

/Makefile

Defines memory map symbols related to MCS8140 board and exports them Defines "arch/arm/boot/bootp/rdisk.bin.gz" as INITRD

Arch/arm/boot/compressed

/head.S

Starting file to load and relocate the kernel. Enabled the D-Cache to have fast Uncompression of linux image on bootup.

Driver file changes

drivers/char

/tty_io.c

Initialization of serial console.

drivers/serial

/serial_scp.c

serial console code.

drivers/net

/Space.c

Ethernet probe added.

include/linux

/skbuff.h

Chiefly added SKB debug messages apart from some minor target specifics.

net/core

/skbuff.c

Target specific enhacements related to packet cache

Init

/main.c

Console initilization delayed - Seems like not necessary.

Config and Makefile changes

Arch/arm/mach-scp

/Makefile

Simple makefile for new C files in this directory.

drivers/net


/Config.in

"tristate ' SCP FIQ network support' CONFIG_SCP_FIQ_ETHER"

/Makefile

FIQ modules added.

drivers/serial


/Config.in

CONFIG_SERIAL_SCP

/Makefile

serial_scp.o modules added.

Arch/arm

/config.in

Config file for adding SCP Architecture.

Arch/arm/boot/compressed

/Makefile

Config file for adding head_scp.o module.


Makefile

- Added info regarding the ARCH type, CC and path to MODLIB sym.link for asm-arm -> asm.

Kernel

/ksyms.c

Preempt_schedule exported ifdef CONFIG_PREEMPT

Arch/arm/kernel

/Makefile

- Add fiq.o module support if CONFIG_SCP_FIQ_ETHER defined

Arch/arm/tools

/mach-types

ARCH_SCP 900 added.

arch/arm

/Makefile

changed to hard float and ifeq ($(CONFIG_ARCH_SCP),y) MACHINE = scp. sym.link for arch-scp -> arch & proc-armv -> proc .

copied below line,

machine-$(CONFIG_ARCH_SCP) := scp

Arch/arm/boot/bootp

/rdisk.bin.gz

- compressed bin file which is defined as INITRD

Arch/arm

/defconfig

Default kernel config file

arch/arm/def-configs


/scp_modules

Selects what components to be built as modules.

/scp_builtin

Selects what components to be made part of the kernel

Net

/Config.in

Selects the Driver SKB pool , PCH, Net profiling ,if CONFIG_ARCH_SCP is there.

drivers/mtd/maps/

Scp.c

Partitioning of flash for bootloader, environment variables, kernel and file system.

MAC, LP ,TSO driver

drivers/net/arm

/mcs8140

New directory for ethernet driver.


Root file system

We are using Journaling Flash File System, version 2 (JFFS2) in MCS8140.

Creating a JFFS2 file system

Basic steps for creating JFFS2 file

A JFFS2 file system (basically a Ram disk using JFFS2) is created under Linux with the mkfs.jffs2 command as follows

mkdir jffsfile

cd jffsfile


/* copy all the /bin, /etc, /usr/bin, /sbin/ binaries and /dev entries that are needed for the filesystem here */


/*Type the following command under jffsfile directory to create the JFFS2 Image */


./mkfs.jffs2 -e 0x40000 -p -o ../jffs.image

The -e option specifies the erase sector size of the flash (typically 64 kilobytes). The -p option is used to pad the remaining space in the image with zeroes. The -o option is used for the output file, which is usually the JFFS2 filesystem image -- in this case, jffs.image.


Before creating root file system we need to compile the kernel and make kernel image.

Steps in compiling kernel

  1. make menuconfig

  2. make zImage

  3. make modules

  4. Copy .ko files to respective directory; these directory will be copy of directory file structure on target board.

  5. run command create_flash_image kernel [./kernel source tree]; this will generate kernel image as scp_zimage.

  6. run command create_flash_image jffs2 [./target directory structure]; this will generate jffs2 file system with name flashdisk_jffs2.

  7. create_flash_image is a script file;


A JFFS2 file system (basically a Ram disk using JFFS2) is created under Linux with the mkfs.jffs2 command as follows

mkdir jffsfile

cd jffsfile


/* copy all the /bin, /etc, /usr/bin, /sbin/ binaries and /dev entries that are needed for the filesystem here */


/*Type the following command under jffsfile directory to create the JFFS2 Image */


./mkfs.jffs2 -e 0x40000 -p -o ../jffs.image

The -e option specifies the erase sector size of the flash (typically 64 kilobytes). The -p option is used to pad the remaining space in the image with zeroes. The -o option is used for the output file, which is usually the JFFS2 filesystem image -- in this case, jffs.image.

/bin and /sbin

The /bin directory contains essential user command binaries and /sbin directory contains essential system administration binaries.

About busybox

BusyBox is a single executable implementation of many standard Linux utilities. BusyBox contains simple utilities, such as cat and echo, as well as larger, more complex tools, such as grep, find, mount, and telnet (albeit, with fewer options than the traditional version); some refer to BusyBox as the Swiss Army knife of utilities. Busybox is a key component of MCS8140, as it gives extremely small footprint (A multi-call binary can perform the functions of many different applications.) for MCS8140 it is 971KB, compaired to standard linux utilites size as 3.4MB.

The easiest way for BusyBox to perform the function of one of the applications that it can emulate is by creating and naming a symbolic link and connecting it to the BusyBox binary. You then type the name of the symbolic link, which executes BusyBox. BusyBox uses symbolic links to make one executable look like many. For each of the utilities contained within BusyBox, a symbolic link is created so that BusyBox is invoked. BusyBox then invokes the internal utility as defined by argv[0].

Currently defined functions in busybox v1.1.3 are

[, [[, addgroup, adduser, ash, awk, basename, bunzip2, busybox,

bzcat, cat, chgrp, chmod, chown, chroot, clear, cp, cut, date,

dd, delgroup, deluser, df, dirname, dmesg, du, echo, egrep, env,

expr, false, fdisk, fgrep, find, free, freeramdisk, ftpget, ftpput,

getty, grep, gunzip, gzip, halt, head, hostname, id, ifconfig,

init, insmod, kill, killall, klogd, linuxrc, ln, logger, login,

ls, lsmod, mesg, mkdir, mkfs.minix, mknod, modprobe, more, mount,

mv, netstat, nslookup, passwd, ping, poweroff, printf, ps, pwd,

reboot, reset, rm, rmdir, rmmod, route, sed, sh, sleep, sort,

start-stop-daemon, su, sulogin, sync, syslogd, tail, tar, tee,

telnet, telnetd, test, tftp, time, top, touch, tr, umount, uname,

uniq, unzip, uptime, usleep, vi, vlock, wc, which, who, whoami,

zcat

These all functions which are present in /bin and /sbin are symbolic link to busybox bin.


/etc

This directory contains system configuration files, including startup files.

About /init.d/rcS

This startup script present in /etc directory creates ramdisk of 42MB, this is being used for storing temporary messages. Actually /tmp -> rdisk0/tmp means /tmp directory is a link to rdisk0/tmp and /var is link to rdisk0/var. After creating ramdisk and /tmp and /var folders this script file starts syslogd and klogd daemons.

/dev

This directory contains devices and other special files.


/proc

This directory contains virtual file system for kernel and process information. This is useful for mounting virtual file system.

/tmp

It contains temporary files.

/var

It contains variable data stored by daemons and utilities.

/lib

It contains essential libraries, such as C library and kernel modules.

/mnt

It contains mount point for temporarily mounted file system.

/modules

It contains specific modules related to hardware block developed.

/usr

This is secondary hierarchy containing most applications and documents useful to most users.

/sys