Open cellphone based on the Raspberry Pi

Suppose you wanted to have an open cellphone that you could modify and experiment with. Specifically, imagine a cellphone where you could add and replace hardware and software, like you can do on most desktop computers. Maybe run Linux, and whatever applications or programs you wish to run. Supposing you wanted an open alternative to iOS and Android.

There are many ways to do this. A particularly clever and comprehensive video is here (with thanks to Curtis Ikehara for pointing me to it).

Following those instructions will give you a cellphone with even a SIM card.

The nice thing about an open cellphone, however, is the number of choices you have. I decided to build a cellphone that uses voice over IP. This is essentially the same technology as is used for voice conversations using any other chat program, but allows dialing phone numbers and receiving calls from regular phones. VoIP is nice in that it works on any internet connection, even outside the country. You can then use a wifi hotspot, perhaps a portable one, to connect to the Internet, or a USB cellular modem.

The main protocol used to connect a computer using VoIP to a regular telephone number is called SIP. This and the internet connection are the two places where you may have to create an account.

As of September 2021, this project is incomplete. However, here's what I've done so far.

Hardware

  1. A Raspberry Pi. I have access to a Raspberry Pi 3B, a Raspberry Pi Zero W, and a Raspberry Pi 4. All work well. The 4 and the 3B are substantially faster and have more memory and more and more accessible USB ports, but are physically bigger and take more energy.

    I'm using a 16GB SD card in the Pi. The same card works with all models of the Pi -- any system can use the same card. Larger cards will of course give you more space.

    The Raspberry Pi 4 has enough main memory (I got the 8GB model) to run full ubuntu, and the 3B and the 4 run better than the Zero, which is especially useful if you want to run programs such as firefox.

  2. A Hyperpixel 4 touch display (with drivers).
  3. A wireless (bluetooth or dongle) or wired keyboard. Since a wired or dongle keyboard will need a free port on the Raspberry Pi, if using the Pi Zero, make sure your keyboard can be connected to a micro-usb port, since that's all that is available on the Zero.

    As long as you have the touchscreen, the keyboard and a mouse are optional -- raspbian has acceptable on-screen keyboards:

    1. sudo apt install matchbox-keyboard, then under the raspberry menu and Accessories
    2. sudo apt install onboard -- then under the raspberry menu and Universal Access -- this one is easier to use but harder to move to the desired position on the screen
    However, for any substantial use of the command-line (particularly for setting things up), I recommend using either a real keyboard and/or mouse.

    As an alternative to a keyboard, you can temporarily enable the sshd daemon so you can connect and enter commands from another computer with a real keyboard. To enable sshd, go to the Raspberry menu (in the upper left corner) -> Preferences -> Raspberry Pi Configuration -> Interfaces, enable SSH (and anything else you need).

More optional hardware includes battery, camera, GPS, and an accelerometer. I'm not there yet!!!

A battery is important if you want portability -- I've been running the Pi plugged into my laptop, but obviously if I'm going to seriously use this as a cellphone, I'll need a battery. Most lithium-ion batteries on the market and in the needed size are 3.7V, so you will need a converter to provide the 5V needed by the Raspberry Pi and the display. You may be able to purchase a converter that also has charging functions, or you may have two separate circuits.

One thing to keep in mind if you use they hyperpixel display is that it takes all the available GPIO pins, so anything else you want to connect has to be USB. If you want to connect several wired components, I recommend using a Raspberry Pi with several usable USB ports such as the 3B+.

Finally, to use this as a phone, you need some kind of audio. The hyperpixel display doesn't have any speakers. A different display, perhaps based on HDMI, may provide audio output. For myself, I've settled on a bluetooth headset when using the Pi Zero, which doesn't have an audio jack, and any old headset when using the Pi 3B, which does. Unfortunately, Linux seems to have a strong preference to use bluetooth audio devices as output only, rather than input and output, so in one test I ended up using a dedicated USB microphone, which works -- but in my experience, using bluetooth devices for audio input is hit-or-miss. This is compounded by the audio jack on the Raspberry PI 3B or 4 boards being only audio output :( (the central contact is some video out rather than audio input).

Software

I've tried installing ubuntu on the Raspberry Pi. I had some luck before running ubuntu on embedded systems on the Pi, but for interactive use I found it rather slow. I've therefore settled on raspbian, which is still slow but less so than Ubuntu. But remember, this is about choices!!! Try different things, and see what you like. I haven't tried all possible versions of ubuntu, and I believe there are more lightweight distributions derived from the main ubuntu.

With Raspbian, my 16GB card has plenty of available space:

$ df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        15G  8.0G  5.7G  59% /

For Ubuntu, I've used larger cards, up to 128GB.

I have tried Tiny Core Linux. It works fine as an embedded system, but at the time of writing, I have been unable to locate one that would support a graphical user interface.

As on any Linux distribution, you have a choice of browsers and other software. The only disappointment so far was firefox, which gave me an Illegal Instruction and which I could not get to run. The default browser is Chromium. Any internet search will give you a good selection of browsers that you can install on Raspbian.

Because I plan to use this as a phone, I needed to install VoIP software. While I'm intrigued by Jami (the executable still carries the former name gnome-ring), I haven't been able to get it to connect to my SIP provider. So instead I went for linphone, which you can install from the commandline, sudo apt install linphone.

Linphone has a GUI (linphone) as well as a commandline (linphonec). As was the case with Jami, the Linphone GUI was tricky to set up. Instead, I ran linphonec, which added some information to .linphonerc. I then modified this .linphonerc information to have my correct SIP configuration (obtained from my SIP provider, see Accounts section). The essentials of the configuration (using example.com for the SIP provider, and my-id and my-pass instead of the real info) is:

[proxy]
reg_proxy=sip:example.com
reg_identity=sip:my-id@example.com
publish=1

[auth_info_0]
passwd=my-pass

[auth_info_1]
username=my-id
ha1=I_did_not_enter_this,_it_happened_by_itself
realm=example.com
domain=example.com

If you modify your .linphonerc, (a) I strongly recommend making a copy first (.linphonerc.orig), and (b) after modifying the .linphonerc, be sure to pkill linphone, since linphone, like any realistic VoIP system, keeps running forever once you start it, even if you close the GUI. This is the normal behavior for a system that is designed to accept incoming calls.

Accounts

If you are going to use your VoIP to call actual phone numbers, and if you want people to be able to call you using a phone number, you have to sign up with a VoIP provider.

The good news is that there are very many VoIP providers, so you have lots of choice. The bad news is that there are very many VoIP providers, and they are not all alike, so you'll either have to choose one at random (not recommended) or spend some time picking one you like.

Many VoIP providers focus on providing service to small businesses. For a single cellphone, this is probably more than you need, and probably needs much more setup than you need. Searching for a residential VoIP provider is more likely to give what you want. I found several that had plans starting at less than $10/month. Unfortunately, I have not (yet) found a residential VoIP provider that supports voice, SMS, and MMS. In particular, all the ones that I've found that support MMS are oriented towards business and marketing. Anttone does support MMS for residential use, but requires you to use their own app, which is not available for Linux (and which anyway runs contrary to the spirit of an open phone). 1-voip works well with linphone for voice calls. Diamondcard.us also looks promising for voice and SMS, but I haven't tried them and they say they do not support MMS.

Once you have VoIP, you can run VoIP software equally well on your desktop, on your Raspberry Pi, or on your cellphone. Many of the apps on cellphones cost money, either one-time or regularly. Be sure to check the terms and conditions -- for the time being, linphone is still free even on cellphone app stores.

Preliminary Results

I have made phone calls to some of the geekier people I know. Outgoing and incoming calls work well (for incoming calls, as long as the VoIP softare is running in the background). Incoming calls display on the screen, but don't "ring" -- at least until I add a speaker to the Raspberry Pi, and then we will see.

To make an outgoing call to a U.S. 10-digit number such as 212-555-1212, I had to enter the number as:

sip:2125551212@example.com
where again, example.com is my VoIP provider.

I sent an SMS (text message), but it wasn't received, and incoming SMS also weren't received. This may be a function of the VoIP software, or of my VoIP provider, or of the plan that I selected. A quick web search tells me that very few VOIP providers support SMS, and even fewer support MMS (which can send pictures and audio as well as text).

Final note: remember to turn off ssh access once you've configured your system! Raspberry menu (in the upper left corner) -> Preferences -> Raspberry Pi Configuration -> Interfaces, disable SSH (and anything else you don't need).

Other Software

An interesting list of mapping software available on ubuntu (most of it probably also available on Raspbian). Disclaimer: I haven't tried most of this software. I like marble but it doesn't seem well designed for small screens, and gnome-maps seems nice too. Haven't (yet, 2021/09/19) tried them with a GPS.

Gallery

The picture above shows the Raspberry Pi zero attached to the hyperpixel display, and next to them, the Raspberry Pi 3. The Pi zero and the display, together, are 97mm by 58mm by approximately 18mm (3.8" by 2.3" by 0.7"). With the Raspberry Pi 3B+, the thickness becomes approximately 25mm or 1".

A U.S. $0.25 cent coin (a quarter) is also in the picture, for scale.


The picture above shows the side view of Raspberry Pi zero attached to the hyperpixel display, and next to them, the Raspberry Pi 3.
The picture above shows the on-screen keyboard and terminal.