5 Best Practices for Porting of Android OS to the Embedded Platforms
Android is undoubtedly one of the most successful Linux based operating systems in the world.
Although it gained prominence with its implementation in smart phones and later in wearables, porting of Android OS in embedded systems has also recently garnered a lot of attention.
Starting with consumer electronics like set-top boxes, smart televisions and gaming consoles, porting of Android is also very popular fo the automotive and IoT applications like Infotainment, HUD and likes.
One of the most striking advantages of porting Android OS to the embedded platforms is the compatibility of developed applications for one platform across different platforms with minimum tweaking.
As we move forward, we will discuss more such advantages and how to go about porting Android to the embedded systems.
What is Meant by Android OS Porting?
OS porting in its general terms refers to the modification of the operating system to make it suitable to run on a different hardware architecture than the OS is intended for.
For instance, if a Linux OS is designed to originally run on a personal computer based on Intel X86 or X64 architecture but business-use requires it to be loaded to an embedded system, some changes in the Linux OS is mandatory.
This set of changes is called OS Porting and when the operating system to be ported is Android, the process becomes Android Porting.
Android’s Compatibility with Embedded Platforms
Android OS runs on a Linux Kernel and its development and testing have been performed on various ARM platforms. Therefore, porting Android to an ARM-based embedded system does not require many changes.
Since, Android OS also finds its implementation in Automotive industry, porting Android to I.MX6 (a widely used hardware platform in multimedia applications) is also quite prevalent these days. Such porting will also require BSP (Board Support Package) customization.
BSP is beyond the scope of the blog and will be discussed in more detail in upcoming blogs.
P.S: In a nutshell, a BSP is an interface that enables the communication between the OS kernel and the hardware assets like microcontroller etc.
Best Practices for Porting of Android to the embedded platforms
As Android stack is built on top of a Linux Kernel, Android porting starts with the porting of the kernel and then the Android Stack.
However, before the actual porting is executed, following are some of the best practices one can follow to ensure efficient and successful Android porting.
- Always design a 2 Stage Bootloader: The first step of Android Porting is to install the bootloader. For X86 platform, one of the widely used bootloaders is GRUB. The reason for using a 2 stage bootloader is to have ample space for installing a 32-bit kernel along with error-handling codes.
- Low memory footprint for the bootloader: Memory footprint is the amount of main memory required for running of any program. By keeping the memory footprint of the bootloader low, maximum memory is made available for the main application that is designed to solve a specific business problem/use-case.
- Code as per Linux/Android standards to ensure bug-free drivers: This goes without saying that the driver customization you make while Android porting must conform to the Linux/Android coding standards.This ensures bug-free and easily maintainable drivers. One of the pointers that the developers also need to keep in mind is that the code is free from any unused or uninitialized variables.
- Fault-handling and error recovery implementations: Handling exception is not enough if you wish to keep the Android OS up and running at all times in an embedded environment. As an Embedded System Developer, one should make sure that the OS is able to recover from the error and report the cause.
- After-boot practices: In the final step of porting, the Android kernel merged with the reference kernel is configured and built and Android file system is setup. After the booting is executed, one of the most common mistake is to expect Android file system to offer similar functionality as Linux file system or work like it. This needs to be avoided.
Although Android was built keeping mobile phones in mind, its potential as a preferred OS for embedded system is quite evident.
Consumer electronics, automotive and IoT are some of the industries that are readily embracing Android.
It is important that the product engineering services companies and the embedded system developers must develop relevant expertise and experience to effectively partner with customers for successful Android porting projects.