This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
libGPS for TinkerBoard Android
#1
Hello there,
I would like to share this GPS library. I worked on it last time, but I was not yet able to test it in my car. I don't remember where I found the original code, but this code was the only one of several, that didn't failed or freezed. I had to search for a bug that caused that there was never a Location Fix and I made the serial port configurable.
Let's say it is a beta version.
The source code you can find here, also a description how to install: https://github.com/joerg65/libGPS_TinkerBoard

Library V3:

.zip   gps.default.so.v3.zip (Size: 14.2 KB / Downloads: 87)


Library V4:
-with some fixes due to my Ublox8 based dongle
-enabled 4800 baud


.zip   gps.default.so.v4.zip (Size: 11.24 KB / Downloads: 95)

How to install:

-unpack the library

-open a terminal in the library folder and copy to TB
Code:
adb root
adb remount
adb push gps.default.so /system/lib/hw/

-check out the serial device by opening a adb shell and command dmesg after connection of the gps usb device
Code:
# dmesg
.
.
.
[ 1475.507432] usb 3-1.4: new full-speed USB device number 5 using usb20_host
[ 1475.606598] usb 3-1.4: New USB device found, idVendor=1546, idProduct=01a7
[ 1475.606624] usb 3-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1475.606631] usb 3-1.4: Product: u-blox 7 - GPS/GNSS Receiver
[ 1475.606644] usb 3-1.4: Manufacturer: u-blox AG - www.u-blox.com
[ 1475.613246] cdc_acm 3-1.4:1.0: ttyACM0: USB ACM device

-create a gps.conf (change the port and baud rate to your needs)
Code:
(already in adb shell terminal)
# echo "'GPSPORT /dev/ttyACM0\nGPSSPEED 115200' > /system/etc/gps.conf"
(or from host pc)
adb shell echo "'GPSPORT /dev/ttyACM0\nGPSSPEED 115200' > /system/etc/gps.conf"

-change permission temporary and restart the Android OS (not the TinerBoard) to check the gps messages
Code:
# chmod 666 /dev/ttyACM0
# am restart
# logcat | grep gps

Change the permission permanently alternative 1 (SuperUser install-recovery-2.sh):

-remount  system partition writeable from inside adb shell
Code:
mount -o remount, rw /system

-create the file 'install-recovery-2.sh' from inside adb shell
Code:
echo '#!/system/bin/sh' >> /system/etc/install-recovery-2.sh
echo 'chmod 666 /dev/ttyACM0' >> /system/etc/install-recovery-2.sh
chmod 755 /system/etc/install-recovery-2.sh

-reboot your TinkerBoard

Change the permission permanently alternative 2 (uevent.rk30board.rc):

To do this you'll need the tools rkflashtool and rkcrc. It can be checked out here: https://github.com/linux-rockchip/rkflashtool/issues and you need to compile it on your host pc.
To get into the bootloader for me the best method is to power the TB over the 40p header and boot with connected usb cable into the Android. Then  you can open a adb connection over the usb cable, and then you can give command 'adb reboot bootloader'.

-read the boot.img (in a terminal on your host pc)
Code:
cd /to/your/prefered/folder
adb reboot bootloader
sudo path/to/rkflashtool r boot >boot.img


-unpack boot.img
Code:
dd if=boot.img of=boot.img.gz skip=8 bs=1 count=100000000000
gunzip boot.img.gz
mkdir unpacked
cd unpacked
cpio -i <../boot.img

-add the line to the uevent.rk30board.rc
Code:
/dev/ttyACM0              0660   gps        gps

-pack boot.img
Code:
cd unpacked
find . | xargs -I file touch -d "1970-01-01 01:00" file
find . | cpio -o -H newc | gzip -n >../newboot.img.gz
cd ..
path/to/rkcrc -k newboot.img.gz newboot.img

-flash boot.img to TB
Code:
sudo path/to/rkflashtool w boot <newboot.img

-reboot the TB
Code:
sudo path/to/rkflashtool b
[-] The following 2 users Like lobo's post:
  • Leskriim, sobrinho
Reply
#2
thanks for this : )

this is only usefull for an external usb or serial GPS Antenna device right?
So it is not possible to use it or to manipulate any chip like W-Lan or so on to get a position for some navi aps?
Reply
#3
It's like that, only for serial messages in form NMEA, that come over serial port. Can be the native serial port ttySx, or from from usb gps mouse like mine u-blox7 based, that creates a ttyACMx serial port.
Reply
#4
great job, thanks for your work !
Reply
#5
Hi lobo,
I've tried your gps library but struggling to get it to work. I've got u-blox 7 based adapter like yourself with the serial port as ttyACM0.

I can read the NMEA stings from the serial port on the tinker, but when opening a location app, it picks up that a device is present (which it didnt before), but doesnt return any positional data.

I also cant seem to get "chmod 666 /dev/ttyACM0" to stick after reboot, even when putting it in init.rc
Reply
#6
Hi lostangel556,

you can't edit init.rc directly, after reboot it restores the version from boot partition. As I wrote on github, there two alternatives (maybe more). You can extract the boot partition, edit the ueventd.rk30board.rc and repack it again. Or you can install SuperUser and add what you need to install-recovery.sh, better to create a install-recovery2.sh as it is written in the file.

I have gone the boot.img way as this:
Code:
#read boot.img:
adb reboot bootloader
sudo path/to/rkflashtool r boot >boot.img

#unpack boot.img:
dd if=boot.img of=boot.img.gz skip=8 bs=1 count=100000000000
gunzip boot.img.gz
mkdir unpacked
cd unpacked
cpio -i <../boot.img

#pack boot.img:
cd unpacked
find . | xargs -I file touch -d "1970-01-01 01:00" file
find . | cpio -o -H newc | gzip -n >../newboot.img.gz
cd ..
path/to/rkcrc -k newboot.img.gz newboot.img

#flash boot.img
sudo ./rkflashtool w boot <newboot.img

Instead the 'adb reboot bootloader' you can also put a jumper on the volume+ header aside the hdmi port and reboot with an usb cable to your host pc. If it is used the adb variant, it is needed to power the tinker board via the 40p header and connect an usb cable at boot time. In the unpacked directory you'll find the files to modify.

Put this line  ueventd.rk30board.rc: '/dev/ttyACM0              0660   gps        gps'

If everything work, you should see NMEA messages in logcat.
Reply
#7
Lobo, you are a legend. GPS now working Big Grin
Reply
#8
I have added in the first post a new version. Reason is I found some problems with the initial version, mainly in the Here We Go app, there are occasionally messages 'Waiting for GPS'. But I found at first use of this version also some problem with location timeout.
If you use it and find some problems, please report here with output of logcat.
I know this is not easy, driving car and save a log file. It is needed a terminal app and to give the command e.g. 'logcat > /storage/emulated/0/logcat.log' and a filemanager app to copy this log to a usb memory.
I must not explain that it is dangerous to do this while driving car! Please stop and do it while parking!
Meanwhile I will test with Google Maps and with Gpstest, if there are also location timeouts.
Reply
#9
I updated the library to V3. The second version was not working well. My changes caused another bug to come in front when in GGA the quality indicator changed from 1 to 2, and that was mostly after about 20 minutes.
This new version I use already since 10 days.
Reply
#10
Hi lobo,

thank you for your work.

Could you explain how to execute "jni" and get librarys? 

Am I need use Android studio or another software?

Could you make couple of screenshots how to do this?

I'm not a developer, realy sorry for dump question, never use android before.

Just trying to make CarPC, something similar to CarPC on Raspberry.

Thank you again.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)