Jun 25, 2010

htc hero on android. (configure for ubuntu )

For to progam each android phone we need to define rules. the rules files are in
  • /etc/udev/rules.d/
For HTC Hero to work with android ubuntu.  First get android tools, eclipse, adt-plugin and bla blas required....( that is a common procedure ).

Jun 23, 2010

square of numbers near to the base



Square of 104 ( faster way.. )


     Answer will have  _ _ _ _ _  .That is five digits.

  1. add the 4 to the entire number that is 104+4 = 108_ _. so we got first 3 digits. we are adding 4 as the distance of the number from base is 4.
  2. remaining two digits.(two more digits are there because base is 100, which contains two zeros). 
  3. That is square of 4 ie 16 ( bcoz 104 is 4 number away from base ).
  4. So answer is 10816
Base means 100,1000,10000.. etc....

Basically what happened is, I have taken the base as 100. Now 104 is 4 more than the base. So immediately add that 4 to the entire number. That is 108 which is the first three digit of our answer. Now since base is 100 and it has two zeros. So now two more digits to go. So there comes square of 4 which is 16.

another example :
square of 112.
  1. 112 + 12 is 124.
  2. As base is 100 which contains two zeros we require two more digits.
  3. 12 square is 144 so answer is
  • 1 2 4
  •       1 4 4
  • That is 12544.
Analyse the number 1 under 4. How and Why :) ?

Another example 
square of 96
  1. 96 is 100 - 4 . here also base is 100 but our number is four less than the base.
  2. so we will subtract that 4 from our number 96 - 4 = 92
  3. now 2 more digits ( as base is 100 )
  4. now 4 square is 16 ( bcoz 96 is 4 number away from base )
  5. so answer is 9216
this is well explained in this video.


May 24, 2010

gnuarm and qemu

This tutorial explains compiling arm programs with gnuarm and porting it into qemu emulator.

Requirements: ( ubuntu linux )
  1. gnuarm toolchain ( www.gnuarm.com )
  2. qemu emulator ( sudo apt-get install qemu )
okie.. so here is the step

save the code in add.s
------------------------------------------
.text

start:
mov r0, #5 @r0 <----- 5
mov r1, #4 @r0 <----- 4
add r2, r1, r0
stop:
b stop @infinite loop to stop execution
------------------------------------------

.text is an assembler directive which says that the following section have to be assembled into the code section, rather than the .data section. So what is sections ?

So next is compiling the code with gnuarm toolchain.

arm-elf-as -o add.o add.s
this will assemble the code into an outputfile

arm-elf-ld -Ttext=0x0 -o add.elf add.o
-Ttext=0x0, specified that address should be assigned to the labels, such that the instructions were starting from address 0x0

arm-elf-nm add.elf
To view the address assigned for various labels.

The output file created by ld is in elf format. there are various formats available for storing executable code.
The elf format works fine when you have the os around.
Here we are going to run the program on a bare metal, we have to convert it into a simple binary format.

arm-elf-objcopy -O binary add.elf add.bin
to convert elf to binary format

ls -al add.bin
-rwxr-xr-x 1 akku akku 16 2010-05-24 10:17 add.bin
check the size it is 16bytes, 4 instructions ---> 4bytes ( 32 bit ) each

So we got the simple binary file which has to be flashed into the board.

So next is porting the binary file into qemu arm emulator

ARM processor on reset it will start executing from 0x0 ( whatever there is.. ram, rom, flash ).
On connex board 16MB flash is located at that address. So ARM executes instructions from 0x0 of the flash.
So we need a flash to use with qemu. For that we create a flash file and load it with full of zeros first.

dd if=/dev/zero of=flash.bin bs=4096 count=4096

add.bin file is copied into the beginning of this flash file
dd if=add.bin of=flash.bin bs=4096 conv=notrunc
this is equivalent of programming the bin file onto the flash memory.

Next start qemu
qemu-system-arm -M connex -pflash flash.bin -nographic -serial /dev/null

-M connex : specifies the machine connex to be emulated
-pflash : specifies that flash.bin represents the flash memory
-nographic : specifies that simulation of a graphic display is not required.
-serial /dev/null : specifies that serial port of the connex board is to be connected to /dev/null, so that the serial port data is discarded.

(qemu) info registers

check register R02 it will be 00000009

Referance:

May 11, 2010

living with ax4510 Board....

The board is based on the processor S3C4510B (ARM7TDMI).. So development requires 2 things...
  1. Toolchain: to compile the code
  2. Uploader: to upload the code
Toolchain: a collection of tools which produce end binary to run on a particular board.
cpp ----> gcc ----> as ----> ld
( cpp, gcc ) : Partially generated and downloaded source is compiled into executables

( as, ld ) : Existing executables are directly used (eg for ld:glibc/newlib ). May be h/w stds and std files for a board.

---------------------------------------------------
Two are required for porting other than u r C code.
  1. Startup code : assembler code which does low-level hardware initialization and sets up such things as stack.
  2. linker script : which will tell to the linker where to put which sections of your complied code
The function of the assembler startup file is to run the C program.The linker script explains to the linker where in the memory to put what.

Linker Script contains:
ENTRY : ENTRY( _startup ) means _startup as entry point, which is defined in the startup file and which is visible to linker as it is declared as global.

MEMORY:
MEMORY
{
RAM (rw) : ORIGIN = 0x40000200, LENGTH = (0x00002000 - 0x00000200 - 0x20 - 0x100)
}
RAM as Read/Write region of memory with origin and length of different sections.

SECTIONS:
.text
.rodata
for read-only data
.data read or write data
.bss
for zero-initialized statically allocated variables.


References:
http://only.mawhrin.net/~alexey/prg/lpc2103/tutorial-hello/
http://www.cse.iitb.ac.in/~uday/courses/cs715-09/gcc-code-view.pdf

Apr 27, 2010

Boot process.... BIOS.... SCSI..... demystified....!!!!

When computer is turned on....


In short : BIOS will find the primary boot device(Hard Disk (HD) ) and loads first 512 bytes of it (MBR area)..
MBR area contains GRUB stage 1 which loads stage 1.5 ( 30kb immediately after 512b ). stage 1.5 loads stage 2...

So BIOS...?

Mar 22, 2010

android file handling

So start an emulator with sdcard some things that I tried ---->
  • emulator -sdcard sdcard1.iso -avd avd_1.5
  • mksdcard 8M sdcard
  • emulator -sdcard sdcard &
  • adb push YOUR_FILE_A /sdcard
list the files(directories also) on an SD card : http://markmail.org/message/qgfx35u7sjb4z4wr

Mar 21, 2010

setting Samsung Galaxy in Ubuntu 9.04


So here it goes…. the environment that I worked with is Ubuntu 9.04… Samsung Galaxy. It was not detecting in my ubuntu… so I fallowed these steps to detect it.. ( Thanks Saurav )….
Steps
Make a file 50-android.rules in /etc/udev/rules.d/ folder and add the following into that
SUBSYSTEM==”usb”, SYSFS{idVendor}==”18d1″, MODE=”0666″
———————————————————————————————
Make another file 90-android.rules in the same folder /etc/udev/rules.d/ and add this into that
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”04e8″, ATTRS{idProduct}==”6640″, MODE=”0660″, OWNER=”root”, GROUP=”androiddev”, SYMLINK+=”android%n”
SUBSYSTEM==”usb”, SYSFS{idVendor}==”04e8″, MODE=”0666″

———————————————————————————————-
Now do this /etc/init.d/udev restart
———————————————————————————————-
Now connect the Galaxy phone into PC
Next go to android-sdk/tools/ then do the following
./adb kill-server
./adb start-server
./adb devices

If it is detected you r lucky…. otherwise you are more lucky, coz you r goin to learn more….
so,…. it should show something like the following
List of devices attached
I7500bH2irb7283 device

If your emulator is running it will show that also.
or if it is showing this…..
List of devices attached
then you have to change the adb with a patch version..
open a terminal
go to android-dk/tools/ folder then do the following….
wget http://floe.butterbrot.org/external/adb.gz
gunzip adb.gz
chmod +x adb

Now do this, ./adb devices.. I am sure it will show the device…. if it is connected… if not check following steps…
Note: here I have used Galaxy model I7500 its ID vendor and ID product is given 04e8 and 6640 respectively. That is why in the rules files I gave like this
ATTRS{idVendor}==”04e8″, ATTRS{idProduct}==”6640″
S if your are using a different model like Galexy I9000 or any other vendor product, you have to change these numbers accordingly. So for to get the number. Connect the mobile to the system and then open a terminal and type lsusb . Then you can see something like this

Bus 001 Device 003: ID 0fca:8004 Research In Motion, Ltd.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 046d:c018 Logitech, Inc. Optical Wheel Mouse
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
ID vendor: product I have highlighted in green. First is my RIM blackberry. so find that two IDs and update that in rules files

Make a file 50-android.rules in /etc/udev/rules.d/ folder and add the following into that
SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"
---------------------------------------------------------------------------------------------
Make another file 90-android.rules in the same folder /etc/udev/rules.d/ and add this into that
SUBSYSTEMS=="usb", ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="6640", MODE="0660", OWNER="root", GROUP="androiddev", SYMLINK+="android%n"
SUBSYSTEM=="usb", SYSFS{idVendor}=="04e8", MODE="0666"
----------------------------------------------------------------------------------------------

Actually I am working with number of mobiles, I have lot of rules files... so edit your rules files as shown in lsusb ... for u r mobile model surely that will be different..

For Web Developer

  open -a "Google Chrome" --args --disable-web-security