Aug 4, 2010

arm memory organisation

This post is some scratches of what I learned from a youtube video for ARM processor memory organization.

Memory organisation? how the different types of memories such as cache, RAM are used to set up the complete memory system in an embedded system.

Aug 2, 2010

android camera tutorial

To learn camera programming with android, what I did is downloaded some sample programs and opened that as existing projects in android. I am using ubuntu 10.04. The links that I used for camera tutorialis given below.
First download the existing projects. (better to hack an existing one than writing from scratch ;) )

Jul 29, 2010

arm assembly work book { incomplete }

This is some of my rough works.
adc r2, r0, r1  ; r2 = r0 + r1 + carry bit

Arm architecture reference manual.pdf is a good reference for to learn ARM Architecture.

The subroutine return is performed by copying R14 back to the program counter.
This is typically done in one of the two following ways:
MOV PC,LR
BX LR

Jul 28, 2010

Page Rank.... Google....

This was the topic that I have selected for my PG-diploma  Seminar. It is actually google's pagerank algorithm developed by Larry Page and later joined by Sergey Brin, together they implemented Google. So here I am publishing my ppt which I compiled for the seminar.

What is boot code and stack initialisation in ARM

[Click here to download a sample complete project for arm. It uses gnuarm's arm-elf- toolchain for compilation and qemu emulator for to emulate]

This post is very much linked with my previous post arm-elf toolchain rough notes of my works...
Actually on powerON or reset, arm will start fetching and executing instructions from 0x00000000. As arm processes 32 bit instructions, each time PC is incremented by 4. like 0x00000000 0x00000004 0x0000000C like that....

Jul 20, 2010

arm-elf- toolchain rough notes of my works......

scratches of my arm works... This is my rough backup.
This post explains how to develop a ready to run assembly code which works on an arm board from scratch. This includes boot.s crt.s and app.s.

Jul 12, 2010

an overview of arm board with mini2440

Mini2440 uses the samsung processor S3C2440 (arm7tdmi) from samsung. 

Processor S3C2440

Flash: 2MB NOR or 64MB(128, 256) NAND. Selected using S2 switch.

SDRAM: 2 Nos - 32MB each So total 64MB. Which has a 32 bit data bus width for maximum speed. Chip select nGCS6 places the SDRAM in 0 x 3000 0000.

Use JTAG Interface to program NOR flash with supervivi bios.

Features of my interest....

Jul 8, 2010

CPU digest.


DMA Controller: It contains source address, destination address and the count of words going to transfer between source and destination. One problem that can occur due to this is cache coherency.


Intel C8237 is a DMA chip.

Jul 1, 2010

Java Com API settings. ( access comm port through java )

Get comm.jar, win32com.dll, javax.comm.properties files.
Then follow the steps.
  1. copy comm.jar to jre/bin
  2. copy win32comm.dll to jre/bin
  3. copy javax.comm.properties to jre/lib
So that is it.... It is tea time... bye....

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..

Mar 16, 2010

Android-Content Providers...

Activities, Service, Content providers, Broadcast receivers the four heros of android... hu hu ha ha.. So this scratch is for the content providers.. simple defnition is 'provider of the content' or database...

Some points...
  1. Android applications can use a file or sqlite database to store data.
  2. CP provides a way in which we can share data b/w multiple applications
  3. Consider Contact DB.. If it is used by different apps,... put it in CP for to hv common access.
  4. if u want u r data to b public and accessed by many apps,.. put it in u r own content provider.
Apps can do following operations on CP
  1. Querying data
  2. Modify records
  3. Add records
  4. Delete Records
Standard CP are there : contacts, images.. implemented by android.

Querying data: We require content provider URI, URI consist of 3 parts..
  1. the string “content://”,
  2. segment representing kind of data to retrieve and
  3. optional ID of specific item of the specified content provider
URI : ( what is its full form ? )
  1. query URIs are somewhat arbitrary and confusing.
  2. For this android provide list of helper classes in android.provider package that define these query strings
this much is from : http://www.androidcompetencycenter.com/category/android-basics/

------------------------------------PART II-----------------------------------

So some scratches about Database ( before CP ) Okie ?.. Okie...
  1. Android uses Sqlite database system
  2. the database that you create for an application is only accessible to itself, others can't access it. is stored in the/data/data//databases folder
  3. Creating the 'DBAdapter' Helper Class; that creates, opens, closes, and uses a SQLite database. encapsulate all the complexities of accessing the database.
More about tat in this link: http://www.devx.com/wireless/Article/40842

Try with the Listings.. I m gonna try....

uph... a little difficult.. okie.. again bk to basics.... hureeee..... HLT

next Page: http://www.devx.com/wireless/Article/40842/0/page/2


reference
Cursor: http://developer.android.com/reference/android/database/Cursor.html
Context: http://developer.android.com/reference/android/content/Context.html

For Web Developer

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