External USB GPS support
dat-tran-halo opened this issue · 8 comments
Does any of the Android versions for RP-14 support a USB GPS module (u-blox neo series)?
I was able to compile and load Android 13 (automotive). I installed Maps but no GPS location with the USB module. I am able to read from /dev/ttyACM0. How can I configure the system to read the location from this device? Thank you.
My personal builds (https://konstakang.com/devices/rpi4/) have support for serial GPS devices.
Raspberry Vanilla project doesn't provide support for external hardware such as USB GPS dongles.
You would need to implement Android serial GPS HAL for this to work on your own build. Some options to look into:
https://github.com/lineage-rpi/android_hardware_gps
https://github.com/zxcwhale/aosp13_gnss_hal
Thank you. I'll give it a try.
I was able to verify that your personal build for AOSP-13 works with the USB GPS module I have.
However, when I try to integrate https://github.com/lineage-rpi/android_hardware_gps with the build from source provided by this repo, it doesn't give me a location. Can you provide your gnss/gps changes to get it working with AOSP? Thanks
My changes:
project device/brcm/rpi4/
diff --git a/device.mk b/device.mk
index de2ed12..f961500 100644
--- a/device.mk
+++ b/device.mk
@@ -273,6 +273,12 @@ PRODUCT_PACKAGES += \
wpa_supplicant \
wpa_supplicant.conf
+# Gnss HAL
+PRODUCT_PACKAGES += \
+ android.hardware.gnss@1.0 \
+ android.hardware.gnss@1.0-impl \
+ android.hardware.gnss@1.0-service
+
PRODUCT_COPY_FILES += \
hardware/broadcom/wlan/bcmdhd/config/wpa_supplicant_overlay.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/wpa_supplicant_overlay.conf
Extra build step:
Default gps path to ttyACM0
mmm vendor/android_hardware_gps/
I get these runtime errors in logcat:
130|rpi4:/ $ logcat | grep gnss
01-01 00:00:17.036 0 0 I init : starting service 'vendor.gnss_service'...
01-01 00:00:22.050 0 0 I init : starting service 'vendor.gnss_service'...
01-01 00:00:22.135 0 0 I init : Service 'vendor.gnss_service' (pid 471) exited with status 0
01-01 00:00:22.143 0 0 I init : Sending signal 9 to service 'vendor.gnss_service' (pid 471) process group...
01-01 00:00:27.062 0 0 I init : starting service 'vendor.gnss_service'...
01-01 00:00:27.119 0 0 I init : Service 'vendor.gnss_service' (pid 493) exited with status 0
01-01 00:00:27.137 0 0 I init : Sending signal 9 to service 'vendor.gnss_service' (pid 493) process group...
01-01 00:00:32.074 0 0 I init : starting service 'vendor.gnss_service'...
01-01 00:00:32.136 0 0 I init : Service 'vendor.gnss_service' (pid 530) exited with status 0
01-01 00:00:32.143 0 0 I init : Sending signal 9 to service 'vendor.gnss_service' (pid 530) process group...
11-19 15:36:53.437 154 154 I servicemanager: Could not find android.hardware.gnss.IGnss/default in the VINTF manifest.
11-19 15:36:53.439 155 155 I hwservicemanager: getTransport: Cannot find entry android.hardware.gnss@2.1::IGnss/default in either framework or device VINTF manifest.
11-19 15:36:53.439 473 473 D GnssJni : gnssHal 2.1 was null, trying 2.0
11-19 15:36:53.440 155 155 I hwservicemanager: getTransport: Cannot find entry android.hardware.gnss@2.0::IGnss/default in either framework or device VINTF manifest.
11-19 15:36:53.440 473 473 D GnssJni : gnssHal 2.0 was null, trying 1.1
11-19 15:36:53.440 155 155 I hwservicemanager: getTransport: Cannot find entry android.hardware.gnss@1.1::IGnss/default in either framework or device VINTF manifest.
11-19 15:36:53.441 473 473 D GnssJni : gnssHal 1.1 was null, trying 1.0
11-19 15:36:53.444 155 155 I hwservicemanager: getTransport: Cannot find entry android.hardware.gnss@1.0::IGnss/default in either framework or device VINTF manifest.
01-01 00:00:37.083 0 0 I init : starting service 'vendor.gnss_service'...
11-19 15:36:53.634 155 155 I hwservicemanager: getTransport: Cannot find entry android.hardware.gnss@1.0::IGnss/default in either framework or device VINTF manifest.
11-19 15:36:53.642 155 155 I hwservicemanager: getTransport: Cannot find entry android.hardware.gnss@1.0::IGnss/default in either framework or device VINTF manifest.
11-19 15:36:53.642 673 673 E HidlServiceManagement: Service android.hardware.gnss@1.0::IGnss/default must be in VINTF manifest in order to register/get.
11-19 15:36:53.642 673 673 E LegacySupport: Could not register service android.hardware.gnss@1.0::IGnss/default (-2147483648).
01-01 00:00:37.187 0 0 I init : Service 'vendor.gnss_service' (pid 673) exited with status 0
01-01 00:00:37.201 0 0 I init : Sending signal 9 to service 'vendor.gnss_service' (pid 673) process group...
11-19 15:36:53.627 673 673 I android.hardwar: type=1400 audit(0.0:86): avc: denied { read } for name="vndbinder" dev="binder" ino=6 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
11-19 15:36:53.627 673 673 I android.hardwar: type=1400 audit(0.0:87): avc: denied { write } for name="vndbinder" dev="binder" ino=6 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
11-19 15:36:53.627 673 673 I android.hardwar: type=1400 audit(0.0:88): avc: denied { open } for path="/dev/binderfs/vndbinder" dev="binder" ino=6 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
11-19 15:36:53.627 673 673 I android.hardwar: type=1400 audit(0.0:89): avc: denied { ioctl } for path="/dev/binderfs/vndbinder" dev="binder" ino=6 ioctlcmd=0x6209 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
11-19 15:36:53.627 673 673 I android.hardwar: type=1400 audit(0.0:90): avc: denied { map } for path="/dev/binderfs/vndbinder" dev="binder" ino=6 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
01-01 00:00:42.093 0 0 I init : starting service 'vendor.gnss_service'...
11-20 15:43:18.682 155 155 I hwservicemanager: getTransport: Cannot find entry android.hardware.gnss@1.0::IGnss/default in either framework or device VINTF manifest.
11-20 15:43:18.697 155 155 I hwservicemanager: getTransport: Cannot find entry android.hardware.gnss@1.0::IGnss/default in either framework or device VINTF manifest.
11-20 15:43:18.697 1259 1259 E HidlServiceManagement: Service android.hardware.gnss@1.0::IGnss/default must be in VINTF manifest in order to register/get.
11-20 15:43:18.697 1259 1259 E LegacySupport: Could not register service android.hardware.gnss@1.0::IGnss/default (-2147483648).
11-20 15:43:18.644 1259 1259 I android.hardwar: type=1400 audit(0.0:94): avc: denied { read } for name="vndbinder" dev="binder" ino=6 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
01-01 00:00:42.282 0 0 I init : Service 'vendor.gnss_service' (pid 1259) exited with status 0
01-01 00:00:42.293 0 0 I init : Sending signal 9 to service 'vendor.gnss_service' (pid 1259) process group...
11-20 15:43:18.672 1259 1259 I android.hardwar: type=1400 audit(0.0:95): avc: denied { write } for name="vndbinder" dev="binder" ino=6 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
11-20 15:43:18.672 1259 1259 I android.hardwar: type=1400 audit(0.0:96): avc: denied { open } for path="/dev/binderfs/vndbinder" dev="binder" ino=6 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
11-20 15:43:18.676 1259 1259 I android.hardwar: type=1400 audit(0.0:97): avc: denied { ioctl } for path="/dev/binderfs/vndbinder" dev="binder" ino=6 ioctlcmd=0x6209 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
11-20 15:43:18.676 1259 1259 I android.hardwar: type=1400 audit(0.0:98): avc: denied { map } for path="/dev/binderfs/vndbinder" dev="binder" ino=6 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
01-01 00:00:47.158 0 0 I init : starting service 'vendor.gnss_service'...
11-20 15:43:23.619 155 155 I hwservicemanager: getTransport: Cannot find entry android.hardware.gnss@1.0::IGnss/default in either framework or device VINTF manifest.
11-20 15:43:23.624 155 155 I hwservicemanager: getTransport: Cannot find entry android.hardware.gnss@1.0::IGnss/default in either framework or device VINTF manifest.
11-20 15:43:23.624 1452 1452 E HidlServiceManagement: Service android.hardware.gnss@1.0::IGnss/default must be in VINTF manifest in order to register/get.
11-20 15:43:23.625 1452 1452 E LegacySupport: Could not register service android.hardware.gnss@1.0::IGnss/default (-2147483648).
11-20 15:43:23.612 1452 1452 I android.hardwar: type=1400 audit(0.0:99): avc: denied { read } for name="vndbinder" dev="binder" ino=6 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
01-01 00:00:47.209 0 0 I init : Service 'vendor.gnss_service' (pid 1452) exited with status 0
01-01 00:00:47.228 0 0 I init : Sending signal 9 to service 'vendor.gnss_service' (pid 1452) process group...
11-20 15:43:23.612 1452 1452 I android.hardwar: type=1400 audit(0.0:100): avc: denied { write } for name="vndbinder" dev="binder" ino=6 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
11-20 15:43:23.612 1452 1452 I android.hardwar: type=1400 audit(0.0:101): avc: denied { open } for path="/dev/binderfs/vndbinder" dev="binder" ino=6 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
11-20 15:43:23.612 1452 1452 I android.hardwar: type=1400 audit(0.0:102): avc: denied { ioctl } for path="/dev/binderfs/vndbinder" dev="binder" ino=6 ioctlcmd=0x6209 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
11-20 15:43:23.612 1452 1452 I android.hardwar: type=1400 audit(0.0:103): avc: denied { map } for path="/dev/binderfs/vndbinder" dev="binder" ino=6 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:vndbinder_device:s0 tclass=chr_file permissive=1
Thanks for your help!
I was able to fix the manifest error by adding to device/brcm/rpi4/manifest.xml
diff --git a/manifest.xml b/manifest.xml
old mode 100644
new mode 100755
index 20e91b0..a574b92
--- a/manifest.xml
+++ b/manifest.xml
@@ -67,4 +67,14 @@
<instance>default</instance>
</interface>
</hal>
+ <hal format="hidl">
+ <name>android.hardware.gnss</name>
+ <transport>hwbinder</transport>
+ <version>1.0</version>
+ <interface>
+ <name>IGnss</name>
+ <instance>default</instance>
+ </interface>
+ <fqname>@1.0::IGnss/default</fqname>
+ </hal>
</manifest>
diff --git a/ramdisk/ueventd.rpi4.rc b/ramdisk/ueventd.rpi4.rc
index bcdd85f..5b4e060 100644
--- a/ramdisk/ueventd.rpi4.rc
+++ b/ramdisk/ueventd.rpi4.rc
@@ -25,3 +25,5 @@
/dev/video18 0660 media media
/dev/video19 0660 media media
/dev/video31 0660 media media
+
+/dev/ttyACM0 0660 gps gps
However, gps still doesn't work. I get these errors from logcat:
rpi4:/ $ logcat | grep gps
11-19 15:36:53.443 268 268 E gps_serial: Setting gps baud rate to 115200
11-19 15:36:53.464 468 485 E GnssLocationProviderJni: android_location_gnss_hal_GnssNative_set_agps_server: IAGnss interface not available.
11-20 17:19:11.094 268 268 E gps_serial: Setting gps baud rate to 115200
11-20 17:19:11.097 468 485 E GnssLocationProviderJni: android_location_gnss_hal_GnssNative_set_agps_server: IAGnss interface not available.
11-20 17:19:12.374 468 485 E LocationManagerService: blocking 0,0 location from gps provider
11-20 17:19:13.333 468 485 E LocationManagerService: blocking 0,0 location from gps provider
11-20 17:19:14.339 468 485 E LocationManagerService: blocking 0,0 location from gps provider
130|rpi4:/ $ logcat | grep gnss
11-19 15:36:53.411 155 155 I servicemanager: Could not find android.hardware.gnss.IGnss/default in the VINTF manifest.
11-19 15:36:53.412 156 156 I hwservicemanager: getTransport: Cannot find entry android.hardware.gnss@2.1::IGnss/default in either framework or device VINTF manifest.
11-19 15:36:53.412 468 468 D GnssJni : gnssHal 2.1 was null, trying 2.0
11-19 15:36:53.413 156 156 I hwservicemanager: getTransport: Cannot find entry android.hardware.gnss@2.0::IGnss/default in either framework or device VINTF manifest.
11-19 15:36:53.413 468 468 D GnssJni : gnssHal 2.0 was null, trying 1.1
11-19 15:36:53.413 156 156 I hwservicemanager: getTransport: Cannot find entry android.hardware.gnss@1.1::IGnss/default in either framework or device VINTF manifest.
11-19 15:36:53.413 468 468 D GnssJni : gnssHal 1.1 was null, trying 1.0
11-19 15:36:53.439 268 268 E GnssHAL_GnssInterface: gnss flp hw_get_module failed: -2
11-19 15:36:53.452 468 468 I GnssManager: gnss hal initialized
11-19 15:36:53.452 468 468 I GnssManager: gnss hal started
11-19 15:36:53.452 468 468 E GnssLocationProviderJni: android_location_gnss_hal_GnssNative_start_antenna_info_listening: IGnssAntennaInfo interface not available.
11-19 15:36:53.464 468 485 E GnssLocationProviderJni: android_location_gnss_hal_GnssNative_set_agps_server: IAGnss interface not available.
11-19 15:36:53.435 268 268 I gnss@1.0-servic: type=1400 audit(0.0:71): avc: denied { read } for name="u:object_r:default_prop:s0" dev="tmpfs" ino=99 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:default_prop:s0 tclass=file permissive=1
11-19 15:36:53.439 268 268 I gnss@1.0-servic: type=1400 audit(0.0:72): avc: denied { open } for path="/dev/__properties__/u:object_r:default_prop:s0" dev="tmpfs" ino=99 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:default_prop:s0 tclass=file permissive=1
11-19 15:36:53.439 268 268 I gnss@1.0-servic: type=1400 audit(0.0:73): avc: denied { getattr } for path="/dev/__properties__/u:object_r:default_prop:s0" dev="tmpfs" ino=99 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:default_prop:s0 tclass=file permissive=1
11-19 15:36:53.439 268 268 I gnss@1.0-servic: type=1400 audit(0.0:74): avc: denied { map } for path="/dev/__properties__/u:object_r:default_prop:s0" dev="tmpfs" ino=99 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:default_prop:s0 tclass=file permissive=1
11-19 15:36:53.439 268 268 I gnss@1.0-servic: type=1400 audit(0.0:75): avc: denied { read write } for name="ttyACM0" dev="tmpfs" ino=307 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:usb_serial_device:s0 tclass=chr_file permissive=1
11-19 15:36:53.439 268 268 I gnss@1.0-servic: type=1400 audit(0.0:76): avc: denied { open } for path="/dev/ttyACM0" dev="tmpfs" ino=307 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:usb_serial_device:s0 tclass=chr_file permissive=1
11-19 15:36:53.439 268 268 I gnss@1.0-servic: type=1400 audit(0.0:77): avc: denied { ioctl } for path="/dev/ttyACM0" dev="tmpfs" ino=307 ioctlcmd=0x5401 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:usb_serial_device:s0 tclass=chr_file permissive=1
11-20 17:19:11.097 468 485 E GnssLocationProviderJni: android_location_gnss_hal_GnssNative_set_agps_server: IAGnss interface not available.
11-20 17:19:11.089 268 268 I gnss@1.0-servic: type=1400 audit(0.0:117): avc: denied { read write } for name="ttyACM0" dev="tmpfs" ino=307 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:usb_serial_device:s0 tclass=chr_file permissive=1
11-20 17:19:11.089 268 268 I gnss@1.0-servic: type=1400 audit(0.0:118): avc: denied { open } for path="/dev/ttyACM0" dev="tmpfs" ino=307 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:usb_serial_device:s0 tclass=chr_file permissive=1
11-20 17:19:11.089 268 268 I gnss@1.0-servic: type=1400 audit(0.0:119): avc: denied { ioctl } for path="/dev/ttyACM0" dev="tmpfs" ino=307 ioctlcmd=0x5401 scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:usb_serial_device:s0 tclass=chr_file permissive=1
11-20 17:19:12.368 468 485 W AlarmManager: Unrecognized alarm listener com.android.server.location.gnss.GnssLocationProvider$$ExternalSyntheticLambda22@beb5889
11-20 17:19:12.374 468 485 W AlarmManager: Unrecognized alarm listener com.android.server.location.gnss.GnssLocationProvider$$ExternalSyntheticLambda22@beb5889
11-20 17:19:13.330 468 485 W AlarmManager: Unrecognized alarm listener com.android.server.location.gnss.GnssLocationProvider$$ExternalSyntheticLambda22@beb5889
11-20 17:19:13.333 468 485 W AlarmManager: Unrecognized alarm listener com.android.server.location.gnss.GnssLocationProvider$$ExternalSyntheticLambda22@beb5889
11-20 17:19:14.339 468 485 W AlarmManager: Unrecognized alarm listener com.android.server.location.gnss.GnssLocationProvider$$ExternalSyntheticLambda22@beb5889
11-20 17:19:14.340 468 485 W AlarmManager: Unrecognized alarm listener com.android.server.location.gnss.GnssLocationProvider$$ExternalSyntheticLambda22@beb5889
11-20 17:19:15.338 468 485 W AlarmManager: Unrecognized alarm listener com.android.server.location.gnss.GnssLocationProvider$$ExternalSyntheticLambda22@beb5889
11-20 17:19:15.340 468 485 W AlarmManager: Unrecognized alarm listener com.android.server.location.gnss.GnssLocationProvider$$ExternalSyntheticLambda22@beb5889
I don't see anything missing but the permission (copy from frameworks/native/data/etc/android.hardware.location.gps.xml
).
Also note that the GPS HAL might involve some hacking around https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-14.0.0_r14/location/java/android/location/LocationResult.java#109 as not all serial GPS devices report complete location. This might also be fixed in some serial GPS HALs you might find.
I'll give that a try. Thanks for all your help.
Here is my latest patch for GPS if it helps anyone else:
project device/brcm/rpi4/
diff --git a/device.mk b/device.mk
index de2ed12..3355c17 100644
--- a/device.mk
+++ b/device.mk
@@ -273,6 +273,15 @@ PRODUCT_PACKAGES += \
wpa_supplicant \
wpa_supplicant.conf
+# Gnss HAL
+PRODUCT_PACKAGES += \
+ android.hardware.gnss@1.0 \
+ android.hardware.gnss@1.0-impl \
+ android.hardware.gnss@1.0-service
+
+PRODUCT_COPY_FILES += \
+ frameworks/native/data/etc/android.hardware.location.gps.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.location.gps.xml
+
PRODUCT_COPY_FILES += \
hardware/broadcom/wlan/bcmdhd/config/wpa_supplicant_overlay.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/wpa_supplicant_overlay.conf
diff --git a/manifest.xml b/manifest.xml
old mode 100644
new mode 100755
index 20e91b0..a574b92
--- a/manifest.xml
+++ b/manifest.xml
@@ -67,4 +67,14 @@
<instance>default</instance>
</interface>
</hal>
+ <hal format="hidl">
+ <name>android.hardware.gnss</name>
+ <transport>hwbinder</transport>
+ <version>1.0</version>
+ <interface>
+ <name>IGnss</name>
+ <instance>default</instance>
+ </interface>
+ <fqname>@1.0::IGnss/default</fqname>
+ </hal>
</manifest>
diff --git a/ramdisk/ueventd.rpi4.rc b/ramdisk/ueventd.rpi4.rc
index bcdd85f..5b4e060 100644
--- a/ramdisk/ueventd.rpi4.rc
+++ b/ramdisk/ueventd.rpi4.rc
@@ -25,3 +25,5 @@
/dev/video18 0660 media media
/dev/video19 0660 media media
/dev/video31 0660 media media
+
+/dev/ttyACM0 0660 gps gps
diff --git a/vendor.prop b/vendor.prop
index c5fd75c..9b05a96 100644
--- a/vendor.prop
+++ b/vendor.prop
@@ -79,3 +79,5 @@ ro.vendor.v4l2_codec2.encode_concurrent_instances=8
# Wifi
wifi.interface=wlan0
+# GPS
+ro.kernel.android.gps=ttyACM0
@KonstaT, your suggestion for the permission file worked perfectly. Thanks again for your help.