Google is currently working on a new operating system, code name Fuchsia OS. The project was started in 2016 and its source code was made available on the Fuchsia official website in 2019 as well as the documentation. The Fuchsia project is built on top of the Zircon kernel.
The Google Nest Hub is the first product that runs on Fuchsia OS. The source code of Fuchsia is available to download for the public (more specifically for the developer’s community).
In this article, we will talk about the Fuchsia operating system, why Google is developing it?, will it replace Android? and the step-by-step process of downloading and building google’s new fuchsia operating system using the source code. The reason behind writing this article is to help developers set up the development environment for Fuchsia correctly so that they can play with the operating system as well as if the project feels interesting to them then they can make some meaningful contributions towards the growth of the project.
There is no doubt that the Fuchsia documentation itself is easy to get through. But there are some things in the documentation which might be confusing or difficult to understand for beginners developers and that’s where this article will come into the picture. You can perform the steps mentioned below either on a 64-bit Linux machine (any distribution will work) or on a 64-bit MAC. Windows and ARM64 Linux are not supported. I have used a Linux machine (Ubuntu) for downloading, building, and flashing the Fuchsia OS.
Previously, I have written an article about the Android open source project (AOSP) Android 11, If you are interested in that do check it out.
Will Fuchsia OS replace android oS?
The Android OS is a popular and widely used OS that runs on billions of devices. But the problem with Android is that lots of manufacturers do not provide the latest updates to their previously manufactured devices (< a year old). This creates a huge security issue. Also, the Linux kernel (even though it’s optimized for low-powered devices), causes some performance issues.
Since the Android OS itself is improving in terms of features, bug fixes, and security patches but these things are not reaching the end-users. And very few devices are able to take advantage of these things. To resolve all such issues, Google is trying to build another operating system that can provide both security as well as performance. But this time they are not just targeting phones or tablets they are also focusing on all the other types of devices like Desktops, Laptops, and MAC’s as well.
Ultimately, Google is a business-driven company, profits are always on the higher priority. If a product can’t generate the profits as expected then they literally scrap those products. And this is not just about Google, almost every product-based company does this. This doesn’t mean that the Android OS is going away anytime soon. The Fuchsia project is still at the early stages of its journey and only time will tell whether it will replace Android or not.
Layers of Fuchsia OS
The Fuchsia OS consists of 4 layers. At the bottom, we have the kernel itself but this time Google has developed its own kernel in-house which is known as the Zircon kernel. The Zircon kernel is made open source (/zircon/kernel).
On top of the zircon layer, we have the Garnet layer which contains the device drivers (networking, graphics, etc) and the software installer. This layer also contains Escher (graphics renderer), Amber (software updater), and Xi code (Text and code editor).
The Peridot is the third layer that handles Fuchsia’s modular application design. It also has a Ledger that is used to sync files across devices. This layer also provides artificial intelligence support called Maxwell which dynamically optimizes the performance of your device based on how you use your phone by enabling or disabling some of its features. At the top, we have the Topaz layer which supports the UI which is designed with Flutter. Armadillo is the name of the Flutter main UI.
System check and Installing Packages required for building Fuchsia OS
To build the Fuchsia OS you will need to download 3 packages, curl, unzip, and git. You can easily download and install these packages by running the following command inside the terminal.
sudo apt-get install curl git unzip
Before starting out, first, we have to check whether the system on which we will be building the Fuchsia source code will be able to successfully build the Fuchsia source code or not. For that, Fuchsia provides us with a tool called ffx platform preflight. The below command will download and run the tool.
curl -sO https://storage.googleapis.com/fuchsia-ffx/ffx-linux-x64 && chmod +x ffx-linux-x64 && ./ffx-linux-x64 platform preflight
In my case, everything is in green except the 2nd and the 3rd warning. If you get the third warning you can run the two commands which are shown below the warning and it will fix that warning. After that, you can again run the above command to check the status. You can ignore the second warning, here it’s unable to detect the Nvidia graphics card but it is able to detect Intel’s integrated graphics which is fine.
Download the Fuchsia OS source code
Since the Fuchsia OS is not that large in size, therefore the process of downloading the Fuchsia source code will hardly take around 40 – 60 min. It’s not like Android source code which is large in size that takes almost half of the day for the download process to complete.
To download the Fuchsia source code, you can create a new directory anywhere on your system and then go inside that directory as shown below.
mkdir fuchsia_source && cd fuchsia_source
And then run the below command which will create a directory called fuchsia and inside this directory, it will download the entire source code of the Fuchsia OS. Make sure you have around 60GB of free space.
curl -s "https://fuchsia.googlesource.com/fuchsia/+/HEAD/scripts/bootstrap?format=TEXT" | base64 --decode | bash
Now let this process run. Till then you can take a break and enjoy some coffee ☕ and come back again after few minutes ⌛.
The download process is now complete. Now you have to add the bin directory to the PATH. For that, go inside your bash file (gedit ~/.bashrc) and paste the below two lines at the bottom of the bash file.
export PATH="~/fuchsia_source/fuchsia/.jiri_root/bin:$PATH" source ~/fuchsia_source/fuchsia/scripts/fx-env.sh
After that, update the environment variables using source.
To check if everything is set up correctly, go inside the fuchsia directory using cd and run the below commands. If you get no errors which mean everything has been set up correctly.
// Run below commands inside fuchsia directory jiri help fx help
Configure and Build the Fuchsia OS source code
For building the source code, we first have to select the product (core or workstation) and the board (x64 or qemu-x64). The core is a product that has minimum features were as the workstation product will have all the features. You can select any one of them, for this tutorial we will use the workstation product with the qemu-x64 board. To set the workstation and the qemu-64 as a target run the following command.
fx set workstation.qemu-x64
After selecting the target device, we can start building the Fuchsia source code as follows.
The building process will take around 1-2hrs to complete.
Flashing Fuchsia OS on the Fuchsia Emulator (FEMU)
We have now reached the final stage where we will be flashing and running the Fuchsia OS on the emulator. The emulator which we will be using is known as Fuchsia Emulator (FEMU). This emulator is available inside the source code itself.
If you don’t want to connect the fuchsia emulator with the external network then you can simply run the following command. Make sure that you are inside the fuchsia directory while running the below command.
fx vdl start -N
If you want to provide internet access to the fuchsia emulator then you can run the below command.
fx vdl start -N -u scripts/start-unsecure-internet.sh
After the operating system boots up, this is how it will look like.
You can play with the terminal by running the Fuchsia command and access any website using the built-in web browser.
If you check the terminal window, then you will notice that there is a prompt. Here, you can execute Fuchsia commands and try to interact with the Fuchsia OS.
To learn more about the Fuchsia commands and how it works you can visit Explore Fuchsia on fuchsia.dev website.
This was the entire process of downloading, building, and flashing Fuchsia OS on the emulator. Thanks for the read. If you like the content then support us on Patreon. Your support will surely help us in writing more of such content.
To read more such blogs about Fuchsia, open source or AOSP related stuff visit our blogs page on LionGuest Studios.