Wednesday, November 28, 2012

The fight for PTM Traces

PTM(Programme trace Marcocell)

This is an interesting feature provided by ARM CoreSight. This piece of hardware monitors a ARM core. When every there is a deviation from the normal execution of the core, PTM generates traces. These deviations can be interrupts or a simple branching.

There is already a linux driver for this at arch/arm/kernel/etm.c. But few patches are missing compared to linaro tree as of this writing. Apart from what driver provides, you have to do few more things.

 1. Register a AMBA device. This has to be done to get the probe of etm driver to be called. You can see how omap guys have done this here,
AMBA_APB_DEVICE(omap3_etm, "etm", 0x102bb921, ETM_BASE, { }, NULL);


2. Configure the funnels. This will require a bigger explanation.
    Can be found from CoreSight documention in arm infocenter.
    In short there will a lot of trace sources(PTM is one amoung them), you need to configure those funnels so the PTM traces will reach ETB or TPIU.
   


Now I got it working. Working here can be divided into two parts.
1. Configure the traces sources(PTM here) and funnels and get the data to ETB.
2. Collect the data from the ETB and decode it to meaningful information.

Some how after two week , PTM stopped working. Actually it is partially working. It is working for single core traces but not for dual core. Either configuring the PTM or decoding the PTM can go wrong.

After lot of debugging, I figure out that this is because of arm going to dormant. When ever arm goes to dormant  it cuts off the power to the processor which results in loosing values in PTM registers.

The reason it worked two weeks before was because dormant was disabled in our kernel. I m just wondering how difficutl it should have been if I have used this driver (PTM) after the dormant is enabled. It would have been a long journey to figure out for me that dormant was the culprit.


compiling fastboot.exe

File location in android,
system/core/fastboot/*

Command to compile,
make -j2 win_sdk

binary will be build here,
out/host/windows-x86/bin/fastboot.exe

Friday, November 23, 2012

Git advanced topics

I m going to write features of git which I feel are advanced.

1. Editing a commit which is not HEAD

git rebase -i e39f5d5f122029f6e1271^

where e39f5d5f122029f6e1271 is the commit which I want to amend.

Now some thing like this will come, which is self explanatory,


now change those commits  to "edit" from "pick". Save and close.

Now edit those files you want to and do git add for the files.

After that git commit --amend
then,
git rebase --continue

2. Interactive adding of files(git add -i)


3. Git bisecting to find out where bug was introduced.

commands,

git bisect start
git bisect bad                     /* inform git that current commit you are on is broken */
git bisect good [good_commit_id]                   /* inform git about the working commit */

Now git will checkout to the middle of these commit. You have to build and test if bug exits now.
If bug is present, then type

git bisect bad

else 

git bisect good

To finish,



4.  git add only few changes in same file

    git add -p filename.c

5. Git grep on different branches

git grep -n "string here"