Monday, September 16, 2013

Using an external toolchain

One option to write software for the native layer is to use external toolchain. You can download codesourcery toolcahin for example (Lite edition is free) and use it to compile your code. The only note is that we need to link it statically (makes the binary file bigger):

arm-none-linux-gnueabi-gcc -static -o myapp myapp.c 

then push it to the device using adb

adb push ./myapp /data/myapp

The benefits you get from using an external toolchain are:

  • You can use the same binary file in linux and android systems
  • You can use features that are not included in google bionic c library like priority inheritance futex or SYS V mailbox etc. 


Thursday, September 12, 2013

Embedded Android

Android is not just a smartphone/tablet OS, it is a great platform for embedded systems especially systems that currently based on linux
when using android as embedded linux alternative we can enjoy the many benefits that the operating system provides us and in fact there is no disadvantages because you can write code that runs in the lower layers exactly as written for Linux
The product must not have a touch screen, it can be "faceless" and you can still take advantage of many infrastructures that google wrote to make the product "time to marker" shorter
Android Stack based on the following layers (bottom up)

  1. Linux kernel
  2. Bionic - C library
  3. Native layer
  4. Frameworks 
  5. Applications

Linux kernel

Android is based on linux kernel with some changes. Currently most of them merged to the formal linux kernel (kernel.org). 
Google added some security features, IPC mechanisms and power management  features
I will get into more details in a future post
In general, if we want to add drivers, file systems, network modules or any other kernel feature its the same as it done on linux

Bionic - C library

Google wrote the c library from scratch. The library interface is the same as glibc but the implementation is much better and fit to embedded devices


Native Layer

This layer is the same as user space layer on linux. It contains native libraries (.so files), daemons and native applications.
Writing code for this layer is the same as writing a linux application and its not connected to any android or java restriction

Frameworks

This layer contains all android services, we can use this layer to connect the java applications with the native layer in a secure way


Application

This is the top layer, we can write code in java and get access to many features, great GUI and more.
We can add code in C/C++ or even write a full C/C++ application 
 
 More details in all my future posts