Getting started with Freenivi Studio
Table of contents
- Downloading and installing Freenivi Studio
- Setting up the SabreLite development environment
- Creating the SD card with the Freenivi OS
- Boot the Sabre Lite
- Using QtCreator
- Launching QtCreator
- Create a "Hello World" project
- Deploy to the Sabre Lite
- Deploy to the Freenivi Emulator
- Debug remotely
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...)
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).
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:
Follow the different steps of the setup wizard. First, set the installation path of Freenivi:
Then, choose the components you want to install (below, every component are chosen) :
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:
Setting up the SabreLite development environment
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
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:
First unzip the image once to be able to use it:
To “burn” the freenivi-package-image-imx6qsabrelite.sdcard on a SD card, follow these steps:
- Insert the SD card in the workstation
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
- Above the device of the SD card just inserted is /dev/mmcblk0
Check that this SD card is not mounted:
mount | grep mmcblk0
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
- 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:
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:
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...”.
Then, a wizard appears to help the project creation, enter a name for the project:
Select a minimal Qt version requirement for your project. Below, Qt version 5.3 is selected:
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:
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.
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”.
Enter the following information (depending on the system specific configuration):
The device will be created, and the connectivity will be checked. If everything went fine, the following success dialog appears:
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.
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.
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:
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:
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.
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.
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:
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.
The "Hello World" will compile, the emulator will be automatically launched and the binary will be automatically deployed and launched into the emulator.
When the boot is finished, the weston "desktop" appears:
Then the application is automatically deployed and ran into the emulator:
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:
Debugging QML is also supported, for that purpose check that the following option is checked into Projects -> (Kit to use for debug) -> Run:
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.