Saravana Pandian Annamalai
17. October 2018 · Write a comment · Categories: Android · Tags: ,

Android offers few emulators for development purposes. As a part of standard AOSP (Android Open Source Project), these emulators come in handy for development such as customization, debugging, middleware development, app development etc. But for underlying hardware access most of the other higher-level developments can be done over these emulators. There are quiet a few variants of emulators such as for general Phone/Tablet emulation or for automotive purposes – Car Emulator. This blog will focus primarily on building Android car emulator and running it in the system. We will also touch up on compiling the kernel from the source and running them as well.

Downloading AOSP source for emulation

First thing to start building car emulator is to finalize on the release version we want to build against. The list of supported variants is available in the Codenames, Tags, and Build Numbers page from the android web site. Based on the requirements, identify the version – in this case let us assume we want to build for OPM6.171019.030.B1. Note the build version it corresponds to android-8.1.0_r33.

Now we will have to download the source code for the same. Android source code is in fact a collection of git repositories. Each of the major directories in the AOSP corresponds to a separate repository. Since it is difficult to manage such a large code base individually one by one, Google has created a tool called repo that helps in this process. Install this tool with the following steps

mkdir -p ~/bin
wget ‘’ -P ~/bin
chmod +x ~/bin/repo

Now that the tool is downloaded, set up your git configuration using the following commands

git config –global “your name”
git config –global “”

Assuming you are running Ubuntu 16.04, to prepare the environment, execute the following

sudo apt-get update

Install the dependencies:

sudo apt-get install openjdk-8-jdk android-tools-adb bc bison build-essential curl flex g++-multilib gcc-multilib gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libssl-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc yasm zip zlib1g-dev

Identify the working directory and create it if necessary.

mkdir -p ~/aosp

Switch to the directory

cd ~/aosp

As mentioned earlier, we need the manifest file to being with. This initial file can be set up using the following commands.

The above command will download an XML file called “manifest.xml” that contains information about all the git repositories that constitute the AOSP.

Since the above command will download a large set of objects including previous versions, if you want to limit the download size, you can set the downloaded version depth to 1.

repo init -u -b android-8.1.0_r33 –depth=1

With everything set, being the download using the following command.

repo sync

This command will perform the actual download operation all the necessary repositories and prepare the directory for further building.

Building Car Emulator

We can now start building Android car emulator. Once again being a large project, it is better to set up a compiler cache so that the incremental builds are quite faster.

export USE_CCACHE=1
prebuilts/misc/linux-x86/ccache/ccache -M 15G

Below output confirms that the command executed successfully.


Set cache size limit to 15.0 Gbytes

Powered by the Soong build system, the AOSP employs a variety of tools to build the source and create the images. Jack compiler used employs a server mechanism where by a single process running in the system compiles files. To configure the same, execute the below commands such that the Java based tool uses the configured amount of RAM for the JVM. In this example, it is limited to 6GB.

export ANDROID_JACK_VM_ARGS=”-Xmx6g -Dfile.encoding=UTF-8 -XX:+TieredCompilation”

With every thing set up now for building the source, now configure the environment variables used by the Android build system using

source build/

The source command simply executes the given script in the same shell so that its environment variables are affected. Below output is shown

root@aosp:/home/user1/aosp/ # source build/
including device/asus/fugu/
including device/generic/car/
including device/generic/mini-emulator-arm64/
including device/generic/mini-emulator-armv7-a-neon/
including device/generic/mini-emulator-mips64/
including device/generic/mini-emulator-mips/
including device/generic/mini-emulator-x86_64/
including device/generic/mini-emulator-x86/
including device/generic/uml/
including device/google/dragon/
including device/google/marlin/
including device/google/muskie/
including device/google/taimen/
including device/huawei/angler/
including device/lge/bullhead/
including device/linaro/hikey/
including sdk/bash_completion/adb.bash

Now choose the platform you want to build. For example, we can either build the car emulator for 32-bit X86 system or 64-bit x86 system.

For building for 32-bit, use the below command.

lunch aosp_x86_car_emulator

For 64-bit use,

lunch aosp_x86_car_emulator

Typically, you will see the below output.



Initiate the build now with make command. To leverage the multiple CPU cores, present in your host machine, specify a number corresponding to it.

make -j8

It will take about 1 hour to 3 hours for the build to complete depending on the host system configuration.

Creating filesystem with parameters:
Size: 2684354560
Block size: 4096
Blocks per group: 32768
Inodes per group: 8192
Inode size: 256
Journal blocks: 10240
Label: system
Blocks: 655360
Block groups: 20
Reserved block group size: 159
Created filesystem with 2219/163840 inodes and 219060/655360 blocks
[ 99% 64341/64342] Install system fs image: out/target/product/generic_x86/system.img
out/target/product/generic_x86/system.img+ maxsize=2740556544 blocksize=2112 total=2684354560 reserve=27684096
[100% 64342/64342] Create system-qemu.img
1+0 records in
2048+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00427205 s, 245 MB/s
2560+0 records in
2560+0 records out
2684354560 bytes (2.7 GB, 2.5 GiB) copied, 3.17107 s, 847 MB/s
1048576+0 records in
1048576+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 1.86999 s, 561 kB/s
Creating new GPT entries.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
Setting name!
partNum is 0
REALLY setting name!
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
#### build completed successfully (01:26:36 (hh:mm:ss)) ####

Running the Car Emulator

Once the build is completed, the images will be created inside the out/target/< product >/directory. The emulator can now be invoked using


Typically, you will see the emulator running as below.

Now you can connect to it over ADB and perform various operations such as installing a new App, debugging it, modifying the AOSP source and testing it etc.

Compiling the kernel

The emulator can be launched to show the kernel output and console by using the show kernel option as below.

emulator –show-kernel
generic_x86:/ $

In the login, we can check the kernel version using uname command.

We can see, this emulator runs kernel version 3.18.74+. Looking for the source, it can be found that it is available in the repository as commit c57e557. Download the same using the below commands:

Get goldfish branch c57e55706abeffafbc52d28155297650dae6e2c0

Build the same using the following commands:

git clone -b android-goldfish-3.18
git clone
cd goldfish
export CROSS_COMPILE=x86_64-linux-android-
export ARCH=x86_64
export PATH=$PATH:/path/to/x86_64-linux-android-4.9/bin
make x86_64_ranchu_defconfig
make menuconfig # enable overlayfs and namespaces support here
make -j8

The output kernel will now be available at arch/boot/x86/bzImage

This image can be used for the emulator when launching as follows:

emulator -kernel <Path to kernel directory>/ arch/boot/x86/bzImage

By giving uname now, it can be seen that the build time/machine reflects

Building Android Car Emulator and running it in the system helps to accelerate various platform/application developments. It is possible to complete some part of underlying driver/HAL development using this kernel in this approach.

About Embien: Embien Technologies is a leading service provider for the Android technologies including Android porting, HAL development, HIDL developments, custom system services, deployment, App development etc. Our team extensively uses emulator for speeding up the developments even before the underlying hardware is available. Apart for developing Auto-infotainment systems, customized tablets, Home Automation consoles, rugged handhelds, Industrial HMI’s, our SMEs offers corporate training covering topics such as Android Platform development, Android for Automotive and Linux Device Drivers.

31. May 2018 · Write a comment · Categories: Embedded Hardware · Tags: , , , ,

This blog is the sequel of the previous blog on Geo positioning system technologies. Here we will discuss more in detail about the important terms related to GPS receivers and guidelines for selecting suitable GPS receiver module for embedded system design.

GPS Receiver

Connection diagram for GPS module

GPS Module – Connection Diagram

The above picture depicts the typical connection diagram of GPS module with any host controller. There are multiple interface options available for a host controller to receive the NMEA data where UART, SPI and USB are most common. PPS signal is an output from GPS and it is discussed in detail in the upcoming sections. Most of the GPS modules have internal patch antenna but also supports external active antenna connection.


 NMEA (National Marine Electronics Association) data is the detailed output from any GPS receiver that includes the current location data of the receiver such as Latitude, longitude, altitude etc. This data is provided in a standard format to the user for compatibility with various manufacturers much like ASCII standard for digital computer characters.

Following is the example of a NMEA message from a GPS receiver,


All the NMEA message starts with a $ character where each field is separated by a comma.

“GP” in GPGGA – represent that it is a GPS position. For GLONASS, it will be GL instead of GP.

GPGGA is a basic GPS NMEA message and many other NMEA messages are also available providing similar or additional information beside GPS coordinates. There are 19 different NMEA messages and they are listed below,

  1. $GPBOD – Bearing, origin to destination
  2. $GPBWC – Bearing and distance to waypoint, great circle
  3. $GPGGA – Global Positioning System Fix Data
  4. $GPGLL – Geographic position, latitude / longitude
  5. $GPGSA – GPS DOP and active satellites
  6. $GPGSV – GPS Satellites in view
  7. $GPHDT – Heading, True
  8. $GPR00 – List of waypoints in currently active route
  9. $GPRMA – Recommended minimum specific Loran-C data
  10. $GPRMB – Recommended minimum navigation info
  11. $GPRMC – Recommended minimum specific GPS/Transit data
  12. $GPRTE – Routes
  13. $GPTRF – Transit Fix Data
  14. $GPSTN – Multiple Data ID
  15. $GPVBW – Dual Ground / Water Speed
  16. $GPVTG – Track made good and ground speed
  17. $GPWPL – Waypoint location
  18. $GPXTE – Cross-track error, Measured
  19. $GPZDA – Date & Time

181908.00 UTC Time stamp in hours, minutes and seconds.

3004.6040718 Latitude in DDMM.MMMMM format. Decimal places are variable.

N North latitude

07040.3900269 Longitude in DDMM.MMMMM format. Decimal places are variable.

W West Longitude

4 Quality Indicator. Other options are as follows,

0 = Fix not valid

1 = Uncorrected coordinate

2 = Differentially correct coordinate (e.g., WAAS, DGPS)

4 = RTK Fix coordinate (centimeter precision)

5 = RTK Float (decimeter precision)

13 Number of satellites used in the coordinate

1.00 denotes the HDOP (horizontal dilution of precision).

408.135 Altitude of the antenna

M unit of altitude (e.g. Meter or Feet)

29.200 geoidal separation. Subtracting this from the altitude of the antenna will provide the Height Above Ellipsoid (HAE)

M Unit of geoidal separation

0.10 age of correction

0000 correction station ID

*40 checksum

Time-To-First-Fix (TTFF)

 Another most important deciding feature of GPS receiver is the TTFF. TTFF of a receiver only decides how fast it can provide a valid NMEA data to the user. So the user must be very careful on the TTFF values while choosing the receiver. The TTFF values will be provided in the datasheet in seconds.

Any receiver can boot up in any one of the following three modes:

  1. Hot start
  2. Warm start
  3. Cold Start

The Time-To-First-Fix (TTFF) depends on the startup mode, with cold starts giving the longest TTFF. Following are the factoring affecting boot mode,

  1. Non availability of valid almanac and ephemeris data
  2. Level of incoming signals
  3. The unit is within 60 miles (100 Km) of location of previous fix
  4. Length of time since previous fix

Cold Start Mode

: Any receiver start in this mode when,

  1. Receiver has not been used for long time
  2. Moved several hundred kilometers
  3. Incoming signals are low or marginal. i.e. the predicted satellites are overhead of the receiver but cannot receive signals due to tall buildings, foliage etc.

Any of the above situation will make the receiver cannot predict which satellites are overhead. Then the receiver works with an internal list of satellites and tries to acquire each one in turn. This allows the receiver to discover the satellite which are in view and eventually establish a position. Normally the TTFF on cold start takes 2 to 4 minutes.

Warm Start Mode

: Any receiver start in this mode when,

  1. It has valid almanac data
  2. The current location of receiver is within hundred kilometers of the last fix location
  3. Receiver has been active in last three days and current time is known
  4. Ephemeris data that has not been stored or it has become stale
  5. Good signal strength and 4 or more satellites are visible

In this mode the receiver can predict which satellites are overhead but it needs to download the current Ephemeris data. TTFF for warm start mode is typically 45 seconds.

Hot Start Mode:

The receiver starts in this mode when the warm start conditions are met and,

  1. A fix has been established within the last 2 hours
  2. The receiver has stored valid ephemeris data for atleast 5 satellites

Receiver tracks the overhead satellites and needs to download minimum data to establish a position. TTFF for a hot start is typically 22 seconds. 


We have come across many startup modes for any receiver, but wonder how smartphone GPS units get a fix almost immediately?

They use Assisted-GPS (A-GPS) as a procedure of improving the TTFF or even allowing a fix in conditions where receiver might not be able to function.

A-GPS device will use a data connection available on the smartphone to contact an assistance server. This server will supply almanac and ephemeris data instead of waiting to receive them from the satellites. The server can also provide approximate location derived from the cell phone towers facilitating immediate fix.

PPS Signal

Most GPS receiver modules have an output called Pulse Per Second abbreviated as PPS. It is a digital output signal with much lower jitter than anything a MCU can do. PPS signal can be used          to time things very accurately at a precision in nanoseconds.

They are most commonly used to wake the MCU from deep sleep mode periodically at an interval of one second. In some applications, they are used to synchronize the system time and rectify the time drift due to the temperature effects of the RTC crystals. 

Selection guide for receiver

There is lot of options available while selecting a receiver module. Some of the main factors to be considered while selecting the receiver are as follows,

  1. Multi system support – Receiver module can be GNSS or GPS only. GNSS module provides simultaneous support to GPS, GLONASS, BeiDuo and Galileo systems. GNSS modules are better than GPS only modules and the cost of the GNSS module will be bit more comparative to the other.
  2. Size – Most important deciding factor for size constraint devices. Nowadays modules are getting very small but in general the antenna will also shrink to fit the module which will reflect in the lock time and accuracy.
  3. Number of channels – At a given time, there are so many satellites available in view but the number of channels a receiver module can track/acquire will affect the TTFF. The more a module can track/acquire many satellites, the faster it will find a fix.
  4. Update Rate – It is the time interval that how often a receiver module can recalculate and reports its position. The standard rate of a module is 1Hz (one report per second). Fast update rate means that there are more NMEA sentences coming out of the receiver module by which any microprocessor will be quickly overwhelmed trying to parse that much data.
  5. Power consumption – Another important factor that decides the success of a battery powered devices. There are many factors deciding the power consumption of a receiver module and in any case the typical power consumption should be low in few tenses of mA ranging between 25 to 30mA. Most of the receivers have various power saving modes which can be used during idle conditions.
  6. Antenna – Antenna defines the quality of the receiver module and it must be finely trimmed good enough to pick up the frequencies. Receiver modules available with a small patch antenna on top of it. It is made of ceramic. Some modules will also have dedicated antenna pin for connecting external active antenna. Receivers used in cars require external antenna support since the receiver module has to be placed inside the vehicle mostly connected to the OBD port which will be placed beneath the dashboard where a patch antenna will struggle to receive the signals.
  7. Accuracy – Varies between modules. Most modules can get it down to +/- 3m and sub meter or centimeter accuracy are also available but bit expensive.

About Embien

Embien Technologies is a product engineering service provider with handsome experience on automotive product developments. Embien has various solutions for time to market developments for automotive domain including Sparklet Embedded GUI library for 2D or 2.5D or 3D Instrument clusters, Flint IDE for GUI prototyping and eStorm-B1 – Automotive grade BLE Module.

Geo positioning system or GPS has become more or less a norm for smart phones. Geo positioning system was first created for the navigation of defense vehicles in any part of world. But over the period of time, this system is being used in many other purposes outside defense and has proved itself to be a revolutionary technology in today’s world. Apart of the smartphone, most of the premium cars and commercial vehicle do have inbuilt GPS for fleet tracking, vehicle Telematics, and driver assistance.

Apart from such fleet navigation use cases, GPS are now being used for many applications such as locating nearby restaurants, hotels and gas stations and finds huge applications in tourism industry. Personal navigation devices also employ GPS technology.

Also most of the IoT/M2M applications use GPS modules. Some of them are as follows

  • Smart utility metering
  • Connected health and patient monitoring
  • Smart buildings
  • Security and video surveillance
  • Smart payment and PoS systems
  • Wearable devices etc

While the term GPS in general represents the technology, there are numerous systems being used to achieve this. In this blog, we will briefly describe about the various such Geo positioning systems and related concepts.

Geo Positioning System – Technology

Any geo positioning system uses about three to four satellites from more than a dozen of satellites orbiting in a group (satellite constellation) to provide autonomous geo-spatial positioning. These satellites transmit 1500 bits of data such as the satellite health, its position in space, propagation delay effects, constellation status, the time of information being sent, etc. This allows a small electronic receiver to determine its location in terms of latitude and longitude based on triangulation of the data obtained from at least three satellites. With four or more satellites, the receiver can also determine the 3D position, i.e. Latitude, longitude and altitude. In addition, a GPS receiver can provide information about the speed and direction.

Anyone with the GPS receiver can access the system. Since it is an open source and providing almost accurate 3D position, navigation and timing 24 hours a day, 7 days a week, all over the world, it is used in numerous applications even in GIS data collection, mapping and surveying.

Geo Positioning System – Types

At present there are many options available for geo positioning system each of them owned and operated by countries such as US, Russia, European Union, China, etc. They are as follows

NAVSTART GPS – GPS, Global Positioning System is a one among the various satellite navigation system designed and operated by the U.S. Department of defense. Official name of GPS is Navigational Satellite Timing and Ranging Global Positioning System (NAVSTAR GPS).

GLONASS – Global Orbiting Navigation Satellite System, GLONASS developed by Russian, is an alternative to GPS and is the second global navigational system in operation providing global coverage with comparable precision. A GLONASS satellite design has various upgraded versions and the latest is GLONASS-K2 which is expected to operate in early 2018.

Galelio – Galelio is created by European Union with the aim to provide an independent high precision positioning system for European nations.

BeiDou – BieDuo Navigation Satellite System (BDS) is a Chinese satellite navigation system consisting of two separate satellite constellations BeiDuo-1 and BeiDuo-2. BeiDuo-1 is decommissioned and BeiDuo-2 also known as COMPASS offering services to customers in the Asia-Pacific region with a partial constellation of 10 satellites in orbit.

IRNSS – Indian Regional Navigation Satellite System also known as NAVIC (Navigation with Indian Constellation) is a regional satellite navigation system covering the Indian region extending 1500Km. This constellation is already in orbit and expected to operate in early 2018.

Satellite Based Augmentation System (SBAS)

All the above systems are autonomous and governed by the respective countries. Other than autonomous systems, other regional augmented systems are available that run with the aid of other autonomous satellites. These augmentation systems will provide reference signals (Signal in Space- SIS) via satellites to the receivers including correction information with the objective of increasing the accuracy of the position. In addition to the accuracy they also help to maintain the reliability and availability of the navigation system. The whole system is known as SBAS (Satellite Based Augmentation System) and satellite providing the SIS signal are known as SBAS GEO satellites. Some of them are as follows,

GAGAN – GPS-Aided Geo Augmented Navigation – It is the implementation of SBAS by Indian government. It supports pilots to navigate in the Indian airspace by an accuracy of 3m.

QZSS Quasi Zenith Satellite System is a project governed by Japanese government and operated in order to receive the US operated GPS in the Asia-Oceania regions with Japan as a primary focus.

Other commonly available SBASs are WAAS (US), EGNOS (EU) and MSAS (Japan).


The above mentioned satellite systems such as global, regional and augmented systems are integrated together to form Global Navigation Satellite System, GNSS. It is a standard term for satellite navigation systems providing autonomous geo spatial positioning with global coverage. It is a satellite system that is used to pinpoint the geographic location of a user’s receiver anywhere in the world. Three GNSS systems are currently in operation: the United States’ Global Positioning System (GPS), the Russian Federation’s Global Orbiting Navigation Satellite System (GLONASS) and the Europe’s Galileo.

Most degrading factor of a receiver, i.e. Line of Sight degradation can be solved with the GNSS system due to its accessibility to multiple satellites and if one satellite system fails, GNSS receivers can pick up signals from other system.

Navigation messages

Any satellite in the constellation will transmit a detailed set of information such as each satellite position, network to receiver called the navigation messages. Following are available in the navigation message, 

  1. Date and time together with the satellite status and an indication of its health 
  1. Almanac data – Contains coarse orbit and status information of all the satellites in the constellation. It allows the GPS receiver to predict which satellites are overhead, shortening acquisition time. Almanac data can be received from any of the satellites. The receiver must have a continuous fix for approximately 15 minutes to receive a complete almanac data. Once downloaded it is stored in the non volatile memory.
  1. Ephemeris data – Contains precision correction to the almanac data necessary for the receiver to calculate the position of the satellite. It is continuously updated every 2 hours and so ephemeris data of a deactivated receiver will become stale after 3 to 6 hours.

Time-To-First-Fix (TTFF)

For a receiver to get a fix, it needs a valid almanac, initial location, time and ephemeris data. When a receiver is switched ON, it requires some time delay for the first fix. This delay depends on how long since the stored data’s being used. The time delay is commonly termed as Time To Fist Fix, TTFF and it is one of the main factor for receiver selection.

About Embien

Embien Technologies is a leading provider of embedded design services for the Automotive, Semi-conductor, Industrial, Consumer and Health Care segments. Embien has successfully designed and developed many products with GPS for various domains such as Wrist wearable based tracker device for healthcare, Vehicle Telematics device for automotive, Data acquisition/logger devices for industry etc.