Author Topic: MagicCode : ARM --> MIPS .apk converter  (Read 6825 times)

forphucksakes (OP)

  • *
  • Posts: 71
MagicCode : ARM --> MIPS .apk converter
« on: December 11, 2014, 10:53:22 am »
Does this imply that if android was installed on the GCW0(ala novo 7), that we could be running native ARM apks on it? Maybe run Mupen64 on it? Or watch movies ?

http://forum.xda-developers.com/showthread.php?t=1411879
http://www.techknow.me/forum/index.php?topic=1243.0

Q :What is MagicCode?
A: MagicCode is a software designed by "c0demag1c dev team"to make it possible to run a arm based nativec apk on a mips device.It change the .so in the apk to the mips mode directllllly so that users can run a arm-apk easily. Up to now,we have tried to run a lot of apps and both of them is working well now.


Does anybody know anything about this ?
« Last Edit: December 11, 2014, 11:10:39 am by forphucksakes »
forphucksakes

Nebuleon

  • Guest
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #1 on: December 11, 2014, 11:13:33 am »
Your original message had this content (paraphrased) before you edited it out: "This would be a stopgap for emulators like PSX/N64". This reply assumes that your intent in asking this question was for those emulators.

In reply #3 of the XDA-Developers thread: http://forum.xda-developers.com/showpost.php?p=20706663&postcount=3

Someone has said that MAME4Droid started working but was "way slow". I have my doubts. If anything, this is an ARM interpreter or static recompiler, just to get the ARM part (ARM native shared libraries) of an ARM-Java Android .apk to work at all on MIPS.

Emulators like PSX/N64 use dynamic recompilation, which means they emit ARM code. That code will either not get converted because it wasn't verbatim in the .apk file, or will get interpreted at runtime to execute the ARM code as MIPS, leading to a 25x slowdown.

But I may be wrong. Try it and see what's up.

A second edit added the text "Or watch movies?"

Playing movies relies heavily on the hardware acceleration of video decoding. I'll let you try to figure out why a movie player optimised for a Nexus wouldn't work on something that isn't a Nexus, without trying to emulate the hardware acceleration in software and ultimately slowing it down even harder.
« Last Edit: December 11, 2014, 11:17:24 am by Nebuleon »

forphucksakes (OP)

  • *
  • Posts: 71
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #2 on: December 11, 2014, 11:30:00 am »
Yes I edited it to add the libretro's ffmpeg ability to emphasize not just emulation(since thats probably less than 1% of the .apks out there.) but either way yes the intent was to see if it was possible to (haphazardly) run android ARM apks on the GCW0.

I would guess because the GCW0 doesnt have the GPU drivers?

forphucksakes

pcercuei

  • ***
  • Posts: 1429
    • My devblog
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #3 on: December 11, 2014, 11:36:51 am »
I would guess because the GCW0 doesnt have the GPU drivers?
I don't know what you are talking about. The GCW0 has a GPU driver.

forphucksakes (OP)

  • *
  • Posts: 71
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #4 on: December 11, 2014, 11:45:34 am »
Quote
I don't know what you are talking about. The GCW0 has a GPU driver.
The driver's crap?
forphucksakes

pcercuei

  • ***
  • Posts: 1429
    • My devblog
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #5 on: December 11, 2014, 12:04:30 pm »
No the driver is pretty good. Way better than the binary blob from Vivante.

forphucksakes (OP)

  • *
  • Posts: 71
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #6 on: December 11, 2014, 12:11:45 pm »
the apks werent built to use the GCW0 drivers?

Quote
Emulators like PSX/N64 use dynamic recompilation, which means they emit ARM code. That code will either not get converted because it wasn't verbatim in the .apk file, or will get interpreted at runtime to execute the ARM code as MIPS, leading to a 25x slowdown.

That would still be faster than the current GCW N64 emulator?

Can a dynamic recompiler be developed from an interpreter/ static recompiler?


Was going through the responses and found this response:

Quote
Great work! Many ARM apps now work on Novo 7 basic.

It seems that MagicCode is doing dynamic translation, when the setting is "off", the installed apps won't run; set it back to "on", then those apps work again

Is dynamic translation the same as dynamic recompiling?
« Last Edit: December 11, 2014, 01:52:10 pm by forphucksakes »
forphucksakes

Nebuleon

  • Guest
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #7 on: December 11, 2014, 08:13:53 pm »
(There is no such thing as a "current GCW N64 emulator"; none has been released.)

Making a proper dynamic compiler (or JIT compiler, or recompiler, or dynarec, or dynamic translator) takes at least a year of research and work, and you can't just run the interpreter on the GCW like you can on PC, because PCs are massively overpowered and can handle 2400% overhead just fine.

The ARM dynamic recompiler in Mupen64plus emits code at runtime, issues jumps to it, rewrites some parts of the code after 1 or 2 executions and writes completely new code to the same locations later... all with ARM code. Can MagicCode can detect code generation, code rewriting and location reuse, and issue MIPS jumps to the locations of the MIPS code it wrote for the ARM code at the other end of ARM jumps?

forphucksakes (OP)

  • *
  • Posts: 71
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #8 on: December 12, 2014, 03:15:04 am »
Quote
(There is no such thing as a "current GCW N64 emulator"; none has been released.)
Which would make the android based emulator , assuming it works with MagicCode, (at least) 25x times faster the the present offering of no emulation

Quote
Can MagicCode can detect code generation, code rewriting and location reuse, and issue MIPS jumps to the locations of the MIPS code it wrote for the ARM code at the other end of ARM jumps?
Does it need to?
« Last Edit: December 12, 2014, 04:33:33 am by forphucksakes »
forphucksakes

Nebuleon

  • Guest
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #9 on: December 12, 2014, 06:40:15 pm »
Yes, it does need to...

forphucksakes (OP)

  • *
  • Posts: 71
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #10 on: December 14, 2014, 07:13:51 am »
Yes, it does need to...

Found this interesting press release by MIPS technologies entitled "MIPS Technologies Corporate Updates and MIPS Android": http://www.android-group.jp/conference/ictera-abc/files/2012/10/ICTERAABC2012MIPSfinal.pdf

On page 29 :
Quote
Binary translation via ?Magic Code? available via xda-developers to dynamically translate to MIPS native code
 -Successfully runs a majority of native ARM Android applications

and again on page 35 :
Quote
Delivering ARM to MIPS binary translator (MagicCode) to customers (available on developer.mips.com)
- Customers successfully integrated and is able to hit 70% ARMv5 translation to MIPS success

Well, on the basis that it has a working reputation(in the android realm) one can only deduce that it does indeed meet those requirements. Is it possible to install Android on the GCW0?



« Last Edit: December 14, 2014, 07:38:39 am by forphucksakes »
forphucksakes

Gab1975

  • ***
  • Posts: 1165
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #11 on: December 14, 2014, 08:02:13 am »
Well, on the basis that it has a working reputation(in the android realm) one can only deduce that it does indeed meet those requirements. Is it possible to install Android on the GCW0?

I have serious doubts about it... moreover the screen resolution and the "non touch screen" display would make Android rather unusable!
In any case the heart of GCW Zero is the full open source operating system (OpenDingux), with a "standard" OS this device would not make a big sense! ;)

forphucksakes (OP)

  • *
  • Posts: 71
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #12 on: December 14, 2014, 08:31:09 am »
Quote
I have serious doubts about it... moreover the screen resolution and the "non touch screen" display would make Android rather unusable!
In any case the heart of GCW Zero is the full open source operating system (OpenDingux), with a "standard" OS this device would not make a big sense! ;)

I think it would be interesting to see it run on the GCW0; a dual boot system for that matter! There are many handhelds out there that run on android so I dont think that the lack of a touchscreen would really be that big of a handicap. Throw into the mix the ginormous app base and I think this is something worth looking into. That and the fact that it would be a showcase on how versatile/open the GCW0 really is!
« Last Edit: December 14, 2014, 08:39:21 am by forphucksakes »
forphucksakes

lemmywinks

  • ****
  • Posts: 2774
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #13 on: December 14, 2014, 09:17:11 am »
It would probably involve a lot of work for no returns so isn't likely. The Zero is underspecced, the resolution is too small and there is no touchscreen so Android apps would be a PITA to use if they even ran properly (which is extremely unlikely). All the Android consoles have touchscreens and this is the primary method of input for menus etc.

There was an N64 emulator ported to Dingux btw, like Reicast it was incredibly low in terms of performance and compatibility though:
http://boards.dingoonity.org/dingux-development/nincest-64-for-dingux/

The Zero is best suited to the OS and software writted for it (retro emulatin and homebrew), trying to force something else onto is designed for more powerful and versatile hardware would not be a pleasant experience.
Handhelds:
GPD Win, GPD XD 64gb, Pap KIII-Plus, RS-97, RS-90, New Bittboy, 3DS XL, DSi XL, GBA SP, GBBC Clone, Gameboy Pocket, PSP Go,
PC:
HP Envy M6, Acer 522, Dell Mini 9
Psion 5 & 5MX
Tons of other old laptops and tablets.....

Nebuleon

  • Guest
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #14 on: December 14, 2014, 09:29:39 am »
Yes, it does need to...

Found this interesting press release by MIPS technologies entitled "MIPS Technologies Corporate Updates and MIPS Android": http://www.android-group.jp/conference/ictera-abc/files/2012/10/ICTERAABC2012MIPSfinal.pdf

[pages 29 and 35]

Well then, if it needs to do that, and it does, then that MagicCode thing should be good. However, ARMv5 was kind of old, wasn't it?

If the success rate is given as 70% of ARMv5, and it doesn't do ARMv6 or v7 and the JITs of the N64 and PS1 emulators you'd want to run do use instructions from those ISA revisions, you're back at square one.

If you think it's worth trying, I don't think the OpenDingux developers would stop you... but because of the limitations of this device, they consider it to be more of an embedded device, for which Android is very heavy. Lemmywinks in #12 mentions this as well.

Dual booting is a pretty serious undertaking on anything other than a PC, too. I'm sure they could tell you more about OpenDingux's requirements for its partitions so that you could balance it and Android on a card, but I'm not sure they would help you with the technical aspects or actually getting Android to run.

Good luck :)

forphucksakes (OP)

  • *
  • Posts: 71
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #15 on: December 14, 2014, 10:56:39 am »
Quote
Well then, if it needs to do that, and it does, then that MagicCode thing should be good. However, ARMv5 was kind of old, wasn't it?

If the success rate is given as 70% of ARMv5, and it doesn't do ARMv6 or v7 and the JITs of the N64 and PS1 emulators you'd want to run do use instructions from those ISA revisions, you're back at square one.
Again with the emulators. What if someone just wants to use Opera(or any other mature browser) on their GCW0? Or a podcast listener? Or a voice to text app? Or read xkcd/Dilbert comics? Or maybe have a medical dictionary? Or a VOIP program? Or a network analyzer? Or a RSS reader? Or a control system to remotely control mechagodzilla through tokyo? Not all of these need the latest and greatest ARM technology to run, yet are immensely useful. Use your imagination. Again, the point being, access to the vast repository of software that is the Android apk library.

Quote
... but because of the limitations of this device, they consider it to be more of an embedded device, for which Android is very heavy. Lemmywinks in #12 mentions this as well.

Dual booting is a pretty serious undertaking on anything other than a PC, too. I'm sure they could tell you more about OpenDingux's requirements for its partitions so that you could balance it and Android on a card, but I'm not sure they would help you with the technical aspects or actually getting Android to run.

Good luck :)
We're not talking about reinventing the wheel:
http://talk.maemo.org/showthread.php?t=35112&page=42
« Last Edit: December 14, 2014, 11:14:11 am by forphucksakes »
forphucksakes

lemmywinks

  • ****
  • Posts: 2774
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #16 on: December 14, 2014, 01:14:32 pm »
Hardly any of the apps would be usable without a touchscreen though, the only ones which would allow for input mapping would be emulators. You would be able to navigate the general Android interface if the keybindings are recognised (haven't a clue if they would be or not) but most apps are designed for touch input.
Handhelds:
GPD Win, GPD XD 64gb, Pap KIII-Plus, RS-97, RS-90, New Bittboy, 3DS XL, DSi XL, GBA SP, GBBC Clone, Gameboy Pocket, PSP Go,
PC:
HP Envy M6, Acer 522, Dell Mini 9
Psion 5 & 5MX
Tons of other old laptops and tablets.....

Gab1975

  • ***
  • Posts: 1165
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #17 on: December 14, 2014, 01:34:36 pm »
What if someone just wants to use Opera(or any other mature browser) on their GCW0? Or a podcast listener? Or a voice to text app? Or read xkcd/Dilbert comics? Or maybe have a medical dictionary? Or a VOIP program? Or a network analyzer? Or a RSS reader? Or a control system to remotely control mechagodzilla through tokyo?

This is just my own opinion (I don't mean to start a controversy):
if someone wants to use the GCW Zero mainly for the above reasons, probably he would do better to buy another device! ;)

forphucksakes (OP)

  • *
  • Posts: 71
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #18 on: December 14, 2014, 02:00:42 pm »
What if someone just wants to use Opera(or any other mature browser) on their GCW0? Or a podcast listener? Or a voice to text app? Or read xkcd/Dilbert comics? Or maybe have a medical dictionary? Or a VOIP program? Or a network analyzer? Or a RSS reader? Or a control system to remotely control mechagodzilla through tokyo?

This is just my own opinion (I don't mean to start a controversy):
if someone wants to use the GCW Zero mainly for the above reasons, probably he would do better to buy another device! ;)

Well it would seem that your opinion would be against the very spirit of the GCW0 project itself:

"The goal of the project is to not only to provide great experiences for gamers worldwide, but to offer them a means to browse, download and install Open Source applications, and games with ease. The repository will also support the Indie/Commercial scene and allow customers to purchase, download and install those applications and games."

http://www.gcw-zero.com/files/gcw%20press%20release.pdf
forphucksakes

codingcampbell

  • *
  • Posts: 25
Re: MagicCode : ARM --> MIPS .apk converter
« Reply #19 on: December 14, 2014, 02:37:19 pm »
Well it would seem that your opinion would be against the very spirit of the GCW0 project itself

I don't think so. That press release doesn't say the goal is to run every open source application ever made, and further, Android apps are not inherently open source anyway.

I agree with the others, GCW is mostly focused on gaming, not general-purpose software. You can choose to use it how you wish, but that alone won't make it typical.