SER2NET, Building .C native project for Android

617 views
Skip to first unread message

T0N1

unread,
Aug 8, 2011, 7:13:25 PM8/8/11
to android-porting
Hello you guys,

First post =)

I'm trying to build ser2net project (ser2net.sourceforge.net) to
use in my Android Tablet.
The tablets are: a M009s from EKEN, and another MID from some
chinese manufacturer, the both with 7" LCD, 256MB, WM8650 too. I
opened it and the electronic is the same. Both are rooted. Android
distro 2.2 (froyo) with kernel 2.6.32.9-default .

What I did:
1. tried to compile with CodeSourcery and it resulted a file that
didn't run. When I tried to run on tablet it says: ser2net not found.
I checked the ELF and mainly I noticed that the EABI version is 5.
Different from others files on tablet like ls, wget, etc... that were
EABI version 4.
2. tried to compile with NDK and it resulted a executable file!!!
It ran ok and has a EABI version 4. But when I try to connect with
telnet on it, it didn't work, and close the process. :S

Do you have some tip to compile .c projects on Android? Some
stepping rocks?

Thank you for your time to read this post.

Bye,
Toni

Chris Stratton

unread,
Aug 8, 2011, 8:50:06 PM8/8/11
to android...@googlegroups.com
On Monday, August 8, 2011 7:13:25 PM UTC-4, T0N1 wrote:
    1. tried to compile with CodeSourcery and

Don't do that. It's rarely the right answer.
 
    2. tried to compile with NDK and it resulted a executable file!!!
It ran ok and has a EABI version 4. But when I try to connect with
telnet on it, it didn't work, and close the process. :S

Now that you have code that executes, you need to figure out why it fails.  Some choices:

1) load up with debug printf's to see what it is trying to do
2) strace it
3) learn to use gdbserver and gdb

I assume you are running this code from the adb command line.  If not, you will need to be launching anything that wants to use network sockets out of an apk that has Internet permission.  And unless you get the program launched as root, you won't be able to bind to privileged ports.

Antonio Spadim

unread,
Aug 8, 2011, 11:46:50 PM8/8/11
to cs0...@gmail.com, android...@googlegroups.com
Hello Chris, thank you very much to answer!

2011/8/8 Chris Stratton <cs0...@gmail.com>
On Monday, August 8, 2011 7:13:25 PM UTC-4, T0N1 wrote:
    1. tried to compile with CodeSourcery and 
Don't do that. It's rarely the right answer.
 
OK. I saw that is very difficult to figure out the right toolchain for my tablet. Even to create it.
 
    2. tried to compile with NDK and it resulted a executable file!!!
It ran ok and has a EABI version 4. But when I try to connect with
telnet on it, it didn't work, and close the process. :S 
Now that you have code that executes, you need to figure out why it fails.  Some choices:
 
The compiled code is avaiable here (http://www.antonio.spadim.com.br/arm/android/ser2net/build.20110809-01/) with the source and .mk that I used.

I saw that when I use telnet protocol to watch simple device like barcode serial and RfID card readers (this is what I have here) it works fine. But when I try to use a USB/1-wire (Dallas converter, to read temperature - see more on www.owfs.org) it work for a little and stop ( =cancel the execution process, and close. I saw this with ps. The process disappears.). The same USB/1-wire adapter + ser2net running in my test x86 pc works great, with no faults or errors, and indefinitely (>4days). I compiled this program to a mini2440  (http://www.friendlyarm.net/products/mini2440?lang=en) with the manufacturer toolchain and worked too, same way as x86 pc. 

So, I presume that the problem is not the code, because it's robust and I'd already tested it in many different archs and devices. It looks like the compiler didn't link something or miss some lib.
 
1) load up with debug printf's to see what it is trying to do

OK
 
2) strace it

I never used this, but I'll try.
 
3) learn to use gdbserver and gdb

OK too.
 
I assume you are running this code from the adb command line.  If not, you will need to be launching anything that wants to use network sockets out of an apk that has Internet permission.  And unless you get the program launched as root, you won't be able to bind to privileged ports.

To deploy the binary to my tablet as I told before I'm using: 
   $scp ser2net root@MYTABLETIP:/etc/ser2net

After that I connect to my tablet as root, normally, ssh root@MYTABLETIP and type:
   #cd /etc  [Go to right directory]
   #chmod 777 ser2net  [Give some grant access]
   #chmod 777 ser2net.conf
   #ser2net  [run the app]

I'm not using any adb command or trick, and as you can see, my tablet is rooted too. I just use ssh and scp. Any tip?

Do you have some stepping rocks or guide to compile it right way?

Thanks again!
Toni

 -- 

unsubscribe: android-porti...@googlegroups.com
website: http://groups.google.com/group/android-porting

T0N1

unread,
Aug 9, 2011, 7:11:49 PM8/9/11
to android-porting
Hello you again,


Reporting my actual status:
1. strace didn't work in my tablet. I tried to build, but it didn't
work too.
I'll try other options. Does anyone have some tip?

My last try was read $NDK/docs/STANDALONE-TOOLCHAIN.html and do the
steps to create my toolchain in froyo. I tried to build with it but no
success to run on tablet. It built an EABI4 file (ok) but when I ran,
I got the same error. After try to connect via telnet it stop the
execution of the ser2net on tablet. :(

Bye
Toni

On Aug 9, 12:46 am, Antonio Spadim <antonio.spa...@gmail.com> wrote:
> Hello Chris, thank you very much to answer!
>
> 2011/8/8 Chris Stratton <cs07...@gmail.com>
>
> > On Monday, August 8, 2011 7:13:25 PM UTC-4, T0N1 wrote:
>
> >>     1. tried to compile with CodeSourcery and
>
> > Don't do that. It's rarely the right answer.
>
> OK. I saw that is very difficult to figure out the right toolchain for my
> tablet. Even to create it.
>
> >     2. tried to compile with NDK and it resulted a executable file!!!
> >> It ran ok and has a EABI version 4. But when I try to connect with
> >> telnet on it, it didn't work, and close the process. :S
>
> > Now that you have code that executes, you need to figure out why it fails.
> > Some choices:
>
> The compiled code is avaiable here (http://www.antonio.spadim.com.br/arm/android/ser2net/build.20110809-01/)
> with the source and .mk that I used.
>
> I saw that when I use telnet protocol to watch simple device like barcode
> serial and RfID card readers (this is what I have here) it works fine. But
> when I try to use a USB/1-wire (Dallas converter, to read temperature - see
> more onwww.owfs.org) it work for a little and stop ( =cancel the execution
> process, and close. I saw this with *ps.* The process disappears.). The same
Reply all
Reply to author
Forward
0 new messages