Sunday, 19 February 2017

Manual setting up of adb keys in Android

There are many cases where we would like to enable ADB debugging without the use of accepting the fingerprint in the UI especially in the cases where you are bringing up the display for embedded device or on a headless android.

If you have already used adb before then there would be ".android" folder present in Linux. If it is present then you can simply copy the adb_keys.pub to the folder in /data/misc/adb folder. 

If you have created a separate "data" partition then mount the partition

For eg:
mount /dev/sdc4 /mnt/android_mnt

After the mount just copy the file to /mnt/android_mnt/misc/adb.
In my case the permissions for the file is as follows:
-rw-r--r-- root     shell         717 2017-02-18 12:43 adb_keys 

If you do not have .android folder or the above keys then create the .android folder. To create the keys do a:
adb keygen adbkey

This will create the above 2 files adbkey and adbkey.pub. Copy the public key. Please note that the file created is adbkey.pub but the file name has to be adb_keys.pub when put in the misc/adb folder.





Monday, 29 August 2016

Pidgin setup for Microsoft Communicator/Lync/Skype

Let me break the hiatus by writing a small post on the setup of pidgin for MS Communicator/Skype. This applies to my network and might vary in your case. Internet resources for setup does not somewhat give a complete picture. Hence I decided to do a writeup.

The base data is that the network uses Skype for Business and Office 365. Hence we need to do the following:

  1. Download pidgin using apt.
  2. Download pidgin-sipe package using apt.
Next start up pidgin and do the following settings:

  1. In the Accounts window (Accounts -> Manage Accounts)  select Add.
  2. Go to "Basic" tab
  3. Select "Office Communicator" as the protocol.
  4. For user name enter it in the format of the email address of your office 365 account.
  5. For "Login" field I enter in the format of "DOMAIN\user". Here "user" being the ldap login user name for your office 365 account.
  6. Enter your password in the password field and check the box "Remember password"
  7. Go to "Advanced" tab.
  8. Enter "Auto" in connection type.
  9. I have entered the User agent string as : "UCCAPI/16.0.6001.1073 OC/16.0.6001.1073 (Skype for Business)" minus the quotes. If you get an error please try other User agent strings as recommended in the FAQ given here: https://sourceforge.net/p/sipe/wiki/Frequently%20Asked%20Questions/#connection-refused-with-error-messagewzxhzdk12you-are-currently-not-using-the-recommended-version-of-the-clientwzxhzdk13you-have-been-rejected-by-the-server-httpsportalmicrosoftonlinecomdownloadlyncaspx
  10. Select the Authentication Scheme as "NTLM". It might vary for your network. Please try different options if the one I selected does not work.
  11. Keep all other options as defaults.
  12. In the proxy tab select "Environment Settings".
  13. Enable the account in the Accounts tab.
  14. Restart pidgin if needed. 
 Enjoy communication with your colleagues.

If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.
-John Von Neumann

Saturday, 6 August 2016

Slow updates

In the past few months life has taken a tough turn. It keeps getting harder and harder to concentrate on anything when mental peace is elusive. I have decided to slow things down a little bit and take things slowly. Hopefully I will be able to get back fresh and continue with my passion and thereby educate you, the viewers with my blog posts. You can always mail or comment on my posts which will help me get me strength.

So wish me luck!

Saturday, 9 July 2016

Linux dts compilation using dtc compiler.

I was reading up on the dts (Device Tree Specification) specification and wanted to try out custom dts and compile it to dtb (Device Tree Blob).

The dts I wanted to compile was for the Wandboard which is the imx6dl-wandboard.dts

To compile I use the following command:

dtc -I dts -O dtb -o imx6dl-wandboard_test.dts

When trying this I get the error "FATAL ERROR: Unable to parse input tree near the includes..."

Turns out we have to use CPP (C Preprocessor)  to parse the includes and substitutions. Hence the next command is as follows:

cpp -nostdinc -I include -undef, -x assembler-with-cpp imx6dl-wandboard.dts > imx6dl-wandboard_bare.dts

 Here we use

-nostdinc:  We do not search system directories for header files. Only the directories I have specified wtih the -I are searched for header files.

-undef: We do not perform any system-specific or GCC-specific macros. All standard predefined macros remain definied.

-x: We provide the option assembler-with-cpp as the dtc compiler cannot auto ditacte whether the file is a "open", "clode", "read and write"

Pass the dts file and redirect the output to an output dts file.
Next we run the dtc compiler as above replacing imx6dl-wandboard_test.dts with the output generated from CPP. This will create the dtb file . You reverse the dtb to a dts by replacing the -I parameter with dtb and -O parameter with dts.

Also make sure you run this command in the arch/arm/boot/dts directory because of the includes present in it. Replace the "arm" with your CPU architecture of choice.

Additionally you can also create the dtb file running the rule dtbs in the makefile.

To make it work edit the Makefile in the arch/arm/boot/dts and add your dts file in the proper architecture. For my wandboard it will be dtb-$(CONFIG_ARCH_MXC).

Next create the dtb file with the following command:

1
ARCH=arm CROSS_COMPILE=`pwd`/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi- make -C kernel_imx/ dtbs



References: https://linux-sunxi.org/Device_Tree#Compiling_the_Device_Tree

"There must be no barriers to freedom of inquiry … There is no place for dogma in science. The scientist is free, and must be free to ask any question, to doubt any assertion, to seek for any evidence, to correct any errors."
--J Robert Oppenheimer



Friday, 8 July 2016

Running bootchart in Android Marshmallow

For the Wandboard that I was customizing I wanted to know the process statistics, processor usage and IO usage to speed up my boot up time. I decided it was time to run bootchart.

There is quite a bit of outdated Internet resources on how to use bootchart for Android. I decided to write one:

First enable bootchart by doing a adb shell "echo 120 > /data/bootchart/start". This would tell the init to start bootcharting for 2 minutes. After this you get a set of files in the /data/bootchart directory. The files are generally as follows:

header
kernel_pacct
proc_diskstats.log
proc_ps.log
proc_stat.log



Next run the shell program grab-bootchart.sh in system/core/init which will use the measurement files above into a visual file either .png, .swf which shows the different processes hogging the CPU and which processes take a long time to init. Before we conclude a boot chart below of my wandboard custom build (Click for a larger image or download it to zoom in).





Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin.
 -Jon Von Neumann

Saturday, 14 May 2016

On Android Marshmallow build on Wandboard Dual

This post will be edited as and when I have progress. The final post will be structured for easy reading.

I have upgraded my Ubuntu to 16.04 (Xenial) and I am having a host of problems compiling Marshmallow and the earlier Lollipop.

In Marshmallow I was getting the "Unsupported reloc error 42". The fix for this is provided here https://android-review.googlesource.com/#/c/223100/

Update the makefile as above and build the kernel. Apart from that try to build using a smaller parallel job option i.e. -j5 for a quad core. I seemed to get the "JACK server could not start" which might be because of high memory usage. Also increasing the swap memory helps. I used to have a 1GB of swap for my 4GB laptop and I used to compiler errors because of out of memory. When multiple instances of JACK starts running there would almost 2GB + of swap memory usage!

There is a problem with the SPL loader when the code is compiled using make. The board refuses to boot up. If the code is compiled manually i.e. ARCH=arm CROSS_COMPILE=prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin/arm-eabi- make wandboard_defconfig etc. and I flash the SPL loader it boots. So this means there is something wrong with the compiler options used. Looking at the Makefile I find at line 974: BOOTLOADER_CROSS_TOOLCHAIN := `pwd`/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-

The problem above is that the toolchain used is wrong. This is why it refused to boot. Changing it to what I was doing normally the board booted up.

If you are using the OpenJDK 8 and you get Guava error as follows:

external/guava/guava/src/com/google/common/reflect/Types.java:317:
error: TypeVariableImpl is not abstract and does not override abstract 
method getAnnotatedBounds() in TypeVariable
 private static final class 
TypeVariableImpl<D extends GenericDeclaration>

The following updated code by google offers the solution.
https://android.googlesource.com/platform/external/guava/+/1bc06418bcf6355136e8f774092eac49805623b6%5E%21/#

Git clone it and checkout the commit id present in the link. Copy the Types.java file to the relevant place and start the compile.

Partitioning

Partitioning is same as lollipop. In the first boot partition we have the following files:
  • u-boot.img
  • zImage
  • imx6q-wandboard.dtb
  • imx6dl-wandboard.dtb
  • uenv.txt
  • uramdisk.img

The difference between lollipop and marshmallow for the wandboard is that the above files should be present in then root partition and not inside a separate /boot directory in the sdb1 partition.

The above can be easily changed but since we are talking about the stock kernel from wandboard I will not deviate.

Friday, 8 April 2016

On Android development and porting

I have decided to work on parallel to learn to understand the android system and porting to a new SoC. My baremetal adventures will continue as is but this a slight distraction/relaxation from the intense work of the baremetal OS.

I will post articles and examples on what I have learnt in android along with some mini projects to demonstrate the concepts. I will referring to "Embedded Android" by Karim Yaghmour to learn my concepts. The development board which I will be using is a Wandboard dual with Bluetooth and WiFi. It has a NXP/Freescale i.MX6 dual core processor in it.