For 4752 please refer to the Android separate documentation package The GPS software delivery for Android based platforms is discussed here for 4750/4751
The IPC between Broadcom's GPS system and the Android framework is implemented as follows.
There are two different builds to make in order to integrate our GPS solution to Android based platform.
To be able to build we need to get the Android source code. Follow the instructions at http://source.android.com/source/download.html . Note that Gingerbread and newer requires Java 6 and a 64-bit OS. Froyo and older requires Java 5.
For Java 6 (Gingerbread and newer), do the following steps:
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" $ sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu lucid partner" $ sudo apt-get update $ sudo apt-get install sun-java6-jdk $ sudo update-java-alternatives -s java-6-sun
For Java 5 (Froyo and older):
$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper main multiverse" $ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper-updates main multiverse" $ sudo apt-get update $ sudo apt-get install sun-java5-jdk $ sudo update-java-alternatives -s java-1.5.0-sun
Additional software to install from http://source.android.com/source/download.html follows:
$ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev $ sudo apt-get install valgrind
To get the Android source, you must install Repo:
$ mkdir ~/bin $ PATH=~/bin:$PATH $ curl http://android.git.kernel.org/repo > ~/bin/repo $ chmod a+x ~/bin/repo
To initialize a Repo client and get the Android source:
# Create an empty directory to hold your working files: $ mkdir directory $ cd directory # Run repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory. $ repo init -u git://android.git.kernel.org/platform/manifest.git To check out a branch other than "master", specify it with -b: $ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake # To get the files $ repo sync
To build the Android source:
$ cd ~/directory $ source build/envsetup.sh $ lunch $ make
In order to compile a specific project (a specific Android.mk file) you should do:
make -C android_root_path files ONE_SHOT_MAKEFILE=/absolute/path/to/my/Android.mk
Or this is what you can do from the Android path:
. build/envsetup.sh mmm /absolute/path/to/my/Android.mk
By default (for standard libraries and execs binaries) it will be copied to system/lib or /system/bin
The build environment can be launched the same way it is done with the UNIX builds but it will call the makefiles specific for Android. Doing that we don't have to deal with the compiler (specific compiler options, paths...) and it could be integrated into the target platform makefiles that the user has defined for their whole Android build. Our builds become more generic as it could be compiled for any hardware platform defined by Android.
Normally the Android makefiles are named like: Android.mk
There is only one config makefile where all the specific settings for the build are defined. We have makefile in customers/<CUST>/Makefile.<CUST><PROJ>android. For example, this is the sample configuration:
OUT_DIR:=$(shell pwd)/$(dir $(lastword $(MAKEFILE_LIST)))/build_out
ANDROIDPATH ?= /usr/local/cross/android
CONFIG_HAL_SERIAL_TYPE=UART
CONFIG_HAL_SERIAL_DEV=/dev/tty<your_serial_port>
CONFIG_HAL_CMD=yes
CONFIG_HAL_CMD_FILE=/cache/glgpsctrl
CONFIG_HAL_LTO=yes
CONFIG_HAL_LTO_DIR=/data/gps/
CONFIG_HAL_LTO_FILE=lto.dat
CONFIG_HAL_NMEA_PIPE=yes
CONFIG_HAL_NMEA_FILE=/cache/gpspipe
CONFIG_HAL_NV=yes
CONFIG_HAL_NV_DIR=/data/gps/
CONFIG_HAL_NV_FILE=gldata.sto
CONFIG_HAL_RRC=no
CONFIG_HAL_GPIO_SYSFS=yes
CONFIG_HAL_CATCH_SIGNALS=yes
CONFIG_HAL_EE_DIR=./gps/
CONFIG_HAL_EE_FILE=cbee.cbee
CONFIG_HAL_LCS_API=yes
CONFIG_HAL_LOG_ANDROID=yes
CONFIG_HAL_TIME_MONOTONIC=yes
CONFIG_HAL_LBS=yes
CONFIG_HAL_FRQ_CUSTOM=yes
CONFIG_HAL_SUPL=true
ENABLE_TLS=yes
HAL_XTRA_SRCS:=<PROJ>/glhal/<your_file1>.c \
<PROJ>/glhal/<your_file2.cpp
TARGET_RELEASE_CFLAGS=<your_optimization_flags>
This file will be only created to set the options (on another linux builds this file has these options + compiler specific ones)
As mentioned before the project could be compiled using the same Makefiles options we've using so far. So in order to build the gll we could:
make -C vendor/broadcom/gps/proprietary/deliverables/gll_dev/project/make CUST=mycustomer PLATF=myplatform all make -C vendor/broadcom/gps/allPartners/deliverables/glct/project CUST=mycustomer PLATF=myplatform all make -C vendor/broadcom/gps/allPartners/deliverables/glhal/unix CUST=mycustomer PLATF=myplatform all make -C vendor/broadcom/gps/allPartners/deliverables/glgpsapp/unix CUST=mycustomer PLATF=myplatform all
Assuming you have the following in your Platform Makefile "config makefile" "vendor\broadcom\gps\customers\broadcom\Makefile.*.mak". See Build Options - config makefile
ifeq "$(TOOLCHAIN)" "2_1" ANDROIDPATH ?= /usr/local/cross/android-2.1 else ifeq "$(TOOLCHAIN)" "2_2" ANDROIDPATH ?= /usr/local/cross/android-2.2 else ifeq "$(TOOLCHAIN)" "2_3" ANDROIDPATH ?= /usr/local/cross/android-2.3 else ifeq "$(TOOLCHAIN)" "4_0" ANDROIDPATH ?= /usr/local/cross/android-4.0 else ANDROIDPATH ?= /usr/local/cross/android-2.1 endif #4_0 endif #2_3 endif #2_2 endif #2_1
To Target ECLAIR
make -C vendor/broadcom/gps/allPartners/deliverables/glhal/unix CUST=mycustomer PLATF=myplatform TOOLCHAIN=2_1 OUT_DIR=~/eclair_out all
To target FROYO
make -C vendor/broadcom/gps/allPartners/deliverables/glhal/unix CUST=mycustomer PLATF=myplatform TOOLCHAIN=2_2 OUT_DIR=~/froyo_out all
To target GINGERBREAD
make -C vendor/broadcom/gps/allPartners/deliverables/glhal/unix CUST=mycustomer PLATF=myplatform TOOLCHAIN=2_3 OUT_DIR=~/gingerbread_out all
To target ICE CREAM SANDWICH
make -C vendor/broadcom/gps/allPartners/deliverables/glhal/unix CUST=mycustomer PLATF=myplatform TOOLCHAIN=4_0 OUT_DIR=~/ics_out all
For Windows users, in case you are building using 64 bit VMWare Virtual Machine with a Shared Folder for the SDK pointing to your Windows OPERATING system, make sure you specify your OUT_DIR to link inside the VM to avoid the following error to occur the error "collect2: ld terminated signal 7 [Bus error]".
All the binaries will be generated in the *out* Android folder, that's the normal way it is when building for Android. On the system/bin a binary with the glgps will be created (this is our gps binary). and the customer can create their own system.img (the disk image) with the driver already there.
Any other intermediate binary will not be copied to the *system* tree
On top of this intermediate libraries the final binary will be copied to the customer folder as it was using the old Makefiles (so then any proprietary binary that the user needs to compile will be there, as it was before).
When we want to build the final binary, dependency libraries that are not built yet will be copied from the customer folder in case there is the library. (e.g. gll)
Customers may not want to use our makefiles that wrap the real Android makefiles, we may find some customers ask to bypass our makefiles and use only Android ones.
Each library can be compiled directly like: make -C /path/to/android files ONE_SHOT_MAKEFILE=/absolute/path/to/Android.mk
If we do that directly from gll, glct, glgps... then the config values will be set by default.
Let's say that we have a makefile that defines all the options we want to set (normally that's the file under the customers folder). Then we could make an Android makefile that includes these options plus the makefiles for each specific library and executable.
As an example:
LOCAL_PATH=$(call my-dir) SOURCE_TOPDIR=$(LOCAL_PATH)/../../ DELIVERABLES_DIR=$(SOURCE_TOPDIR)/allPartners/deliverables PROPRIETARY_DIR=$(SOURCE_TOPDIR)/proprietary/deliverables GLCT_DIR=$(DELIVERABLES_DIR)/glct GLGPS_DIR=$(DELIVERABLES_DIR)/glgpsapp GLHAL_DIR=$(DELIVERABLES_DIR)/glhal GLL_DIR=$(PROPRIETARY_DIR)/gll_dev GLNET_DIR=$(PROPRIETARY_DIR)/glnet_dev include $(LOCAL_PATH)/Makefile.Myandroidconfig include $(GLL_DIR)/project/make/Android.mk include $(GLCT_DIR)/project/Android.mk include $(GLHAL_DIR)/unix/Android.mk include $(GLGPS_DIR)/unix/Android.mk
The Android specific code is for the interface library. On most Android platforms the gps driver will not really differ from the generic linux driver.
The Android makefile and code are located at:
It can be compiled as usual in Android e.g:
$ make -C android_root_path files ONE_SHOT_MAKEFILE=allPartners/deliverables/middleware_connectors/unix/gps_jni/Android.mk
By default standard libraries will be copied to /system/lib. In Gingerbread, the gps.($TARGET_BOARD_PLATFORM).so file will need to be copied to /system/lib/hw. When building for Gingerbread, the following can be added to Android.mk to copy the library to the correct place:
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
The gps driver binary should be launched from init. We should add an entrance in the init.rc
service gps-demon /system/bin/glgps -c /system/etc/glconfig.xml user root group root
If you have questions regarding init.rc setting, please refer to Initial Kickstart with the Customer if you are a Broadcom (F)AE..
For Froyo and older Android versions, in order to link our JNI interface against the JNI interface we should add this option to the BoardConfig makefile definition:
BOARD_GPS_LIBRARIES := libgps
Once you compile a new system image our interface will be used.
We can test with the emulator. To do that we need to tell the emulator which serial com port will be mapped to the emulator.
Install avd from http://developer.android.com/guide/developing/tools/avd.html and run:
$ emulator -avd eclair -qemu -serial COM1=
settings for the COM port to be used in Android emulator:
The previous command will map windows serial com port COM1 to /dev/ttyS2 on the Android virtual machine (ttyS0 and ttyS1 are already used for different things)