Wednesday, March 16, 2011

Free Electrons

http://free-electrons.com/

They offer free training materials about Linux kernel. And their blog is interesting to read to keep you updated about the current kernel developments.

Thursday, March 10, 2011

System revision

Development boards usally have many version. Because no board can be perfect first time. So in the process of improving the boards we end up in many system revisions. One way of doing this is to dedicate few gpio lines(may be 3 in this case you can have 2^3 = 8 board versions). Disadvantage of this way is thay you will end up waisting 3 gpios. Another way is to use the ADC for this purpose. The mechanism is to connect two resitance in series and varry the resistance amoung the boards. Measure the voltage across one resitor and find out the board.
For example, R1 = 100K and R2 = 100K. R1 and R2 are in series with volatge of 3.3V. So the voltage drop across R2 will be 1.65V, which we measured using ADC and decision is made.

In C110 processor we use ADC with resolution of 12 bits so the range is 0 to 4095. But the voltage range is 0 to 3.3V. Now we need to map adc value to our voltage range.

Here is the mathematics,
3.3V = 4095 units of ADC
1 unit of ADC = 3300 mV/4095 = 0.8058mv
for 3.3 v adc value is 4095 units( ie 3300/0.8058)

So in our case we need 1.65V or 1650 mV. So the adc value should read 2047(ie 1650/0.8058)

Tuesday, March 8, 2011

NOR Vs NAND

NOR
Access - linear random
Replace - ROM
Cost - expensive
Density - low
Earse time - 1 second
Programing - byte by byte
OOB data - no
NAND
Access - pagewise
Replace - mass strorage
Cost - cheap
Density - high
Earse time - 2 ms
Programming - pagewise, must be erased before
OOB - yes

yaffs2 and nand drivers

The crespo board was booting android with system and data partititons on the Movi-nand. Now the task is to move this to the one-nand memory. The main area to be modified is at the bootloader where partitons are defined. This will be passed to kernel as ATAGS. so modified the partition table to point the system and the data partitions to nand. Then edited the init.herring.rc file to
mount yaffs2 mtd@system /system wait ro
mount yaffs2 mtd@userdata /data wait noatime nosuid nodev

Next is to create yaffs2 filesystem. Initally I used the command,
./out/host/linux-x86/bin/mkyaffs2image out/target/product/crespo/system sytem.img
But file system was not mounting with this. The reason was that by default mkyaffs2image utility used page size as 2048 and spare area(OOM) as 64. Later when I checked the data sheet of the One-nand, it was 4096 and 128 respectively. So modifed the command to,
./out/host/linux-x86/bin/mkyaffs2image -c 4096 -s 128 out target/product/crespo/system system.img

But this time Odin was giving and flashing failure. So I checked the size of the system.img. It was 155MB and compared with the size of the system partitions which was only 152MB. So that was the reason for flashing failure. After stealling some space from data partiton, flashing works. And the yaffs2 filesystem was successfully mounted. :-)

If you want to know more about the NAND and Yaffs2 File System here is a good link.

Monday, March 7, 2011

The power of Vim

Command line is one of the main thing most of the people hate about the Linux. But the power of linux comes form command line. Yes its a bit hard to learn and remember all the commands and keywords. But it worth learning. In my humble opinion its is the fastest editor than any GUI apps. Code travesing is so easy. Here I m presenting some of the vim command I frequently use. Read and move fast on your coding and debugging....

Travesing the code. ============= This is the first thing an editor should provide, to traverse through the code. To go to any reference, use

1) g + ] . This will list all the instance of the definition of a variable of a function if there are more than one. Press the number to go to the definition you prefer. To return back, 2) CTRL + t

This works with ctags. Before using the short cut keys, you should create the database using the command(Ctags -R). This command will create tags file.

To search any string in the current file, prese esc and type / Another way is using (SHIFT + *). Move to variable or function name and press (SHIFT + *). It will move to the next instance in the file. Then you can use " n" to move to next instance and "SHIFT + n" to search in backward direction. "SHIFT + g" will move to the end of the file. ":number" will move to the corresponding line number. If you want to find the end of any loops, put the cursor on the bracket and press "SHIFT + %"

"CTRL + e" to move down "CTRL + y" to move up. EDITING For selecting the lines, I use virtual mode. Press "v" then use the arrow keys to select as many line as you want. Then press "y". Use "p" to paste. To delete any blank space before the lines, use coloumn virtual mode by pressing "CTRL + v"

For auto completion, type till whatever you remember and use "CTRL + p" For substitution, %s/arun/avin/gc If you remove gc it will substitute all the instances of arun with avin without asking. If I want to copy from another file, use the following format, e filename Then use virtual mode and copy then type "e + #" . This will bring back to our old file. Then use "p" for pasting. Copying the format: If you want to format a code like intentation etc. Make few lines of code mannualy and then select the reset of the code along with the modified one in visual mode. Then press "=". The rest of the code will also get the intentation.

Undo and Redo
==============
press "u" for undo and
press "ctrl + r" for redo.


To use Marks
==============
http://vim.wikia.com/wiki/Using_marks


How do I repeat an edit on multiple lines in vim?

How do I repeate an edit on multiple lines ?
=================================

lets say for the text
abc1234
def5678
xyz3456

if you hit CTRL  + V with your cursor over the 1, use arrow keys twice to go down two columns, then Shift + i + ,  Then press ESC, your text would look like this:

abc,1234
def,5678
xyz,3456

.Vimrc
==============
Below are the thing to find in my .vimrc



Multiple copies(Vim copy paste buffers)
============================

"ay12 – create a buffer named ‘a’ with 12 lines in it
"ayw – create a buffer named ‘a’ with 1 word in it
"ap – put the contents of buffer named ‘a’

Please note that the named buffer can be any single letter between a – z

Usage: lets say you are writing a new driver and you want to type some words frequently. You can save them to the buffer.

For eg these two words are pmic_tw123 and PMIC_TW123

keep the cursor at the "pmic_tw123" and type "ayw. This creats a buffer named a and copies pmic_tw123 to it

keep the cursor at the "PMIC_TW123" and type "byw. This creates a buffer named b and copies PMIC_TW123 to it.

To paste use "ap and "bp.

We are actually using registers feature of the Vim. you can see the yanked words by issues :registers 

Similarly you can create for lines too.