Android and RISC-V: What you need to know to be ready
opensource.googleblog.com
opensource.googleblog.com
They're thinking about this wrong. They need to make it zero work, followed by optional optimizations, like Apple did with their M1.
Remember when Google told everyone to test their Android apps on x86. And then again on MIPS? And then nothing happened. Developers will not waste their time.
Apple rented out DTK systems for $500 for developers to get their hands on ARM hardware and port their applications. Hardly zero work. You couldn't even keep the hardware, you had to send it back (and originally you wouldn't even get $500 in credit to buy a production system with, luckily they fixed that after the easily predictable uproar).
Google is providing software emulators instead, much easier to work with and doesn't require complicated device logistics. Not only that, but the only audience that really needs to do work to get ready, are either those producing NDK applications, or those working on hardware support for RISC-V.
Java/Kotlin applications would not need any porting. Sounds like zero work to me!
You'd need a DTK to know if you're fine with emulation or not.
If you cared at all about your app running, you wouldn't just assume that it magically runs fine on an emulation layer you never touched, and that at speeds that are reasonable.
For a reference point, Rosetta was far from being great, and while some apps could run against it, it was most of the time an ultra painful experience. That pain helped devs to put the effort into making native versions, but it also means you couldn't expect Rosetta 2 to give acceptable performances from Apple's track record.
Rosetta 2 was straightforward and surprisingly fast, requiring zero tweaking or user interaction. Most people never even noticed.
Yes, but if you were a developer who had to make sure your application worked on the upcoming M1 models, there was no way to know that without getting the DTK.
At the time when Apple announced their transition to their own silicon and that there would be a Rosetta 2, the only thing you had to go on other than the DTK was the precedent of the first Rosetta. It was a major feat back in its day (god I feel old just writing that...) but it was nowhere near Rosetta 2's compatibility and speed. Armed with nothing but the first Rosetta's precedent, it was a somewhat risky outlook.
Rosetta translates all x86_64 instructions, but it doesn't support the execution of some newer instruction sets and processor features, such as AVX, AVX2, and AVX512 vector instructions.
I can imagine quite a number of users running into the above situation in multimedia related code.
“Not all apps needed to worry about the CPU change”
“But some did!”
“And Apple made test hardware available for those people”
“But not enough for all apps to be tested”
“Not all apps needed to worry about the CPU change”
The initial claim was, lxgr: "If you were initially fine with software emulation (i.e. Rosetta 2), as were many small and large software projects for macOS or Unix, you had no need whatsoever to get a DTK."
The subsequent claim was, xvector: "Rosetta 2 was straightforward and surprisingly fast, requiring zero tweaking or user interaction. Most people never even noticed."
Posters, myself included, are reacting against these claims, as they both put the cart before the horse, and the second gives only an end user perspective.
Devs had verified with a DTK that Rosetta2 ran their programs acceptably. Keep in mind patches had to be issued for programs which did not check for the presence of AVX, AVX2 or AVX512, else they would crash. This invalidates the first claim. It shows why the second claim is only the second half of the story.
So the logic follows a line rather than a circle.
Also nobody made the claim that: “And Apple made test hardware available for those people, But not enough for all apps to be tested”
For Rosetta 2, I agree Apple made a much better translation layer. There were still swaths of software that couldn't run on Rosetta 2, but the previous generation of Intel machine was still there kicking and alive, so people who didn't feel like taking the risk didn't need to.
luckily because this has mostly been fixed and is also the biggest stumbling block when going from x86 => RISC-V
Through there was something about the specific LR/SC definition which I found quite problematic when it comes to implementing certain atomic patterns. But that was 2?? years or so ago and I don't remember the details at all.
Eitherway theoretically if you have a correct C++ standard compatible program without UB it should "just work" on RISK-V by now, but then I don't think such a thing exists (/s/j).
Fortunately, what does exist is programs that have been ported to work on arm64 (or are native there), which will Just Work on RISC-V which has a slightly stronger memory model than Arm.
0. https://buildd.debian.org/status/architecture.php?a=riscv64&...
Note that ART as it is now is the third implementation, first it was Dalvik, then ART pure AOT, and now ART interpreter/JIT/AOT.
Nokia and Sony-Ericsson already had relatively good J2ME implementations for Symbian, and Blackberry OS was powered by Java, when Android came out.
Unfortunately it didn't went for Google the same way, as it did for Microsoft.
Gosling interview on the matter,
https://www.youtube.com/watch?v=ZYw3X4RZv6Y&feature=youtu.be...
But a more nit-picky/correct definition would expect the JVM to follow various specs (e.g. expect the bytecode the have exact the same format, features etc. as the one you find in a classical java application) and have various features which do not apply to the ART at all.
Or in other words, people which have nothing to do with java might call the ART a JVM in a generic way but people which do might be for good reason very insistent that this isn't the case. (Also Google lawyer will be VERY insistent it's no a JVM.)
Not all of them are available, however all of them do support AOT compilation, and their own bytecode format more optmized for their use cases than regular .class files.
The big difference between them and Google, is that they always played by the Sun/Oracle rules regarding Java licensing.
and in general there where tons of issues with multi threaded code during the time Java did move to the "current" memory model (was that in Java 1.5 or Java 1.6? I don't remember), through Sun(Oracle) JVM having issues on ARM was still a think after a huge part of the ecosystem moved to Java 1.6+ but I think wasn't anymore much of an issue when Java 1.8 was approaching but uh that was many years ago the my memory is a bit vague
I wrote code or managed Java development teams from around 1996 to ~2010 and I don't remember any problems with multi threaded code or memory models. But of course you might be right if you did run Java on an ARM mobile like the Nokia.
The only challenge I remember with two high load (thousands of write transactions/sec - back then) websites were GC pauses, where we had to hire consultants to help with tuning the GCs on different machines for the high load.
(It's not that many Debian or Fedora community contributors have a mainframe in their basement—yet the software they package tends to build and run on s390x just fine. Okay, maybe there are some endianess issues, but you wouldn't hit those with RISC-V.)
no, this has little to do with android
but "GNU/Linux applications are typically quite portable across CPUs" is only this case because a lot of people have a lot of interest and time invested into making that work
but for many commercial apps there is little insensitive to spend any time into making them work with anything but ARM (even older armv7 might not be supported because depending on what your app does the market share makes that not worth it)
still with both ARM and RSIV-V havine somewhat similar memory models and in general today people writing much more C/C++ standard compatible code instead of "it's UB in therefor but will work on this hardware"-nonsense I don't see to many technical issues
on issue could be that a non negligible amount of Android apps which use the NDK use it only to "link" code from other toolchains into android apps, e.g. rust binaries. And while I'm not worried about rust I wouldn't be surprised if some toolchains used might not support RISK-V when it starts to become relevant. Especially when it comes to the (mostly but not fully) snake oil nonsense stuff banking apps tend to use I would be surprised if there wouldn't be some issues.
Through in the end the biggest issue is a fully non technical one:
- if you release an app with NDK you want to test it on real hardware for all archs you support (no matter if there is some auto cross compilation or interpretation (like Roseta)
- but to do so you need access to such hardware, emulators might be okay but are not always cutting it
- but there aren't any RISK-V android phones yet
- but to release such phones you want to have apps, especially stuff like paypal or banking apps available
- but to have such things available the providers much evaluate it to be worth the money it costs to test which is based on marked share which is starting at 0 and slow growing due to missing support for some apps and missing killer features
So I think RISK-V android will be a think but as long as multiple big companies are not pushing it strongly it will take a very long time until it becomes relevant in any way.
In reality I have a lot more trouble with differences between macOS versions than differences between CPU architectures.
x86 builds of Android apps & libraries are extremely common to have since it's the most common target for emulators.
As for MIPS, I don't think Google ever pushed it. It was just kinda there.
Also also, this blog post is aimed at device manufacturers more than app developers which is why it talks about building AOSP & pending patches. It's not asking app devs to do anything (in fact it even says at the bottom "Make sure to stay tuned as we look into ways to make it as easy for Android developers writing native to target new platforms as it is for our Java and Kotlin developers!")
No, I don't think they do in a general sense. It's in the title: "What you need to know to be ready" --> if you would like to be ready, we have some information/advice for you. You can take it or leave it.
% Note: I'm using the word "you" here as it is used in the title, not you specifically.
Also, and I missed this at the time, it seems like Qualcomm was restricting manufacturers from also using competitors chips[2], although it seems the ruling was reversed on appeal [3], there's still evidence of restrictions. It would be unappealing to market an x86 device if it means losing access to Qualcomm cpus, especially in an era where Qualcomm modems were practically mandatory, so it makes sense that the only x86 (Asus Zenphone) I can think of is made by a company that didn't make a lot of phones.
Personally, I don't think the lack of app support would have been that much of a problem for sales of phones in the 2012 to 2016 time frame. If you got a couple hundred thousand phones out there, app developers would add support, because it wasn't too hard, a lot of developers were running x86 Android emulators, and they may have already had the x86 native code libraries and just didn't ship them because why bother when there's no phones.
Some of the first generation Asus Zenphone ran on x86, and it might have been rough for a while, but I think they sold reasonable numbers, and app developers started shipping x86 libraries. I don't know when Google Play added support for ABI specific APKs, maybe that was a factor too (if you have to have everything you support in the APK, then you'll be careful about what you support)
[1] https://www.pcworld.com/article/414673/intel-is-on-the-verge...
[2] https://www.cnn.com/2019/05/22/tech/qualcomm-antitrust/index...
[3] https://www.reuters.com/article/us-qualcomm-antitrust-idUSKC...
Android apps aren't AOT-compiled to any specific architecture at build time; that happens after installation on the device itself.
Nowadays AOT compilation happens when the device is idle, taking into account either the generated PGO metadata gathered by the JIT, or the one downloaded alongside the APK at installation time.
All versions of Android keep the original DEX bytecode around to allow for later recompilation (JIT or AOT) and "later" can mean anything from "seconds after the APK was downloaded" to "during/after the next Android update" or "at any convenient time" (e.g. when the phone is charging and has nothing else to do).
how prevalent is ndk use? games and multimedia apps maybe?
This is ARM to RISC V.
Yeah, they really have got their work cut out for themselves!
A transition to RISC-V will be cold turkey. It's technically possible of course to build one CPU that can run both A64 and RV64, but only ARM can legally do it, and they probably won't unless they're really losing, sometime 5 or 10 years from now.
It's kind of an issue for ARM too but they're a bit further towards solving it than RISC-V.
In any case it's mainly a problem for people that want OS updates or the ability to install other OSes, so it's not going to affect app writers or normal users much.
Can you elaborate on why you think so?
I understand it is the opposite: RISC-V is much further towards solving it.
This is because RISC-V has put effort from the start into standardizing boot process (spl -> sbi -> uboot|uefi), ISA (profiles), the firmware-kernel interface (sbi, uefi protocol, acpi) as well as the platform itself (platform spec, standards for interrupts, timers, hypervisor support, the uart requirement, the watchdog and further platform standardization efforts).
This has happened (and is happening still) before significant deployment of SoCs using RISC-V microarchitectures as the application processor.
Meanwhile, ARM realized, quite late, that this is important, and is lagging behind, with plenty of non-fixable, bespoke platform hardware deployed, and low vendor uptake as they are asking their clients to change what they already have in place.
Yes. The experience will be equal or better over the IBM PC-derived platform, by design.
PC was an accidental platform, RISC-V platform spec is an intentional (and very informed) one.
See the subthread at https://news.ycombinator.com/item?id=37996820
Qualcomms latest: https://lists.riscv.org/g/tech-profiles/attachment/400/0/AOS... where they claim that their proposed "make RISC-V a bit like aarch64" Zics extension plus a 32-bit long jump achieves better code density than RV64GC, and without the downsides of the C extension they've been harping about.
I guess google forcing RV64GC or RV64G_Zigs could be the tie braker here.
But while removing or changing the C instruction when it's rolled out isn't really an option as long as it's mostly about emulator testing they probably don't care too much.
Their proposal is no good[0].
>No clearly discernible technical benefit for native RISC-V cores, and some clear technical disadvantages for both low-end and highend implementations
0. https://lists.riscv.org/g/tech-profiles/attachment/353/0/RIS...
In reality, it seems logical to me that all the players here have an interest in the long term health of RISC-V, including applicability to higher end cores. Qualcomm is showing data supporting their position. And Sifive is showing data supporting their position. Will be interesting to see which wins, and whoever it will be it'll hopefully be the best for the long term health of RISC-V even if it means one of the parties needs to partially redesign their cores.
This is an application profile question -- what extensions are required in the CPU in order to run shrink-wrapped software -- not an ISA or hardware question.
The real question is why?
nm: https://www.quora.com/Why-was-the-ARM-Thumb-instruction-set-...
Unsure what you asking? The RISC-V C extension has some vague similarities with thumb. But the Qualcomm proposed Zics extension absolutely hasn't. Zics adds things like more advanced addressing modes, load/store pair instructions etc. that are found in the aarch64 ISA, all with 32-bit instructions. Notable that ARM didn't create any 16-bit Thumb variant of aarch64.
The old emulator is a real pain to get working, and the new one comes with many benefits.
Somehow I never knew you could just run `launch_cvd` manually.
Would also be cool if we could get Android Studio for Platform running as well, I'm guessing it shouldn't deviate too much from regular Android Studio.
I'd be more concerned about ARM support stagnating.
RISK-V is currently not really that competitive on the lower end marked as there are just too cheap ARM chips
but it is e.g. very competitive for companies needing large quantities of simple but slightly customized chips where existing cheap ARM chips aren't an option and customized arm chips are too expensive
and there are currently no competitive RISK-V chips in the high end marked
it can somewhat compete on the mid marked, if it wouldn't be for too low quantities driving the price up
it also could be interesting if e.g. Intel or AMD decides to enter the non x86 market as they could cut out license cost to ARM
but all in all I wouldn't be worried about ARM support being reduced in the ecosystem for many many years to come
the reason is, unlike phone and tablet vendors, small players just can't catch up the new changes from Android, which is very complex, gradually they moved away.
Or even nothing at all, you can run Qt6 standalone and have a very nice touch interface.
¹ https://www.edn.com/teardown-google-home-hub-smart-speaker-a...
² Chromecast builds, which are slightly less than full Chrome: https://source.chromium.org/chromium/chromium/src/+/main:chr...
³ https://www.chromium.org/developers/how-tos/trace-event-prof...
[0] https://docs.tizen.org/platform/release-notes/tizen-8-0-m2/
We have our own JVM tailored for MCU.
> Also, does this require across the stack changes? i.e. not just OS ones.
I'm not sure where you draw the boundary between 'stack' and 'os'. Can you expand a bit?
Do you have any links? I'm curious, and not a little bit skeptical about the near-term competitiveness of RISC-V in the mobile space.
https://news.ycombinator.com/item?id=37924092
https://news.ycombinator.com/item?id=37919907
It doesn't exactly sound imminent.
Mostly Chinese companies have been very busy designing & manufacturing actual silicon. And prices for such products have come down a lot, too.
It wouldn't surprise me if at some point there's RISC-V based phones, tablets & other devices on Chinese market, that most people outside China simply don't know about.
Or that teardown of a cheap phone sold in say, India, turns out to have a RISC-V SoC inside without much public attention beforehand.
Probably sooner than later. RISC-V is bound to become a lowest common denominator for computing devices especially at the low end. Picked by default unless <insert specific requirement here>.
Android being ported is a logical consequence of this.
It typically takes 2-3 years from core announcement to being in an SoC for a high end phone.
They are coming.
Arm will have something newer by then, of course, but a 2023 flagship Galaxy S23 is not going to look stupid in 2026.
Haven't tried the AOSP port for the LiCheePi 4a yet. Probably should give it a whirl just to see if things just work.
That's easier just to try downloading Minecraft through the Play Store than boot strapping the entire toolchain needed to get PolyMC working.
The one problem is banking, at least in Sweden we are still dependent on mobile BankID (for online purchases above $20 f.ex.), which only runs on iOS and Android.
Without that, one must run Android to get access to mobile apps, which is essential.
e.g. in Germany you have similar situations when it comes to online banking for some banks (through not when it's about card->terminal payment)
for example credit card apps in the EU have 2FA (which doesn't always trigger and there is still the legacy protocols for payments from outside of the EU so a bit uh, maybe, pointless)
this 2FA is for most banks handled by and app (different apps tho)
and many of this apps bathed in "security" snake oil making them impossible to run even on a non-rooted but de-googled android phone
same for pay with you phone over NFC, e.g. it currently doesn't work for my bank with my phone and I'm speculating that it's because the secure modules attestation is not is not whitelisted (the phone uses a "industry" ARM chip instead of a typical consumer one so attestation derived ids/keys can be "unexpected")
(Through also where I live there is a law for having some kind of b2b online banking API, so theoretically a company could create an app which does work on unusual phones, or create a device like you mentioned.)
To boil down the problem: To access the western systems you need to keep feeding Apple, Google and Microsoft (AGM).
The alternatives are non-existing still 15 years after the release of the smartphone (that in retrospective probably was the dumbest thing humans have made).
The dream device = dual boot tablet Android/iOS and vanilla linux will never exist?
So you have to shoot for vanilla linux (maybe ARM, probably RiscV) and tell the banks that you are dropping support for AGM.
It's a "I'm not in here with you, you are in here with me" sort of moment.
This goes hand-in-hand with root certificates, taxes and the health/legal system at large; everything made by humans without consulting nature first.
I got popcorn, but I'm kinda worried too.
BankID is owned by the Swedish banks. It is required for some government- and healthcare sites as well, despite it being a commercial monopoly.
The openness of the RISC-V specification is great for chip designers, manufacturers, and researchers. But it has basically no effect on end users, except indirectly (i.e. hopefully the chips are cheaper, because there's more competition and no license fees).
[0] https://mntre.com/media/reform_md/2022-09-29-rkx7-showcase.h...
The indirect effects are the point.
It's the graphics card, the display hardware, the camera, the video encoding/decoding - these are all proprietary, undocumented blobs of IP with no upstream support. Your RISCV Android phone is still going to have all of those, it makes exactly zero difference.
It possibly could work with a community of companies, but my imagination stops there, can’t see how mbas could ever agree to giving away differentiators when fixed costs are so high, it’d destroy margins.
It can be dodged by either licensing some of the hundreds of commercial core designs available, or by using one of the (several) available open source RISC-V implementations.
Other competitive ISAs also have a few -albeit not anywhere as many- open source implementations, but there's no dodging the ISA royalty fee on these.
RISC-V CPUs don't have any of that as there's no requirement that actual implementation be open source, only the ISA. And it's not like you can change it. You can't buy a RISC-V CPU and fiddle with the design, you don't get the source nor the toolchain. All you get are the man pages, and guess what? You get those with x86 and ARM, too!
There's a growing list of RISC-V cores that are themselves open source (that's how RISC-V ecosystem got started, btw). And unlike in x86 or ARM world, no-one would hassle you for licensing or royalties if you bring those designs to a foundry & mass-produce.
Now as for say, GPUs to stick onto those, that is another matter.
And so far entirely about AOSP and getting that running.
GApps (the non-free part) isn't mentioned at all. And like someone else said, there's use cases besides phones that use android. And some people Run de-googled android on phones, it's just degraded :/
- googler, but far from anything android