GPS uart on android

Hi to all.
Has anyone managed to connect the gps module to Rock Pi 4?
I’m trying to connect u-blox neo-7m, but there are difficulties.
cat /dev/ttyS4 displays the receipt of NMEA data.
But there’s no “satellite” in settings - location and navigation programs do not find my locations.
What am I doing wrong?

1 Like

I think HAL also needs to be compatible with your GPS device.

u may need to add some additional code
path must be changed to your needs

added to device/rockchip/rk3399/BoardConfig.mk

-include vendor/quectel/ec25/BoardConfigPartial.mk

BUILD_WITH_EC25 := true
BOARD_HAS_GPS := true
BOARD_HAVE_DONGLE := false

in device/rockchip/rk3399/rk3399.mk
$(call inherit-product-if-exists, vendor/quectel/ec25/device-partial.mk)

................

ifeq ($(BOARD_HAS_GPS),true)
    PRODUCT_PACKAGES += \
        android.hardware.gnss@1.0-impl \
        android.hardware.gnss@1.0-service

    PRODUCT_COPY_FILES += \
            vendor/quectel/ec25/gps/gps.default.so:vendor/lib64/hw/gps.default.so \   #Hardware Related Driver
            vendor/quectel/ec25/gps/gps_cfg.inf:system/etc/gps_cfg.inf \    #Optional Harware related
            vendor/quectel/ec25/gps/gps.cfg:system/etc/gps.cfg \  #Optional Harware related
            frameworks/native/data/etc/android.hardware.location.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.location.xml \
            frameworks/native/data/etc/android.hardware.location.gps.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.location.gps.xml

    PRODUCT_PROPERTY_OVERRIDES += \
        ro.kernel.android.gps=ttyUSB1 \     # change to the tty you use**
        ro.kernel.android.gps.speed=115200 \      # depends on Hardware 9600-115200**
        ro.kernel.android.gps.max_rate=1
endif 

also add to manifest.xml

<manifest version="1.0" type="device" target-level="3">
    <hal format="hidl">
        <name>android.hardware.gnss</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IGnss</name>
            <instance>default</instance>
        </interface>
    </hal>
</manifest>

add to init.rc

# hardware/interfaces/gnss/1.0/default/android.hardware.gnss@1.0-service.rc
service gnss_service /vendor/bin/hw/android.hardware.gnss@1.0-service
    class hal
    user gps
    group system gps radio

ueventd.rc

# for GPS
#/dev/ttyX                0600   gps        gps

my Modem/GPS (Quectel EC25) runs via mini PCIE and it uses ttyUSB instead of UART

1 Like

Thanks for your answer.
In principle, I understand. Only two question:

  1. Where to get the contents of the vendor folder (vendor/quectel/ec25). And as I understand it - this content should be different for me? I have a u-blox neo-7m module.
  2. Where is the ueventd.rc located?

/vendor/quectel/ec25 is Hardware related.
usually you should have a driver provided by HW Vendor such as gps.default.so
For U-Blox Hardware you have to change it to your needs.

ueventd.rc is located in
/system/core/rootdir/ueventd.rc

on Linux you can find file via:

find . -name “filename”

1 Like

Bottom line is that for GPS, you need a HAL that is compatible with your gps hardware.

Most GPS will work with GPSd, which has an Android HAL: https://gitlab.com/gpsd/gpsd

Would I need a root access to install GPSd to Android?
If so, how do I go about getting root access please?

I would also like to add a compass and other IMU sensors (that would be I2C) and make use of them in say Google map, how should I go about doing this?

Sorry, I’m a newb and inexperienced in Android.

I think I got the root access figured out.

adb shell
su

I got my GPS module connected to UART2.
But doing so causes android to freeze soon after booting.
Is that because UART2 is used as serial console by default?
How do I configure UART2 to use with GPS?

Add to the manifest and device makefiles to build it into the system image.

I wonder if you succeded

I want to ask in continuation of this topic, someone was able to connect the u-blox module. For this module, I can’t find the contents of the vendor folder (vendor/quectel/ec25) anywhere. There is only a gps.default.so driver