Lazarus

Programming => Operating Systems => Android => Topic started by: turronet on August 20, 2017, 11:37:07 am

Title: [Solved] LAMW: how to add mips target?
Post by: turronet on August 20, 2017, 11:37:07 am
It is possible to add the mipsel target to the ide?

Thanks
Title: Re: LAMW: how to add mips target?
Post by: jmpessoa on August 22, 2017, 11:20:56 pm

Hello Turronet!

I will try to add support to "mipsel"...

Thank you!
Title: Re: LAMW: how to add mips target?
Post by: jmpessoa on September 24, 2017, 11:02:23 pm
Hi, Turronet!

Have you  a cross-compile system  for "mipsel-android" ???
[my Laz4android (out-of-box) do not support mipsel, so I dont got a good test/debug...]
Title: Re: LAMW: how to add mips target?
Post by: jmpessoa on September 26, 2017, 01:50:32 am

Done! 

mipsel chip support added to LAMW!

Thank you!
Title: Re: LAMW: how to add mips target?
Post by: majid.ebru on September 26, 2017, 05:48:05 am
Hi

waht is mipsel?

thank you
Title: Re: LAMW: how to add mips target?
Post by: jmpessoa on September 26, 2017, 05:59:56 am
A chip architecture.... ex: x86  ... arm ... mipsel

Yes, some phone/device are  "mips" ... not "arm" or "x86"
Title: Re: LAMW: how to add mips target?
Post by: turronet on September 26, 2017, 07:49:36 am
Hi all,

Many thanks jmpessoa!

A device that use mips cpu running android 5.1 is the huami amazfit pace, it' s a sportwatch.

Ciao
Title: Re: LAMW: how to add mips target?
Post by: DonAlfredo on September 26, 2017, 05:00:26 pm
Sidenote:
I have added mipsel-android crosscompiler for Windows x86 and Linux x64 into the latest version of fpcupdeluxe.
 :)
Title: Re: LAMW: how to add mips target?
Post by: turronet on September 28, 2017, 01:04:52 pm
Hi All,

Now I'm able to create an hello world apk with mipsel

Unfortunately I get force close in the mips avd emulator and wrong abis while sending apk to smartwatch.

Apk created with arm target runs well on phone and tablet so the lamw is more or less tuned.

Next step will be trying fpc 3.1.1 instead of 3.0.4.

Hopefully it's only a matter of ndk,sdk and fpc versions

Let's see
Title: Re: LAMW: how to add mips target?
Post by: turronet on September 30, 2017, 11:16:00 am
A little update:

...lib/mipsel/libcontrol.so has to be lib/mips/libcontrol.so....
After that modification in the target setting within lazarus I'm able to run the apk in the avd and installing apk in the smartwatch.
"Unfortunately bla.apk has stopped" is what I get in the device ( no issues in the avd)

The battle continue...
Title: Re: LAMW: how to add mips target?
Post by: jmpessoa on October 01, 2017, 12:01:14 am

Quote
...lib/mipsel/libcontrol.so has to be lib/mips/libcontrol.so....

Fixed!

Thank you!
Title: Re: LAMW: how to add mips target?
Post by: turronet on October 01, 2017, 05:20:52 pm
Hello Jmpessoa,

I tried but it asked me to create mipsel folder, this means that target name (-o option) wasn't updated.

I kindly ask You an help, I'm not so good in android and java (otherwise I would use android studio..) and I like lazarus, so I would like to understand why I'm not able to create apk for my target device.

Always talking about an hello world app these are the results achieved:
If I create an apk for arm, everything is fine on both emu and devices (moto g5+, kindle fire 8, etc...) so great job , really well done!
If I create a console app (not JNI) for mips(el) everything is fine on both emu and device (huami amazfit pace) which runs 5.1.1 sdk 22.
If I create a GUI (JNI) apk for mips(el) it's running well on mips emulator, but I get "unfortunately x.apk has stopped" on the device
If I create a Console (JNI) apk for mips(el) it's running well on mips emulator, but I get "unfortunately x.apk has stopped" on the device

I attached the logcat
I'm not expert but it seems the failure is due to lib loading and function addresses... how about this?
I read some issues on PIC libraries and fpc+android, but no way to get libcontrol.so built with -Cg- flags.

Could You kindly send me a mips apk so I can check if it behaves the same?

many thanks for Your help

Valerio
Title: Re: LAMW: how to add mips target?
Post by: jmpessoa on October 01, 2017, 09:12:38 pm
Quote
this means that target name (-o option) wasn't updated.
Sorry.... fixed!

From log:
Quote
F/art     ( 5232): art/runtime/runtime.cc:289] java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.hide()' on a null object reference
F/art     ( 5232): art/runtime/runtime.cc:289]   at void org.lamw.lamwguiproject18.jForm.HideActionBar() (Controls.java:625)
If you have some "HideActionBar()"  in your pascal code,  try to comment it....
Title: Re: LAMW: how to add mips target?
Post by: turronet on October 02, 2017, 12:17:11 am
Thanks for the fix, now it is fine.
Have You changed something else recently?
"[Lamw] Build and run apk" now opens a terminal which closes almost immediatley so I can't see what's happen, it says all green all the times in the message windows but actually if it fails for some reason You don't know.
Manually launching the scripts build-debug and install work perfectly (at least I know the reason of failure)

Coming back to "my problem" I found a way to avoid actionbar but unfortunately it fails just after...

Code: Pascal  [Select][+][-]
  1. W/linker  ( 9999): libcontrols.so: unused DT entry: type 0x6ffffffe arg 0xf48
  2. W/linker  ( 9999): libcontrols.so: unused DT entry: type 0x6fffffff arg 0x2
  3. W/linker  ( 9999): libcontrols.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
  4. W/art     ( 9999): Can't call EnsureArtActionInFrontOfSignalChain due to unitialized fault manager
  5. F/art     ( 9999): art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI GetObjectClass called with pending exception 'java.lang.NullPointerException' thrown in unknown throw location
  6. F/art     ( 9999): art/runtime/check_jni.cc:65]     in call to GetObjectClass
  7. F/art     ( 9999): art/runtime/check_jni.cc:65]     from void org.lamw.lamwguiproject2.Controls.pAppOnCreate(android.content.Context, android.widget.RelativeLayout, android.content.Intent)
  8. F/art     ( 9999): art/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable
  9. F/art     ( 9999): art/runtime/check_jni.cc:65]   | group="main" sCount=0 dsCount=0 obj=0x35da4000 self=0x74427800
  10. F/art     ( 9999): art/runtime/check_jni.cc:65]   | sysTid=9999 nice=0 cgrp=default sched=0/0 handle=0x77f28460
  11. F/art     ( 9999): art/runtime/check_jni.cc:65]   | state=R schedstat=( 96463376 109199391 87 ) utm=8 stm=1 core=0 HZ=100
  12.  

I'm comparing androidmanifest.xml and styles.xml from a working apk, it looks like the AppCompat them should be used, of course at the moment it doesn't build the apk

the battle go forward....
Title: Re: LAMW: how to add mips target?
Post by: jmpessoa on October 02, 2017, 02:57:19 am

We do not have "AppCompat" [and others 'support" library]   in LAMW....  so, it will fail!!!

Stay with LAMW default style e try change minSDK and tarqetSDK in manifest....
Title: Re: LAMW: how to add mips target?
Post by: turronet on October 04, 2017, 10:59:41 pm
Hi Jmpessoa,

I found a way to get the Nogui JNI app working, simply in the new project template You left getSum and getString method unimplemented, so I got it work.
I discovered this by analyzing the demos.
so the toolchain is definitely correct, but still failiing when using GUI.
I tried to open and build a demos gui, but I'm getting invalid apk.

so .... go forward....

Title: Re: LAMW: how to add mips target?
Post by: jmpessoa on October 04, 2017, 11:13:20 pm
Quote
I tried to open and build a demos gui, but I'm getting invalid apk.

No!

Please, try first a simple "hello world" .... [like a form and a button ...]

Thank you!
Title: Re: LAMW: how to add mips target?
Post by: turronet on October 05, 2017, 01:10:06 am
I hope there were some unimplemented method even in GUI template....it wasn't.
Anyway got demo GUI compiled but still fc.

Do You know how to debug these apk made by fpc?
Title: Re: LAMW: how to add mips target?
Post by: jmpessoa on October 05, 2017, 01:48:55 am

In Attachment,  there is my first and incomplete mips project...
but there is a "libcontrols.so"  by my experimental  mips cross-compile.

Can you complete [build apk] and test/run it ?

Thank you!

[EDITED]

apk [download] link:

https://od.lk/d/Ml8xNDczMDExMTRf/LamwGUIProjectMips1-debug.apk
Title: Re: LAMW: how to add mips target?
Post by: turronet on October 05, 2017, 12:10:48 pm
Many Thanks Jose!

still crash  :'(

did You use win fpc 3.0?

Code: Pascal  [Select][+][-]
  1. I/ActivityManager(  386): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=org.lamw.lamwguiprojectmips1/.App} from uid 1000 on display 0
  2. V/WindowManager(  386): addAppToken: AppWindowToken{13a74407 token=Token{33f6ea46 ActivityRecord{6865621 u0 org.lamw.lamwguiprojectmips1/.App t1179}}} to stack=1 task=1179 at 0
  3. I/HmHomeView(  504): onPause
  4. I/art     (15351): Late-enabling -Xcheck:jni
  5. I/ActivityManager(  386): Start proc 15351:org.lamw.lamwguiprojectmips1/u0a117 for activity org.lamw.lamwguiprojectmips1/.App
  6. I/HmLauncher-Test(  504): Set prop under watch face page. 0
  7. I/art     (  504): Background partial concurrent mark sweep GC freed 8218(438KB) AllocSpace objects, 36(2MB) LOS objects, 9% free, 19MB/21MB, paused 42.112ms total 496.466ms
  8. W/linker  (15351): libcontrols.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
  9. W/art     (15351): Can't call EnsureArtActionInFrontOfSignalChain due to unitialized fault manager
  10. F/libc    (15351): Fatal signal 10 (SIGBUS), code 128, fault addr 0x0 in tid 15351 (guiprojectmips1)
  11. I/DEBUG   (   91): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  12. I/DEBUG   (   91): Build fingerprint: 'Huami/huanghe/watch:5.1/PACEfied/28:user/release-keys'
  13. I/DEBUG   (   91): Revision: '00000001'
  14. I/DEBUG   (   91): ABI: 'mips'
  15. I/DEBUG   (   91): pid: 15351, tid: 15351, name: guiprojectmips1  >>> org.lamw.lamwguiprojectmips1 <<<
  16. I/DEBUG   (   91): signal 10 (SIGBUS), code 128 (SI_KERNEL), fault addr 0x0
  17. I/DEBUG   (   91):  zr 00000000  at 00000001  v0 00000006  v1 7fecd048
  18. I/DEBUG   (   91):  a0 73c78ac0  a1 7fecd03c  a2 7fecd040  a3 7fecd044
  19. I/DEBUG   (   91):  t0 00000000  t1 00000101  t2 00000001  t3 00000000
  20. I/DEBUG   (   91):  t4 00000000  t5 00000000  t6 00000000  t7 00430000
  21. I/DEBUG   (   91):  s0 0000005b  s1 73c27800  s2 7fecd424  s3 00000004
  22. I/DEBUG   (   91):  s4 30ef53d8  s5 7fecd3c0  s6 7fecd3b0  s7 7fecd424
  23. I/DEBUG   (   91):  t8 73bfd5e8  t9 56aaf665  k0 00000001  k1 00000000
  24. I/DEBUG   (   91):  gp 56aff5d0  sp 7feccf98  s8 7fecd010  ra 56a65664
  25. I/DEBUG   (   91):  hi 00000000  lo 00000e20 bva 56aaf665 epc 56aaf665
  26. I/DEBUG   (   91):
  27. I/DEBUG   (   91): backtrace:
  28. I/DEBUG   (   91):     #00 pc 0006b665  /data/app/org.lamw.lamwguiprojectmips1-1/lib/mips/libcontrols.so
  29. I/DEBUG   (   91):
  30. I/DEBUG   (   91): Tombstone written to: /data/tombstones/tombstone_02
  31. I/BootReceiver(  386): Copying /data/tombstones/tombstone_02 to DropBox (SYSTEM_TOMBSTONE)
  32. W/ActivityManager(  386):   Force finishing activity 1 org.lamw.lamwguiprojectmips1/.App
  33. I/Zygote  (  113): Process 15351 exited due to signal (10)
  34. W/InputMethodManagerService(  386): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@1cd1335d attribute=null, token = android.os.BinderProxy@3c72c47e
  35. W/ActivityManager(  386): Exception thrown during pause
  36. W/ActivityManager(  386): android.os.DeadObjectException
  37. W/ActivityManager(  386):       at android.os.BinderProxy.transactNative(Native Method)
  38. W/ActivityManager(  386):       at android.os.BinderProxy.transact(Binder.java:496)
  39. W/ActivityManager(  386):       at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:706)
  40. W/ActivityManager(  386):       at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:833)
  41. W/ActivityManager(  386):       at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:2738)
  42. W/ActivityManager(  386):       at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:2595)
  43. W/ActivityManager(  386):       at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:2497)
  44. W/ActivityManager(  386):       at com.android.server.am.ActivityManagerService.handleAppCrashLocked(ActivityManagerService.java:11504)
  45. W/ActivityManager(  386):       at com.android.server.am.ActivityManagerService.makeAppCrashingLocked(ActivityManagerService.java:11401)
  46. W/ActivityManager(  386):       at com.android.server.am.ActivityManagerService.crashApplication(ActivityManagerService.java:12085)
  47. W/ActivityManager(  386):       at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:11596)
  48. W/ActivityManager(  386):       at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)
  49. E/lowmemorykiller(   83): Error opening /proc/15351/oom_score_adj; errno=2
  50. D/PowerkeyUtils(  504): clearDisablePowerKey
  51. I/Hmclc   (  504): onResume
  52. D/CompassWidgetManager(  504): on resume
  53. I/springboard(  504): plugin [com.huami.watch.compass.CompassWidgetView] onResume
  54. I/StepLauncherView(  504): onResume
  55. D/HmLauncher-Test(  504): onResume
  56. I/ActivityManager(  386): Process org.lamw.lamwguiprojectmips1 (pid 15351) has died
  57.  

I found by enabling debugging symbol that jform.show2 crashes, there is something bad when accessing to graphics as native console and console + libcontrol.so work.

Start thinking the framwork of the smartwatch have a reduced set so not everything implemented or highly customized
Title: Re: LAMW: how to add mips target?
Post by: turronet on October 06, 2017, 10:01:48 pm
From log:
Quote
F/art     ( 5232): art/runtime/runtime.cc:289] java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.hide()' on a null object reference
F/art     ( 5232): art/runtime/runtime.cc:289]   at void org.lamw.lamwguiproject18.jForm.HideActionBar() (Controls.java:625)
If you have some "HideActionBar()"  in your pascal code,  try to comment it....
[/quote]

MANY THANKS!!!! now it works!!!!!

by commenting the content of GetActionBarHeight() method in controls.java I got it working on mipsel smartwatch!
Title: Re: [Solved] LAMW: how to add mips target?
Post by: jmpessoa on October 06, 2017, 10:24:36 pm
\o/  \o/ \o/ \o/ \o/

Congratulations!!!!

Thank you!

[EDITED 1]

Can you comment [only to test...] this code in "AndroidWidget.pas"   [line number 2754 in jForm "init" method ..]
Code: [Select]
// ActionBarHeight:= jForm_GetActionBarHeight(FjEnv, FjObject);  //comment here ...
not in " controls.java"  ?

[EDITED 2] Fixed!!!
Title: Re: [Solved] LAMW: how to add mips target?
Post by: turronet on October 16, 2017, 11:04:54 pm
Hi Jose,

tested Today on both win32 and ubuntu, GREAT!!! everything works fine to me.
Even the cross fpc builder works as expected

Many thanks for Your amazing work!
TinyPortal © 2005-2018