How to use 3G modem with Android

Post Reply
JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

How to use 3G modem with Android

Unread post by JediMax2 » Sat Sep 24, 2016 1:13 am

I want to use 3G USB modem with C2 and Android. I read this topic http://forum.odroid.com/viewtopic.php?f ... 3g#p114144 but can't do it. Then I buy Huawei E303 modem with HiLink. When I connect modem to Odroid, after 30 sec. it flashed blue (3G connected). But no Internet. I check, my Odroid haven't /sys/class/net/usbnet0 folder. As I think, it is general problem.
Please, any help.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Mon Sep 26, 2016 5:16 am

It seems that on C2 and also C1 Lollipop is different. Now is needed usb_modeswitch to switch the modem from CD mode to Hilink mode. On the C1 with Kitkat in my car the kernel switches the modem direct to Hilink mode.
I can show here how to switch my modem, but so far I wasn't able to make it autostart. My modem has vid:pid when connected:

Code: Select all

lsusb
Bus 001 Device 009: ID 12d1:1f01
To switch the modem to Hilink mode:

Code: Select all

usb_modeswitch -v 12d1 -p 1f01 -M '55534243123456780000000000000a11062000000000000100000000000000'
Something wrong with the script init-hilink.sh I made once, on C2 Lollipop..
To check if modem switched:

Code: Select all

lsusb
Bus 001 Device 010: ID 12d1:14dc
If the interface is up or down:

Code: Select all

cat /sys/class/net/usbnet0/operstate                         
up
To check if interface has ip:

Code: Select all

netcfg                                                       
usbnet0  UP                               192.168.8.100/24  0x00001043 0c:5b:8f:27:9a:64
If no address, can start dhcp as this:

Code: Select all

/system/bin/dhcpcd usbnet0
There should be internet now.
I will look, if I can find solution to make it autostart.

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Wed Sep 28, 2016 3:00 am

Thank you for answer.
lsusb result is ID 1211:1f01 (as you say). But I don't have usb_modeswitch.
In topic http://forum.odroid.com/viewtopic.php?f=113&t=16489 you say "To get usb_modeswitch you can download PPPWidget apk from some apk download site and extract binary from folder /assets/bin-arm/"
I find /assets/bin-arm folder in PPPWidget.apk file and there usb_modeswitch. But I can't run it. I copy it to /bin foldeer, and when I try to run it, I get error "only position independet executables are supported".
Then I try to use usb_modeswitch file from here http://antipastohw.blogspot.com/2012/05 ... em-on.html
Last edited by JediMax2 on Wed Sep 28, 2016 4:58 am, edited 1 time in total.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Wed Sep 28, 2016 4:56 am

Yes, sorry I forgot about to post it. To run usb_modeswitch you need to install the patched linker. You find here in thread, how-to install also there:http://forum.odroid.com/viewtopic.php?f ... 65#p133065

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Thu Sep 29, 2016 12:34 am

Thank you very much. It's working!!!
I make file init-hilink.sh with follow text

Code: Select all

usb_modeswitch -v 12d1 -p 1f01 -M '55534243123456780000000000000a11062000000000000100000000000000'
And I start it

Code: Select all

su
sh init-hilink.sh
After it, when I enter lsusb, I get vid/pid 12d1:14db And internet is working!
But after reboot I have to start script again. What can I do to start it avtomatically after every reboot (with superuser right)?

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Thu Sep 29, 2016 3:11 am

That a step forward! As I tried on C2 I saw that something in init-hilink.sh is not working as on C1. I have to check and to rewrite the script. Please be patient as I don't have so much time these days. I think there must be programmed inside the loop a probe if vid:pid 12d1:1f01 is there, and only then start the command usb_modeswitch. And there have been also errors with the command 'ndc resolver' I have to figure out. If you are able to do, maybe you can check it. Once the script is running well, it can be started as service from init.odroidc2.rc:

Code: Select all

service hilink /system/bin/init-hilink.sh                                   
    class main                                                                 
    disabled                                                                   
    oneshot

on property:dev.bootcomplete=1                                                 
    start hilink  

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Thu Sep 29, 2016 11:43 pm

I add this code to init.odroidc2.rc and Odroid not boots. I try to start scrypt noy as service and add to init.odroidc2.rc only

Code: Select all

sh ./system/bin/init-hilink.sh
Then it not boots too.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Fri Sep 30, 2016 1:43 am

How did you edit the init.odroidc2.rc? It can be that the permissions are not any more 644. If so, you need to remove the sdcard or emmc from odroid and with a linux host to set the permissions of init.odroidc2.rc again to 644. If the permissions wrong the odroid is in a bootloop.

Code: Select all

ls -l init.odroidc2.rc
-rw-r--r-- root     root        17958 1970-01-01 01:05 init.odroidc2.rc

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Fri Sep 30, 2016 2:42 am

Thank you. My mistake - not checking file right.
Odroid boots now. But the script is not working. When I run it manually - working good. Maybe, in init.odroid2.rc it will starting without properly rights?

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Fri Sep 30, 2016 4:16 am

Thats good news that it is booting again.
I saw that the commands not working well on Lollipop, it changed from Kitkat to Lollipop. Maybe to have only usb_modeswitch in the script is enough. I am trying now. But I am suffering with this terrible script language.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Fri Sep 30, 2016 5:55 am

To make the script start from init.odroidc2.rc need to change owner:

Code: Select all

chmod root:shell /path/to/init-hilink.sh
If I have time this weekend I will try more. Wasn't able to have internet when starting my modified script from init.odroidc2.rc, but if I start from shell.
This I have so far:

Code: Select all

#!/system/bin/sh
printf $$
printf "\n"
while true
do
	result=$(lsusb | grep -e "12d1:1f01")
	printf $?
	result=$(lsusb | grep -e "12d1:1f01")
	if [ "$?" -eq 0 ]; then
		/system/bin/usb_modeswitch -v 12d1 -p 1f01 -M '55534243123456780000000000000a11062000000000000100000000000000'	
		sleep 2
		/system/bin/netcfg usbnet0  dhcp
	else
		result=$(lsusb | grep -e "12d1:14dc")
		printf $?
		result=$(lsusb | grep -e "12d1:14dc")
		if [ "$?" -eq 1 ]; then
			printf "No Hilink device connected\n"
		else
			printf "\n"
		fi
	fi
	sleep 10     
done

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Fri Sep 30, 2016 10:38 pm

joerg wrote:To make the script start from init.odroidc2.rc need to change owner:

Code: Select all

chmod root:shell /path/to/init-hilink.sh
Sorry. But not working. I don't know why...

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Sat Oct 01, 2016 12:52 am

My mistake, I am sorry. To change owner must be:

Code: Select all

chown root:shell /path/to/init-hilink.sh
It was to late yesterday and I was in hurry.
Of course you need to put your real path as /system/bin, if you have saved it there.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Sat Oct 01, 2016 3:56 am

I changed the script a little and it seems that it is doing. With yesterday posted script sometimes there was no internet in chrome but I could ping http://www.google.com, sometimes there was internet. When I disconnected the modem and connected there was always no internet. Now with this little change seems that the routing table is set correct. I made several reboots and there was always internet , and I disconnected and connected the modem and there was always internet.
Try out and report please. And thanks for your great idea to put the usb_modeswitch into the script.
I let the printf there, if it is needed to debug from terminal.

init-hilink.sh

Code: Select all

#!/system/bin/sh
printf $$
printf "\n"
while true
	do
		result=$(lsusb | grep -e "12d1:1f01")
		printf $?
		result=$(lsusb | grep -e "12d1:1f01")
		if [ "$?" -eq 0 ]; then
			/system/bin/usb_modeswitch -v 12d1 -p 1f01 -M '55534243123456780000000000000a11062000000000000100000000000000'   
			sleep 2
#			/system/bin/netcfg usbnet0  dhcp
			/system/bin/dhcpcd -n usbnet0
		else
			result=$(lsusb | grep -e "12d1:14dc")
			printf $?
			result=$(lsusb | grep -e "12d1:14dc")
			if [ "$?" -eq 1 ]; then
				printf "No Hilink device connected\n"
			else
				printf "\n"
			fi
		fi
		sleep 10     
	done

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Sat Oct 01, 2016 7:45 pm

Ok.
I change the owner of file init-hilink.sh, but this script successful starting only after su command.
I change script to

Code: Select all

#!/system/bin/sh
printf $$
printf "\n"
while true
   do
      result=$(lsusb | grep -e "12d1:1f01")
      printf $?
      result=$(lsusb | grep -e "12d1:1f01")
      if [ "$?" -eq 0 ]; then
         /system/bin/usb_modeswitch -v 12d1 -p 1f01 -M '55534243123456780000000000000a11062000000000000100000000000000'   
         sleep 2
#         /system/bin/netcfg usbnet0  dhcp
         /system/bin/dhcpcd -n usbnet0
      else
         result=$(lsusb | grep -e "12d1:14db")
         printf $?
         result=$(lsusb | grep -e "12d1:14db")
         if [ "$?" -eq 1 ]; then
            printf "No Hilink device connected\n"
         else
            printf "\n"
         fi
      fi
      sleep 10     
   done
(I change vid/pid to my modems vid/pid)
And, when I try to start, I get systax error: 'if' unmached.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Sat Oct 01, 2016 8:26 pm

I tried your script, for me it's working. I think it depends of the editor you use. If you use a windows editor, there could be some hidden characters there. Try to use the editor "vi" inside the adb terminal, it's somehow from past century, but if one have learned how to use it, it works. Look here, I explained in other thread some weeks ago how to use: http://forum.odroid.com/viewtopic.php?f ... vi#p158948

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Sat Oct 01, 2016 9:11 pm

With script thats all right.
When I add to init.odroid2.d

Code: Select all

/system/bin/init-hilink.sh
after reboot script not work. I look what is in UART, and when script starts, I get "init: cannot execve('/system/bin/init-hilink.sh'): Exec format error"

But, when I try to use it manually

Code: Select all

su
init-hilink.sh
worked good.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Sun Oct 02, 2016 3:41 am

The only I can imagine is that the permission is not correct, should be like that:

Code: Select all

# ls -l /system/bin/init-hilink.sh
-rwxr-xr-x root     shell         598 2016-10-01 19:27 init-hilink.sh
I think this is a typo?: "init.odroid2.d", should be "init.odroidc2.rc".
In case it could be a typo in the script, try this, I changed already the pid to your modem:

[The extension sh has been deactivated and can no longer be displayed.]

But after saving on your C2, you would need to change the permissions again to 755 and owner to root:shell.
I hope it is working for you, because on my C2 it's working.

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Sun Oct 02, 2016 5:00 pm

Thats all right for the end!!!
The right path to to it
1. copy the patched linker file http://forum.odroid.com/viewtopic.php?f ... 65#p133065 or
linker.rar
Patched linker
(41.45 KiB) Downloaded 153 times
2. put the linker file to the right place (/system/bin)
3. dowload usb-modeswitch file
usb_modeswitch.rar
(33.87 KiB) Downloaded 151 times
and put it to /system/bin folder
4. dowload init-hilink.sh file

[The extension sh has been deactivated and can no longer be displayed.]

and put it to /system/bin folder
5. set rights and permissions for init-hilink.sh
6. edit init-hilink.sh file and put your modem's vd/pid (it is 12d1:1f01 of my Huawei e303)
7. add to the end of file init.odroid2.rc code

Code: Select all

service hilink /system/bin/init-hilink.sh                                   
    class main                                                                 
    disabled                                                                   
    oneshot

on property:dev.bootcomplete=1                                                 
    start hilink  

8. You can try to start init-hilink.sh manually to check how it works
9. reboot

All informatoin I receive from joerg. I thank him for his patience and help.
Last edited by JediMax2 on Sun Oct 02, 2016 7:10 pm, edited 8 times in total.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Sun Oct 02, 2016 6:00 pm

Thank you also for the guide! So all others who need can follow easily.

noodles783
Posts: 5
Joined: Wed Oct 12, 2016 5:31 am
languages_spoken: english, español
ODROIDs: C0 - C1+
Contact:

Re: How to use 3G modem with Android

Unread post by noodles783 » Thu Oct 20, 2016 4:28 am

Hi joerg!
I´m following your tutorial, http://forum.odroid.com/viewtopic.php?f=113&t=16489
But I´m stuck at some point.

The modem is a Huawei E1756. I added the usb_modeswitch and it´s on hilink mode.


When I try the following command I get internet connection.

Code: Select all

/system/bin/pppd /dev/ttyUSB0 460800 debug modem noauth nodetach defaultroute  noccp nobsdcomp novj  noipdefault usepeerdns user "" password "" connect "/system/bin/chat -v -s -f /system/etc/ppp/provider.chat" 
So...I don´t know what I´m missing in the tutorial.

Also added the APN Movistar chile in Settings->More->Mobile Networks->Access Point Names

Here is my log:
Logs.rar
(9.67 KiB) Downloaded 114 times
Best regards

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Thu Oct 20, 2016 5:11 pm

@noodles783
If your modem is in Hilink mode you don't need this old stuff any more (pppd). You only need to follow what JediMax2 has posted here. But if you are on C1, it may not work well this script.

Arnd
Posts: 9
Joined: Tue Oct 11, 2016 8:56 pm
languages_spoken: english, german
ODROIDs: C2
Contact:

Re: How to use 3G modem with Android

Unread post by Arnd » Fri Oct 21, 2016 4:42 pm

Hi,

i am using a Huawei 3276s-150 in Hilink mode and the how to from JediMax2 worked flawless. Many thanks.

noodles783
Posts: 5
Joined: Wed Oct 12, 2016 5:31 am
languages_spoken: english, español
ODROIDs: C0 - C1+
Contact:

Re: How to use 3G modem with Android

Unread post by noodles783 » Sat Nov 05, 2016 5:36 am

Joerg,
Thanks for your reply.

Now I´m using a Huawei E3131 and it´s working in my ODROID C1+.
The only problem is that isn´t resolving DNS. With getprop I see the [net.usbnet0.dns1]:[192.168.1.1] set.
If I connect the C1+ to a WiFi network the DNS starts working, and when disconnects from Wifi the DNS still works with the huawei modem.
Do you know what problem can it be? I tried to set manually the net.usbnet0.dns1 and net.dns1 with 8.8.8.8 but still can´t get dns working.

Thanks in advance.

Best regards

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Tue Nov 08, 2016 4:30 am

@noodles783
Please tell me if you have Kitkat or Lollipop on your C1+.

noodles783
Posts: 5
Joined: Wed Oct 12, 2016 5:31 am
languages_spoken: english, español
ODROIDs: C0 - C1+
Contact:

Re: How to use 3G modem with Android

Unread post by noodles783 » Wed Nov 09, 2016 12:43 am

Dear Joerg,
I downloaded and tried the latest version, is Android 4.4.4 (v3.3).

Best regards.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Wed Nov 09, 2016 4:41 am

Can't install V3.3 on my Odroid C1 and don't know why. Need to look into this. So please stay patient.

noodles783
Posts: 5
Joined: Wed Oct 12, 2016 5:31 am
languages_spoken: english, español
ODROIDs: C0 - C1+
Contact:

Re: How to use 3G modem with Android

Unread post by noodles783 » Wed Nov 09, 2016 8:55 pm

Thanks for your time joerg, if you want I can install another version and try it.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Wed Nov 09, 2016 10:33 pm

I was now able to install v3.3.
Try to replace this line in init-hilink.sh

Code: Select all

/system/bin/dhcpcd -n usbnet0
with this 3 lines

Code: Select all

/system/bin/dhcpcd usbnet0
/system/bin/ndc resolver setdefaultif usbnet0 
/system/bin/ndc resolver setifdns usbnet0 8.8.8.8 8.8.4.4
Note, that setting route and interface with resolver only works on Kitkat, on Lollipop is different like in the former script.

noodles783
Posts: 5
Joined: Wed Oct 12, 2016 5:31 am
languages_spoken: english, español
ODROIDs: C0 - C1+
Contact:

Re: How to use 3G modem with Android

Unread post by noodles783 » Thu Nov 10, 2016 2:29 am

Dear joerg,
It´s working! I test it manually, I will add to the init script.

Thanks for your help!

Best regards!

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Tue Nov 22, 2016 4:58 am

When I renew Odroid firmware it's stop wotking. :-(
I replace linker file (with correct rights) and add properly strings to Odroid.rc file. It is not working automatically.
When I try to start init-hilink by the hand, I get error message "only position independent executables (PIE) are supported". And some times it's start working, some times - not.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Tue Nov 22, 2016 4:35 pm

Please try the usb-modeswitch from command line. If this makes the error with PIE than th linker is not yet replaced. I will try to find another solution as using usb-modeswitch.

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Wed Nov 23, 2016 4:11 am

Thank you.
Today I install last update of Android. And copy new linker file with correct rights. I try to start usb_modeswitch from command line. And I get PIE error. But after error message, I get anoser messages (looks like usb_modeswitch works). With no result.

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Wed Nov 23, 2016 4:52 am

I can't understand. Now I power down my Odroid and power up, manually start init-hilink.sh script (then I stopped it) and check result (via lsusb). I get PIE error, but I see, modem's vid/pid changes.

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Wed Nov 23, 2016 5:07 am

And now I connect USB modem to not-OTG USB porrt. And all works good. I reboot Odroid about 3 or 4 times - it's working.

icu
Posts: 3
Joined: Mon Dec 05, 2016 10:09 pm
languages_spoken: english
ODROIDs: Odroid C1, Odroid C2
Contact:

Re: How to use 3G modem with Android

Unread post by icu » Tue May 23, 2017 5:28 am

I tried to download the "Linker.zip" but is not available now ("The selected attachment does not exist anymore."). Can you help me to find it? Thank you.

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Wed Jun 14, 2017 1:35 am

I try to use patched linker file (for Lollipop) in Android 6 - not working.
Who knows where I can get thess file for Android 6?

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Wed Jun 14, 2017 1:41 am

Here is the patch I used for Lollipop:
bionic/linker/linker.cpp

Code: Select all

  ...
  ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(si->base);
  if (elf_hdr->e_type != ET_DYN) {
    __libc_format_fd(2, "error: only position independent executables (PIE) are supported (patch: disabled).\n");
    //patch:
    //exit(EXIT_FAILURE);
  }
  ...
I would do it but i need to download whole Android source first, and this takes time...

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Thu Jun 15, 2017 4:56 pm

My knowlege is not enough to do it. I'll wait for your help.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Thu Jun 15, 2017 6:14 pm

Hello JediMax,
I started the download of Android 6.0.1, it takes time ...
It's a little disappointing for me that no one here who have already the sources can assist.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Fri Jun 16, 2017 6:53 pm

As I told, it takes time. Downloaded, but compiling ends in errors I have to search fixes...

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Fri Jun 16, 2017 7:19 pm

Thank you for your work.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Sat Jun 17, 2017 7:47 pm

Hello JediMax2,
here is the patched linker for 6.0.1:
linker_6.0.1.zip
(91.73 KiB) Downloaded 76 times
BTW. The most work has done my host computer ;)

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Sun Jun 18, 2017 7:25 pm

Thank you very much. I try to use this file and get follow
1. when I try tu start init-hilink script with user rights, I get rights error
2. when I start script as superuser, I get PIE error. But script works good (modem's vid/pid changed)
3. internet not working (network is unreachable)

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Mon Jun 19, 2017 3:40 am

Hi, I tried but I didn't found a solution yet. There has something changed in Android 6.0.1.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Wed Jun 21, 2017 4:00 am

Hello JediMax2,
I searched so much for a solution, but learned that on Marshmallow the number of interfaces are limited. So it can't be done the dns settings in the former matter. It would be possible to ping a webpage from command line, but in Android system the internet connection is not there.
And here is a solution I found now. This is by replacing the framework-res.apk in that I changed the value config_ethernet_iface_regex from eth to usbnet. With this solution it would not be possible to use the eth inteface, meens cable ethernet. But I think for using in the car it is O.K. because we want to have mobile internet connection.

1. In the init-hilink.sh must be commented the line /system/bin/dhcpcd -n usbnet0

2. In init.odroidc2.rc must be:

Code: Select all

service hilink /system/bin/init-hilink.sh                                       
    class main                                                                  
    disabled                                                                    
    oneshot                                                                     
                                                                                
on boot                                                                         
    start hilink 
Note that it is not anymore on property:dev.bootcomplete=1 because the interface should be there when Android starts.

3. Download the framework-res.apk from here:https://www.dropbox.com/s/xlgr8ly9nhvv3 ... k.zip?dl=0
and copy with adb to /system/framework/

4. Reboot, best with modem connected as it would be also in the car.

I havn't tried it in the car yet. But I tried if modem is disconnected and connected again, the connection reestablish again.

Addon:
Here is a version of usb_modeswitch I compiled with PIE support, not needed the patched linker anymore.
usb_modeswitch.zip
(63.44 KiB) Downloaded 73 times
Question to Hardkernel team:
Would it be possible to make this configurable in Settings? To use ether eth or usbnet.

JediMax2
Posts: 53
Joined: Sat Sep 10, 2016 3:37 am
languages_spoken: english, russian
ODROIDs: c2
Contact:

Re: How to use 3G modem with Android

Unread post by JediMax2 » Wed Jun 21, 2017 4:29 am

Ok, joerg! Thank you for your work.
Now I'am not in home and I can't check this solution right now.

legsim
Posts: 13
Joined: Sun Aug 13, 2017 7:34 am
languages_spoken: english, french
Contact:

Re: How to use 3G modem with Android

Unread post by legsim » Wed Mar 14, 2018 6:44 am

Hi Joerg,

Thanks for all your work!

I'm trying to make a Huawei E3372h work and I'm starting with the HiLink mode (12d1:14dc).
After switching it, it does appear as a cdc_ethernet USB device, thus creating a usbnet0 interface.

I have the exact same problem, the interface is not tracked by the Android Framework.
Is the framework-res.apk still the only solution?

Thanks!
Last edited by legsim on Fri Mar 16, 2018 4:46 am, edited 1 time in total.

joerg
Posts: 819
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Contact:

Re: How to use 3G modem with Android

Unread post by joerg » Fri Mar 16, 2018 12:09 am

Hi legsim,
I found another solution, but it also need to compile Android. Better, because it reads a system property.
Here is a diff #repo diff frameworks/opt/net/ethernet/:

Code: Select all

project frameworks/opt/net/ethernet/
diff --git a/java/com/android/server/ethernet/EthernetNetworkFactory.java b/java/com/android/server/ethernet/EthernetNetworkFactory.java
index 6074dda..058fa80 100644
--- a/java/com/android/server/ethernet/EthernetNetworkFactory.java
+++ b/java/com/android/server/ethernet/EthernetNetworkFactory.java
@@ -49,6 +49,7 @@ import com.android.server.net.BaseNetworkObserver;
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
 
+import android.os.SystemProperties;
 
 /**
  * Manages connectivity for an Ethernet interface.
@@ -194,12 +195,16 @@ class EthernetNetworkFactory {
     private boolean maybeTrackInterface(String iface) {
         // If we don't already have an interface, and if this interface matches
         // our regex, start tracking it.
-        if (!iface.matches(mIfaceMatch) || isTrackingInterface())
-            return false;
-
-        Log.d(TAG, "Started tracking interface " + iface);
-        setInterfaceUp(iface);
-        return true;
+        if (isTrackingInterface()) return false;
+        String[] mInterfaces = mIfaceMatch.split(" ");
+        for (String mIface: mInterfaces) {           
+            if (iface.matches(mIface)) {
+                Log.d(TAG, "Started tracking interface " + iface);
+                setInterfaceUp(iface);
+                return true;
+            }
+        }
+        return false;
     }
 
     private void stopTrackingInterface(String iface) {
@@ -355,9 +360,8 @@ class EthernetNetworkFactory {
         mNMService = INetworkManagementService.Stub.asInterface(b);
         mEthernetManager = (EthernetManager) context.getSystemService(Context.ETHERNET_SERVICE);
 
-        // Interface match regex.
-        mIfaceMatch = context.getResources().getString(
-                com.android.internal.R.string.config_ethernet_iface_regex);
+        mIfaceMatch = SystemProperties.get("net.eth.iface", "eth0");
+        Log.i(TAG, "mIfaceMatch = " + mIfaceMatch);
 
         // Create and register our NetworkFactory.
         mFactory = new LocalNetworkFactory(NETWORK_TYPE, context, target.getLooper());
After install need to add a system property setprop net.eth.iface usbnet0, if no property set, it stays with eth0.
Sorry, no easier solution found due to the limitations of Android M.

legsim
Posts: 13
Joined: Sun Aug 13, 2017 7:34 am
languages_spoken: english, french
Contact:

Re: How to use 3G modem with Android

Unread post by legsim » Sun Mar 18, 2018 8:12 pm

Hi Joerg,

I edited my framework-res.apk to replace the regex and that works fine for now!
But I'll need to swap back this APK every time I want to use the ethernet port, so your solution seems better. I'll try it once I get my build environment ready.

For anyone wondering about the framework-res.apk modification, I decompiled it with APKtool, edited the value and recompiled it to a new APK.
Then I extracted the newly generated resources.arsc into the original APK to keep the META-INF folder containing the signature.

So yeah, it could be great if your modification could be integrated into Hardkernel builds ! :)

Post Reply

Return to “Android”

Who is online

Users browsing this forum: No registered users and 2 guests