Tizen RT - Step by Step Guide for running Sample Application on ARTIK 053

From Tizen Wiki
Jump to: navigation, search

Tizen RT is a lightweight RTOS-based platform to support low-end IoT devices. This getting started document will show how to setup the development environment, download source code, compile/build Tizen RT and eventually flash and run a sample application on a low-end IoT device. For this purpose we have chosen: ARTIK053 (with starter kit). Information about ARTIK053 starter kit: https://www.artik.io/modules/artik-053/

Development Environment Setup:

For this tutorial, Ubuntu 16.04 Linux machine is used with internet connectivity.

Step 1: At first, Update and installation of some packages are required for setup. Update is needed to get information on the newest versions and their dependencies. Package installation is also necessary to set up the environment for running a flexible GNU development environment and flashing over the JTAG interface.

Open up the command terminal and execute the commands below:

sudo apt-get update

sudo apt-get install git gperf libncurses5-dev flex bison

sudo apt-get install openocd libusb-1.0

Step 2: This step ensures the Installation of toolchain. Toolchain is a tool that produces executables to run on a different architecture (e.g. ARM).

Installation of ARM toolchain is done by executing the command below:

sudo apt-get install gcc-arm-none-eabi

Step 3: After installation, edit the bash init script to add the correct tool chain path prefix.

The command below will allow editing the .bashrc file. (More information about the usage of Vi editor is available at: https://www.tutorialspoint.com/unix/unix-vi-editor.htm)

vi ~/.bashrc

Add the line below at the end of file (using Vi editor’s insert mode).

export CROSSDEV=arm-none-eabi-

After adding the line at the end, it may look as below:

TizenRT StepbyStep ARTIK053 OSA 1.jpg

To exit the editor, press Esc to exit from insert mode. Then Press: “:q!” to exit.

TizenRT StepbyStep ARTIK053 OSA 2.jpg

Please check if the above mentioned line is saved in .bashrc file by re-opening the file. If you face trouble editing with “Vi editor” then find the ~/.bashrc file (In home directory by using keyboard shortcut Ctrl + H) and edit using a text editor.

Do not proceed until you are confirmed this change is done.

Step 4: Restart the PC for changes to take effect.

Step 5: This step is about Installing & Configuring a serial communication program.

Installation of serial communication programs is required to listen to the specified device port and provide a serial console. Recommended programs are listed as below:

 Minicom

 Screen

Minicom is selected for this tutorial.

Before installing Minicom, Open up command terminal in home directory and connect the ARTIK053 starter kit using a USB cable. The starter kit may look as below (with a light being ON):

TizenRT StepbyStep ARTIK053 OSA 3.JPG

Then run the command below to find port name.

dmesg | tail | grep tty

The result of the above command may look as the image below:

TizenRT StepbyStep ARTIK053 OSA 4.JPG

Anyone of the ports i.e. ttyUSB0 or ttyUSB1 can be used for configuring Minicom.

Now, installation of Minicom can be done using the command below:

sudo apt-get install minicom

Once installation is done, it is ready for configuration. To start Minicom in configuration mode use the command below:

sudo minicom –o –s

This command will allow configuring Minicom as the below image:

TizenRT StepbyStep ARTIK053 OSA 5.JPG

Scroll down to the Serial port setup and hit Enter. Now, it’ll open an interface like the image below:

TizenRT StepbyStep ARTIK053 OSA 6.JPG

Using the alphabet letters indicated, select serial port settings to change. Here it’s set to ttyUSB1. Change the settings according to the above image.

Now, press Enter by itself to leave this screen. After that, select 'Save setup as dfl', and then select 'Exit' from Minicom.

When setting up for the first time, it may not show the 'Save setup as dfl’ option. In that case, select the option as the below image:

TizenRT StepbyStep ARTIK053 OSA 7.JPG

It’ll allow entering the name as the image below:

TizenRT StepbyStep ARTIK053 OSA 8.JPG

Enter dfl and then select Exit.

From next time, it’ll show 'Save setup as dfl’ option in the list. In this stage Minicom configuration is complete.

Step 6: This step talks about Installing D2XX driver. D2XX drivers allow direct access to the USB device through a DLL.

Please go to the link below to download D2XX driver: http://www.ftdichip.com/Drivers/D2XX.htm

Download driver depending upon the dev PC, in this case for Linux (x64) from the chart as shown in the image below:

TizenRT StepbyStep ARTIK053 OSA 9.JPG

Download .tgz file in home directory.

Then using command terminal, execute the command below to unpack downloaded archive. (Please modify the platform name as per dev PC’s config)

tar xfvz libftd2xx-x86_64-1.4.6.tgz

Now, enter into the release/build using the command below:

cd release/build

Run the below command to promote current user to super-user to use installation privileges:

sudo -s

or log in as root user by running below command (if sudo is not available on your system run):

su

Copy libraries to a central location using the command below:

cp libftd2xx.* /usr/local/lib

Allow non-root access to the shared object by using:

chmod 0755 /usr/local/lib/libftd2xx.so.1.4.6

Create a symbolic link to the 1.4.6 version of the shared object by:

ln -sf /usr/local/lib/libftd2xx.so.1.4.6 /usr/local/lib/libftd2xx.so

End super-user session.

exit

Now, for building the shared-object examples, change the directory to ~release/examples. Then run the command below:

make –B

This builds all the shared-object examples in subdirectories. With an FTDI device (in this case ARTIK053 starter kit) connected to a USB port, try one of the examples, e.g. reading EEPROM by changing the directory to EEPROM/read. Then run this command:

sudo ./read

If the message "FT_Open failed" appears, it may mean the kernel automatically loaded another driver for the FTDI USB device. Run the below command and find "ftdi_sio" in the list.

sudo lsmod

TizenRT StepbyStep ARTIK053 OSA 10.JPG

If "ftdi_sio" is listed as the image above then unload it running the commands as follows.

sudo rmmod ftdi_sio

sudo rmmod usbserial

Run the command (sudo lsmod) to show the list again. Now, it’ll not appear in the list as below:

TizenRT StepbyStep ARTIK053 OSA 11.JPG

If it still shows, it's possible that libftd2xx does not recognize your device's Vendor and Product Identifiers.

Now run the read command again (sudo ./read) and find the result as per below image:

TizenRT StepbyStep ARTIK053 OSA 12.JPG

Download Tizen RT:

Tizen RT is open-source code. The repository can be found into this link: https://github.com/SamsungARTIK/TizenRT/

Download the project in .zip format from that URL. Create a directory as: ARTIK053/tinyara in home directory and keep all the contents in that directory like below after uncompressing:

~/ARTIK053/tinyara

TizenRT StepbyStep ARTIK053 OSA 13.JPG

The folder structure should be as the above image.

Configure Tizen RT:

To configure for building, at first the directory should be changed as below:

cd ~/ARTIK053/tinyara/os/tools

Configure to typical build config by using below command:

./configure.sh artik053/typical

The script will initialize the Tizen RT’s typical configuration, preparing it for building.

Compile Tizen RT: Before compiling Tizen RT, make sure the build process can find toolchain. Verify that the setting is correct (it was set in ~/.bashrc using Vi editor in the 3rd step of Development Environment Setup section). Run the command below: Change to home directory and run the below command:

echo $CROSSDEV

Find the result as below:

TizenRT StepbyStep ARTIK053 OSA 14.JPG

Now, change to the Tizen RT operating system directory using below command:

cd ~/ARTIK053/tinyara/os

Build image running the below command:

make

The result should look as below:

TizenRT StepbyStep ARTIK053 OSA 15.JPG

This build will create a tinyara_head.bin file in the ~ARTIK053/tinyara/build/output/bin directory. It contains the compiled Tizen RT binary image for ARTIK053. Compilation will end with the result as the image below:

TizenRT StepbyStep ARTIK053 OSA 16.JPG

Subsequent Re-Compile:

After you have built and loaded the image, you'll probably want to make some code changes and recompile.

When you are ready to recompile, run:

make clean

If you optionally want to start again from the original project run

make distclean

Set the initial configuration again as done in Configure Tizen RT step.

Run make command from the os directory as done in the previous step.

Load Tizen RT Image:

To load the built image on ARTIK053 board, go to OpenOCD directory by:

cd ~/ARTIK053/tinyara/build/configs/artik053/tools/openocd

Flash the required images to ARTIK 053 module by executing the command as below:

./linux64/openocd -f artik053.cfg -c \

' \ flash_write bl1 ../../bin/bl1.bin; \ flash_write bl2 ../../bin/bl2.bin; \ flash_write sssfw ../../bin/sssfw.bin; \ flash_write wlanfw ../../bin/wlanfw.bin; \ flash_write os ../../../../output/bin/tinyara_head.bin; \ shutdown \ '

The flash command should look like the image below:

TizenRT StepbyStep ARTIK053 OSA 17.JPG

After completing flash operation, the result should look as below:

TizenRT StepbyStep ARTIK053 OSA 18.JPG

Load Tizen RT Image with customized application:

Installing Kconfig Tools:

Kconfig tool is used to customize Tizen RT to use selected applications as well as add and remove applications.

Before installing Kconfig tool, at first download the tool from below URL:

https://bitbucket.org/nuttx/tools

Once downloaded in .zip format, unzip it and keep all the contents in ~/ARTIK053/tinyara/tools directory. Now, the tools directory will look like below:

TizenRT StepbyStep ARTIK053 OSA 19.JPG

Now, enter into the kconfig-frontends directory:

cd ~/ARTIK053/tinyara/tools/kconfig-frontends

Then run the command below for some configuration:

./configure --enable-mconf --disable-gconf --prefix=/usr

Adding the option --enable-mconf assures that 'kconfig-mconf' will be built or if it is not built, it will tell the reason why it was not built.

The above command will end up with a similar result like below:

TizenRT StepbyStep ARTIK053 OSA 20.JPG

To build the Kconfig-frontend for Tizen RT menu configurations run this command:

make

It will show as the image below:

TizenRT StepbyStep ARTIK053 OSA 21.JPG

Finally install as below:

sudo make install

It will show as image below:

TizenRT StepbyStep ARTIK053 OSA 22.JPG

Adding sample Application using Kconfig:

Now, Kconfig GUI menu will be used to set options to add selected applications. From ~/ARTIK053/tinyara/os directory, run:

make menuconfig

It will direct to the entry screen as below image.

TizenRT StepbyStep ARTIK053 OSA 23.JPG

Scroll down to Application Configuration (it may initially be at the bottom of screen) and hit Enter to select.

TizenRT StepbyStep ARTIK053 OSA 24.JPG

On the sub-menu, select Examples.

TizenRT StepbyStep ARTIK053 OSA 25.JPG

Scroll down to Sensor Board Example and hit the space bar to select.

TizenRT StepbyStep ARTIK053 OSA 26.JPG

Select Save and then exit from program.

TizenRT StepbyStep ARTIK053 OSA 27.JPG

TizenRT StepbyStep ARTIK053 OSA 28.JPG

TizenRT StepbyStep ARTIK053 OSA 29.JPG

Special note: All the settings are stored in the hidden os/.config file. If you re-initialize your configuration (make distclean) you will lose all changes you made.

Finally, exit from the Kconfig tool.

Now, compile & load the image (follow Compile Tizen RT & Load Tizen RT Image steps) again to run selected example.

To run example, TASH can be used. From Home directory, run this command:

sudo minicom

Now, press the reset button. Try to find it as below image:

TizenRT StepbyStep ARTIK053 OSA 30.JPG

After pressing reset button check the result as below:

TizenRT StepbyStep ARTIK053 OSA 31.JPG

Find TASH as marked with an arrow in the above image. Then run the command below:

help

This command will result as the image below. The selected application can be seen from the list, e.g. sensorbd.

TizenRT StepbyStep ARTIK053 OSA 32.JPG

  • If the TASH window doesn’t appear on the screen then try pressing Reset button again of the ARTIK 053 board.

Run the example using below command:

sensorbd ledst

Now press the button marked in the image below, it will turn on the light marked with arrow.

TizenRT StepbyStep ARTIK053 OSA 33.JPG