Getting started with Freenivi Studio

Getting started with Freenivi Studio

Table of contents

 

  1. Introduction
  2. Requirement
  3. Downloading and installing Freenivi Studio
  4. Setting up the SabreLite development environment
    1. Requirements
    2. Creating the SD card with the Freenivi OS
    3. Boot the Sabre Lite
  5. Using QtCreator
    1. Launching QtCreator
    2. Create a "Hello World" project
    3. Deploy to the Sabre Lite
    4. Deploy to the Freenivi Emulator
    5. Debug remotely

Introduction

Freenivi Studio allows to quickly develop and prototype on three different level of platforms:

  • Starter platforms includes RPi and RPi2
  • Car ready platform includes Sabre Lite and Nitrogen 6x
  • Advanced platform is a custom hardware dedicated to automotive industry (Contact us for more informations)

Currently two emulator are available, one for the x86 architecture and the other one for ARM architecture.

Freenivi Studio includes the following elements:

  • QtCreator 3.5
  • A QtCreator plugin to use the emulators directly inside the IDE
  • Various SDK to develop on the supported platform (including: Qt 5.5, a Freenivi OS image, a toolchain...)

Requirement

To work with Freenivi Studio it is mandatory to have a 64bits workstation with a Linux operating system.

We strongly advise to use Ubuntu 14.04.1 LTS, as it is our “reference” distribution for the Freenivi project. All the following instructions have been tested with this distribution. Nevertheless, any “modern” Linux distribution will also work.

Before going to the next step, be sure that you have the package build-essential installed on your Ubuntu:

sudo apt-get install build-essential

To work with one of our supported platform, the following element are needed: the development board, a screen for this board, a RJ45 cable and a serial/USB adapter (optional).

The Sabre lite development configuration

See chapter Setting up the SabreLite development environment for more details.

It is possible to work only emulating the target, in this case there is no need for a board.

Downloading and installing Freenivi Studio

Go to the Freenivi website, http://www.freenivi.org, then go to the “Downloads” page. Download the latest Freenivi Studio offline or online installer. Note that the offline installer is is pretty big (~6GB). To ensure that the download went fine compare the md5sum provided on the web page and the one of your installer file:

md5sum -c online-installer.md5

Begin Freenivi Studio installation by typing the following commands in a terminal:

chmod +x ./online-installer
./online-installer

Note: If you choose to download the offline-installer replace online-installer by offline-installer in the commands above.

A wizard dialog appears:

Welcome wizard

Follow the different steps of the setup wizard. First, set the installation path of Freenivi:

Installation path

Then, choose the components you want to install (below, every component are chosen) :

Select components

Click on next and the setup wizard will copy all the element you need on your workstation.

In order to use the Freenivi kits in an already existing QtCreator installation, you can use the sscripts add-kit-*.sh and del-kit-*.sh provided with the kits.

Assuming the Freenivi Studio installation path is the default one, type these command to add the kit to the already installed QtCreator:

cd ~/FreeniviStudio/SDK/freenivi-(version)/(KitToAdd)/
./add-kit-(KitArch).sh (PathToQtCreator)/bin/sdktool

To remove the kit:

./del-kit-(KitArch).sh (PathToQtCreator)/bin/sdktool

Setting up the SabreLite development environment

Requirements

Requirement to develop on the Sabre lite are the following:

  • A Sabre lite board from Boundary Device1
  • A SD card containing the Freenivi OS for iMX6 based boards
  • A RJ45 cable to connect the sabre lite to your local network (a crossed cable if you connect the Sabre lite directly to your workstation)
  • A DHCP server running somewhere on your LAN (or on your workstation if directly plugged to it2) to give an IP address to your Sabre lite
  • A serial/USB adapter to see on your workstation the serial console of the Sabre lite
  • A touchscreen for the Sabre lite, in the picture below the screen is the LCD8000-97C from Embest

Scheme of the development configuration

Creating the SD card with the Freenivi OS

Supposing Freenivi Studio is installed in ~/FreeniviStudio, the SD card image can be found a the following path:

~/FreeniviStudio/images/freenivi-wayland_v1.0.0/cortexa9hf-vfp-neon-freenivi-linux-gnueabi/freenivi-package-image-imx6qsabrelite.sdcard.gz

First unzip the image once to be able to use it:

gunzip ~/FreeniviStudio/images/freenivi-wayland_v1.0.0/cortexa9hf-vfp-neon-freenivi-linux-gnueabi/freenivi-package-image-imx6qsabrelite.sdcard.gz

To “burn” the freenivi-package-image-imx6qsabrelite.sdcard on a SD card, follow these steps:

  1. Insert the SD card in the workstation
  2. Check which device it is with the following command:

    $ dmesg | tail
    [...]
    [ 9965.316169] mmc0: new SDHC card at address 1234 
    [ 9965.333502] mmcblk0: mmc0:1234 SA04G 3.63 GiB 
    [ 9965.335071]  mmcblk0: p1 p2 
  3. Above the device of the SD card just inserted is /dev/mmcblk0
  4. Check that this SD card is not mounted:

    mount | grep mmcblk0
  5. If it is not mounted, “burn” the SD card image (all the SD card content will be lost)

    dd if=freenivi-package-image-imx6qsabrelite.sdcard of=/dev/mmcblk0 bs=4M 
    94+0 records in 
    94+0 records out 
    394264576 bytes (394 MB) copied, 132.777 s, 3.0 MB/s
  6. Insert the SD card in the SabreLite, it is now ready to boot.

Boot the Sabre Lite

Minicom allows you to get the serial console on the workstation, to install it just type:

sudo apt-get install minicom 

Then when the USB/Serial adapter is plugged launch Minicom with the following command:

sudo minicom -w -c on

-w means to wrap the lines and -c on means to activate colors.

Now boot the Sabre lite by plugging the DC supply.

To ensure that the DHCP server attributed an IP address to the Sabre lite and to know it, use the following command inside Minicom:

root@imx6qsabrelite:~# ifconfig 
eth0      Link encap:Ethernet  HWaddr 96:F7:D3:25:D5:A0  
          inet addr:192.168.2.2  Bcast:192.168.2.255  Mask:255.255.255.0 
          inet6 addr: fe80::94f7:d3ff:fe25:d5a0/64 Scope:Link 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1 
          RX packets:20589 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:30455 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:2648306 (2.5 MiB)  TX bytes:2522355 (2.4 MiB)

It is important to know the IP address of the Sabre lite as it will be needed to configure the deployment of the applications through QtCreator.

It is also possible to connect through the network to the Sabre lite using SSH to have a console:

ssh root@192.168.2.2

Using QtCreator

Launching QtCreator

To launch QtCreator, go to the following path in a terminal (supposing Freenivi Studio is installed in ~/FreeniviStudio):

cd ~/FreeniviStudio/
./freenivi-studio

In order to launch QtCreator graphically, a shortcut was also created by the installer in your system.

The QtCreator Welcome window appears:

QtCreator Welcome window

Create a "Hello World" project

To create a “Hello World” project, go to: File → New File or Project... → Application → Qt Quick Application, then click on “Choose...”.

Create project

Then, a wizard appears to help the project creation, enter a name for the project:

Project name

Select a minimal Qt version requirement for your project. Below, Qt version 5.3 is selected:

Define Project Details

On the next step make sure that the Freenivi kits are selected (especially cortexa9hf-vfp-neon-freenivi-linux-gnueabi for the Sabre Lite) as in the screenshot below:

Select Freenivi Kit

The code of the HelloWorld project appears. The next chapter is about how to build and deploy this code example on the Sabre lite board running the Freenivi OS or on an emulator running this same OS.

HelloWorld welcome

Deploy to the Sabre Lite

First, select the Sabre Lite kit (cortexa9hf-vfp-neon-freenivi-linux-gnueabi) by clicking on the quick access build option menu on the bottom left corner above the "Run" green triangle. Then, check that your project build without problem by clicking the hammer located on the bottom left corner of the QtCreator screen.

Before you go on, make sure that the SabreLite development environment is correctly set1.

In order to deploy the HelloWorld example to the Sabre lite board, the device has to be created in QtCreator. Go to Tools → Options... → Devices → Add... Choose “Generic Linux Device”.

Add Generic Linux Device

Enter the following information (depending on the system specific configuration):

Configure the device

The device will be created, and the connectivity will be checked. If everything went fine, the following success dialog appears:

Device test

Make sure that the device you created is the one selected into the kit you are using. Go to Tools → Build & Run → Kits → Freenivi. Select “SabreLite” into the device list.

Select device in kit

It is now ready to deploy, click on the green triangle on the bottom left corner, the “Hello World” application should appear on the screen of your SabreLite.

Hello world on the Sabre lite

Deploy to the Freenivi Emulator

The Freenivi Emulator uses QEMU and an image of the Freenivi OS specially built for this purpose. To develop and deploy to the emulator a specific toolchain has to be used. As of today, two different platforms can be emulated:

  • armv5te-freenivi-linux-gnueabi
  • i586-freenivi-linux

Each platform is a kit in QtCreator. Each kit contains: the QEMU emulator built for x86_64 architecture, the corresponding toolchain and the Freenivi OS images to be emulated. In this chapter we will focus on the i586-freenivi-linux kit.

The images and the script to launch the emulator in standalone are located here:

cd ~/FreeniviStudio/SDK/freenivi-wayland_v1.0.0/i586-freenivi-linux/emulator/

To begin, create an "Hello World" project as it has been described in the chapter. Make sure to use the i586-freenivi-linux kit.

Go to Tools -> Option -> Emulator. Make sure that Use Freenivi Emulator is checked.

Freenivi Emulator Settings

For each emulator available in Freenivi Studio, a default Freenivi Emulator Device is created at the first start of Freenivi Studio. This is totally transparent. In order to check the settings of these devices and create new emulator devices go to Tools -> Option -> Devices.

You can create your own Freenivi Emulator Devices with specific parameters. Keep in mind that every Freenivi Emulator Device is isolated from the others. It means that each Freenivi Emulator Devices has its own rootfs. It is possible to reset the rootfs of every Freenivi Emulator Devices by clicking the button "Reset emulator rootfs..." on a Freenivi Emulator Device in the Device panel of QtCreator.

Freenivi Emulator Devices

For the devices used, it is advised to check Use KVM acceleration as the emulator will be a lot faster. But in order to activate it, you must have an host operating system having the KVM modules compiled and you must insert these modules before launching the emulator. Ubuntu 14.04.1 is compatible out-of-the-box with KVM, just type in a terminal the following command to insert the KVM modules:

sudo modprobe kvm-intel

Now open the Freenivi Emulator Console (on the bottom of the QtCreator screen) to see the console output of the emulator:

About to launch the i586-freenivi-linux emulator

Make sure that the emulator kit is selected for the project by click on the quick access menu on the bottom left corner above the green "Run" triangle. Build the project with the kit you just selected (i586-freenivi-linux). Click on the green triangle on the bottom left of the screen, a dialog appears asking which emulator you want to launch. Select the x86 one and click on the Launch button.

Launch emulator dialog

The "Hello World" will compile, the emulator will be automatically launched and the binary will be automatically deployed and launched into the emulator.

Booting the Freenivi Emulator

When the boot is finished, the weston "desktop" appears:

Weston desktop

Then the application is automatically deployed and ran into the emulator:

Hello World deployed

Debug remotely

Debugging is possible on every supported platform, including emulators.

/!\ Using the development kit cortexa9hf-vfp-neon-freenivi-linux-gnueabi and the default configuration of QtCreator debugger, a SIGILL signal will be raised during the startup of the program and debugging will be impossible.

This is due to the fact that the used GDB doesn't support some ARM instructions and misinterpret them as a SIGILL.

In order to avoid that, add the following line into the Additional Startup Commands field of the Tools -> Options -> Debugger -> GDB menu of QtCreator:

handle SIGILL nostop noprint

As in the picture below:

Avoid SIGILL

Debugging QML is also supported, for that purpose check that the following option is checked into Projects -> (Kit to use for debug) -> Run:

Debugging QML

Click on the Start debugging icon on the bottom left corner of the window, select the emulator to use (in case of debug in a emulator). The emulator boots, the executable is deployed and run, you can know debug remotely inside the Debugger mode of QtCreator.

Debugging in an emulator