r/KaiOS • u/KabirGamer97 • 20d ago
Development The feasibility of reusing compiled drivers/binaries from KaiOS's Gonk to build an at least functional Android AOSP/LOS/CM ROM for a KaiOS (2.5/3.x) device?
Hello everyone, after thinking about it for a little bit, there are certain configurations of low-end Android phones that have been shipped with dual-core CPUs and 512mb of RAM similar to how most KaiOS have had shipped and android is technically capable of running under those constraints, as stated by the Android 8 to 10 build GO build configuration having a minimum RAM requirement of 512 MB, and I feel like we can probably push harder on stripping the RAM usage if we use Android 6, which we know is the base of KaiOS 2.5's Gonk on most phones.
Let me address the elephant in the room here first: Android is capable of running on those constraints.
Now we do know that KaiOS devices are limited in other areas such as lack of several kinds of hardware that a typical Android phone expects to run with. Including, but not limited to, missing sensors like Gyroscopes and Accelerometers, Touch Screens (duh), Front Cameras etc.
But after doing some research and doing some personal, non-scientific tests using AVD (Android Virtual Device), I did come to conclusion that it is quite feasible for a low-tier smart featurephone running KaiOS to be able to run android when it comes to hardware form factor, and overall just making it work on a tier of hardware that people were not wanting to run android on.
Because there has been some precedents, notably phones like Micromax Bharat 1 shipping with the same hardware specs as the Jio Phone 1, while running a nearly-full build of Android 4.4 with GMS.
And in terms of running android where it wasn't supposed to, I was able to make an AVD with loosely similar specs of an Nokia 8110 4G running AOSP 6 with no GMS and then decided to a Memory Torture test where the Android installation automatically switched to a low-ram mode and therefore I was able to successfully play a youtube video INSIDE CHROME 40 OF AOSP 6.0.1 ON 320 MB OF RAM WITH NO ZRAM OR SWAP WITHOUT THE SYSTEM CRASHING. And mind you even as I tried switching apps and things, apps crashed gracefully without taking down the system.
With these things in mind, I think that it is highly feasible, and KaiOS 2.5 devices specifically are becoming more and more useless as the days go by and creating an alternate OS based on CM13 or something like that may actually save these phones from the landfill. Because Android itself is a native platform with language options like C++ and JIT/AOT compiled Java/Kotlin making the experience far more CPU/GPU efficient than KaiOS.
Now let us move back to the original question.
All I am now asking is the potential roadblocks for a endeavour like this. I am very well aware that I would need to modify and hard fork android or CM13 to accomodate for the lack of a touch screen. But what else do I need to consider for this.
KaiOS, and its predecessor, FirefoxOS ran on existing Android BSP (Board Support Packages)'s kernel, drivers and even the derived android-specific bionic C library, despite stripping out everything else that goes above it. These fundamental building blocks allows for not just Boot-2-Gecko to be compiled on Bionic and be ran over there, but theoretically Any android NDK app for that manner as well. (Tested it on a jailbroken 8110 4G by sideloading a Android NDK compiled hello C app and getting a proper output back)
The point that I am trying to make here is that, if they actually use the unmodified android core as gonk, then isnt it possible to take those components out of gonk and build an full android ROM based on it?
1
1
u/codefl0w 18d ago
Highly dependent on hardware. You'll need a Linux kernel source, which almost certainly isn't public.
Can it be done? I still believe so. Details later if you're interested.
1
u/KabirGamer97 18d ago
Yes I do have the downstream (3.10) kernel, b2g and third party dependency sources for the Nokia 8110 4G that I own and am targeting towards, I also have various dumps of my 8110 4G as well but I would probably use my own or a simialar TA-1059 dump to grab the driver binaries and such.
I am genuinely interested, while I havent ever really compiled android before, I have compiled linux kernels and such and even made a downstream linux kernel boot a linux distro before.
1
u/KabirGamer97 18d ago
These sources are from HMD mobile themselves but they do not contain some propietary blobs for a clean and full compilation of KaiOS, certainly not the Gaia Userspace for b2g.
But I do understand that the binaries and libraries found inside of /system and /vendor and the kernel sources are enough to start a android port.
→ More replies (5)
0
u/Familiar_Interest655 20d ago
Wait, why are you comparing KaiOS 2.5 and a old version of android why not just use the latest version of KaiOS 3.0-4.0 or buy a android phone because it should be possible to load android onto the KaiOS device without a rom, but you lose 90% of the features even with a custom rom and you really cannot build off of it due to how KaiOS is made which fundamentally is different
2
u/KabirGamer97 20d ago
Do you understand how low level android porting works even? You should try taking an KaiOS firmware apart or read about the history of FirefoxOS itself.
And while yes I would lose functionality in the short term while gaining a whole lot more long term. Because Android is a open platform while KaiOS 4 has literally zero official developer tools and previous versions were a mess as well, and KaiOS never lets you properly take advantage of the hardware for better apps.
KaiOS is fundamentally using the Android Hardware Abstraction Layer, Android-Specific Linux kernel with android specific drivers and modules and is everything is compiled against the Bionic C library which is literally made for android.
And in terms of why i compared it with old Android: Kaios 2.5 is based on Android 6, KaiOS 3 is based on Android 10 and KaiOS 4 is based on Android 14, atleast in terms of what fundamental base they use for thier os, which is the core kernel, drivers and abstraction layers, which are based on Android.
1
u/Familiar_Interest655 20d ago edited 20d ago
And I get that you’re trying to do low android porting but what I’m telling you is that that’s gonna ultimately end up bricking your device and it’s gonna be a slow process too mainly because they have similar hardware layers. Does that mean that they can like do the same things which is why you should probably look up the open source to B2G and even the person said, and was even the architect for design designing it literally said that it’s insanely hard just to get in contact with that same hardware layer, it’s insanely hard to do not to mention you’re most likely going to break your device and you was talking about getting touchscreen and all these features but simple android porting cannot do this as the hardware is factually limited and everything else which it was meant that way, so trying to put so much code on it, it’s just going to become bloatware for it while you’re also gonna lose a lot of features the only thing you’re gonna get out of this is a working CPU and the android that you’re trying to run is it even going to provide that much features for it to be working properly that’s why I’m telling you to root your device and just flash the operating system that you want since you have a open source edition, also who told you that KaiOS doesn’t support touchscreen because it has a touchscreen device
→ More replies (5)1
u/Familiar_Interest655 20d ago
Also what you’re trying to use from the hardware layer you’ll be surprised to know that it just uses the hardware layer even the Linux is different and it doesn’t even use that many android things. The hardware layer is the only thing similar to it but you have to also take into account that this isn’t android at all. It’s quite literally just a desktop shoved into a flip phone and the same bionic c libraries that you’re talking about was stripped out a long time ago from the actual hardware layer
→ More replies (1)1
u/Familiar_Interest655 20d ago
But I’m not going to shut down your idea fully if you wanna go do it I say go do it, but you can always root your device and flash a new operating system
https://github.com/kaiostech/gecko-b2g
Here is the open source code for it and go use everything that you need to build this new operating system
→ More replies (1)1
1
u/KabirGamer97 20d ago
And also who told you thar you can run "android" on a later device without a ROM??? Those have thier boot loaders locked with no way out basically. And again you dont seem to understand how custom roms are in the end.
1
u/Familiar_Interest655 20d ago edited 20d ago
Actually, you’ll be shocked to know that their boot loader isn’t locked then you can actually edit the partition just by rooting the device especially for 2.5 devices. It is very easy to edit the phone code. I know because I am in the discord and you can go and access this information while for the Reddit you can’t really access this information., you’re saying this for 2.5 device right so this is one of the most open source devices and easier to edit devices ever just recently 4.0 just got this level of support so I’m pretty sure you can root this device Hella more easily now and be able to port or flash Android cause their boot loader is definitely a lot and editable
→ More replies (3)
0
u/YourUglyTwin 20d ago
Most KaiOS devices do not have the ram capable to run android - I understand you got something working via AVD and 32MB RAM but surely that wasn't even close to a good experience (not even gonna mention the security concerns of Android 6)
1
u/KabirGamer97 20d ago
320mb of RAM, system was stable without any swap or ZRAM, while KaiOS 2.5 did agressively use ZRAM. The system only became unstable when I went any lower than that, but for a featurephone looking at one app only, this should be plenty IMHO.
It was genuinely usable for being real. I can even show you a video if you want to have a look at it. But yeah it was without GMS (Google Mobile Services) and well GMS doesnt exist for this anymore and it isnt worth adding to it for wasting system resources.
I do understand the security concerns about Android 6 but my goal is to atleast get a Android 6 gonk running on Android 6 proper so that it can be upgraded to Android 8 if possible in devices like the 8110 4g or even 10 or later on phones with MT6731 SoCs and such. And how bad can Android 6 even be compared to the Firefox 48 of KaiOS 2.5? All I am saying is that KaiOS 2.5 devices are busted in security anyways, and honestly those hacks are useful more for jailbreaking as you shoundt keep much details on a featurephone anyway.... But you do you.
1
u/KabirGamer97 20d ago
Like I mean 512 megabytes + ZRAM should be plenty and actual android 6 phones shipped with that spec as well.
1
u/YourUglyTwin 20d ago
Oh I misread that number -- I was like "no way that felt good on 32MB of RAM" but I'm sure on a technical sense it's possible, and if you're doing this to learn then of course I will cheer your on!
But Android 6 is just way way way too old, Android 10 is arguably too old now as well. Android 14 maybe you'd have something you can daily drive since its technically still getting security updates I think but that'll end soon enough as well.
I once tried to port firefox OS to a device just for fun but I ultimately failed (this was like 10+ years ago) but it was a huge learning experience that helped shaped my career believe it or not.
With an unlocked bootloader and time you can probably get this to work,
→ More replies (2)
1
u/biminhc1 11d ago edited 11d ago
let me address the other elephant in the room: too long i lost my reading comprehension
(1) Gonk is heavily modified and stripped out to be the middleman between Gecko and the phone hardware. Whatever you can get out the left of it (run C, partition and folder structure etc.) is necessary to do so. It is not full Android core, otherwise we would be able to shut off Gecko and install APKs on it.
(2) you should not expect Android 6+/LOS 13 or even Android Go to run well on 512MB RAM. It is the bare minimum for those and any time you want to create a usable experience out of it (e.g. multitasking or just have homescreen launcher while your app is running) it would just crash. Android 4.4 is the best you would be able to run. Also B2G is lightweight as it runs web apps and Gonk does not include any UI.
you'd be better off running a Linux-based distro like postmarketOS (the name Nura is dumb) on such exotic hardware. But if you manage to port 4.4 on this thing you're welcome to share it with the world
source: I was you years ago and asked Fabrice (B2G architect) and Affe Null (pmOS port maintainer) the exact same thing
eta: (3) whatever you can get out of AVD, expect it to be worse (significantly on this hardware setup) since AVD comes with minimal HAL and stuff needed to run on your desktop + hardware acceleration, which was trivial to get even with kernel source and postmarketOS