2015-04-18

The Raspberry Pi is the most popular single-board computer with more than 5 million sold. While there are numerous Linux Distributions that run on RPI including Raspbian, Pidora, Ubuntu, OSMC, and OpenElec, the Tizen OS does not currently run on it. Since Tizen is being positioned as an important player within the growing Internet of Things (IoT) ecosystem, providing a Raspberry PI 2 port can help developers gain more Tizen experience. For this reason, the Samsung Open Source group decided to work on such port. This article will go over how to build a bootable Tizen image for Raspberry Pi from a computer running Linux.

The Raspberry Pi 2 has several advantages over the first version. Among them:

It has a quad-core CPU

It runs at 900 MHz

It uses an ARM Cortex-A7 CPU

The ARM Cortex-A7 CPU is very nice since most distributions are compiled to use the arm instruction set found on ARMv7 processors.

Initial Tests

Before doing a native Tizen build, we needed to determine if the new Raspberry PI2 was capable of running Tizen. To do this, we used a small trick: we downloaded a pre-built Tizen image found at tizen.org and borrowed a Debian boot image. Since the Tizen root image was built for ARMv7, the image ran properly on Raspberry Pi 2, except for a few issues related to graphics. That gave us enough confidence to go to step 2: building the boot image and root machine targeted for Raspberry Pi2.

Building Images on Tizen

Currently, as described on the Tizen Wiki, there are two ways used to build a Tizen image:

Via GBS: The “traditional” way, which requires setting up a GBS server to compile several packages

Via Yocto: The “new” way, which uses OpenEmbedded bitbake recipes to generate the image. This can easily be done on a user’s machine, provided a good Internet link is available.

GBS would require a lot of time, and we would need to allocate a dedicated build server, because of this, we decided to use Yocto to produce the images.

Creating a Tizen image for Raspberry PI2

BEFORE STARTING: As Yocto build will download lots of packages, you should ensure that your firewall policy won’t be blocking ftp, http, https and git protocols, as otherwise the build may fail.

1) Create a Local Copy of tizen-distro

The first step is to clone the Tizen distro tree. We actually use an alternate version of the already existing tizen.org tizen-distro tree.

Our variant has some patches on the top of the tree that allows building Tizen for ARM CPUs. It also disables the usage of the Open Source mesa/gallium 3D driver, since the Broadcom GPU used on Raspberry PI2 is not currently supported by this open source driver. The plan is to rework these patches to submit them to Tizen upstream, without breaking anything for x86.

To create the clone, do the following from any terminal window:

2) Add Raspberry PI 2 BSP Meta Repository

Yocto works with several layers of software. The BSP (Board Supported Package) layer provides support for the board, and writing a BSP can consume a lot of time. Fortunately, there’s already a Yocto BSP for Raspbery PI 2, and the only extra requirement is to adjust the BSP to work with Tizen. Again, we opted to create a fork of the tree, to avoid interfering with other distros supported by this BSP, but the plan is to rework these patches in order to submit them to Yocto upstream in a way that would not affect builds for other distros.

The steps to create the clone is:

3) Initialize the Environment to Prepare for Build

Now that we have a copy of both the Tizen and BSP Yocto bits, we need to setup the build environment in order to use bitbake. It should be noted that some packages may be needed to be installed, depending on the distribution you’re using at the build machine. The Yocto builder (bitbake) requires Python 2.7.3 or greater. So, we don’t recommend using an LTS distro for the build, as it may have packages that are too old. Here, we used Fedora 21, as it provides recent packages, while being stable enough for desktop needs.

The command to initialize the build environment is:

4) Modify Config Files to Point to Build for Raspberry PI2

The Tizen build is controlled by configuration files. Assuming Tizen was installed at ~/tizen-distro the previous steps would have changed the working directory to the new build directory. So, the current directory should be ~/devel/tizen-distro/build and the configuration files are in the ./conf directory.

From the build directory, you’ll need to edit the conf/local.conf with your favorite editor. You should comment out any existing line that starts with “MACHINE”, and add the line bellow:

This will tell bitbake that it should compile for Raspberry PI 2 board.

Now, we need to add the BSP meta-raspberrypi layer to the conf/bblayers.conf file, at both BBLAYERS and BBLAYERS_NON_REMOVABLE. Again, use your favorite editor.

After the changes, the file contents should look like the one below, with your home directory instead of /home/mchehab:

Notice the new entry for “~/tizen-distro/meta-raspberrypi \” in each of the sections.

5) Start building

Now that everything is set, it is time to start the build. This is the step that will take a considerable amount of time, and will require a good Internet connection because it will download thousands of packages and/or clone upstream git trees for several packages.

Do this by running the following command:

NOTE: On some distros, this step will cause an error (this has been confirmed on multiple Debian-based distros):

If such an error happens, just pull an extra patch, and re-run bitbake with the following commands:

If everything goes well, the images will be located in the tmp-glibc/deploy/images/raspberrypi2 directory, and will look like the ones below:

Use the Image

Be careful at this point, because the steps below should be run as root, and will rewrite a disk image. If you do something wrong at this point, you may end by damaging what’s stored on your disks!

Let’s assume that the SD card will be mapped as /dev/sdc. Replace /dev/sdc with the device where your SD card is stored. To find out where your device is mapped, you can run the command:

WARNING: In the next section, be sure to change any instance of /dev/sdc to your specific disk that it is mapped. Otherwise you may damage your system!

1) Fill the SD Card With the Image

Insert an SD card on your computer using an SD->USB adapter and check if it was mapped at /dev/sdc.

The current image size is about 620 MB. Be sure to have an SD card big enough to fit the size of the generated image.

Now, write the image with the following command:

NOTE: the actual image size may vary, as we add more packages to the build image.

The image is now created and you can use it to boot into Tizen.

NOTE: The root password used on this image will be “root”.

2) Optional: Resize the Root Image to the Disk Size

By default, the image size doesn’t fill the entire SD disk. If you want to extend it to use all your SD card space, you can check what’s the first sector of the second partition of the disk.

Assuming that the first sector is 49152, you should delete it and re-create, using the maximum SD size as the last sector, as shown below:

Now, we’ll use e2fsck to extend the ext4 partition to fill the entire partition. Before that, the partition should be checked with e2fsck.

Those steps are shown below:

Get Involved

Now, You’re ready to use Tizen on your Raspberry PI 2. If you want to learn more or get involved, you can join us in the Tizen IRC chatroom, or subscribe to the Tizen on RPI2 Community mailing list. Lastly, you can also stay tuned to this blog to catch more articles about building things on Tizen and Raspberry Pi. Have fun!

Raspberry Pi is a trademark of the Raspberry Pi Foundation

Show more