6.04.2013

Linux Boot Sequence

 

1.Introduction:

 

Booting a Linux system is influenced by the design of hardware involved in booting. Whole boot mechanism can be divided into several logical steps, doesn’t matter whether you are booting a standard x86 desktop machine or an embedded system powered with Linux. This article explains boot process from initial power on state to start of first user application. It also covers other boot-related topics such as the boot loaders, kernel decompression, the initial RAM disk, and other elements of Linux boot.

 

2. Starts with hardware design: 

 

Design of hardware defines initial steps to be performed, when a system is powered on. How to read data from nonvolatile memory to RAM depends upon the type of memory, used for volatile and non volatile storage. Some devices may employ a core to perform security check before actual boot against any tampering in boot code and application, while in some cases there may be a tiny code to initialize basic hardware. 

 

  3. Boot Sequence:

 

Following figure shows different steps involved in booting of a typical Linux machine. Each step is described in detail in later sections.

 

 System Start-up:

 

When a typical Linux desktop machine is powered on, the hardware needs time for voltage to stabilize and reset to be released. After reset, processor executes code from a well known location. In a desktop machine this location is in BIOS (Basic Input Output System), which is stored in flash memory of mother board. The purpose of BIOS is to perform some low level initialization like Cache, Memory controller, clocks. CPU initially executes a portion of BIOS from flash itself, which includes low level initialization. Once initialization of chipset is done, CPU loads remaining portion of BIOS into RAM and executes it. BIOS searches for bootable devices in their order of priority, and looks for first level boot loader i.e. MBR(Master Boot Record). If MBR is found, it is loaded into RAM. If no MBR is found, BIOS gives error message "no bootable device, insert boot disk".

While in embedded systems there may be independent hardware block to perform some primary tasks like initialization of essential hardware, security checks etc. Once these primary tasks are successfully done, it resets CPU. In some cases, reset vector can be configured through these blocks. It provides flexibility to boot from any memory location.

 

First Stage Boot Loader:

 

The first stage boot loader resides inside MBR. The MBR is 512 byte image containing first stage boot loader, partition table, and magic number (See figure 2). First 446 bytes of MBR is executable primary boot loader, next 64 bytes are the partition table, which contains information about four partition tables. Last two bytes are magic number (0xAA55) used for validation check of MBR. The Primary boot loader finds and loads secondary boot loader. It searched for an active partition from partition table. Once active partition is found, its boot record is read from device into RAM and executed.

 In embedded system bootstrap environment is used. The boot strap environment includes uboot, Redboot etc. These programs are stored at predefined location of flash memory of target platform. These programs download and decompress kernel image into RAM and then execute it. They also perform some level of system test and hardware initialization before downloading kernel. They cover functionality of first stage and second stage boot loaders both. 

 

Second Stage Boot Loader:

 

The second stage boot loader is also called as kernel loader. The task of second stage boot loader is to load kernel and an initial ramdisk (optional). LILO(Linux LOader) and GRUB(Grand Unified Bootloader) are generally used in x86 desktop environment. They include functionality of first stage and second stage boot loader both. GRUB includes knowledge about Linux file system, so GRUB can load Linux kernel from ext2 and ext3 file system. It breaks the two stage process in three stages; stage 1, 1.5 and 2. In stage 1.5, it builds knowledge of the Linux file system containing the Linux kernel. Stage two boot loader displays list of kernels available for booting. Once a kernel is selected to boot, second stage loader consults file system and loads kernel image and initial ramdisk in RAM. The kernel loaded into RAM may not be executable kernel. It is a compressed image. The head of the kernel image contains utility routine, which initializes some hardware and decompress the kernel image. Second stage boot loader executes this routine.  

 Kernel:

When the routine bzImage (for an i386 image) is invoked by second stage boot loader, it begins at ./arch/i386/boot/head.S in the start assembly routine (see Figure 3 for the major flow). This routine does some basic hardware setup and invokes the startup_32 routine in ./arch/i386/boot/compressed/head.S. This routine sets up a basic environment (stack, etc.) and clears the Block Started by Symbol (BSS). The kernel is then decompressed through a call to a C function called decompress_kernel (located in ./arch/i386/boot/compressed/misc.c). When the kernel is decompressed into memory, it is called. This is yet another startup_32 function, but this function is in ./arch/i386/kernel/head.S. 


startup_32() function (also called the swapper or process 0; PID 0), the page tables are initialized and memory paging is enabled. The type of CPU is detected along with any optional floating-point unit (FPU). The start_kernel() (init/main.c) function is then invoked, which takes you to the non-architecture specific Linux kernel. This is, in essence, the main function for the Linux kernel.

In the new
With the call to start_kernel(), a long list of initialization functions are called to set up interrupts, perform further memory configuration, and load the initial RAM disk. In the end, a call is made to kernel_thread (in arch/i386/kernel/process.c) to start the init function, which is the first user-space process. Finally, the idle task is started and the scheduler can now take control (after the call to cpu_idle). With interrupts enabled, the pre-emptive scheduler periodically takes control to provide multitasking
.

initrd:

During the boot of the kernel, the initial-RAM disk (initrd) that was loaded into memory by the stage 2 boot loader is copied into RAM and mounted. This initrd serves as a temporary root file system in RAM and allows the kernel to fully boot without having to mount any physical disks. Since the necessary modules needed to interface with peripherals can be part of the initrd, the kernel can be very small, but still support a large number of possible hardware configurations. After the kernel is booted, the root file system is pivoted (via pivot_root) where the initrd root file system is unmounted and the real root file system is mounted.
The initrd function allows you to create a small Linux kernel with drivers compiled as loadable modules. These loadable modules give the kernel the means to access disks and the file systems on those disks, as well as drivers for other hardware assets. Because the root file system is a file system on a disk, the initrd function provides a means of bootstrapping to gain access to the disk and mount the real root file system. In an embedded target without a hard disk, the initrd can be the final root file system, or the final root file system can be mounted via the Network File System (NFS).


User Space

After the kernel is booted and initialized, the kernel starts the first user-space application /sbin/init. This is the first program invoked that is compiled with the standard C library. Prior to this point in the process, no standard C applications have been executed. Init will start the services setup in the system.  This program also creates a process called init process with process id 1. The init process is parent of all process.
The init process reads the file "/etc/inittab" and uses this file to determine how to create processes. The init process is always running and can dynamically do things and run processes based upon various signals. The administrator can also cause it to dynamically change system processes and run levels by using the telinit program or editing the "/etc/inittab" file. Unix and Linux utilize what is called "run levels". A run level is a software configuration of the system that allows only a selected group of processes to exist. Init can run the system in one of eight run levels. These run levels are 0-6 and S or s. The system runs in only one of these run levels at a time.


0 - halt
1 - Single user mode
2 - Multiuser, without NFS (The same as 3, if you don't have networking)
3 - Full multiuser mode
4 - unused
5 - X11
6 - Reboot

The /etc/inittab file instructs init which runlevel to start the system at and describes the processes to be run at each runlevel. An entry in the inittab file has the following format:
Id  :  run_levels  :  action  :  Process
Id: A unique sequence of 1-4 characters which identifies an entry in inittab.
Run levels:  Lists the run levels for which the specified action should be taken. This field may contain multiple characters for different run levels allowing a particular process to run at multiple run levels.
For example, 123 specifies that the process should be started in run levels 1, 2, and 3.

Action:

  Describes which action should be taken. Valid actions are listed below respawn: The process will be restarted whenever it terminates. wait: The process will be started once when the specified run level is entered and init will wait for its termination. once: The process will be executed once when the specified run level is entered boot: The process will be executed during system boot. The run levels field is ignored. bootwait: Same as "boot" above, but init waits for its termination off: This does nothing. ondemand: This process will be executed whenever the specified ondemand runlevel is called. initdefault: Specifies the run level which should be entered after system boot. If none exists, init will ask for a run level on the console. The process field is ignored.

sysinit: 

 The process will be executed during system boot. It will be executed before any boot or bootwait entries. The run levels field is ignored.

powerwait: 

 The process will be executed when init receives the SIGPWR signal. Init will wait for the process to finish before continuing.

powerfail: 

Same as powerwait but init does not wait for the process to complete.


powerokwait: 

The process will be executed when init receives the SIGPWR signal provided there is a file called "/etc/powerstatus" containing the word "OK". This means that the power has come back again.

ctrlaltdel: 

This process is executed when init receives the SIGINT signal. This means someone on the system console has pressed the "CTRL-ALT-DEL" key combination.

kbrequest: 


The process will be executed when init receives a signal from the keyboard handler that a special key combination was pressed on the console keyboard.

Process:

 Specifies the process to be executed. If the process starts with the '+' character, init will not do utmp accounting for that process. The utmp file allows one to discover information about who is currently using UNIX. The file is a sequence of entries with the following structure declared in the include file:


struct utmp {
            char      ut_line[8];          /* tty name */
            char      ut_name[8];       /* user id */
            long       ut_time;             /* time on */
};


This structure gives the name of the special file associated with the user's terminal, the user's login name, and the time of the login in the form of time (2).
The /etc/inittab file: (Example)
On line 1 you'll see "id:3:initdefault:". The id is "id" which stands for initdefault. Note it is unique on all the numbered lines. The runlevel is 3 which sets the default starting run level to run level 3.


You will also find following entry in /etc/inittab: 


“con:2345:respawn:/sbin/getty console”


It instructs init process to start getty application for run level 2,3,4, and 5. getty opens a tty port, prompts for a login name and invokes the /bin/login command. It displays login prompt and performs random administrative things, such as setting the UID and GID of the tty. Then it executes /etc/profile script to set the HOME, PATH, SHELL, TERM, MAIL, and LOGNAME environment variables.  PATH defaults to /usr/local/bin:/bin:/usr/bin for normal users, and to /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin for root.
 After this, it starts user’s shell.  If no shell is specified for the user in /etc/passwd, then /bin/sh is used. If there is no directory specified in /etc/passwd, then / is used. The user shell then in turn invokes user’s shell profile file (.cshrc or .bashrc) from his home directory and then displays prompt to run commands.
 



2.15.2013

Micromax Canvas HD goes on sale for Rs 13,990

 Micromax’s first quad core processor phone, A116 Canvas HD, has officially gone on sale in India.  The phone priced at Rs 13,990 will currently be available only through the company’s website.



The phone which will have a 5 inch touchscreen, is powered by MediaTek’s MT6589 1.2 GHz quad-core processor and is run on Android Jelly Bean 4.1.
Its HD screen has a resolution of 1280×720 pixels and a colour depth of 16.7 million, providing the user with superior graphics and HD viewing experience. Supported by a 2000mAh battery, the phone will be delivered between 5-7 working days.
The phone also sports an 8MP rear camera with LED flash, multiple camera settings, 4X zoom and auto focus. It is 3G enabled, with memory expandable up to 32GB.

Even as Samsung leads the Indian smartphone race with a 41.6 percent share, followed by Nokia (19.2 percent) and Research in Motion (12.1 percent), according to Cybermedia Research, Micromax with its aggressive strategy of launching 30 smartphones this year to expand the portfolio of handsets and tablet PCs is set to give them stiff competition.
The Canvas HD smartphone will be in the “phablet” category — a cross between a phone and a tablet.

 Micromax A116 canvas HD Specifications

  • 1.5GHz quad core Process
  • 5 inches  capacitive touch screen 
  • Jellybean 4.1 OS
  • Internal Memory 4GB
  • Internal RAM 1GB
  • Memory with microSD expandable to 16 GB
  • 8 MP rear camera
  • 2 MP front camera
  • Li-Ion 2000 mAh battery to provide 5 hours of talktime
  • Connectivity :
    • EDGE
    • 3G+2G
    • 802.11 ac Wifi 
    • Wifi hotspot
    • Bluetooth4.0
    • USB 2.0

Micromax has shared that they are now looking at replenishing the stock at the earliest but did not mention the exact availability date for the same.
 

Micromax introduces the Bolt series with the launch of A35

Micromax has introduced a new category called Bolt and also launched the Micromax A35, the first handset in the Bolt family. The Micromax A35 is priced at around Rs. 4,250 and comes powered by a 1GHz single core processor.


      

The Bolt category will include handsets that will feature Flash Transfer. The Flash transfer makes use of Wi-Fi and one can easily share data between two handsets without using any other network. One of the devices will function as a hotspot.

There is a special app that is pre-loaded that provides better file sharing experience. Users can swipe the files (videos, MP3, documents etc) across the screen of another device or simply shake and share between android phones.

The A35 is another budget phone that supports dual SIM, comes pre-loaded with the Flash Transfer app and runs on Gingerbread OS. The CPU is clocked at 1GHz and the screen size is 4 (3.9) inches with 800×480 pixels resolution.

Other features included are Wi-Fi, micro USB and Bluetooth. There is a 2MP rear camera and a front VGA camera. The battery is of 1500 mAh capacity. The Micromax A27 also comes with the flash transfer feature (swipe and share).

 Micromax A35 Bolt Specifications :
  • 1 GHz Single core Processor
  • 4 inches  capacitive touch screen 
  • Android 2.3.5 Gingerbread OS
  • Memory with microSD expandable to 16 GB
  • 2 MP rear camera
  • 0.3 MP front camera
  • Li-Ion 1500 mAh battery to provide 5 hours of talktime
  • Connectivity :
    • GPRS
    • EDGE
    • 2G,
    • 802.11 ac Wifi
    • Bluetooth 2.1
    • USB 2.0

With a MOP of Rs 4,250 the Bolt A35 will be available across all leading retail outlets in India, Feb 15 2013.

2.11.2013

How to root Micromax A87 phone step by step procedure

Hi Folks ,

I used MMX A87 phone past three month. First and far most we need adb working Environment for the next process like root the phone MMX A87.

Please make setup for android SDK  for ubuntu or windows .

-------------------------
 Windows Setup
-------------------------

Please download these files

android sdk
http://dl.google.com/android/installer_r20.0.3-windows.exe
java sdk
http://download.oracle.com/otn-pub/java/jdk/7u7-b11/jdk-7u7-windows-i586.exe?
AuthParam=1350317070_8a229567d69b6871e02fb949ab25aa76

install both
now to go c:/android-sdk-windows
run sdk manager.exe and select tools
make sure you have selected two options (tick)under the tools
note : you need Internet connection for this
after successful installation you will find platform-tools folder in c:/android-sdk-windows
inside platform-tools folder you will find adb and fastboot files.
Now run cmd and type cd c:\android-sdk-windows\platform-tools(navigating to the adb folder)
Now connect your phone to pc and make sure usb debugging is enabled in phone goto settings and select application then select development then tick usb debugging.

In cmd window type adb devices(if you have installed the drivers already) xxxxxxxxxxxx xxxx will be displayed that means adb is working if not then drivers is not installed properly.
Now download Micromax a87 drivers from here http://micromaxsuperfone.com/products/PDF/A87.zip
or
http://d-h.st/RIi
http://www.directmirror.com/files/AHLJI7BT


How to root your micromax a87 phone

Rooting phone(MMX A87) will void your warranty and you will not get services by the Micromax people, to solve this download this file
http://www.mediafire.com/?dtcgdwxe689zdcj (credits goes to original uploader)

Its a stock a87 rom by flashing this your phone will be like the 1st day you brought your phone and Micromax people will not be having any idea. Just copy the zip file to sdcard and turnoff your phone. Now press volume up + power button ,phone will be booted into recovery mode use volume rocker to navigate and select apply update from zip and select downloaded file from sdcard and press power button and relax, your phone will be restored!
1st you need to have the working adb to proceed check the how to get your adb working perfectly section before looking here.
If your adb is working and your devices is listed then you are ready to root your phone.
Download this file
http://www.directmirror.com/files/1RPFSGKI
Install and run the downloaded file
On the left bottom u will find the root button just click on it, takes sometime and now you have rooted your phone.
Now install this apk in phone
busybox

http://www.directmirror.com/files/6AWSIT7R


superuser
http://d-h.st/XCK
root checker
 
Run root checker, it will confirm the root access. Now you have fully working rooted phone.



How to flash stock A87 ROM (in case you bricked it).
In case if you bricked your phone or made some serious changes and cant revert back or some kind of malfunction happened and you’re worried, no need to worry from now on. We have stock a87 rom which is the original os shipped with Micromax devices.
Just download this file and copy it to sdcard
Then turn off ur phone.
Now press up volume + power button until u see micromax logo.
Then u will enter the recovery mode ,there by using the volume rocker select the apply update.
From the sdcard and press power button ,now select yes and press power button again.
After sometime you will see successful message.
Now select reboot.
Thats all your phone is back to stock rom shipped from micromax.
Download stock a87
http://www.mediafire.com/?dtcgdwxe689zdcj

Amazing and Interesting 25 facts about incredible india

  1. India is about 1/3 the size of the United States, yet it is the second most populous country in the world, with a population of 1220200000(1.22 billion). India is the seventh largest country in the world, at 1.27 million square miles.
  2. India is the largest democracy in the world.
  3. Many Indians find toilet paper repellent and consider it cleaner to splash water with the left hand in the appropriate direction. Consequently, the left hand is considered unclean and is never used for eating.
  4. To avoid polluting the elements (fire, earth, water, air), followers of Zoroastrianism in India don’t bury their dead, but instead leave bodies in buildings called “Towers of Silence” for the vultures to pick clean. After the bones dry, they are swept into a central well.
  5. rupee
    It is illegal for foreigners to import or export Indian currency (rupees)
  6. It is illegal to take Indian currency (rupees) out of India.
  7. India leads the world with the most murders (32,719), with Russia taking second at 28,904 murders per year.
  8. India has one of the world’s highest rates of abortion.
  9. Cows can be found freely wandering the streets of India’s cities. They are considered sacred and will often wear a tilak, a Hindu symbol of good fortune. Cows are considered one of humankind’s seven mothers because they offer milk as does one’s natural mother.
  10. Dancing is one of India’s most highly developed arts and was an integral part of worship in the inner shrines of every temple. It is notable for its expressive hand movements.
  11. Many Indian wives will never say their husband’s name aloud, as it is a sign of disrespect. When addressing him, the wife will use several indirect references, such as “ji” or “look here” or “hello,” or even refer to him as the father of her child.
  12. A widow is considered bad luck—otherwise, her husband wouldn’t have died. Elderly women in the village might call a widow “the one who ate her husband.” In some orthodox families, widows are not allowed near newlyweds or welcomed at social gatherings.
  13. India is the birthplace of chess.The original word for “chess” is the Sanskrit chaturanga, meaning “four members of an army”—which were mostly likely elephants, horses, chariots, and foot soldiers.
  14. The Indian flag has three horizontal bands of color: saffron for courage and sacrifice, white for truth and peace, and green for faith, fertility, and chivalry. An emblem of a wheel spinning used to be in the center of the white band, but when India gained independence, a Buddhist dharma chakra, or wheel of life, replaced the spinning wheel.
  15. Khajuraho erotic sculptures
    Khajuraho’s exotic art may suggest that sex was a step for attaining ultimate liberation or moksha
  16. The temples of Khajuraho are famous for their erotic sculptures and are one of the most popular tourist attractions in India. Scholars still debate the purpose of such explicit portrayals of sexual intercourse, which sometimes involve animals.
  17. In ancient and medieval India, suttees, in which a recently widowed woman would immolate herself on her husband’s funeral pyre, were common.
  18. The Himalayas—from the Sanskrit hima, meaning “snow,” and alaya, meaning “abode”—are found in the north of India. They extend 1,500 miles and are slowly growing taller, by almost an inch (2.5 cm) a year. Several ancient Indian monasteries are found nestled in the grandeur of these mountains.
  19. India is the world’s largest producer of dried beans, such as kidney beans and chickpeas. It also leads the world in banana exports; Brazil is second.
  20. In India, the fold and color of clothing are viewed as important markers of social classification. Additionally, a woman will be viewed as either a prostitute or a holy person depending on the manner in which she parts her hair.
  21. With 150,000 post offices, India has the largest postal network in the world. However, it is not unusual for a letter to take two weeks to travel just 30 miles.
  22. The Bengal tiger is India’s national animal. It was once ubiquitous throughout the country, but now there are fewer than 4,000 wild tigers left.
  23. All of India is under a single time zone.
  24. On India’s Independence Day, August 15, 1947, the country was split into India and Pakistan. The partition displaced 1.27 million people and resulted in the death of several hundred thousand to a million people.
  25. In recent years, Indian authors have made a mark on the world with such novels as Salman Rushdie’s The Satanic Verses (1988), Vikram Seth’s Suitable Boy (1993), and Arundhati Roy’s The God of Small Things (1997).
  26. India experiences six seasons: summer, autumn, winter, spring, summer monsoon, and winter monsoon.
  27. India is the world’s largest tea producer, and tea (chai) is its most popular beverage.