您的位置:首页 > 移动开发 > Android开发

Android 4.22 GPS移植实战总结

2013-09-02 13:46 183 查看
7月刚学完嵌入式,找了一个月的工作,最后还是在老师的推荐下进了现在的公司,老板交代要移植gps,感觉“亚历山大”,话说这应该属于安卓底层,可是我们学的主要是嵌入式 linux c编程,底层只是讲了三天而已呀!

果不其然,GPS都搞了一个月了,虽然有了一些进展,但是距离目标还相差甚远。。。。

首先介绍下安卓下gps的调用层次结构吧,具体看了下面这张图我想就清楚多了



相关目录及文件
头文件 hardware/libhardware/include/hardware/gps.h
framework层 frameworks/base/services/java/com/android/server/location/GpsLocationProvider.java

JNI层 frameworks/base/services/jni/com_android_server_location_GpsLocationProvider.cpp

HAL层 /android4.2/device/softwinner/common/hardware/libhardware/gps/gps.c.

static void
gps_state_init( GpsState*  state, GpsCallbacks* callbacks )
{
state->init       = 1;
state->control[0] = -1;
state->control[1] = -1;
state->fd         = -1;
ALOGD("gps_state_init");
//state->fd = qemud_channel_open(QEMU_CHANNEL_NAME);
state->fd = open(GPS_Serial_Name, O_RDWR|O_NOCTTY|O_NDELAY );
if (state->fd < 0) {
D("no gps emulation detected");
return;
}
if ( isatty( state->fd ) ) {
struct termios  ios;
tcgetattr( state->fd, &ios );
ios.c_lflag = 0;  /* disable ECHO, ICANON, etc... */
ios.c_oflag &= (~ONLCR); /* Stop \n -> \r\n translation on output */
ios.c_iflag &= (~(ICRNL | INLCR)); /* Stop \r -> \n & \n -> \r translation on input */
ios.c_iflag |= (IGNCR | IXOFF);  /* Ignore \r & XON/XOFF on input */
cfsetispeed(&ios, B9600);
cfsetospeed(&ios, B9600);
tcsetattr( state->fd, TCSANOW, &ios );
}
ALOGD("gps emulation will read from '%s' qemud channel", GPS_Serial_Name );

if ( socketpair( AF_LOCAL, SOCK_STREAM, 0, state->control ) < 0 ) {
ALOGE("could not create thread control socket pair: %s", strerror(errno));
goto Fail;
}

state->thread = callbacks->create_thread_cb( "gps_state_thread", gps_state_thread, state );

if ( !state->thread ) {
ALOGE("could not create gps thread: %s", strerror(errno));
goto Fail;
}

state->callbacks = *callbacks;

ALOGD("gps state initialized");
return;

Fail:
gps_state_done( state );
}


用的蓝牙管脚 PI20 PI21

串口对应关系 UART7 -》 ttyS1

Z:\android4.2\hardware\libhardware\modules\gps

“注释蓝牙”

内核 Z:\lichee\linux-3.3\.Config

CONFIG_BT=y
CONFIG_BT_RFCOMM=y
CONFIG_BT_RFCOMM_TTY=y
CONFIG_BT_BNEP=y
CONFIG_BT_BNEP_MC_FILTER=y
CONFIG_BT_BNEP_PROTO_FILTER=y
CONFIG_BT_HIDP=y

Wing-k70
Z:\android4.2\device\softwinner\wing-k70\BoardConfig.mk

Boardconfig.mk
#BOARD_HAVE_BLUETOOTH := true
#BOARD_HAVE_BLUETOOTH_BCM := true

Fex

Z:\lichee\tools\pack\chips\sun7i\configs\android\wing-k70\sys_config.fex
固件位置 lichee/tools/pack/sun7i_android_wing-k70.img
Adb Logcat>c:\logcat.txt

提示:生成的gps.default.so最终会在out/target/product/generic/system/lib/hw目录下,如果该目录下同时还有gps.goldfish.so文件,必须先把gps.goldfish.so文件删除,然后再打包镜像文件。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: