Stephen Smith's Blog

Musings on Machine Learning…

Raspberry Pi OS Goes 64-Bit

with 3 comments


Introduction

The Raspberry Pi Zero 2, Raspberry Pi 3 and Raspberry Pi 4 all sport a 64-bit ARM CPU; however, the Raspberry Pi OS has remained at 32-bits until now. This new 64-bit version of the Raspberry Pi OS has been in beta for over a year and was finally officially released on February 2, 2022. Raspberry’s previous argument for staying at 32-bits was that they produced one operating system that worked on all Raspberry Pi’s no matter how old; however, there are quite a few compelling reasons to move to 64-bits so I’m glad they finally made the move.

This isn’t the first 64-bit Linux for Raspberry Pis. Many of the standard distributions including Kali and Ubuntu Linux have been shipping 64-bit versions since shortly after the Raspberry Pi 3 came out. My book, “Programming with 64-Bit ARM Assembly Language”, was written using the 64-bit version of Kali Linux, except for the parts specifically for Android or iOS.

Raspberry will still be releasing their OS in both 32-bit and 64-bit flavors for quite some time, so if you don’t want to move, you don’t have to. In this article we will have a quick look at some aspects of the new 64-bit version.

How Does it Run?

First off, even though it will run on a Raspberry Pi 3 or even a Raspberry Pi Zero 2, I wouldn’t recommend it. A 64-bit operating system uses more memory than the corresponding 32-bit version and 1 Gig of RAM isn’t enough. To use this, you really need a Raspberry Pi 4 with at least 4 Gig of RAM. On my Raspberry Pi 4 with 8 Gig of RAM, it is noticeably peppier than the 32-bit version, especially when browsing with Chromium.

Installing the 64-bit operating system is nearly identical to installing the 32-bit version. It has been added to the list of operating systems in the Raspberry Pi Imager. By default the imager will install the 32-bit version, but you can choose the 64-bit from the “Raspberry Pi (other)” menu. From that point on it is hard to tell the difference. When you boot the new image it first resizes the filesystem for your SD card, then boots the Raspberry Pi OS as usual and puts you in the same setup wizard as you get in the 32-bit version, asking the same questions about timezone, wifi and whether the menu fits on your monitor. After installing any updates, it reboots and you are happily running the 64-bit version.

The only caveat that Raspberry lists is that the Chromium library for running streaming services like Netflix is missing. This isn’t something I do and I’m sure it won’t be long. Otherwise all the usual Raspberry Pi programs are there and from my experience using Kali and Ubuntu, most things are available to install through the apt system. In fact one of the reasons Raspberry was finally forced to move to 64-bit is that several software packages have dropped 32-bit support.

Why Move to 64-Bit?

The Raspberry Pi OS has been around for a while in 32-bits, the advantage is that it runs on all Raspberry Pi’s no matter how old and it runs in compact memory footprints of 512 MB or 1 Gig. It runs a vast library of open source software and has provided a great platform for millions of students and DIY’ers. However, most of the rest of the world including mainstream Linux, Windows, MacOS, Android and iOS have all been 64-bit for some time. So let’s look at some reasons to move to 64-bits.

  1. Memory addressing simplifies, making life simpler for Linux.
  2. In 64-bit mode, each ARM CPU has twice as many general purpose registers (32 vs 16) allowing programs to keep more variables in registers, saving loading and storing things to and from memory.
  3. All new compiler optimizations are targeting the ARM 64-bit instructions set, not much work is being done on the 32-bit code generators.
  4. The CPU registers are now 64-bits, so if you are doing lots of long integer arithmetic, it will now be done in one clock cycle rather than taking several under 32-bits.

All that being said, there are a couple of disadvantages, namely 64-bit tends to take more memory due to:

  1. If integers are 64-bit, rather than 32-bit then it takes twice as much memory to hold each one.
  2. Normal ARM instructions are 32-bits in size when running in either 32-bit or 64-bit mode. However in 32-bit mode there is a special “thumb” mode where each instruction is only 16-bits in size. Using these can greatly reduce memory footprint and the GCC compiler supports producing these as an option.

Summary

Raspberry has done a good job making their 64-bit operating system painless to use. It is a direct 64-bit compilation of the current 32-bit one, and most users wouldn’t know the difference, unless they know where to look. I find the 64-bit version noticeably peppier than the 32-bit version and so far everything works as expected. The future is 64-bit and better late than never.

If you are interested in learning more about ARM’s 64-bit architecture, check out my book: “Programming with 64-Bit ARM Assembly Language”.

Written by smist08

February 4, 2022 at 11:43 am

3 Responses

Subscribe to comments with RSS.

  1. I just found your blog and am using a feed reader to receive posts. Every post arrives twice in my feed. Is there something you can do about that?

    Tom

    February 4, 2022 at 5:24 pm

    • Sorry Tom, that is a feature of wordpress.com that I don’t have any control over.

      smist08

      February 5, 2022 at 10:20 am

  2. […] second article looks at writing Assembly Language for the 64-bit version of Raspberry Pi OS. This tutorial shows how to access memory, use 64-bit registers, use loops, […]


Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.