Although Android is based on Linux, both architectures are quite different. This can be seen even in the example of low-level C language routines, which Google exchanged for Android. In addition to this, Google prohibits all code that's licensed under GPL (GNU Public License). For this reason, Android only implements a rudimentary shell featuring only a few shell commands. Due to the C-library incompatibilities, normal Linux code, even if it's especially compiled for the ARM architecture, will not run under Android. Nevertheless, Android is a very popular operating system (OS) that's used by many phones and tablets. It fully supports graphic hardware in terms of accelerated video and 3D graphics. For this reason, the first Banana Pro version of
Kodi (formerly known as
XBMC and
Xbox Media Centre) made use of an accelerated Android graphics library (refer to Chapter 4, An Arcade Cabinet).
Applications for Android can be developed using a special
software development kit (SDK) and Java itself as most Android applications are based in Java. Although this book concentrates on Linux projects rather than Android projects, we will take a short look at Android on Banana Pro.
LeMaker provides three different Android images: one for a 5 inch TFT, the second for a 7 inch TFT, and the third using the HDMI cable as a video output. To install an Android OS, simply download the required version. You most probably want to start with the HDMI enabled version. Use PhoenixCard (as seen in the previous section) in order to write the image to an SD card. Insert this SD card and boot Android. After a while, the start screen of Android will be visible.
Android can be controlled by using a keyboard and mouse. Bluetooth and WLAN will work out of the box and some applications are already preinstalled.
There are a variety of Linux distributions available on the LeMaker download site (Figure 13). The most famous operating systems are Raspbian, Bananian, Lubuntu, and Gentoo. LeMedia, a special Linux distribution that provides the Xbox media center, Kodi (formerly known as XBMC), is not available on the official LeMaker download website. We will later on compile and install XBMC for other operating systems such as a Debian distribution. No matter which Linux OS you decide on incorporating, the procedure is always the same: Copy the image to an SD card and boot the card within Banana Pro.
After copying the image, the SD card will contain a directory called /boot
. This directory contains the Linux kernel (called uImage
; refer to Chapter 2, Programming Languages, for this), a file called uEnv.txt
, and a binary file (usually script.bin
or bananapro.bin
). The uEnv.txt
file contains kernel parameters, such as screen resolutions, and the binary file contains the complete settings for Banana Pro with respect to all connectors.
My uEnv.txt
file looks like this:
It defines /dev/tty1
as a console terminal, uses the first partition of an SD card as a root device (/dev/mmcblk0p1
), and provides some additional kernel parameters. The video output mode is completely HD progressive (1920x1080p50
). The binary file is called bananapro.bin
in my case, and the kernel is uImage
within the /boot
directory. The function of the binary file is described in the next section (the FEX file).
For my experiments, I've used a Banana Pi Linux image of Igor Pečovnik (http://www.igorpecovnik.com/2014/09/07/banana-pi-debian-sd-image/), which I adapted to Banana Pro. In the meantime, the Banana Pi image is compatible with Banana Pro.
I recommend that you download the Debian Wheezy version that comes with kernel 3.4. Although this kernel is not up to date, it enables all the hardware features of Banana Pro as opposed to kernel 4.2, which, for example, neither has an audio driver nor an accelerated video output.
The image itself is based on Debian Wheezy and comes with kernel 3.4. Similar to Bananian, this distribution does not come with any X11 server or display manager. Therefore, I've installed the MATE
Windows manager and the slim
login manager. Similar to the X11 framebuffer driver, I've used sources from https://github.com/ssvb/xf86-video-fbturbo. This driver requires a number of packages to be installed first as follows:
Now, acquire the sources of xf86-video-fbturbo, compile them, and then install them as follows:
Afterwards, copy the default xorg.conf
file to the location of your xorg.conf
like this:
Do not forget to back up any existing xorg.conf
files first. In Chapter 4, An Arcade Cabinet, we will install accelerated Mali drivers for a desktop in addition to a framebuffer turbo driver.
MATE needs to be installed from the Debian Wheezy backports. Add deb http://http.debian.net/debian wheezy-backports main
to the /etc/apt/sources.list
file. This can be done using this command:
Afterwards, run the following shell commands:
In order to install the MATE desktop and slim, a configuration can be done in the /etc/slim.conf
file. I've added/changed the following lines:
The first line disables access control to the X-windows server. This is needed later on in Chapter 4, An Arcade Cabinet. In addition to this, screensavers and power management for the X-server are switched off. The second line sets the default user as the pi
user. The last line allows the pi
user to automatically log in without providing a password.
This user pi
can be added to the system using this shell command:
You need to answer all the questions prompted by the system and use the pi
as a username.. Most Linux distributions provide an already secure shell access (ssh
). If not, simply install the openssh
server by typing the following command that will enable a remote login with ssh
on port 22
:
Banana Pro reads interface settings from a binary file called script.bin
or bananapro.bin
that is located in the /boot
directory. This file defines video output, GPIO selection, and much more. Each value consists of a key = value
pair combination under a [sectionheader]
. All three entries are case-sensitive. A complete selection of all possible entries can be found at http://linux-sunxi.org/Fex_Guide.
The FEX files can be compiled into a binary file (and recompiled into an ASCII FEX file) using the fex2bin
or bin2fex
commands. These tools are available on GitHub (sunxi-tools
is available at https://github.com/linux-sunxi/sunxi-tools). The sunxi-tools
require libusb
as a prerequisite.
Additionally, git
will be installed. Git can be used in order to clone a directory that's available on the Internet on a local SD card or hard disk using this command:
Afterwards, clone the sunxi-tools
repository and then build and install the tools:
The syntax of fex2bin
and bin2fex
is easy. Simply provide two filenames (the original and the converted one, respectively). Take a look at the following example:
This will generate a new script.bin
binary file that's based on the script.fex
ASCII file in the /boot
directory.
Tip
If uEnv.txt
redefines, for example, display settings as compared to script.bin
, this file will be preferred over script.bin
.
A typical display section in the FEX file looks like this:
The section header of the FEX file is [disp_init].disp_init_enable
, the value of which can be either 1
(enabled display output) or 0
(disabled display output). The display mode is a value between 0
and 4
according to the following table:
Table 2: The display modes for Banana Pro
The screen0_out_color_range
mode defines the output color for HDMI. It applies to both screen0
and screen1
. Therefore, there is no screen1_out_color_range
. The output color range can be set according to the following table:
Table 3: The output color range for Banana Pro
The screen0_output_type
mode sets the output type for screen0
according to the following table. Therefore, use screen0_output_type
accordingly:
Table 4: The output types for Banana Pro
The following screen output modes (screen0_output_mode
and screen1_output_mode
) can be defined for screen0
and screen1
:
Table 5: The screen output modes for Banana Pro
The fb0_framebuffer_num
value is the number of framebuffers to be used for the 0
framebuffer. It can be set to 2
for double buffering. Use fb1_framebuffer_num
accordingly. The pixel format for both framebuffers can be defined as fb0_format
or fb1_format
according to this table:
Table 6: The framebuffer format for Banana Pro
The framebuffer pixel sequences (fb0_pixel_sequency
and fb1_pixel_sequence
) must be set to 0
for Linux and 2
for Android operating systems (refer to this table):
Table 7: The framebuffer pixel sequence for Banana Pro
The Framebufferscaler
mode can be enabled or disabled for both framebuffers (fb0_scaler_mode_enable
and fb1_scaler_mode_enable
). Use a value of 0
to disable the scaler
mode and a value of 1
to enable the scaler
mode. The Scaler
mode may improve the picture quality of some settings. The lcd0_backlight
is a value between 0
and 240
and sets the PWM rate on a selected PWM GPIO. The same is true for lcd1_backlight
. All the remaining settings are self-explanatory.
LeMaker provides special configuration files that can be used with LCD screens (refer to The LCD module section).
Transferring an OS to a hard disk
Banana Pro cannot boot directly from a hard disk. This section will show you how the Linux operating system can be copied from a microSD card to a hard disk and how a system can boot into the OS of the hard disk.
First, boot your Banana Pro with a connected hard disk (SATA and DC). The kernel messages will show the SATA device (usually /dev/sda
). In order to get a filesystem overview, the lsblk
command can be used. This command will list the complete filesystem including the attached hard disk.
Verify the contents of the hard disk using the following command:
Principally, the available hard disk space must be equal to or larger than the size of the SD card in order to host the OS. The fdisk
command can be used to partition the disk in terms of erasing or adding hard disk partitions. Use this program with care as it can delete everything that exists on your hard disk. The following steps assume an empty hard disk or a hard disk whose content is not needed any more.
The hard disk can be partitioned using the fdisk
command:
The p
(print) command will print partition table:
Existing partitions can be removed using the d
(delete) command:
New partitions can be added using the n
(new) command:
The w
(write) command writes all changes to the disk:
After this, the fdisk
write command will automatically quit. If no other partitions (for example, swap) are required, you can press RETURN
when prompted for the first and last sectors. In its simplest sense, a swap partition serves as an overflow to Banana Pro's memory (RAM). It might be useful when compiling huge software packages such as Kodi (formerly known as XBMC). As an alternative, a file on a hard disk or SD card can be used for swapping. A swap partition itself has the 82
partition ID, which can be changed using the t
(toggle) command followed by the ID. Swap partitions can be formatted using the following command:
X
represents the swap partition (for example, 6
). Swap partitions will be activated as follows:
New (empty) partitions must be formatted before usage. The following command formats the first partition (sda1
) with the .ext4
filesystem and labels it as rootfs
. In doing so, all existing data on this partition will be erased. Therefore, use this command with caution and only format empty partitions or partitions whose content is not needed any more:
In this step, the complete data from the microSD card will be copied to the hard disk. In our example, the first partition of the hard disk will be mounted into the /mnt
directory; rsync
will be used to transfer all data to the directory:
The complete copy process will take a while. In the last step, the boot parameters of the uEnv.txt
file will be adjusted to use the hard drive. Change root=/dev/mmcblk0p1
in the /boot/uEnv.txt
file to this:
This can be done using the nano
editor by typing this:
Finally, restart Banana Pro with the following command:
The system should be redirected from the microSD card to the hard disk right now. A df -h
command on my system delivers the following (320 GB of free hard disk space):
Tip
If you want to make any changes to uEnv.txt after booting to the hard disk, you will need to mount the SD card first, change into the SD card boot
directory, and edit uEnv.txt
accordingly:
The same applies to the installation of a new kernel (refer to Chapter 2, Programming Languages).
The gparted
software is a graphical frontend for fdisk
and other tools. It is very useful to add, delete, or even resize partitions. It may later be required for backups, where it can be used to shrink a partition, for example, on an SD card in order to use windisk32imager
to copy the contents of the SD card to the backup medium.