Engineering Pie Build for the Sony Xperia XA2 Ultra!

So it’s been a rough start for me, stepping into the modern world with a modern phone that has a/b partitioning and was Android 8.0+. I’ve built dozens of roms for dozens of phones, some that were even unsupported, and to God be the glory, I was moderately successful, but these modern phones have been a different story. My first attempt with the Xperia XA2 Ultra ended up hard bricked. Then, I built a pie version of AOKP, which did boot, but would immediately crash after getting to the home screen.

Today, however, was off to a much better start. I successfully tested my engineering build of LineageOS 16.0 (pie) for my XA2 Ultra (discovery). Everything seems to work well, and you are welcome to try it out. Keep in mind, though, it is an engineering build as opposed to a user build. Also note that this is for the 50.1.x firmware variants.

Granted, a lineage build is already available, and most of the work was done by Luke. I like to compile a build on my own, though, to make sure my system is set up properly and that the source material does work before I get started on my own roms.

Now to get back to that AOKP build…. Or should I start on a Resurrection Remix build instead?

Linux – keep it simple.

Advertisements

Home photo server, part 2: Apache, phpAlbum, and Piwigo

Last time we talked about how to set up the domain name with DDNS for free, and then using very secure FTP, vsftp, and SyncTool (the Android app) to automatically move photos from your phone to your home server. But that’s only half of the battle. One of the big perks to using Google Photos is that you can browse them anytime from anywhere. You can share them with friends, make comments on them, and other socially related things. We need a way to do that from our home server, too.

There are many, many methods to accomplish this, and I tried several, but I’d like to point out two options that worked really well, were simple to use and set up, and used little to no JavaScript. There are several reasons why one might not want to use JS, like security, etc., but I’ll save that for another post. The two best options were phpAlbum, which is 100% JS free, and Piwigo, which only uses JS for some display themes, I chose one without it and it seems to work just fine.

Either way, I needed a web server, so I installed Apache.

# yum install httpd

# systemctl enable httpd

#firewall-cmd –add-port=80/tcp

# firewall-cmd –add-port=80/tcp –permanent

Right out of the box, you could browse to my web server. Of course, it was insecure and it only displayed the main page. I’ll break down adding certs and making it TLS and SSL compliant in another post. I was ready to set up my router, make sure you route that traffic to your server! Since that is rather router specific, you’ll have to look that up on your own, but there are tons of guides on it. Now it was time to install a photo gallery web server.

So, first on the list, I tried phpAlbum. It worked great and seems to be a good fit, provided that you have a smaller photo collection. One big plus is that it doesn’t need a MySQL database or anything. The only downside: once I surpassed 8000 photos, and numerous folders, it seemed to not be able to keep up. So, for a short time I got around this by setting up multiple web pages, each running a unique instance of phpAlbum, each with it’s own set of photos. This was simple, really, I made one for a couple of years worth, and one for the next 3 or 4 years, and then had a main web page that linked to the different ones. This is a bit tedious and cumbersome though, but wasn’t too bad if you have a lot of static images.

Since it is so simple, and has a good installation guide, which you can read here, I’ll be very brief about how I set this up. You can also click here for a phpAlbum demo.

# yum install php php-xml php-mbstring php-gd

# yum install ImageMagick

# yum install unzip zip

After downloading the latest phpAlbum zip from their website, unzip it and edit config_change_it.php to your needs with nano or vi, basically by setting the data directory and the photo directory, and rename it config.php. Now copy the entire directory to /var/www/html. So in my setup, it was /var/www/html/phpAlbum/ with all of the files in it.

Next, chmod 777 the cache, data, and photo directory inside your folder, so you can write to it with other users (the uploading functions). Then:

# chown -R apache:apache /var/www/html/phpAlbum

so your web server can own it (since I’m using Apache as the web server). Now all you have to do is navigate to http://yourDomainNameIPaddress/phpAlbum and you will be greeted by a login, to which the default is admin and admin for the username and password. Once your in, it will ask you a few questions, and you can be up and running in a few minutes! It worked really great, like I mentioned earlier, when I had a smaller photo collection (under 8000 for me, but your mileage may vary).

Since it was struggling with more photos, I decided to switch to Piwigo. You can check out a demo of it here. There is a really, really great guide on TecMint, that I drew from when putting this together, but it was relatively simple. Start by installing the dependencies – note that a lot of these were already installed for phpAlbum, and I’m not 100% sure you need all of these, but this is what I installed:

# yum install php php-xml php-mbstring php-gd wget unzip zip ImageMagick python python-tk python-psyco mariadb-server php-mysqlnd

Now you need to enable and set up your MySQL/mariaDB:

# systemctl enable mariadb

# mysql -u root -p
MariaDB [(none)]> create database piwigo;
MariaDB [(none)]>grant all privileges on piwigo.* to ‘piwigouser’@’localhost’ identified by ‘pass123’;
MariaDB [(none)]>flush privileges;
MariaDB [(none)]>exit

# systemctl restart httpd

Be sure to use your own usernames and passwords. I don’t recommend the defaults! Then you need to download Piwigo and unzip it, placing it in your Apache web server root directory. After you put it in place, you need to set the proper read and write permissions, as well as ownership:

# wget http://piwigo.org/download/dlcounter.php?code=latest -O piwigo.zip
# unzip piwigo.zip
# cp -rf piwigo/* /var/www/html/
# chown -R apache:apache /var/www/html/
# chmod -R 755 /var/www/html/
# chmod -R 777 /var/www/html/_data/

# systemctl restart httpd
# systemctl restart mariadb

Now it’s up to you how you want to handle moving the pictures we automatically uploaded to the server into the Piwigo directory. For instance, you can have your photos upload from your phone to your home directory, and then make a cron job or script, or manually put them into your Piwigo directory. One benefit of this is deleting blurry or useless photos. I like this option best, but that’s my opinion.

Another option is to set the /var/www/html/galleries photo permissions to be writable/readable by others, or add your user to the group and upload your photos directly to it. I tried this as well, and it works good, too. Either way, now all you have to do is use your web browser to navigate to your server, and you should see the Piwigo first login/setup screen.

Choose your options, such as language, etc., tell Piwigo what the MySQL/MariaDB is called and what that password is, and you should be up and running in no time! Now you can log into the web interface as the admin user (that you just set) and start choosing themes, uploading photos with the web app, or syncing the galleries folder for the photos you put there via FTP or moved manually or scripted.

piwigoPublic

In this screenshot, you can see the light theme that I went with, and how there are some photos available for the public to see. If I log in, then I can see the rest of the pictures:

piwigoPrivate

You can have more users and give each user access to certain files, folders, or groups. Groups is nice because you can give “family” the option to see this, and “friends” the option to see that. You can control everything from the web admin screen:

piwigoAdmin

Another plus to Piwigo is that there are several Android apps out there, some paid, some free, some open source. So there are options, but quite honestly the web browser of Android works great, since Piwigo has two theme settings, one for desktop browsing, and one for mobile browsing as well. So you can have two different themes, one for each desktop and mobile, to maximize what works best for you.

There’s still a few things to cover though. Right now, it is only using port 80 for unsecure web traffic. We definitely want to use secure http on port 443, so we will cover certificates and security next.

Linux – keep it simple.

Home photo server, part 1: Server Setup, SCP and FTP

While there are many, many options out there for photo storage, if you are looking for a home storage solution that does NOT involve just plugging in your phone and dumping the pictures to your hard drive, you have to get a little technical. (By the way, if that is what you have to do, there is no shame in it. It is probably a lot safer doing that than letting Google hold all of your photos.)

The first thing I needed was a server. Granted, you could use just about anything these days, and there are a lot of open source/open hardware type solutions, but I was gifted an older, generation 1 Dell PowerEdge 1950 from a friend. Granted, it was made in 2006, but it still is 64 bit, has two quad core Xeon 2 GHz processors, and I loaded it with 24 GB of ram. You can get them on eBay now for about $60. A little overkill for this sort of thing, but the price was right! As a bonus, it supported hardware raid, and I put two 2 TB drives in a mirror array, so that 2 TB of space that was backed up.

From there I loaded CentOS 7 on it per the usual installation method, and updated the system. I also purchased an APC battery backup unit, a Back-UPS 1350. This would only hold the power on for about 15 minutes, but it would help for brown outs, and frequent “blips” where the power goes out for only a second or so, which is common where I live. Later I’ll have to do a post on setting up the auto-shutdown and controls, because that was rather interesting.

So the next thing I needed, if I wanted this to work, was a domain. I needed a way to contact my home computer from my cell phone, especially while not at home. Granted, you could set all of this up so when you come home your phone would automatically back up your photos, but I wanted to be able to do this from abroad. Thus enter No-ip.com. I’ve used them before, and it is great if you are looking for a cheap, cheap solution. Because it is free.

Granted, a free account your hostname will need to be manually renewed every 30 days, but they send you an email, and all you have to do is click the link to keep it active, so it is pretty easy. After creating an account, logging in, getting a dynamic IP address, then all I had to do was install the DUC software. DUC is the Dynamic Update Client software that allows:

“Remote access your computer, DVR, webcam, security camera or any internet connected device easily. Dynamic DNS points an easy to remember hostname to your dynamic IP address.” (noip.com)

All you have to do is download the source code and compile it. It went like this:

$ cd noip-2.1.9-1/
$ make
$ sudo make install

After entering my password, it ran through an installation script and asked me for my account name, password for the account, and which DDNS I wanted to associate with this computer. It is interesting, you can have several.

From here, it then became a matter of preference on how to continue. I toyed with several options on my Android phone for how to get the photos from the phone to the computer over the internet.  One of the first methods I tried was using scp, or secure copy over ssh. So, I installed ssh on my server.

# yum install ssh-server

# cd /etc
# cd ssh/
# ls
# nano sshd_config

I then edited the sshd_config to my liking, there are a lot of guides on this on the internet, so I wont belabor the point here. I will note that I use non-standard ports as a form of extra security, however slight that may be, so you may consider doing the same, but essentially it works as is once installed. Then I opened the ports in the firewall – I list the standard ports here, for ease of following along:

# firewall-cmd
# firewall-cmd –help\
# firewall-cmd –help
# firewall-cmd –add-port=22/tcp
# firewall-cmd –add-port=22/tcp –permanent

And that worked great. Unfortunately, scp is slow and can be cumbersome from an Android phone, especially since I didn’t find any apps that would sync my directories automatically (that were open source so I knew what was really being sync’ed). However, I found several open source options that would sync automatically via FTP. So I decided to install “very Secure FTP”, or vsftp, like so:

# yum install vsftpd

# cd /etc/vsftpd/

# ls

# nano vsftpd.conf

Again, I set it up to my needs, but you can check out this guide for ideas. I also needed to punch some holes in the firewall for the service and for both active and passive mode, since several Android apps would use either.

# firewall-cmd –add-port=21/tcp
# firewall-cmd –add-port=21/tcp –permanent
# firewall-cmd –add-port=20/tcp
# firewall-cmd –add-port=20/tcp –permanent

# firewall-cmd –permanent –add-port=40000-50000/tcp

And viola! All that was left was a quick restart of the processes:

# firewall-cmd –reload

# systemctl restart vsftpd

And now I could use FTP apps on my Android phone to sync my pictures from my phone automatically to the home server! In case you are wondering, a great app for this is on F-Droid, the open source app repository of open source apps. It is called SyncTool, and it is very handy. It supports FTP sync one way, both ways, automatic scheduling or running jobs manually.
image

Wheeow, that was a long post, but now my photos were being automatically backed up. However, that’s only part of the story, because if I was convincing my wife to ditch Google Photos, I needed to also have a way to browse them online, share them, organize them, etc…. It was time for a web server. Guess we’ll cover that next.

Linux – keep it simple.

Going Gapp-Less, Again….

Trebuchet

Don’t worry, you can put the tinfoil hats away. That being said, I’m going Google App Less (gappless) again. A few years back, I tried to go gappless, and it was rather difficult. Everything seemed to be tied into Google somehow, and I just couldn’t make it with the limited number of apps available outside the Google Play Store. This time around, however, is a different story.

With my new Xperia XA2 Ultra, I decided to flash LineageOS 16 (android pie), but I also decided not to flash the Google Apps package (Gapps). So, my phone was complete, without any of Google’s apps, such as the Play Store, Gmail, Google Photos, etc. It’s not that I distrust Google. I’m just not sure if I trust them. So, I thought I’d see how well it works to go without them for a while.

The truth is: I haven’t even noticed they’re gone.

The big things that you need to replace though, if you don’t have Google’s apps, are gmail, app stores, calendar, and photo backup and sharing.

The first thing I did was use the Chromium browser (the open source front runner of Google Chrome, essentially, Chrome without Google’s additives), and downloaded F-Droid. This app “store” is a repository of free and open source apps.

I know what you’re thinking, but F-Droid has come a long, long way since it’s humble beginnings. There are a lot of high quality apps on there now, covering just about every major category. Not only are there tons of apps in it, they are all free and open source. F-Droid even has an update system that makes sure you keep your apps current!

qksms

From there I downloaded QKSMS for all of my texting needs. It’s one of the best texting apps out there, open or closed source! (I borrowed the above picture so as not to show you all of my contacts….) It’s high quality, open source, easy to use and very nice to look at.

I also downloaded Librem Mail to handle all of my emails and replace the Gmail app. It supports multiple accounts, works great with Gmail and other mail accounts (like SDF) and supports PGP encryption as well. I really like it. The color coding and unified inbox is great.

Of course, I also downloaded AndBible, an open source Bible reading app, and FOSS Browser for web surfing, and AsteroidOS’s app to sync to my LG Watch Urbane smart watch (running AsteroidOS). A chess clock app, and several games like frozen bubble. Amaze for file browsing, Android CUPS for printing, GetBack GPS and PocketMaps and SatStat for GPS navigation, and a few other odds and ends.

I needed a calendar replacement, and I tried several, but Simple Calendar is my favorite. It can import “.ics” extensions, which you can export from your old Google calendar online and put onto your phone. It’s not synced with my Google calendar, but that is what I was trying to avoid anyways. I’d show some pics, but I have a lot of work related things on my calendar that I can’t show here. But it supports customization for color. The author likes orange, but I prefer blue, and fortunately you can change the color scheme.

The other big elephant in the room is a replacement for the Google Photo app with unlimited storage, which is really, really hard to beat. This is actually what started my most recent kick to try going gappless, as there is now more information about how they process photos is becoming more interesting and complex. Actually, they were talking about it in 2015 and 2017. For this reason, I set up my own home server running Piwigo photo manager.

I know you probably think I’m crazy, but consider this: on my home server version of Piwigo, without any AI intelligence looking at my photos, each photo comes in with exif data, which can (and usually does) include stats for each photo, date, time, location, phone/camera taken with, aperture data, etc. Without even trying, on the exif data alone, Google *could* know your location, what kind of phone you have, etc.

Even without location enabled, the date/time stamp plus amount of sunlight can narrow down where in the world you are with little effort (I know, I used to navigate a submarine in the Navy, and we would use stars and sun position to double check our navigation equipment). Let alone if they actually look at the photo. They would know all your friends, who you are related to, what you like to eat, what kind of car you drive, etc.

Anyways, off the hobby horse.

So, after installing Piwigo on my home server (you can host them online at BlueHost or other places as well), I then installed a simple app called SyncTool from F-Droid which allows me to FTP sync my phone’s camera folder to my home computer. For all of this, you don’t actually need something like Piwigo, but it is nice that my wife and I can use the open source app (there are non open source ones too) or a web browser to view our photos or share them with friends.

So far, it’s worked out really, really well. Albeit, you would need to be a little more tech savvy to set this up yourself. Fortunately, you could host it places that will help you with that, but then you get back to cloud storage. At least with my home server, I know exactly who’s looking at my photos.

On the other hand, all you need is a USB cable to just copy your photos to your computer every now and then. Just saying.

You might be wondering though, what about that closed source app I really need/want? Well, I have a few of those, like Bluino Loader, and arduino tool for using your phone to program arduino devices through the OTG cable. Well, it’s not open source, and not in the F-droid repository. Fortunately for me, though, there is Aptoide.

Aptoide comes in two variants, full and lite. I use the “lite” version myself. It uses less bandwidth and works faster, in my opinion. Aptoide is a Google Play Store alternative. The apps in this store are scanned with several virus scanners to ensure a good clean product. I’ve never had any issues with it myself.

For the most part, with a few exceptions, any non-paid app you can find on the Play Store seems to be here in Aptoide. It seems like they download the latest versions from the Play Store and host them here. Users can also make their own app store to host their own apps. (I did that once before… probably an old post about it on here somewhere.)

It has an update function, and you can also search back for old versions of the software, which is handy, like going back to the version before they started putting adds in! I’m not sure if it is regulated quite as well as the Play Store, and certainly not as well as F-Droid, so be careful to make sure the file scans virus free.

Another alternative is Amazon’s app store, which hosts all the usual paid apps you might need. One thing to keep in mind, though, is many apps require Google’s services running in the background to work. Thus far, I haven’t had a single issue with any of the apps I installed, though, which you can see is quite a few of them. Maybe you should try going gappless….

Linux – keep it simple.

Beginning AOKP Pie for the Xperia XA2 Ultra

I knew I couldn’t keep away from Android forever. It was only a matter of time before I jumped back into development. A lot has changed since my old rom building days. Back then everything was pre-treble, and there were no A/B partitions. That all changed for me with an Xperia XA2 Ultra.

It seems harder than I remember, and a lot more time intensive than it used to be. But, to kick things off, I started by building AOKP Pie for my new phone. To God be the glory, it does boot, but it doesn’t work right. Something is causing a pretty big hang up as soon as you are done with the setup. It locks up graphically once you get to the home screen for the first time.

Initial thoughts are perhaps tiles or menu item problems, but we will see.

Under the hood, though, everything is still running, even though the screen doesn’t update. If you use ADB, you can connect and do all the usual ADB command line stuff. But that doesn’t make for a very handy cell phone if you have to bring your computer everywhere so you can use it!

It’s also a bit harder as I had to switch to a nano sim card to be able to use the XA2. This is a problem because all of my other phones are not nano. It makes it difficult to switch to another phone while I test this out. Using a phone as your daily driver and for developing is a bit cumbersome and does slow me down quite a bit, but hopefully I’ll be able to work on it more later.

If you want to try out the “alpha” of my rom, you can download it on my MediaFire account. I will warn you, though, it doesn’t work very well.

Linux – keep it simple.

Fixing my bricked Sony Xperia XA2 Ultra

a

The photo above is not a mirrored image, it is actually two distinct Sony Xperia XA2 Ultra phones.

Whether it is fishing or phones, it all has to start with a story. Unlike fishing, though, this phone story really does start out as a big whopper! I guess I should back track to the beginning….

I was researching a new phone for Mom, and found that the Xperia XA2 Ultra is a really, really great phone. Sure, there are reviewers that were not enthusiastic, and some that were ecstatic, but I really felt that this would be a great phone for my mom. And I think it is. In fact, I liked it so much, that I picked up a slightly used one for myself. All was well.

Then, I decided to ditch the stock rom and start working on some custom stuff, as usual. The first thing I needed to do was test a current custom rom someone else made to make sure things work, and that I understand what’s going on under the hood. That is where things went horribly wrong.

I was following a guide on XDA. Several users had a similar guide, so I figure it must be right. Unfortunately, it not only didn’t work, but following the guide to a “T” bricked my phone. Here’s where I got hung up:

1. Download latest firmware with XperiFirm.
NOTE: When using mono XperiFirm will fail to unpack the firmware, you can do it manually using following commands:

Code:
for f in FILE_*; do unzip $f; done
unzip boot.zip -d boot

2. Go to the directory where the firmware got downloaded to and remove following files:
– kernel_X-FLASH-ALL-18AE_0x00.hash
– kernel_X-FLASH-ALL-18AE.sin
– persist_X-FLASH-ALL-18AE_0x00.hash
– persist_X-FLASH-ALL-18AE.sin
– system_other_X-FLASH-ALL-18AE_0x00.hash
– system_other_X-FLASH-ALL-18AE.sin
– system_other_X-FLASH-ALL-9B8D_0x00.hash
– system_X-FLASH-ALL-18AE_0x00.hash
– system_X-FLASH-ALL-18AE.sin
– system_X-FLASH-ALL-9B8D_0x00.hash
– userdata_X-FLASH-CUST-18AE.sin
– vendor_X-FLASH-ALL-18AE_0x00.hash
– vendor_X-FLASH-ALL-18AE.sin
– vendor_X-FLASH-ALL-9B8D_0x00.hash
3. Turn off your phone, hold vol dn and plug in the USB cable, the screen should be off and green LED lit.
4. Run Newflasher, it’ll flash entire FW to your current slot then unplug the USB cable and power on your phone.
5. Turn off your phone, hold vol up and plug in the USB cable, the screen should be off and blue LED lit.
6. Enter this command: `fastboot getvar current-slot`, it should return something like this:
current-slot: _b
Finished. Total time: 0.001s
7. Now switch to the opposite slot by entering command: `fastboot set_active a` if the current slot is `_b` or `fastboot set_active b` if its `_a`, you should see this:
Setting current slot to ‘a’…
OKAY [ 0.012s]
Finished. Total time: 0.014s
or
Setting current slot to ‘b’…
OKAY [ 0.012s]
Finished. Total time: 0.014s
8. Unplug usb cable and repeat steps: 3, 4
9. Profit?

At step 7, I was supposed to switch to the other slot. So I did, but when I unplugged the USB cable and repeat steps 3 and 4, it bricked the phone on the repeat of step 4. After that, it never booted up. All that happened when plugging it in or pressing any button combo was a triple blink of the green LED, and nothing else.

So, I made a post on the thread asking for help. But there was none to be found. Shortly after my post, others started posting as well. They all had the same issue. So, I take comfort in my misery loving company. Although I wish other’s phones had not also bricked, I was somewhat glad that I didn’t “mess up”, since several others following the instructions had the same results. What went wrong? I really don’t know.

The big question became, how do I fix it? I had about $100 invested in this useless paperweight, so I really wanted to turn a positive result. Thus enter ebay. I started bidding on phones with broken screens. I really just wanted to buy another main board, or motherboard for the phone, but I couldn’t find any suppliers. Eventually, I won a phone with a shattered screen.

The screen may have been shattered, but the phone still turned on and worked, so I simply disassembled the two phones (my brick and the one with the shattered screen) and swapped the main board! Now I had a working phone with the good screen, and I was back in business!

Next, I went about the process of installing Lineage 16 (pie) on the phone. According to the instructions, you have to update your phone to 50.1.A.13.123 to use this version of Lineage, but my phone was already 50.1.A.13.83, so I decided to try it as is, without updating the firmware. Praise God, it worked! So I was able to unlock the bootloader, boot TWRP, and flash LineageOS 16!

WARNING: This worked for me on software 50.1.A.13.83, but I don’t think it works if your software version is 50.2+! Try this at your own risk. I can’t promise that it won’t brick your phone.

Here’s what I did:

  • Went to Sony’s Unlock Bootloader section of their website and followed the specific instructions there to unlock the bootloader. You have to input your IMEI to generate a code that you use to unlock it in fastboot.
  • Downloaded TWRP for “discovery” (the nickname for XA2 Ultra).
  • Turned off my phone, held Volume up and plugged in the USB cable, which turned it on and put it in fastboot mode.
  • Typed fastboot boot ./twrp-3.2.3-0-discovery.img

fastboot boot ./twrp-3.2.3-0-discovery.img
downloading ‘boot.img’…
OKAY [ 1.431s]
booting…
OKAY [ 5.131s]
finished. total time: 6.562s

  • The phone rebooted into TWRP. I suggest making a backup at this point. I did, and copied it to my computer.
  • Download the latest LineageOS 16 (pie) rom for your XA2 Ultra. I used the 20190621 nightly, and it worked great for me.
  • Then, since I was ready to install LineageOS, select wipe, advanced, and wipe everything, then format data! Really important, if you don’t format data, you can’t boot lineageOS, as it will hang trying to unencrypt the data directory.
  • Still in TWRP, go to advanced, and select sideload.
  • On the computer, type:

adb sideload <name_of_lineage_zip.zip>

  • It will show a type of progress bar, and then will tell you when it is done. Don’t be alarmed if it “hangs” for a few minutes at the end, that was normal for me.
  • Reboot to system and enjoy LineageOS!

So, after a test run, I went back into TWRP, from fastboot, and flashed Magisk v19.3, and that worked great as well. I didn’t try Gapps, since I am actually going Gapp-less again. But that’s another post for another time….

Hopefully this was helpful for you. It was a lengthy process for me, and not optimal to say the least. If you do go this route, I will note that the Xperia XA2 ultra has been phenomenal for me. The battery life on Pie is incredible, the camera (that everyone loves or hates) is the best I’ve ever used, and I love it so far!

Linux – keep it simple.

LTE Project renamed “Bone Phone”!

Well, today is my last post on the LTE project. After showing it to my co-workers, it has now been renamed the “bone phone” because of it’s unique shape and color! I’ve also included the README.md at the end of this post with the full story.

To God be the glory, I learned a lot, and made a lot of functions with this phone. The main points are:

  • Send Text messages to any valid number
  • Receive and read text (SMS only) messages from anyone
  • Reply or delete text messages
  • Turn LTE on/off
  • Turn GPS on/off
  • Get your current location
  • Send your current location to someone else via text
  • Compass heading (must be moving to be accurate, based on GPS)
  • Status Bar with battery, GPS, cellular, and messages stats
  • Current local time

There was a lot more things that I wanted to do with this project. unfortunately, I ran out of memory:

Sketch uses 26938 bytes (83%) of program storage space. Maximum is 32256 bytes.
Global variables use 1567 bytes (76%) of dynamic memory, leaving 481 bytes for local variables. Maximum is 2048 bytes.
Low memory available, stability problems may occur.

As you can see from the warning, I’m running out of dynamic memory, or ram. I’ve tried adding a few more things, but anything I add tips it over the edge. Even just a few bytes added seems to make the device slow down so much that it is unusable. You are supposed to leave 512 bytes for running the program, and I’m only leaving 481, which slows it down a bit. But, be sure to check out the project on my GitLab for all the files, the pictures, videos, and 3d printer cad drawings and program! It’s all up for you to work on and improve!

Thanks for following along with me on this project! It’s been a really great learning experience! Not only that, but to God be the glory, it even works! You can read more about it in the readme if you’d like. This readme also includes operating instructions. (It’s easier to read by following the link to the mark down document, but I’ll post it here in case you need it.)

# LTE project (nickname: “Bone Phone”)

You can read more about this project on my blog: https://thealaskalinuxuser.wordpress.com
Just search for “LTE project” to see how you can build this open source hardware texting phone for yourself!

This phone can send and receive text messages. Runs off of a 9 volt battery, and has six buttons.

# Operating instructions:

1. Turn on the Bone Phone by flipping the power switch to the “on” position.
2. Once it boots up, you will be presented with the main screen. On every screen, use the numbered button that corosponds to the menu item to select it.
3. Any screen that has you input text or numbers, use the buttons to navigate, 1 is up, to scroll through the numbers or letters, 2 is down, to scroll through the numbers and letters. Whatever letter or number you select is not saved to that spot until you use button 3 (left) or button 4 (right), at which point the letter/number is saved/entered.
4. Some screens tell you to push the select button (button 5) to do special functions. If needed, the screen will display the action you should take.
5. At any time, you can press the “home” button (button 6), which will take you back to the main menu.

# Features

– Send/receive text messages
– Turn on/off data or gps
– View GPS location and send as text
– Compass heading screen if GPS is on
– View network info.
– Using serial over USB, you can do many more features such as download web pages, upload to the web, and more.

# Notes

– I tested this with StraightTalk and Hollogram.io simcards. Both worked, but only the hollogram card would allow data if using the serial over USB connection. Both worked for texting.
– When sending a text to a number, you need either of these two formats: +19078675309 or 19078675309. Some phones will not accept unless you have the “+” sign in front of the number. So far, all phones accept the text when you use the “+” sign.
– The device has 2 batteries. One 9 volt battery, which is disposable, and non-chargable. The second battery is a 3.7 volt battery for the modem, which is charged by power from either board input or the 9 volt battery. The power battery percentage from the phone on the status bar is actually for the modem battery, and doesn’t tell you how much battery power you have left in the 9 volt battery, unfortunately.
– The serial over USB works, and you can talk to the board that way, sending and receiving texts, etc.
– The included truth table outlines the different screens and button combinations.
– The bone phone was also supposed to have a mini browser/ftp/http get/put method, as well as a game, but I ran out of memory on the device. Come on, I only had 32 kb of space and 2 kb of ram to work with!

# About – Or, Why “bone phone”?

Well, the design is somewhat dog bone treat shaped, to protect the buttons. Add to that the fact that the original that I 3d printed was white, it did look like a big bone. While showing it to my co-workers one day, one of them said it’s a bone. One then said it was a bone phone. They then all started laughing and we nicknamed it the bone phone.

I built this phone so I can learn about cell phones, c and c++ programming, and work with open source open hardware on a project. This bone phone met all those goals. This bone phone cannot make phone calls, but can send or receive texts.

# Hardware Components

The main board is an Arduino Uno (or knock off), and a Botletics LTE shield, both of which are open source hardware. There is also a Nokia 5110 screen, a slider (on/off) dpst switch, and 6 momentary switches, made by QTEATAK. There were also 6 550 ohm resistors, and a 3.7v lithium cell phone battery that I took out of an old HTC sense cell phone, but any 3.7volt LiPo/Li-ion battery would do.

I also included the files for the 3d printed case that I made. I used a glue gun and glue sticks to hold most of the components and wiring in place. Please see my website for tutorials about how it was put together.

The hardware used was specifically selected because it is all open source hardware.

“Open source hardware is hardware whose design is made publicly available so that anyone can study, modify, distribute, make, and sell the design or hardware based on that design.”

# License

My portion of the software is licensed under the Apache2.0 license:

Copyright 2019 by AlaskaLinuxUser (https://thealaskalinuxuser.wordpress.com)

Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
The software includes three libraries:

– The Adafruit Phona Library – Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, all text above must be included in any redistribution. Which was modified by Botletics, maintaining the BSD license.
– The PCD8544 Library – The MIT License (MIT), Copyright (c) 2013 Carlos Rodrigues <cefrodrigues@gmail.com>
– The Arduino software serial library – GPL2.0

Linux – keep it simple.

LTE Project: GPS and Compass screens!

d

Another update on my LTE project. This one is fairly small, but I worked out the compass screen, which runs off of the GPS. You can see the whole commit here.  What is interesting about this is that I actually edited the library for the LTE shield itself to do what I wanted. Fortunately, it was pretty simple.

The problem is space. I’m running out of dynamic memory. I need to maintain around 500 bytes to run the sketch, but it is difficult when I start adding variables. The Arduino Uno only has 2 kb of ram. So, to call the GPS to get the heading, you need this:

boolean Adafruit_FONA::getGPS(float *lat, float *lon, float *speed_kph, float *heading, float *altitude,
uint16_t *year, uint8_t *month, uint8_t *day, uint8_t *hour, uint8_t *min, float *sec) {

But I only had room for one more float variable. But I found this in the library:

// only grab altitude if needed
if (altitude != NULL) {
// grab altitude
char *altp = strtok(NULL, “,”);
if (! altp) return false;
*altitude = atof(altp);
}

What does that mean? Well, a lot of variables in the above are allowed to be “null” or nothing. So, I edited the libraries/Botletics_SIMCom_Library_v1.0.0/Adafruit_FONA.h file from this:

boolean getGPS(float *lat, float *lon, float *speed_kph, float *heading, float *altitude,

To this:

boolean getGPS(float *lat, float *lon, float *speed_kph, float *heading, float *altitude = NULL,

Claiming the altitude is null. This is perfect because I can call one float, named heading, and then call the method with just one float instead of a bunch of them. Like this:

case 4:{ // Compass screen
                float heading;
                if (fona.getGPS(&heading, &heading, &heading, &heading)) {
                  lcd.setCursor(0, 1);
                  lcd.print("Heading: "); lcd.print(heading);
                }

So, even though I technically need a float for lat, long, heading, and altitude, now I am just using the heading one and letting it be overwritten by lat, long, etc., and the last one written is the heading! Yes, this is cheating, but praise God, it worked! This LTE project is really coming along!

Linux – keep it simple.

LTE Project: SMS, read and reply!

Of course the Botletics shield that houses the modem was able to receive sms messages the moment I put a sim card in it, but now I can read them on my device! That’s right! Using nothing but the interface and buttons on the device, I can select which message to read, I can view it, and then reply or delete it!

Originally, I was going to have a scrolling screen that you could use the buttons to scroll through and read the text messages. This had several advantages, like being able to see a conversation flow. However, it had some disadvantages too. Namely, I don’t have enough memory left on this thing to hold the messages in the Arduino’s ram.

That said, I needed to just read the message and display it to the screen. I already have a buffer for sending a text message, and a buffer for what phone number to send it to (2 char arrays, the message one is 140, and the phone number is 21). This actually worked out in my favor greatly. With the read screen, you get to choose a message number to read, so I made a small int to hold that number and you can use up and down to change it, or move it by 10 with left and right.

Once you settle on the message to read, you press select, which then reads that message from line into the phone number send char array, and the from message into the send message char array. These are simply displayed on the screen.

With that done, it is actually really easy to delete the message, since you have a message number already, so selecting to delete it, it already knows which one to delete!

Also, replying becomes easy, since the send to phone number is already saved in the send to phone number char array! Also the text message is saved their too, so you can read the message you were sent while you write the new message. I think it is great! The only problem is this: if your wife texts you and says “what should we have for dinner tonight?”, when you hit reply, you have to overwrite that whole message so you can say, “tacos”. So I’m not sure, I may want to blank it out instead, but for now, it’s pretty hand for testing, since I can just hit reply and send the same message back for testing purposes.

Be sure to check out the entire commit for all the good details I missed here!

Linux – keep it simple.

LTE Project: Sent a text message!

Today was a great day for my LTE project! Today I sent a text message using only the buttons on the device itself! It was great to be able to do that from the gui/interface without the need for a serial over USB connection!

So, how does it work? Well, you can check out the entire commit on my GitLab, but I’ll highlight the main parts here. First, I needed a way to type with only 6 buttons, one of them permanently being the “home” button, and one always being the “select/ok” button. So really just 4 buttons. With that in mind, I made a simple interface that I’ve seen before: Up/Down to cycle through the letters/numbers, and Left/Right to move which place you are typing at.

To make that work, I added an array of characters that you can cycle through, like so:

char letterNumbers[91] = {'0','1','2','3','4','5','6','7','8','9',' ','A','B','C','D','E','F','G',
  'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e',
  'f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','`','~','!',
  '@','#','$','%','^','&','*','(',')','_','+','|','-','=',';',':',',','/','.','<','>','?'};

Notice that not every keyboard character is there. You have the forward slash, but not the back slash, due to an issue with char. I’m sure I can work it in, but I needed to get it working first, then I can edit it more later.

Then, I use a variable called curPos to mark which spot in the message you are, and numLetter to hold which number of the 91 characters you are trying to use. It looks like this:

case 30:{ // Screen 5 – Enter phone number screen.
// Up one character
if (numLetter >= 91){
numLetter = 0;
} else {
numLetter++;
}
break;
}
case 35:{
// Down one character
if (numLetter <= 0){
numLetter = 91;
} else {
numLetter–;
}
break;
}
case 40:{
// Left one position
if (curPos <= 0){
curPos = 0;
} else {
sendText[curPos] = letterNumbers[numLetter];
curPos–;
}
break;
}
case 45:{
// Right one position
if (curPos >= 21){
curPos = 21;
} else {
sendText[curPos] = letterNumbers[numLetter];
curPos++;
}
break;
}

It allows you to wrap around from character 91 back to character 0 in the list. Then when you press left or right, it saves the character you chose, say “A” in the spot where you were! It’s a little cumbersome, but it actually works!

The only thing I wonder is if the left button should be like delete, and leave a blank space instead of writing the current character and going left. I’m not sure which works better. I suppose a smart person can actually write the entire text backwards if they mess up and want to retype it…. maybe not.

It can be a little confusing, because it doesn’t save the letter/number/punctuation you have chosen until you move left or right, which appears like it is there, but it is not saved until you move off of it. You also can’t read what is under the “cursor” because it always displays the current chosen character you want to write. I’ll look at ways to fix that, but for now, it’s pretty functional, just not very pretty.

Linux – keep it simple.