Wednesday, May 26, 2010

How to set PATH in linux

This is the command you have to execute:-

export PATH=$PATH:/usr/local/bin


And if you want the PATH to add to root user if you are not present then make change in /root/.bash_profile.
This will be the permanent change.


Tuesday, May 25, 2010

Difference between NOR & NAND flash

Comparison between NOR and NAND are:-

1> Size of an erase block in NOR ranges from 64 to 128 Kbytes, which means its write/erase operation can take up to 5 s, whereas

Size of erase block of NAND ranges from 8 to 32 Kbytes, which means its write/erase operation takes 4ms of time.

Therefore,
NAND has high cell densities due to which its "write" and "erase" programs are faster than NOR flash.
2> EASE OF USE:-

NOR flash has an SRAM interface. It has enough address pins, through which allowing for easy access to every byte contained in it.

NOR-based flash is a straightforward process. It is connected like other memory devices, and code can be run directly from it.


NAND device, however, is complicated with its requirement for an I/O interface. Accessing rules for NAND interfaces may differ depending on the NAND vendor.

A driver must be written and used for performing any operation on a NAND device.

Therefore,
NOR "reads" slightly faster then the NAND flash.

3> NOR devices are used as a code-storage media.
NAND devices are used as a data-storage media.

Friday, May 21, 2010

How to create ramfs filesystem

There are few simple steps to create the ramfs filesystem:-

1) dd if=/dev/zero of=image_name bs=1M count=35
where bs -> block size and 1M-M-means Megabyte or if we want in kb we can directly write the figures.
count = number of times to be multiply the "bs".
So the result of above image will be 35M.

2) mke2fs -m 0 image_name
where "mke2fs" which is a tool that allows you to create a second extended (ext2) file system on any block device.

3)mount -o loop image_name /dev/dir_name
After then load the file system directories in this directory with required libraries.

After mount change in the filesystem whatever change needed after then we will umount the directory.

4)gzip -v -9 image_name
This command will generate the file with the name "image_name.gz".
After all that you will get a file with image_name.gz i.e. your required image you wanting.

5) mkimage -T ramdisk -C gzip -n 'RISHABH Testing Image' -d rishabh.gz uRamdisk

where:-
-T ==> set image type to 'type'. (Here it is ramdisk)
-C ==> set compression type 'comp'.
-n ==>no-name do not save or restore the original name and time stamp .
-d ==> decompress.

So after that you will get the image prepared for use.

After that you will umount that directory.
Work completed.


IF YOU WANT TO MODFIY THE EXISTED EXT2 FILESYSTEM IMAGE:-

1) Extract compressed ramdisk image (ramdisk.gz)
bash$:- dd if=uRamsdisk bs=64 skip=1 of=ramsdisk.gz

2) Uncompress ramdisk image (if it was a compressed one).

bash$:- gunzip -v ramdisk.gz

3) Mount ramdisk image

bash$:- mount -o loop ramsdisk dir_name/
Here we will now make the changes in the filesystem.

4) After then we will follow the same steps as above from step 4.

Thursday, May 20, 2010

Under what license will you write your driver

Q)Under what license will you write your driver?
A) Linux is licensed under Version 2 of the GNU General Public License (GPL).

The GPL allows anybody to redistribute, and even sell, a product covered by the GPL, as long as the recipient has access to the source and is able to exercise the same rights.

The main goal of such a license is to allow the growth of knowledge by permitting everybody to modify programs.

Wednesday, May 19, 2010

How will you register the device

Q)How will you register the device?
A)By default the device are registered from the list of devices made in the /dev/ files.
This is done when we are registering the device:-

--------------> register_chrdev(
unsigned int major,const char *name,const struct file_operations *fops).
There are other two methods other than this which are:-
register_chrdev_region();
alloc_chrdev_region(); Out of all this one is preferred.

If major == 0 this functions will dynamically allocate a major and return its number.

If major > 0 this function will attempt to reserve a device with the given major number and will return zero on success and if not it will returns a -ve errno on failure.

This is done when we are removing the device:-
--------------> unregister_chrdev(
unsigned int major,const char *name).









Why do you want to write a device driver

Q)Why do you want to write a device driver?
A:-
Basically device driver are written to communicate with the hardware and which is OS specific.

When a calling program invokes a routine in the driver, the driver issues commands to the device.

Once the device sends data back to the driver, the driver may invoke routines in the original calling program.

Drivers are hardware-dependent and operating-system-specific.

They usually provide the interrupt handling required for any necessary asynchronous time-dependent hardware interface.