Stephen Smith's Blog

Musings on Machine Learning…

Posts Tagged ‘Ubuntu

The Race for 64-Bit Raspberry Pi 4 Linux

with 2 comments


When the Raspberry Pi 4 was announced and shipped this past June, it caught everyone by surprise. No one was expecting a new Pi until next year sometime, if we were lucky. The Raspberry Pi 4 has updated faster components, including an updated ARM processor and USB 3.0. Raspbian, the official version version of Linux for the Pi was updated to be based on Debian Buster and shipped before the official Debian Buster actually shipped. However, Raspbian is still 32-bit, where the Raspberry foundation say this is so they only have to support one version of Linux for all Raspberry Pi devices.

Others in the Linux community, have then figured out how to run 64-bit Linux’s on the Raspberry Pi. For instance there are 64-bit versions of Ubuntu Mate, Ubuntu Server and Kali Linux. These work on the Raspberry Pi 3, but due to changes in the Raspberry architecture, didn’t work on the Raspberry Pi 4 when it shipped. We still don’t have official 64-bit releases, but we are reaching the point where the test builds are starting to work quite well.

Why 64-Bit?

To be honest, 64-bit Linux never ran very well on the Raspberry Pi 3. 64-bit Linux and 64-bit programs requires quite a bit more memory than their 32-bit equivalents. Each memory address is now 64-bits instead of 32-bits and there is a tendency to use 64-bit integers rather than 32-bit integers. The ARM processor instructions are 32-bits in both 32-bit and 64-bit mode, so programs tend to be about the same size, though 64-bit doesn’t have use of the 16-bit ARM thumb instructions. The Raspberry Pi 3 is limited to 1Gig of memory, that can just barely run a 64-bit Linux, and tends to run out of memory quickly as you run programs, like web browsers. The Raspberry Pi 4 now supports up to 4Gig of memory and that is sufficient to run 64-bit Linux along with a respectable number of programs. Plus the Raspberry Pi 4 has faster access to the SDCard and USB 3, so you can attach an even faster external drive, so if you do get swapping, it isn’t as painful.

In spite of these limitations, there are reasons to run 64-bit. The main one is that you can get better performance, especially if you actually need to work with 64-bit integers. Further the 64-bit instruction set has been optimised to work better with the execution pipeline, so you don’t get as many stalls when you perform jumps. For instance in 32-bit ARM, there is no function return instructions, so people use regular branches, pop the return address from the stack directly into the program counter or do a number of other tricks. As a result, function returns causes the execution pipeline to be flushed. In 64-bit, the pipeline knows about return instruction and knows where to get the next few instructions.

If 64-Bit Worked on the Pi 3, What’s the Problem?

If we had 64-bit working for the Pi 3, why doesn’t it just work on the Pi 4? There are a few reasons for this. The first obstacle was that Raspberry changed the whole Pi boot process. The Raspberry Pi 3 booted using the GPU. When it started the Pi 3’s GPU runs a program that knows how to read the boot folder on an SDCard and will load this into memory and then start the ARM CPU to run what it loaded into memory. The Raspberry Pi 4 now has a slightly larger EEPROM, this contains ARM code that executes on startup and then loads a further step from the SDCard. The volunteers with the other Linux distributions had to figure out this new process and adapt their code to fit into it. Sadly, the original EEPROM program didn’t provide a good way to do this, so the Linux volunteers have been working with Raspberry to get the support they need in newer versions of the EEPROM software. The most recent version seems to be working reliably finally.

The Raspberry Pi 4 then has all new hardware, so new drivers are required for bluetooth, wifi and everything else. To keep the price down, Raspberry uses older standard components, so there are drivers already written for all these devices. It’s just a matter of including the correct drivers and providing default configurations that work and settings dialogs if anything might need user input. This is all being worked on in parallel, and the consensus is that we are already in a better place than we were for the Pi 3.

It’s All Open Source so Why not Copy from Rasbian?

The Raspbian kernel is open source so anyone can look at that source code, but the EEPROM firmware is not open source. This can be reverse engineered, but that takes time. The Raspberry Pi foundation has been quite helpful in supporting people, but that is no substitute for reading the source code. This again shows the importance of open source BIOS.

Development got off to a slow start, because the Raspberry Pi foundation didn’t give anyone a heads up that this was coming. The developers of Ubuntu Mate had to order their Raspberry Pi 4’s just like everyone else when the announcement happened. This meant no one really got started until into July.

In spite of claiming up and down that they will never produce a 64-bit version of Raspbian, the Raspberry Pi foundation has produced a test Raspbian 64-bit Linux kernel. This then tests out that the Raspberry Pi firmware will support 64-bits and that all the device drivers are available. I couldn’t get this kernel to work, but it is proving very helpful for other developers. It also makes people excited that maybe Raspbian will go 64-bit sooner than later.

How Are We Doing?

The first distribution to get all this going is Gentoo Linux. They have a very smart developer Sakaki who provided the first image that actually worked. This then led to Arch and Majaro Linux releases based on Gentoo. This was a good first step, though these distributions are more for the DIY crowd due to their preference to always installing software from source code.

Next James Chambers put together a guide and images to allow you to install Ubuntu Server 64-bit on the Pi 4. Ubuntu Server is character based, but installing a desktop is no problem. The main limitation of this release is that you need a hardwired Internet connection to start. You can’t start with Wifi as the Wifi software isn’t installed with the base image. If you do have a wired Internet connection, getting it installed and installing the desktop is quite straightforward and works well. Once you have the desktop installed, then you can configure Wifi and ditch the ethernet cable.

The changes required for the Raspberry Pi 4 are being submitted to the standard Linux kernel for version 5.4. When this ships it will have available drivers for the Pi 4 hardware and official support for the Broadcom chips used in the Pi. Version 5.3 of the Linux kernel just shipped and added support for the NVidia Jetson Nano. Hopefully the wait for Linux 5.4 won’t be too long.


I’ve been running the 64-bit version of Ubuntu Linux Server, with the Xubuntu desktop for a few days now and it works really well on my Raspberry Pi 4 with 4Gig of RAM. Performance is great and everything is working. I’ve installed various software, including CubicSDR which works great. This is the first time I’ve been happy with Software Defined Radio running on a Pi.

I look forward to the official releases, and given the state of the current builds, think we are getting quite close.

Written by smist08

September 20, 2019 at 6:38 pm

Refurbishing an Old Laptop

with 2 comments


My wife typically used an HP laptop running Windows 10. This laptop is probably about three years old now. Unfortunately she dropped it off the bed onto a cement floor (she claims one of the dogs pushed it off the bed, but I’m suspicious). She actually broke its fall with her foot which is very bruised now, and then it hit the floor after her foot. The laptop then stopped working. She took the laptop to a coffee shop and spilled coffee on it. This didn’t help. She then gave it to me to see if I could get it working. I took it apart to see if it was just a matter of some wires coming loose. Sadly this wasn’t the case. This blog article recounts my attempts to disassemble and repair the laptop, which I successfully accomplished. I’m writing this article on said laptop, while my wife now uses my MacBook Air.

Diagnosing the Problem

On bootup the laptop displayed a text message prompt saying no boot device present. To me this meant that the screen and processor were still working and that the likely problem was the hard drive. After all the harddrive is mechanical with moving parts and likely to be damaged by a shock such as hitting the floor (or a foot). So my first thought was to take it apart and ensure the cables connecting the harddrive were in place.

Opening the Case

It turns out an HP laptop is held together by a lot of screws and many of the screws are hidden behind plastic plugs, the laptop’s feet and various other sneaky bits of plastic. Plus there is a bead of glue around the case that needed to be broken. My first attempt to remove all the screws didn’t allow me inside. Fortunately for doing DIY repairs, there is YouTube. Doing a quick search revealed lots of videos on opening HP laptops and showed a lot of complaining about how HP makes this unnecessarily complex. Anyway watching one of the videos revealed to me where to look for the additional screws (behind some nondescript covers) and allowed me to get the case open.

I removed the hard drive, made sure all the cables were snug and put it back together. And the same result. So I assumed the harddrive was either physically broken or the boot sectors had somehow been erased. So I thought I may as well try installing Ubuntu Linux and repurpose the laptop as a Linux machine. After all running Windows 10, the laptop has been getting slower and slower, so giving up on Windows 10 seemed like a good idea.

Installing Ubuntu Linux

I downloaded an ISO image of Ubuntu Linux for desktop computers. And then installed this onto a USB key to make a bootable USB with Linux. I did this on a really old AMD Windows 7 laptop. Its slow but it’s always been reliable and since I’ve uninstalled nearly everything from it, it works fairly well. Anyway Ubuntu has really good instructions on how to do this at their website. You just download the ISO image and then use the Rufus utility program to copy it to the USB making it bootable.

I then put it in the damaged laptop and booted it up. At this point I could run Ubuntu Linux from the USB or run the Ubuntu installation program. That both of these worked gave me more confidence that the only problem was the laptop’s hard drive. Anyway I went ahead and tried to install Ubuntu Linux, which goes quite a long way before it finally tries to format the hard drive. This failed. So I concluded the harddrive was physically damaged and useless.

Fortunately I have a couple of other laptop hard drives lying around from even older laptops which I could try. The first one I tried didn’t work, so I guess that one is toast as well. But the second one I tried worked. The Ubuntu installation program was able to format the drive and the installation finished successfully. My impression is that installing Linux is now even easier than installing Windows. It didn’t ask too many questions. The screens were simple and easy to understand.

Now I had the laptop restored. Even using the old harddrive, my impression is that the laptop is much faster now running Ubuntu. Of course now I don’t need to run all that Windows stuff that slows computers down so much (like Windows Defender).

Adding Programs

Ubuntu, like Raspbian is based on Debian Linux so anything I’ve blogged about installing things on my Raspberry also works pretty much the same. Plus Ubuntu comes with Firefox, LibreOffice and a number of other useful programs already installed. I was able to quickly add Chrome, Macchanger, Gimp and Tensorflow. For amateur radio there is a program called Chirp that can be used to program most radios. I never got Chirp to talk to my radio from my MacBook due to supposed driver incompatibilities with the USB to serial cable. But when I added Chirp to Ubuntu, it just worked and communicated with my radio no problem, first try.

With my MacBook I use an external drive to hold my photo library since its so large. I use one that is formatted for the MacOS filesystem, so I wasn’t sure it would work connected to Ubuntu, but when I plugged it in, Ubuntu recognized it and automatically mounted it with no problems. I imagine this is since both operating systems are Unix based and their file systems are compatible. I’ve never tried to make this work with Windows, because the instructions are rather daunting and require quite a bit of extra software to be installed.


The end result of all this is that I have a new refurbished laptop which I’m now using as my regular laptop running Ubuntu Linux. My wife is happily continuing writing her novels on the MacBook Air. And at least for now we don’t need to buy a new laptop. Perhaps we will down the road if we see a really good deal, but it isn’t an emergency. I never feel rushed to buy a new computer since they keep getting better all the time, plus prices are bit high right now because of the run on graphics cards by people doing BitCoin mining. Might be nice to let this run its course first.


Written by smist08

February 1, 2018 at 9:48 pm

Posted in Life

Tagged with , , ,

The Road to TensorFlow – Part 1 Linux

with 12 comments


There have been some remarkable advancements in Artificial Intelligence type algorithms lately. I blogged on this a little while ago here. Whether its computers reading hand-writing, understanding speech, driving cars or winning at games like Go, there seems to be a continual flood of stories of new amazing accomplishments. I thought I’d spend a bit of time getting to know how this was all coming about by doing a bit of reading and playing with the various technologies.

I wanted to play with Neural Network technology, so thought the Google TensorFlow open source toolkit would be a good place to start. This led me down the road to quite a few new (to me) technologies. So I thought I’d write a few blog posts on my road to getting some working TensorFlow programs. This might take quite a few articles covering Linux, Python, Python libraries like Pandas, Stock Market technical analysis, and then TensorFlow.


The first obstacle I ran into was that TensorFlow had no install image for Windows, after a bit of Googling, I found you need to run it on MacOS or Linux. I haven’t played with Linux in a few years and I’d been meaning to give it a try.

I happened to have just read about a web site that provides VirtualBox and VMWare images of all sorts of versions of Linux all ready to go. So I thought I’d give this a try. I downloaded and installed VirtualBox and downloaded a copy of 64Bit Ubuntu Linux. Since I didn’t choose anything special I got Canonical’s Unity Desktop. Since I was trying new things, I figured oh well, lets get going.

Things went pretty well at first, I figured out how to install things on Ubuntu which uses APT (Advanced Packaging Tool) which is a command line utility to install things into Ubuntu Linux. This worked pretty well and the only problems I had were particular to installing Python which I’ll talk about when I get to Python. I got TensorFlow installed and was able to complete the tutorial, I got the IDLE3 IDE for Python going and all seemed good and I felt I was making good progress.

Then Ubuntu installed an Ubuntu update for me (which like Windows is run automatically by default). This updated many packages on my virtual image. And in the process broke the Unity desktop. Now the desktop wouldn’t come up and all I could do was run a single terminal window. So at least I could get my work off the machine. I Googled the problem and many people had it, but none of the solutions worked for me and I couldn’t resolve the problem. I don’t know if its just that Unity is finicky and buggy or if it’s a problem with running in a VirtualBox VM. Perhaps something with video drivers, who knows.

Anyway I figured to heck with Ubuntu and switched to Red Hat’s Fedora Linux. I chose a standard simple Gnome desktop and swore to never touch Unity again. I also realized that now I’m retired, I’m not a commercial user, so I can freely use VMWare, so I also switched to VMWare since I wondered if my previous problem was caused by VirtualBox. Anyway installing TensorFlow on Fedora seemed to be quite difficult. The dependencies in the TensorFlow install assume the packages that Ubuntu installs by default and apparently these are quite different that Fedora. So after madly installing things that I didn’t really think were necessary (like the Gnu Fortran compiler), I gave up on Fedora.

So I went back to and downloaded an Ubuntu image with the Gnome desktop. This then has been working great. I got everything re-installed quite quickly and was back to being productive. I like Gnome much better than Unity and I haven’t had any problems. Similarly, I think VMWare works a bit better than VirtalBox and I think I get a bit better performance in this configuration.

I have Python along with all the Python scientific and numerical computing libraries working. I have TensorFlow working. I spend most of my time in Terminal windows and the IDLE3 IDE, but occasionally use FireFox and some of the other programs pre-installed with the distribution.


I’m greatly enjoying working with Linux again, and I’m considering replacing my currently broken desktop computer with something inexpensive natively running Linux. I haven’t really enjoyed the direction Windows has taken after Windows 7 and I’m thinking of perhaps doing most of my computing on Linux and MacOS.


I am enjoying using Linux again. In spite of my initial problems with Ubuntu’s Unity Desktop and then with Fedora (running TensorFlow). Now that I have a good system that seems to be stable and working well I’m pretty happy with it. I’m also glad to be free of things like App stores and its nice to feel in control of my environment when running Linux. Anyway this was the small first step to TensorFlow.

Written by smist08

August 23, 2016 at 11:40 pm