How to Boot Tizen on ARTIK

The fact that Tizen can be run on ARTIK is not the latest breaking news, considering it was previously demonstrated live at the 2015 Tizen Conference. There, the ARTIK project was also explained as an IoT platform of choice. Since then, ARTIK has become a new Tizen reference device, so here are a couple of hints that will help you test upcoming Tizen release on this hardware. First let me point out that Tizen’s wiki has a special ARTIK category, where you’ll find ongoing documentation efforts, you’ll want to bookmark this page.

In this article, I will provide a deeper explanation of how to use the bleeding edge version of Tizen:3.0:Common on ARTIK10, and how to start working on this platform. As explained in my previous Yocto/meta-artik article, I suggest you avoid using the eMMC for development purposes; for this article I will boot the ARTIK from an SDcard. In the long term I think it could be possible for the community to assemble Tizen infrastructure that automatically builds bootable SDcard tizen images to save time, but I’ll detail the whole process here in the meantime.

The Short and Easy Path

For your convenience, you can download an image of the build I’ll be describing here (md5=0d21e2716f67a16086fdd2724e7e11f1). It’s a binary image of the latest Tizen weekly development version (plus the latest IoTivity build too) prepared for the ARTIK10. All you have to do is flash it to the SD card, switch SW2/1 to on and SW2/2 to off, setup USB link to change a couple of U-Boot variables (set rootdev 1 ; set rootpart 3 ; boot ) as explained later in this tutorial.

# lsblk
disk=/dev/sdTODO
file=tizen-common-artik_20160627.3_common-wayland-3parts-armv7l-artik10.qcow2
# time qemu-img convert -p "${file}" "${disk}"

If you want to take the long road, or you want to do this for the ARTIK5, follow the rest of this guide; it will explain how to build Tizen and IoTivity to run on the ARTIK.

Download Tizen

Development for the Tizen project is a continuous process, the latest version can be downloaded here.

In the images/arm-wayland/ sub folder you’ll need to download 2 archives, the first is the boot image, which is different based on whether you’re using the ARTIK5 or ARTIK10. This image includes kernel and modules and the bootloader. The main difference between the ARTIK5 and ARTIK10 images is that U-Boot parameters are written at different media offsets.

I’m using the ARTIK10 for this guide, so I downloaded the tar.gz file found here. If you want to save bandwidth and time, it’s possible to grab a headless image archive tizen-common-artik_YYYYMMDD.*_common-headless-3parts-armv7l-artik.tar.gz.

If you own an ARTIK5, download the image from here; the ARTIK1 is totally different and it’s unlikely the same Tizen 3 codebase will be ever supported.

Prepare the SD Card

To write data to SD card, I’ll use the helpful sdboot script to handle the partitioning, formating and copying tasks that would be done manually using dd.

git clone https://github.com/tizenteam/sdboot -b master 

Insert the SD card into the host computer and identify the device node:

lsblk
disk=/dev/sdX # replace X with matching letter

Next, partition the SD card (8GB is minimal requirement), and format no less than 6 partitions.

sudo bash -x ./mk_sdboot.sh -f "$disk"

In the repo that was cloned earlier there is tizen-sd-bootloader-artik10.tar.gz; this contains early stages of the signed bootloader (bl1.bin, bl2.bin and ARM Trust Zone Software tzsw.bin). Note: don’t be confused by the “tz” in “twsw.bin” it means ARM TrustZone software not Tizen. The general purpose is to establish a chain of trust to ensure software integrity. The general purpose is to establish a chain of trust to ensure software integrity. U-boot.bin and its parameters file params.bin will be overridden later, and uInitrd, while not totally mandatory, will be helpful to setup systemd and mount the modules partition.

Use the mk_sdboot.sh helper script to write these files at the specific offets (Seek by 1231 for artik10’s U-Boot params file):

sudo bash -x ./mk_sdboot.sh -w /dev/sdb  tizen-sd-bootloader-artik10.tar.gz

Now, the SDcard should be able to launch U-Boot’s shell, so the next step is to prepare the operating system. Copy the Linux kernel to the 1st partition and its modules to the 2nd, and override the copied uboot and params just before the 1st partition:

sudo bash -x ./mk_sdboot.sh -w "$disk" tizen-*-boot-armv7l-artik10.tar.gz

Now, you can try to boot the kernel if you want, but let’s also dump Tizen’s rootfs to our SD card’s 3rd partition. Along with this, 2 other partitions are copied too: user and systemd-data.

sudo bash -x ./mk_sdboot.sh -w "$disk" tizen-*-3parts-armv7l-artik.tar.gz 

The device should now be capable of booting into Tizen.

Boot Tizen

For the purpose of this guide, I’m going to assume you’ve already booted your ARTIK with an existing OS (Fedora) or others (Ubuntu, Yocto) and know how to setup your debug link.

 

 

Power up the ARTIK10.

screen /dev/ttyUSB0 115200

U-Boot 2012.07-g801ab1503-TIZEN.org (Jun 20 2016 - 15:27:02) for ARTIK10

CPU: Exynos5422 Rev0.1 [Samsung SOC on SMP Platform Base on ARM CortexA7]
APLL = 800MHz, KPLL = 800MHz
MPLL = 532MHz, BPLL = 825MHz

Board: ARTIK10
DRAM:  2 GiB
WARNING: Caches not enabled

TrustZone Enabled BSP
BL1 version: /
VDD_KFC: 0x44
LDO19: 0x28

Checking Boot Mode ... SDMMC
MMC:   S5P_MSHC2: 0, S5P_MSHC0: 1
MMC Device 0: 7.4 GiB
MMC Device 1: 14.6 GiB
MMC Device 2: MMC Device 2 not found
In:    serial
Out:   serial
Err:   serial
rst_stat : 0x100
Net:   No ethernet found.
Hit any key to stop autoboot:  0 

Hit any key to stop and get a shell, if you don’t, U-Boot will try to boot the OS from the eMMC. Once you are in UBoot’s shell, change some variables temporarily:

ARTIK10 # version
U-Boot 2012.07-g801ab1503-TIZEN.org (Jun 20 2016 - 15:27:02) for ARTIK10
gcc (Tizen/Linaro GCC 4.9.2 2015.02) 4.9.2
GNU ld (GNU Binutils) 2.25.0 Linaro 2015_01-2

ARTIK10 # env default -f ;
ARTIK10 # set rootdev 1 ; set rootpart 3 ; boot 

In the next step of the boot process, the kernel, device tree and rootfs are loaded and executed:

reading zImage
5339682 bytes read in 67299 ms (77.1 KiB/s)
reading exynos5422-artik10.dtb
69754 bytes read in 117983 ms (0 Bytes/s)
reading uInitrd
1353683 bytes read in 29687 ms (43.9 KiB/s)
## Loading init Ramdisk from Legacy Image at 43000000 ...
   Image Name:   uInitrd
   Image Type:   ARM Linux RAMDisk Image (uncompressed)
   Data Size:    1353619 Bytes = 1.3 MiB
   Load Address: 00000000
   Entry Point:  00000000

Starting kernel ...

[    0.092805] [c0] /cpus/cpu@0 missing clock-frequency property
(...)
[    0.093269] [c0] exynos-snapshot: exynos_ss_init failed
[    0.335618] [c5] Exynos5422 ASV : invalid IDS value
(...)
Welcome to Tizen 3.0.0 (Tizen3/Common)!
(...)

Login to Tizen

The first boot will take a bit longer than usual, but eventually a prompt will appear that will allow you to login as root with “tizen” as the password:

Welcome to Tizen 3.0.0 (Tizen3/Common)!
(...)
localhost login: 
Password: 

# cat /etc/os-release 
NAME=Tizen
VERSION="3.0.0 (Tizen3/Common)"
ID=tizen
VERSION_ID=3.0.0
PRETTY_NAME="Tizen 3.0.0 (Tizen3/Common)"
ANSI_COLOR="0;36"
CPE_NAME="cpe:/o:tizen:tizen:3.0.0"
BUILD_ID=tizen-common-artik_20160627.3_common-wayland-3parts-armv7l-artik

# cat /proc/cmdline 
console=ttySAC3,115200n8 root=/dev/mmcblk1p3 rw rootfstype=ext4 loglevel=4 asix.macaddr=d2:40:??:??:??:?? bd_addr=C0:97:??:??:??:??

# cat /proc/version 
Linux version 3.10.93-3.1-arm-artik10 (abuild@w17) (gcc version 4.9.2 (Tizen/Linaro GCC 4.9.2 2015.02) ) #1 SMP PREEMPT Mon Jun 27 16:54:57 UTC 2016

# df -h /
Filesystem            Size  Used Avail Use% Mounted on
/dev/mmcblk1p3        2.0G  726M  1.2G  38% /

Hotfix

I noticed a critical bug that can be worked around for now. Some daemons are causing damage to the root filesystem after a short period (less than 5 minutes), I suspect they could generate too much output and fill our low disk space, this is something that needs to be investigated. As a temporary solution, they should be stopped as soon as possible:

# systemctl stop deviced ; systemctl stop resourced ;
# systemctl disable deviced ; systemctl disable resourced

To make sure they won’t be re installed / restarted, they need to also be renamed:

# mv /usr/bin/deviced /usr/bin/deviced.orig
# mv /usr/bin/resourced /usr/bin/resourced.orig
# systemctl status deviced
Active: inactive (dead) since Mon 2016-07-25 10:05:09 PDT; 25s ago

Then, make sure the modules partition is mounted and matches the kernel version:

ls -l  /lib/modules/$(uname -r)/modules.dep
-rw-r--r-- 1 root root 21574 Jun 27 09:56 /lib/modules/3.10.93-3.1-arm-artik10/modules.dep

If not you aren’t using uInitrd, you’ll have to tweak fstab.

Connect to the Network

Check to make sure the network is working and the device has an IP address assigned to it:

ifconfig -a
eth0: flags=-28605  mtu 1500
        inet 192.168.0.42  netmask 255.255.255.0  broadcast 192.168.0.255

If it doesn’t, it can be set it up manually after loading the AX8817X USB NIC’s driver:

# modprobe -v asix

insmod /lib/modules/3.10.93-3.1-arm-artik10/kernel/drivers/net/usb/usbnet.ko 
insmod /lib/modules/3.10.93-3.1-arm-artik10/kernel/drivers/net/usb/asix.ko macaddr=d2:40:??:??:??:??

The LAN’s DHCP server should then assign an IP address to the device.

Install Packages

The headless image should already have zypper installed, it will be used for this section. If for some reason it’s not part of the image, it’s possible to use sdb to install it. This is outside the scope of this article, but if you have questions, feel free to post them to the comment section.

First, add the remote repos:

# zypper lr
Warning: No repositories defined.
Use the 'zypper addrepo' command to add one or more repositories.

# zypper addrepo http://download.tizen.org/live/Tizen:/Base/arm/Tizen:Base.repo
# zypper ar http://download.tizen.org/live/Tizen:/Common:/3.0b:/artik/arm-wayland/Tizen:Common:3.0b:artik.repo

Now it’s possible to install packages and upgrade the distro to latest snapshot.

# zypper in screen openssh
# zypper up

Take IoTivity for a Spin.

What’s next? Many people have expressed interest in using IoTivity on new platforms like Tizen, so let’s take a look at some of the IoTivity apps.

# zypper in iotivity-test iotcon-test 
# downgrade if needed
# rpm -ql iotivity-test

The binary image I shared at the beginning of this article contains the recently-released iotivity-1.1.1. I built it locally from sources using GBS on the 1.1.1 git tag with security enabled. The example apps must be run in the same directory where *.dat files are stored. Here are some instructions to launch a sample app I described in my previous article on IoTivity on ARTIK:

ls /usr/bin/*.dat
/usr/bin/oic_svr_db_client.dat
/usr/bin/oic_svr_db_server.dat
cd /usr/bin/ ; /usr/bin/simpleserver 2 
# in an other terminal :
cd /usr/bin/ ; /usr/bin/simpleclient 1 

What’s Next?

I’m going to continue hacking away at Tizen on my ARTIK10, stay tuned for more articles about developing on these platforms. Also check upcoming Tizen Community Online Meeting, a live chat about ARTIK is planned this fall, see you there.

 

Author: Phil Coval

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

5 thoughts on “How to Boot Tizen on ARTIK”

  1. Dear Phil,

    Thanks a lot for a bunch of material concerning Artik boards!
    I’ve found it very informative!
    Anyway, I cannot find the information about the boot sequence regarding TrustZone binaries, like “tzsw.bin”.
    Also I cannot find information about current TrustZone’s interoperation model.
    Where is located TrustZone’s monitor software? BL1, BL2, tzsw?
    How do they interoperate?

    Can you please explain, or at list give web resources, where listed questions may be enlighten?

    Thank you!

    WBR,
    Piligrim

    1. I guess the flow is:
      ROM, BL1, (BL2 + TrustZone), U-BOOT, Linux kernel, Tizen OS’s userland

      Boot level files are coming from tizen-artik

      You’ll find more hints online on ARM or Linaro website

      If you want to share your discoveries don’t hesitate to update tizen’s wiki:

      https://wiki.tizen.org/Category:ARTIK

      Regards

  2. Dear Phil,

    thank you for a quick response!
    I got you point.
    Probably you may know right person to get this information without reverse engineering.
    Would you be so kind to give a public blog link or public person’s e-mail responsible for this?
    Thanks!

    WBR,
    Piligrim

Comments are closed.