Page 1 of 1
Mobile Operating System Basics
Posted: Wed Sep 15, 2021 7:21 am
by monarrk
Hello,
Are there any resources available for making a mobile operating system? I have to get a new phone since AT&T is shutting down 3G, and they are offering me an Radiant Core phone for free. I don't like modern mobile operating systems (there are a lot of reasons why, but I won't get into it) so I would like to try to make my own OS with the same general goals as the light phone (
https://www.thelightphone.com/). Basically just texting and calling for now. Is this a plausible goal, or are docs too scarce?
Re: Mobile Operating System Basics
Posted: Wed Sep 15, 2021 10:07 am
by nullplan
Phones are a can of worms you should probably leave closed until you've immersed yourself in them. But I can tell you the basics. A modern smartphone has two processors: The "baseband" processor talks to the SIM card and the radio, and actually implements texting and calling and MMS and all that good stuff, and the "application" processor displays the screen and talks to the user. When you make a call, the application processor sends commands to the baseband, and I am not entirely sure how the voice is then transmitted. And when a call is received, the baseband sends an interrupt to the application processor.
In any case, if you view the application processor as CPU and the baseband as peripheral, then a modern smartphone is basically a normal microcomputer with slightly funky hardware attached. Figuring out how to make an OS for these means you first have to get into the bootloader to get your kernel loaded, then basically your OS (however you divvy up the work between kernel and userspace) has to present some kind of interface to the user that will allow them to express their desire to make a call or text, and allow the OS to present to them the fact that someone is calling or has texted them. The hard part is going to be to interface with the hardware - as usual. Talking to underdocumented and non-trivial hardware is always the hardest part of OSDev. Anyone can draw (or steal) pretty pictures.
What I don't know is how the baseband firmware works. You will probably want to use a pre-approved blob from the manufacturer, since - let's face it - you probably don't want to learn how the SIM card and the radio interface work, and you probably won't be able to write these things in an FCC-compliant manner, let alone FCC-approved. But I don't know if that is stored on the baseband processor, or if you have to provide it, and if you can accidentally overwrite it, bricking the phone in the process (even the prettiest pictures don't make up for lack of wireless connectivity).
Anyway, that was the broadest of strokes. I have no idea about the specifics for any given device. You are going to have to dig up documentation for those. Good luck!
Re: Mobile Operating System Basics
Posted: Wed Sep 15, 2021 7:51 pm
by foliagecanine
Just as a starting point, the AT&T RADIANT Core (ATTU304AA) phone seems to have a MediaTek MT6739.
According to
MediaTek's site, this chip is an ARM Cortex-A53.
The spec for Cortex-A53 can be found on the
ARM Developer site
Additionally, the MediaTek site lists that the integrated graphics is the IMG PowerVR GE8100.
I can't find the spec for this online, but you could try clicking the contact link on
ImaginationTech's site and request the specification.
Otherwise, you could try to look at the
Android Kernel source branch for MediaTek to see if there's an implementation there.
These two things are probably the minimum required to actually be able to work on the OS.
However, to access peripherals, you would need to figure out which peripherals you need to access (such as the baseband like nullplan said) and implement drivers for them.
You could again try looking at the
Android Kernel source branch for MediaTek for implementations of how to do this.
You also may need to open up the phone to see which chips are actually on the PCB and then look them up.
Lastly, there's the problem of actually getting the OS on the phone. (In my experience) most of the time there's a separate chip that starts before the CPU that manages the bootloader, updating the ROM, etc.. Some phones allow bootloader unlocking, some don't. I don't know whether your phone does or not.
Just know that doing this will be a very long and hard task, there is a chance that you could brick your phone, and there's a good chance that the phone will break/die before you finish writing this if you do end up doing this.
Good luck!
nullplan wrote:What I don't know is how the baseband firmware works. You will probably want to use a pre-approved blob from the manufacturer, since - let's face it - you probably don't want to learn how the SIM card and the radio interface work, and you probably won't be able to write these things in an FCC-compliant manner, let alone FCC-approved. But I don't know if that is stored on the baseband processor, or if you have to provide it, and if you can accidentally overwrite it, bricking the phone in the process (even the prettiest pictures don't make up for lack of wireless connectivity).
There's a good chance that you just send commands to the chip and it sends interrupts and data back. There likely isn't any messing with radio signals at the OS level, but I wouldn't know as I've never tried messing with the baseband before.
Re: Mobile Operating System Basics
Posted: Thu Sep 16, 2021 5:25 am
by BigBuda
On the baseband front, maybe you should refer to these guys:
http://osmocom.org/
Re: Mobile Operating System Basics
Posted: Thu Sep 16, 2021 7:27 am
by eekee
Edit: Headache-influenced post; better info in following posts.
I'm not happy with modern smartphones either, but don't have the energy to do better. Still, one option I've considered is getting a "feature phone" (not a smartphone), and having a more open device communicate with the phone over bluetooth. You needn't even take the phone out of your pocket. It's one more thing to keep in your pockets, but I used to have a PDA & feature phone in the 00s & it wasn't bad. But this is an old idea.
There's more open hardware now than ever before. There ought to be some phone kit. I'm sure some of the mobile data hardware in laptops has open-source drivers, but making practical use of one of those would mean doing some hardware hacking and probably changing your number to a VOIP service. I think they're tiny boards, at least.
Edit: Actually, OSMoCom which BigBuda linked would be the first place I'd look, especially if I was thinking of hardware hacking.
Just for completeness, the most practical option might be one of the Linux distros listed here:
https://itsfoss.com/open-source-alternatives-android/
There's also at least one fully open-source privacy-enabled version of Android out there. Any of these could give you some (terrible) driver source code to look at, perhaps as a last resort. None of them work perfectly on very many phones, so you might honestly do just as well seeing if you can get datasheets for the chips themselves.
You could hypothetically disable Android on your phone and run your code in its place, using the vendor's Linux kernel, but this has its own problems. It's not always obvious how to communicate with the Linux kernel modules which drive the baseband processor. The
Hellaphone project had that trouble. (The Inferno OS Hellaphone ported has all its userspace in bytecode; it can run under Linux as well as on hardware.) Hellaphone was nice when it worked though. You could dial by sending a text string to a device file, and you could configure "the plumber" to dial if you sent it a number in plain text. You could "plumb" text from just-about anywhere, like a shell or text editor or whatever.
I think you could also read GPS coordinates as plain text from another device file.
(I really miss using my Samsung Galaxy S3, sometimes. There was nothing obviously invasive about it and it still looks perfect. If PostmarketOS's supported list is anything to go by, there's not enough documentation for it.)
Re: Mobile Operating System Basics
Posted: Thu Sep 16, 2021 7:42 am
by BigBuda
eekee wrote:I'm not happy with modern smartphones either, but don't have the energy to do better. Still, one option I've considered is getting a "feature phone" (not a smartphone), and having a more open device communicate with the phone over bluetooth. You needn't even take the phone out of your pocket. It's one more thing to keep in your pockets, but I used to have a PDA & feature phone in the 00s & it wasn't bad. But this is an old idea.
A probably much more interesting alternative would be making your own phone. Today you can do it with off-the-shelf-parts with Arduinos, NanoPi/RasPi, and breakout boards for mobile basebands especially built for these tinkerer platforms. Open source software for that is also easily available, so it's easy to improve/customize.
eekee wrote:There's more open hardware now than ever before. There ought to be some phone kit. I'm sure some of the mobile data hardware in laptops has open-source drivers, but making practical use of one of those would mean doing some hardware hacking and probably changing your number to a VOIP service. I think they're tiny boards, at least.
OSMoCom that BigBuda linked seems like a well-intentioned resource but very new? All these open mobile initiatives seem to spring up like mushrooms and die just as quickly.
Might be worth seeing if there's another of those open smartphone projects going at the minute, and seeing if you can get some hardware before it dies.
Actually they've been around well over a decade if I'm remembering correctly.
eekee wrote:You could hypothetically disable Android on your phone and run your code in its place, using the vendor's Linux kernel, but this has its own problems. It's not always obvious how to communicate with the Linux kernel modules which drive the baseband processor. The
Hellaphone project had that trouble. (The Inferno OS Hellaphone ported has all its userspace in bytecode; it can run under Linux as well as on hardware.) Hellaphone was nice when it worked though. You could dial by sending a text string to a device file, and you could configure "the plumber" to dial if you sent it a number in plain text. You could "plumb" text from just-about anywhere, like a shell or text editor or whatever.
I think you could also read GPS coordinates as plain text from another device file.
(I really miss using my Samsung Galaxy S3, sometimes. There was nothing obviously invasive about it and it still looks perfect. If PostmarketOS's supported list is anything to go by, there's not enough documentation for it.)
A better alternative to that would be to just opt for a PinePhone. I'm thinking of getting my hands on one, you can choose a lot of alternative operating systems for it, seems to be better than the Librem 5 and you can easily develop your Linux based OS for it. One of the main distros they support is Manjaro, which is Arch based and thus, a relatively low level distro, within the high level that is being already inside a Linux environment.
Though I'm also considering building my own - just getting a 4G modem, putting it together with a NanoPi, a LoRa module, a screen and installing libgammu on it to control the Modem. I've been doing things like these for almost a decade now, with carrier pen-modems using libgammu to initiate calls and send messages directly from software I've written (work belongs to former employer, so can't disclose code, but it's actually quite easy). On some laptops, the integrated modem can easily be used as a phone with the appropriate software gluing everything with the sound card, and most have non-disclosed but easily usable GPS functionality (for instance, the F3607gw Ericsson modem on the Tecra S10).
EDIT: another place to search would be XDA Developers. It's likely they're close to the OSDev.org of the mobile space.
Re: Mobile Operating System Basics
Posted: Thu Sep 16, 2021 8:12 am
by eekee
The best way to get good info on the Internet is to post something a little bit incorrect.
But that was not intentional on my part, I'm sorry. BigBuda, thanks for the extra info!
BigBuda wrote:A probably much more interesting alternative would be making your own phone. Today you can do it with off-the-shelf-parts with Arduinos, NanoPi/RasPi, and breakout boards for mobile basebands especially built for these tinkerer platforms. Open source software for that is also easily available, so it's easy to improve/customize.
Oh you
can get the hardware. Good! This is what I was hoping when I wrote, "There ought to be some phone kit."
BigBuda wrote:eekee wrote:OSMoCom...
Actually they've been around well over a decade if I'm remembering correctly.
Yeah, my mistake. I had some more glucose tablets, realised my mistake, checked the last news page & fixed my post. They have been around for more than a decade.
BigBuda wrote:eekee wrote:You could hypothetically disable Android ... but this has its own problems. ...
A better alternative to that would be to just opt for a PinePhone. I'm thinking of getting my hands on one, you can choose a lot of alternative operating systems for it, seems to be better than the Librem 5 and you can easily develop your Linux based OS for it. One of the main distros they support is Manjaro, which is Arch based and thus, a relatively low level distro, within the high level that is being already inside a Linux environment.
Oh the PinePhone reached the market, and so did the Librem 5. Also good! I had assumed they were going the way of OpenMoko and some other projects; glad I was wrong. It's nice that the PinePhone offers booting from microSD card.
BigBuda wrote:Though I'm also considering building my own - just getting a 4G modem, putting it together with a NanoPi, a LoRa module, a screen and installing libgammu on it to control the Modem. I've been doing things like these for almost a decade now, with carrier pen-modems using libgammu to initiate calls and send messages directly from software I've written (work belongs to former employer, so can't disclose code, but it's actually quite easy). On some laptops, the integrated modem can easily be used as a phone with the appropriate software gluing everything with the sound card, and most have non-disclosed but easily usable GPS functionality (for instance, the F3607gw Ericsson modem on the Tecra S10).
If my health improves, I'd like to build my own too. I've got ideas about chording keyboards and no heavy glass. Interesting to know about the laptop modems.
Re: Mobile Operating System Basics
Posted: Thu Sep 16, 2021 8:27 am
by BigBuda
eekee wrote:Oh you can get the hardware. Good! This is what I was hoping when I wrote, "There ought to be some phone kit."
It's much easier to build and find than it would seem at first sight. I think the biggest challenge I'm seeing on my own build would be the enclosure.
eekee wrote:Yeah, my mistake. I had some more glucose tablets, realised my mistake, checked the last news page & fixed my post. They have been around for more than a decade.
Sorry, didn't see until I submited, because I'd already written the reply. I think these guys were also linked to a much broader usage of SDR.
eekee wrote:Oh the PinePhone reached the market, and so did the Librem 5. Also good! I had assumed they were going the way of OpenMoko and some other projects; glad I was wrong. It's nice that the PinePhone offers booting from microSD card.
Yeah, although I found the Librem5 to be underwhelming and unjustifiably priced. I'd much rather a new Nokia N9 came about. IMO, Meego Harmattan was the best mobile OS to this day, and the N9 was the best phone of its time. It was the most open mobile platform I've seen (not in the open source sense, despite being heavily Debian based), but rooting it was just a question of going to the settings panel and flipping a switch to turn on programmer mode. You could SSH to the phone, teather it for internet sharing as an ACM modem, do all kinds of cool stuff with it.
eekee wrote:If my health improves, I'd like to build my own too. I've got ideas about chording keyboards and no heavy glass. Interesting to know about the laptop modems.
Why not use this project as therapy? Doing something you enjoy and that makes you fill fulfilled is as important as any treatment. In my case, I wish I just had access to enough information to repurpose my E72. I'd love to have it either as a Linux phone or some other tiny Mobile OS that could give it some new life and teach it some new tricks.
Re: Mobile Operating System Basics
Posted: Thu Sep 16, 2021 10:25 am
by trinopoty
As pointed out, this is a can of worms best left closed.
Modern baseband processors are riddled with patented technology, and the companies holding the patent wouldn't part with the source code under any circumstances (unless you buy them out of course).
The best you can get your hands on is a binary blob. The driver that's loaded into the kernel is usually extremely simple. For instance, Qualcomm uses shared memory to access the baseband. The driver only exposes the memory to applications and all the magic happens in the binary blob. Unless you have a million dollar contract with Qualcomm (or Mediatek, or any other company), chances are, you won't get your hands on a blob tailored for your OS.
As for the microphone, that's usually connected to the baseband processor. The main OS will request access from the baseband when needed.
Re: Mobile Operating System Basics
Posted: Thu Sep 16, 2021 11:09 am
by BigBuda
trinopoty wrote:As pointed out, this is a can of worms best left closed.
Modern baseband processors are riddled with patented technology, and the companies holding the patent wouldn't part with the source code under any circumstances (unless you buy them out of course).
The best you can get your hands on is a binary blob. The driver that's loaded into the kernel is usually extremely simple. For instance, Qualcomm uses shared memory to access the baseband. The driver only exposes the memory to applications and all the magic happens in the binary blob. Unless you have a million dollar contract with Qualcomm (or Mediatek, or any other company), chances are, you won't get your hands on a blob tailored for your OS.
As for the microphone, that's usually connected to the baseband processor. The main OS will request access from the baseband when needed.
That depends greately on the baseband used. Some of the basebands work as modems, using AT commands. And not all require the mic to be directly connected to them, they can receive digital audio data already preprocessed by the main CPU. With basebands such as those you mentioned memory access is often bidirectional which means the entire phone can be remotely compromised by a stingray attack. Actually, the main reason I'm looking at buying either a PinePhone or building my own, is precisely because of that. The baseband being physically disconnectable and not sharing memory with the main CPU as a security measure.
Re: Mobile Operating System Basics
Posted: Thu Sep 16, 2021 12:50 pm
by trinopoty
BigBuda wrote:That depends greately on the baseband used. Some of the basebands work as modems, using AT commands. And not all require the mic to be directly connected to them, they can receive digital audio data already preprocessed by the main CPU. With basebands such as those you mentioned memory access is often bidirectional which means the entire phone can be remotely compromised by a stingray attack. Actually, the main reason I'm looking at buying either a PinePhone or building my own, is precisely because of that. The baseband being physically disconnectable and not sharing memory with the main CPU as a security measure.
Baseband modules/chips using AT commands are usually pretty limited. At least in my experience. Most of them don't support advanced features like 3G or 4G (if any; most in my experience only support 2G).
Then again, I only worked on those in an industrial context where high speed internet wasn't critical so maybe I only worked with low end chips.
Re: Mobile Operating System Basics
Posted: Thu Sep 16, 2021 1:52 pm
by BigBuda
trinopoty wrote:Baseband modules/chips using AT commands are usually pretty limited. At least in my experience. Most of them don't support advanced features like 3G or 4G (if any; most in my experience only support 2G).
Then again, I only worked on those in an industrial context where high speed internet wasn't critical so maybe I only worked with low end chips.
Actually, there are a lot that do support 3G and 4G. Many of them are the same you can find inside 4G pens or laptop 4G modules. Telit HE910 is one 3G module that I use quite often. The LE910 is quite often used with Arduinos and Raspberry Pi, and has 4G and GPS+GLonass embedded, supporting 100Mbps downstream and 50Mbps upstream.
Edit: trinopoty, I'm guessing you're probably used to solutions based on SIM900?
Re: Mobile Operating System Basics
Posted: Thu Sep 16, 2021 7:25 pm
by foliagecanine
BigBuda wrote:eekee wrote:Oh you can get the hardware. Good! This is what I was hoping when I wrote, "There ought to be some phone kit."
It's much easier to build and find than it would seem at first sight. I think the biggest challenge I'm seeing on my own build would be the enclosure.
I think the biggest challenge with building your own smartphone would be condensing all the parts into a form factor small enough to fit in your pocket.
Otherwise you'd end up with a brick phone.
Just think of all the different things you'd need:
- Touchscreen (probably the most restricting part)
- Battery (probably the biggest part)
- The computer itself
- 4G Cellular Module
- GPS Module
- WiFi/Bluetooth Module (might be built into the computer or the 4G module)
- Speakers/Audio jack
- Cameras, front and back
- Accelerometer
- USB port for charging and data
- Enclosure for all the parts
Obviously you could remove some of these for your use case, but it's still a lot and quite expensive. Might match some mid to high-end phones in price.
You could go through the process of sourcing your own chips (the chips that are inside the RPi 4G/GPS/etc. modules), designing a PCB, and building it from scratch, but that seems like a lot of work.
But hey, maybe someday someone will make a phone equivalent of a Framework laptop
Replaceable parts, customizable OS, non-carrier restrictive...
Re: Mobile Operating System Basics
Posted: Fri Sep 17, 2021 2:57 am
by BigBuda
foliagecanine wrote:I think the biggest challenge with building your own smartphone would be condensing all the parts into a form factor small enough to fit in your pocket.
Otherwise you'd end up with a brick phone.
Just think of all the different things you'd need:
- Touchscreen (probably the most restricting part)
- Battery (probably the biggest part)
- The computer itself
- 4G Cellular Module
- GPS Module
- WiFi/Bluetooth Module (might be built into the computer or the 4G module)
- Speakers/Audio jack
- Cameras, front and back
- Accelerometer
- USB port for charging and data
- Enclosure for all the parts
Obviously you could remove some of these for your use case, but it's still a lot and quite expensive. Might match some mid to high-end phones in price.
Well, the GPS modules are built into the 4G celular modem, as I mentioned earlier, and the WiFi+Bluetooth are built into the SoC. Just look at the NanoPi as I mentioned, for example, the NanoPi Duo2, which is just a few mm bigger than an Arduino Nano, already has the USB port for charging and all the other ports can easily be added anywhere on the phone because of the pads on the board. You might need to do a PCB for the SMD speakers and mic, but that's easy. And if, as mentioned, the objective is to have something simple to make and receive calls and texts, then there's not need for an accelerometer or cameras, neither for a big screen, although even that you could easily fit. It wouldn't be as slim as credit card sized phone, but it wouldn't be uncomfortably big either. Because of all the craze on IoT, things have come a long way in terms of modules and components that you can just piece together to do something nice and not bulky.
foliagecanine wrote:You could go through the process of sourcing your own chips (the chips that are inside the RPi 4G/GPS/etc. modules), designing a PCB, and building it from scratch, but that seems like a lot of work.
With the current OTS modules that you can find, it's unlikely you'll need to do that, at most you'll need to design a PCB for the connectors and audio (even that can be avoided, most of them will just be a bunch of wires soldered directly between the connectors and the motherboard and it will depend on your choice of speaker and mic) and designing and making your own PCBs (two layers at most) at home isn't hard to do at all. In fact, I do it frequently (though I set up a small "lab in a closet" for that) and there are companies who make cheap short run PCBs, if you need something more professional. You don't need to create an entire motherboard because you have SoMs with SoCs like the NanoPi Duo and others (some are even 64 bit already) that you can easily use to do that. They're small and packed full of features. The Duo, for example, is a $25 board (but you can get it way cheaper) which has a quad core Cortex-A7 CPU, 512MB RAM, ethernet, composite video out, audio in + out, WiFi+BT,4, camera input support, USB OTG, serial ports for debugging, GPIO with IR, SPI, I2C... and most other components you'd need don't stray far from this pricing. I think the most expensive one is actually the screen, if you want something more high end, otherwise you can just use a cheap I2C or SPIO screen ready made for these types of boards.
foliagecanine wrote:But hey, maybe someday someone will make a phone equivalent of a Framework laptop
Replaceable parts, customizable OS, non-carrier restrictive...
Take a look at Fairphone. They even went through the trouble of sourcing all components from reputable non-conflict zones.