and
http://source.android.com/porting/gps.html
說要根據gps.h去implement gps driver (libgps.so)
http://blog.chinaunix.net/u3/118873/showart_2339574.html
有解釋GPS底層檔案分佈, JNI以及Android提供service的部份
http://www.douban.com/note/80170485/
提供Application開啟GPS呼叫到底層回覆的過程
有人回應說需要implement HAL
http://groups.google.com/group/android-developers/browse_thread/thread/3bb4dd9070451df2#
http://blog.chinaunix.net/u1/56680/showart_2143187.html
android gps 需要實做HAL(hardware abstruct layer)
該怎麼作呢
參考glgps.c
用mm來buidl libhardware_legacy.so
所以要想辦法讓mm可以build出libhardware_legacy.so
Modify
/device/fsl/imx51_bbg/BoardConfig.mk
add BOARD_GPS_LIBRARIES := libgps
switch /hardware/libhardware_legacy
choosecombo設定一下平台
Build for the simulator or the device?
1. Device
2. Simulator
Which would you like? [1]
Build type choices are:
1. release
2. debug
Which would you like? [1]
Which product would you like? [imx51_bbg]
Variant choices are:
1. user
2. userdebug
3. eng
Which would you like? [eng]
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.2
TARGET_PRODUCT=imx51_bbg
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=FRF85B
============================================
build:
elsonchung@gps1004:~/myandroid9.1/hardware/libhardware_legacy$ mm
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.2
TARGET_PRODUCT=imx51_bbg
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=FRF85B
============================================
No private recovery resources for TARGET_DEVICE imx51_bbg
make: Entering directory `/home/nelsonchung/myandroid9.1'
Copy: out/target/product/imx51_bbg/root/init.rc
target thumb C: libhardware_legacy <= hardware/libhardware_legacy/gps/glgps.c
target SharedLib: libhardware_legacy (out/target/product/imx51_bbg/obj/SHARED_LIBRARIES/libhardware_legacy_intermediates/LINKED/libhardware_legacy.so)
target Prelink: libhardware_legacy (out/target/product/imx51_bbg/symbols/system/lib/libhardware_legacy.so)
libelfcopy: Warning: Range lists in .debug_info section aren't in ascending order!
libelfcopy: Warning: Range lists in .debug_ranges section start at 0x5a8
target Strip: libhardware_legacy (out/target/product/imx51_bbg/obj/lib/libhardware_legacy.so)
Install: out/target/product/imx51_bbg/system/lib/libhardware_legacy.so
make: Leaving directory `/home/nelsonchung/myandroid9.1'
如果用mm showcommands
可以看到
glgps.c 編譯成glgps.o 並放到out/target/product/imx51_bbg/obj/SHARED_LIBRARIES/libhardware_legacy_intermediates/gps/
message:
out/target/product/imx51_bbg/obj/SHARED_LIBRARIES/libhardware_legacy_intermediates/gps/glgps.o hardware/libhardware_legacy/gps/glgps.c
最後編譯好的libhardware_legacy.so就會放到以下路徑
out/target/product/imx51_bbg/system/lib/libhardware_legacy.so
croot
make snod
去產生system.img
這之間為了讓Android能夠正常起來
follow http://nelsonchunglife.blogspot.com/2010/12/disable-original-audio-driver-and.html
重新編譯了system.img
使用Denny寫好的GPSDemo
利用adb install X.apk裝到機器上
操作Panel
Settings-->Applications-->Manage applications-->Downloaded
就會看到剛剛install的程式
點擊執行
能夠看到在glgps.c裡面加上的message
D/gps_BRCM( 2106): *****20101216: gps_init *****
AP還沒看到gps相關訊息
底層有些訊息值得參考
E/ThrottleService( 2102): Could not open GPS configuration file /etc/gps.conf
W/GpsLocationProvider( 2102): Could not open GPS configuration file /etc/gps.conf
D/gps_BRCM( 2102): *****20101216: gps_init *****
D/gps_BRCM( 2102): gps state initialized
D/gps_BRCM( 2102): gps thread running
Could not open GPS configuration file /etc/gps.conf的訊息只是warning not error.
follow this information.
http://groups.google.com/group/android-framework/browse_thread/thread/9c2a9b8b7c7fb394
發現卡住epoll_wait
恢復預設值 /cache/gpspipe
執行GPSDemo 出現
E/GpsLocationProvider( 2107): native_start failed in startNavigating()
設成 /dev/ttymxc1
看一下會不會
E/GpsLocationProvider( 2107): native_start failed in startNavigating()
一樣
此錯誤訊息發生在GpsLocationProvider.java的startNavigating()
因為將gps mode設成 GPS_POSITION_MODE_MS_BASED
造成HAL(glgps.c)判斷gps mode非 GPS_POSITION_MODE_STANDALONE回傳false
而出現的錯誤訊息
誰應該設定gps mode為 GPS_POSITION_MODE_STANDALONE呢?
是根據這行判斷而來的
if (Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ASSISTED_GPS_ENABLED, 1) != 0) {
positionMode = GPS_POSITION_MODE_MS_BASED;
} else {
positionMode = GPS_POSITION_MODE_STANDALONE;
}
Denny 說 ASSISTED_GPS_ENABLED 就是所謂的AGPS.
Android 2.2版已經建議移除
上面code的意思是 如果ASSISTEND_GPS_ENABLED沒有定義
會回傳第三個參數值(1)
1 != 0
所以設定成GPS_POSITION_MODE_MS_BASED
參考
http://developer.android.com/reference/android/provider/Settings.Secure.html#getInt(android.content.ContentResolver, java.lang.String, int)
compare /hardware/qcom/gps/loc_api/libloc_api/loc_eng.cpp with /hardware/libhardware_legacy/gps/glgps.c
loc_eng_set_position_mode and gps_set_position_mode
if (!native_start(positionMode, false, 1)) {
mStarted = false;
Log.e(TAG, "native_start failed in startNavigating()");
return;
}
nelsonchung@gps1004:~/myandroid9.1$ cgrep native_start
./frameworks/base/core/jni/android_location_GpsLocationProvider.cpp:519: {"native_start", "(IZI)Z", (void*)android_location_GpsLocationProvider_start},
native_start會對應到 android_location_GpsLocationProvider_start
--
Update: 20110119
Solution請見其他相關文章
http://nelsonchunglife.blogspot.com/2010/12/introduction-of-android-gps-interface.html
http://nelsonchunglife.blogspot.com/2010/12/android-gps-porting-hal-code-fix.html
http://nelsonchunglife.blogspot.com/2010/12/gps-nmea-gpgsa-and-gpgsv.html
http://nelsonchunglife.blogspot.com/2010/12/android-gps-porting-hal-code-try-to-fix.html
AP還沒看到gps相關訊息
底層有些訊息值得參考
E/ThrottleService( 2102): Could not open GPS configuration file /etc/gps.conf
W/GpsLocationProvider( 2102): Could not open GPS configuration file /etc/gps.conf
D/gps_BRCM( 2102): *****20101216: gps_init *****
D/gps_BRCM( 2102): gps state initialized
D/gps_BRCM( 2102): gps thread running
Could not open GPS configuration file /etc/gps.conf的訊息只是warning not error.
follow this information.
http://groups.google.com/group/android-framework/browse_thread/thread/9c2a9b8b7c7fb394
發現卡住epoll_wait
恢復預設值 /cache/gpspipe
執行GPSDemo 出現
E/GpsLocationProvider( 2107): native_start failed in startNavigating()
設成 /dev/ttymxc1
看一下會不會
E/GpsLocationProvider( 2107): native_start failed in startNavigating()
一樣
此錯誤訊息發生在GpsLocationProvider.java的startNavigating()
因為將gps mode設成 GPS_POSITION_MODE_MS_BASED
造成HAL(glgps.c)判斷gps mode非 GPS_POSITION_MODE_STANDALONE回傳false
而出現的錯誤訊息
誰應該設定gps mode為 GPS_POSITION_MODE_STANDALONE呢?
是根據這行判斷而來的
if (Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ASSISTED_GPS_ENABLED, 1) != 0) {
positionMode = GPS_POSITION_MODE_MS_BASED;
} else {
positionMode = GPS_POSITION_MODE_STANDALONE;
}
Android 2.2版已經建議移除
上面code的意思是 如果ASSISTEND_GPS_ENABLED沒有定義
會回傳第三個參數值(1)
1 != 0
所以設定成GPS_POSITION_MODE_MS_BASED
參考
http://developer.android.com/reference/android/provider/Settings.Secure.html#getInt(android.content.ContentResolver, java.lang.String, int)
compare /hardware/qcom/gps/loc_api/libloc_api/loc_eng.cpp with /hardware/libhardware_legacy/gps/glgps.c
loc_eng_set_position_mode and gps_set_position_mode
if (!native_start(positionMode, false, 1)) {
mStarted = false;
Log.e(TAG, "native_start failed in startNavigating()");
return;
}
nelsonchung@gps1004:~/myandroid9.1$ cgrep native_start
./frameworks/base/core/jni/android_location_GpsLocationProvider.cpp:519: {"native_start", "(IZI)Z", (void*)android_location_GpsLocationProvider_start},
native_start會對應到 android_location_GpsLocationProvider_start
--
建立軟連結的方式
modify the content on /device/fsl/imx5x/init.rc
symlink /dev/ttymxc1 /pipe
在將glgps.c GPS_PIPE 由原先的 /cache/gpspipe 改成 /gpspipe
就不會發生open com port fail的問題
猜測是權限的問題
叫glgps.c檔案起來的process權限可能不足
--
之後open後回傳fd去作註冊的動作epoll_register
就不會一直卡在epoll_wait
epoll是linux為了改善poll的機制
透過發送event的方式改善performance
註冊完之後如果該com port有送出訊息的話
linux就會送出event出來
就可以繼續往後執行
之後用read方式讀取gps nmea
透過nmea_reader_addc丟給Android structure - NmeaReader
之後透過nmea_reader_set_callback回應給Android gps interface.
這樣子之後用Denny GPSDemo程式可以讀到經緯度的資料
另外
GPS status and nmea還沒辦法完整呈現
Update: 20110119
Solution請見其他相關文章
http://nelsonchunglife.blogspot.com/2010/12/introduction-of-android-gps-interface.html
http://nelsonchunglife.blogspot.com/2010/12/android-gps-porting-hal-code-fix.html
http://nelsonchunglife.blogspot.com/2010/12/gps-nmea-gpgsa-and-gpgsv.html
http://nelsonchunglife.blogspot.com/2010/12/android-gps-porting-hal-code-try-to-fix.html