An Introduction to Tizen Development on ARTIK

This article is a direct follow up of my previous post about booting Tizen on the ARTIK10. Before starting, you should bookmark this wiki page as an entry point for Tizen on ARTIK devices.

At the 2015 Tizen Developer Conference, I had the opportunity to present a tutorial about Tizen platform development; it’s still valid today. This article is very similar but is adapted for ARTIK10 and ARTIK5 configuration.

For some context, check out to the following slide deck along with the recorded video on how to patch Tizen and build with GBS for x86a as well as this page about Tizen:Common on VMware.

 

 

Tools Setup

If you’re familiar with Tizen you probably know about Git Build System (GBS): a very convenient tool to build packages. It’s adapted from Debian’s git-build-package to support zypper repos.

First, gbs and some other Tizen tools need to be installed on the host machine used for development; On a debian based distro this is trivial: add the proper apt source for your specific OS as listed in the tools folder.

For instance, edit and adapt:

# cat /etc/os-release # mine is NAME=Ubuntu VERSION_ID=14.04
# cat /etc/apt/sources.list.d/org_tizen.list # edit and adapt 

deb http://download.tizen.org/tools/latest-release/${NAME}_${VERSION_ID}/ /
deb-src http://download.tizen.org/tools/latest-release/${NAME}_${VERSION_ID}/

# sudo apt-get install gbs mic lthor sdb

Then, the configuration file ~/.gbs.conf must be created, it should contain something like the following:

# cat ~/.gbs.conf

[profile.tizen_common_3.0b_artik_armv7l]
repos=repo.tizen_base_armv7l,repo.tizen_common_3.0b_artik_armv7l
buildroot=~/tmp/gbs/tmp-GBS-tizen_common_3.0b_artik_armv7l/

[repo.tizen_base_armv7l]
url = http://download.tizen.org/snapshots/tizen/base/latest/repos/arm/packages/

[repo.tizen_common_3.0b_artik_armv7l]
url=http://download.tizen.org/snapshots/tizen/common_artik/latest/repos/arm-wayland/packages/

By the way, here is my current .gbs.conf, with more profiles:

wget -O ~/.gbs.conf https://notabug.org/tizen/tizen-helper/raw/master/config/gbs.conf

Hello Tizen Source

Here, is the “helloworld project” and the packaging file needed to create a minimal platform package.

# mkdir -p tizen-example/packaging
# cd tizen-example
# cat main.c

#include "stdio.h"
void main()
{
    printf("Hello Tizen!\n");
}

A trivial makefile is needed to install it, as GNU make will guess how to build it (note, tabs are used not spaces) :

# cat Makefile

prefix?=/usr

install: main
    install -d ${DESTDIR}${prefix}/bin/
    install main ${DESTDIR}${prefix}/bin/

Finally write a minimal RPM spec file, like on any RPM based distribution (Red Hat, SUSE, Mer, etc):

# cat packaging/tizen-example.spec

Name: tizen-example
Version: 0
Release: 0
Summary: example
Source: %{name}-%{version}.tar.gz
License: TODO
BuildRequires: make
%description
Basic hello world example
%prep
%setup -q -n %{name}-%{version}
%build
%install 
%make_install
%clean
%files
%{_bindir}/*

Then commit those files into a newly created git project:

git init
git add .
git commit -sam 'Import'

Build the Software

The next step is to build it with this single command line:

gbs build -P "tizen_common_3.0b_artik_armv7l" --arch armv7l --include-all

It will download dependencies and eventually produce an RPM file; the contents can be listed with this command line:

rpm -qlp ~/tmp/gbs/tmp-GBS-tizen_common_3.0b_artik_armv7l/local/repos\
tizen_common_3.0b_artik_armv7l/armv7l/RPMS/rzr-example-0-0.armv7l.rpm

/usr/bin/main

Deploy to Target Device

At this stage, the package can be uploaded using scp, but let’s use an alternate way: Tizen’s Smart debug bridge (sdb) which was installed earlier.

On the target side, the SDB daemon should be already running:

# systemctl status sdbd    

sdbd.service - sdbd
   Loaded: loaded (/usr/lib/systemd/system/sdbd.service; disabled; vendor preset: enabled)
   Active: active (running) since Mon 2016-07-25 10:03:00 PDT; 7min ago
  (...)

If not, (re)start it:

# systemctl restart sdbd

# ifconfig -a 

Take note of the target’s IP address. Back on the host, use the sdb client to connect to it.

# sdb connect  192.168.0.42
connecting to 192.168.0.42:26101 ...
connected to 192.168.0.42:26101

# sdb devices
List of devices attached 
192.168.0.42:26101     device          artik

Perfect! Now files can be pushed or pulled just like the Tizen SDK IDE, but this has the benefit of providing shell access with su supported:

# sdb shell

sh-3.2$ pwd
/opt/home/owner

Now, we’re ready to upload our built RPM and install it with rpm running as root:

# sdb push ~/tmp/gbs/tmp-GBS-tizen_common_3.0b_artik_armv7l/local/repos/tizen_common_3.0b_artik_armv7l/armv7l/RPMS /opt/home/owner/RPMS
pushed   tizen-example-0-0.armv7l.rpm   100%          3KB
(...)

# sdb shell
sh-3.2$ su
Password: # tizen
bash-3.2# rpm -i /opt/home/owner/RPMS/tizen-example-*.rpm

bash-3.2# /usr/bin/main
Hello Tizen!

It’s not rocket science, but this is enough to validate the Tizen toolchain.

Setting up a private repo

Note: a quick tip for deploying is to setup an HTTP repo on the host machine and pull packages with zypper.

On the host machine, execute the following:

sudo apt-get install apache2
sudo a2enmode userdir
mkdir -p ~/public_html/tmp/
ln -fs ~/tmp/gbs  ~/public_html/tmp/gbs
ifconfig -a # note host_ip for later ie: 192.168.0.154

Then, some variables need to be adapted on the target side.

# sdb shell # or ssh root@$target_ip
# su # password=tizen
# host_ip=192.168.0.154 # adapt
# user=pcoval # adapt
# profile=tizen_common_3.0b_artik_armv7l
# url="http://${host_ip}/~${user}/tmp/gbs/tmp-GBS-${profile}/local/repos/${profile}/armv7l/"
#
# zypper removerepo ${user}
Repository 'pcoval' not found by alias, number or URI.

# zypper addrepo ${url} ${user} 
Adding repository 'pcoval' ...............................................[done]
Repository 'pcoval' successfully added
Enabled: Yes
Autorefresh: No
GPG check: Yes
URI: http://192.168.0.154/~pcoval/tmp/gbs/tmp-GBS-tizen_common_3.0b_artik_armv7l/local/repos/tizen_common_3.0b_artik_armv7l/armv7l/

# zypper repos
# | Alias                   | Name                                  | Enabled | Refresh
--+-------------------------+---------------------------------------+---------+--------
1 | Tizen_Base              | Bootstrap Project of Tizen  (arm)     | Yes     | No     
2 | Tizen_Common_3.0b_artik | Tizen:Common:3.0b:artik (arm-wayland) | Yes     | No     
3 | pcoval                  | pcoval                                | Yes     | No     

By the way, here are some zypper commands, you will probably use:

# zypper
# zypper refresh -r ${user} 
# zypper repos -r ${user} 
# zypper update -r  ${user} 
# zypper clean -r ${user} 
# zypper install --force -r ${user} ${package}

What’s Next ?

This should have summed up all that is needed to get into Tizen platform development on ARTIK devices. Now there are many new possibilities open for things like IoT development; let us know about your plans or join existing discussions about hardware support related to things like Graphics, Bluetooth/BLE, or maybe try to compare the results of this with Yocto’s meta-artik or other Operating Systems.

Remember, we also plan to have a quick chat about ARTIK at next Tizen Community Online Meeting, I hope to see you there! As a parting gift, here are some extra hints about packaging new software for the Tizen contrib repo.

 

Author: Phil Coval

Philippe is committed to free software and open hardware and is deeply involved in the Tizen and IoTivity communities.

One thought on “An Introduction to Tizen Development on ARTIK”

Comments are closed.