PHYTEC Development Environment Guide (L-833e.A9)
Table of Contents
Compatible BSPs | BSP Release Type | BSP Release Date | BSP Status |
---|---|---|---|
BSP-Yocto-i.MX6UL-PD19.1.1 | Minor Release | 31.08.2020 | Released |
BSP-Yocto-i.MX6UL-PD19.1.0 | Final Release (stable final Release) | 29.05.2019 | Released |
BSP-Yocto-AM335x-PD19.1.1 | Final Release (stable final Release) | 15.03.2019 | Released |
BSP-Yocto-i.MX8M-PD19.1.0 | Final Release (stable final Release) | 16.12.2019 | Released |
Introduction
Content Description
In this manual, you will find instructions on how to start up with PHYTEC Kits and PHYTEC's virtual machine hard disk image which includes a complete developer environment. You will learn how to ...
- ... use the prepared virtual machine hard disk image.
- ... work with Eclipse® and Qt Creator®.
- ... set up your own Linux host system.
This first section gives a short introduction about PHYTEC's preliminary work and the requirements to successfully complete this manual.
PHYTEC Documentation
PHYTEC will provide a variety of hardware and software documentation for all of our products. This includes any or all of the following:
- QS Guide: A short guide on how to set up and boot a phyCORE board along with brief information on building a BSP, the device tree, and accessing peripherals.
- Hardware Manual: A detailed description of the System on Module and accompanying carrier board.
- Yocto Guide: A comprehensive guide for the Yocto version the phyCORE uses. This guide contains an overview of Yocto; introducing, installing, and customizing the PHYTEC BSP; how to work with programs like Poky and Bitbake; and much more.
- BSP Manual: A manual specific to the BSP version of the phyCORE. Information such as how to build the BSP, booting, updating software, device tree, and accessing peripherals can be found here.
- Development Environment Guide: This guide shows how to work with the Virtual Machine (VM) Host PHYTEC has developed and prepared to run various Development Environments. There are detailed step-by-step instructions for Eclipse and Qt Creator, which are included in the VM. There are instructions for running demo projects for these programs on a phyCORE product as well. Information on how to build a Linux host PC yourself is also a part of this guide.
- Pin Muxing Table: phyCORE SOMs have an accompanying pin table (in Excel format). This table will show the complete default signal path, from processor to carrier board. The default device tree muxing option will also be included. This gives a developer all the information needed in one location to make muxing changes and design options when developing a specialized carrier board or adapting a PHYTEC phyCORE SOM to an application.
On top of these standard manuals and guides, PHYTEC will also provide Product Change Notifications, Application Notes, and Technical Notes. These will be done on a case by case basis. Most of the documentation can be found in the applicable download page of our products.
Documentation Overview
This section gives an overview on how to use the virtual machine hard disk image and how to work with Eclipse® and Qt Creator®. Besides this manual, PHYTEC brings a handful of documentation to get deeper into and more familiar with our products.
- QuickStart Guide for the initial startup (read this first)
- The specific Hardware Manual for your board
- Hardware schematics
- The Yocto Reference Manual
- The BSP Manual
For the i.MX 6 based products, PHYTEC also provides camera documentation for the Image Processing. You can find this documentation on our website www.phytec.eu or www.phytec.de and in our virtual machine hard disk image under /opt/PHYTEC_Tools/Documentation.
Tip
If you want a deeper look into Yocto and our BSP, please read the Yocto Reference Manual (L-813) for a better understanding of Yocto and the BSP Manual specific for your controller to learn how to use the BSP and accessing peripherals.
System Requirements
The following items will be needed to complete this manual successfully:
- The PHYTEC Board with a DB-9 serial cable, Ethernet cable, and a DC power supply.
- The PHYTEC virtual machine hard disk image available on the enclosed USB flash drive.
- A host-PC with x64 processor and 2 GB RAM (or more).
- To avoid incompatibilities the major PD version (only PDXX.X) of the Board Support Package on your target must match with the installed toolchain (SDK) on the virtual machine hard disk image.
- Get the version of the BSP:
After the board is booted login in with root and enter the following command:
lsb_release -r
The output shows the version of your BSP:
Example: BSP-Yocto-AM335x-PD19.1.1
Only the major version (PDXX.X )
- Get the version of the SDK:
Open a terminal in the booted virtual machine hard disk image and enter the following command:
cat /opt/phytec-yogurt*/*/version-*
The output shows the distro version of the SDK:
Example: BSP-Yocto-AM335x-PD19.1.1
Only the major PD version must match. This means PDXX.X the minor version behind doesn't matter.
Example comparisons: BSP-Yocto-AM335x-PD19.1.2 (BSP) works with BSP-Yocto-AM335x-PD19.1.0 (SDK) BSP-Yocto-AM335x-PD19.1.0 (BSP) not work with BSP-Yocto-AM335x-PD18.1.0 (SDK)
- Get the version of the BSP:
- Compatible Board Support Packages (BSPs) with this documentation:
Compatible BSPs | BSP Release Type | BSP Release Date | BSP Status |
---|---|---|---|
BSP-Yocto-i.MX6UL-PD19.1.1 | Minor Release | 31.08.2020 | Released |
BSP-Yocto-i.MX6UL-PD19.1.0 | Final Release (stable final Release) | 29.05.2019 | Released |
BSP-Yocto-AM335x-PD19.1.1 | Final Release (stable final Release) | 15.03.2019 | Released |
BSP-Yocto-i.MX8M-PD19.1.0 | Final Release (stable final Release) | 16.12.2019 | Released |
Virtual Machine Hard Disk
PHYTEC provides an easy to use virtual machine hard disk which includes the Linux distribution Ubuntu and includes all necessary software for a direct start for PHYTEC's products. An overview of the installed and configured software is as follows:
- Ubuntu
''Ubuntu'' - which is used as an operating system for our virtual machine - is a free and open-source operating system based on ''Debian Linux''. Basically, it is designed for desktop use. Web statistics suggest that ''Ubuntu'' is one of the most popular operating systems in the Linux desktop environment. The ''Ubuntu'' release which we deliver is ''18.04.2'' and was released in February 2019. ''Ubuntu'' 18.04 code name "Bionic Beaver" is designated as a ''Long Term Support (LTS)'' release and the first stable release was on 26. April 2018. LTS means that it will be supported and updated for five years. Our ''Ubuntu'' version comes with ''Unity'' as a desktop environment, ''dpkg'' as a package management system, the update method is based on ''APT (Advanced Packaging Tool)'' and the userspace uses ''GNU''.
- Yocto
The Yocto Project is an open-source collaboration to create custom Linux-based systems for embedded products regardless of the hardware architecture. We use the Yocto Project to create the Board Support Package (BSP) for our hardware.
- Eclipse® with Example Project
The Eclipse® platform provides support for C/C++. Because the Eclipse® platform is only a framework for developer tools, it does not support C/C++ directly. Instead, it uses external plug-ins. This Development Environment Guide shows you how to make use of the CDT plug-in. The CDT is an open-source project (licensed under the Common Public License) implemented purely in Java as a set of plug-ins for the Eclipse® SDK platform. These plug-ins add a C/C++ perspective to the Eclipse® Workbench that can now support C/C++ development with a number of views and wizards, along with advanced editing and debugging support.
- Qt Creator® with Example Project
Qt Creator® is a cross-platform development environment for the Qt® framework. A code editor and a Qt Designer® to build graphical user interfaces (GUI) are included. It uses the GNU C/C++ compiler.
- Software Development Kit (SDK) with cross compiler toolchain
- Git
- x64-Qt
- serial port communication program
- tftp server
Professional Support Packages
If you have any questions concerning installation and setup, you are welcome to contact our support department. For more in-depth questions, we offer a variety of custom-tailored packages with different support options (e-mail, phone, direct contact to the developer) and different reaction times. Please contact our sales team to discuss the appropriate support option if professional support beyond installation and setup is important to you. For more information, please refer to the following sources:
http://www.phytec.de/support/support-pakete/ http://www.phytec.eu/europe/support/support-packages.html support@phytec.de
Making Use of the Virtual Machine Hard Disk
Warning
- We assume that you have first successfully completed our QuickStart Guide in which you learned how to start the virtual machine hard disk image, and how to connect and power up the PHYTEC board.
- To ensure a successful introduction to the development with the PHYTEC board, we strongly recommend continuing with the prepared virtual machine hard disk image. If you want to use your already existing environment, we will explain how to modify your system to get the same experience as with our virtual machine in the section Linux Host PC Setup. Please be advised that using your already existing environment is at your own risk. We can not guarantee that we can successfully support you with your own environment.
In this section, you will find a short overview on how to make use of the preconfigured virtual machine hard disk. Most of the prepared installations can be found in the directory: /opt/. The following is a list with the subdirectories and a short explanation:
- /opt/eclipse/
Install folder from Eclipse®
- /opt/PHYTEC_Tools/
Documentation (Manuals, Schematics …), example projects, icons from PHYTEC
- /opt/phytec-yogurt*/
Installed Yocto SDK including the cross compiler toolchain
- /opt/prj_workspace/
Workspace folder for Qt Creator® and Eclipse® projects
- /opt/Qt/
Install folder from Qt Creator® and x64-Qt
- /opt/VBoxGuestAdditions-X.XX.X/
Virtual Guest Additions for Virtualbox in the latest version at the time of the release.
Another important directory is /tftpboot. The preconfigured TFTP-Server is linked to this directory to copy images to the target via Ethernet.
Note
Now you are ready to make further use of the virtual machine hard disk image.
Working with Eclipse®
After the virtual machine hard disk has been started, we will show how to develop your own applications with the help of Eclipse® and the cross-compile toolchain.
Programming in the C/C++ Perspective
We start with the C/C++ workbench. First, you will import an existing Eclipse® project into your workspace. The imported example project will be compiled with the cross-compiler. After that, you will copy and execute the newly created program on the target.
Working with the Demo Project
- Open a terminal by clicking the icon on the desktop.
- Enter the path to the environment file for cross-compiling, start with:
source /opt/phytec-yogurt...
- From here, complete the only path available:
example AM335x: source /opt/phytec-yogurt/BSP-Yocto-AM335x-PD17.2.2/environment-setup-cortexa9hf-neon-phytec-linux-gnueabi example i.MX8M: source /opt/phytec-yogurt-vendor-wayland/BSP-Yocto-FSL-i.MX8M-PD19.1.0/environment-setup-aarch64-phytec-linux
Tip
This line depends on your target and PD version. When you start typing the line in your terminal program, the autocomplete function should show you the appropriate path. In the virtual machine, only the correct directory is available.
- Enter the following command to start Eclipse®:
eclipse &
- Change the workspace directory to /opt/prj_workspace/Eclipse if necessary and confirm with OK.
Now you can see the Eclipse® workbench:
First, we will import an existing project.
- Select File ►► Import from the menu bar.
- Expand General, select Existing Projects into Workspace, and click Next.
- Select Browse.
- Double-click the HelloWorld directory under /opt/prj_workspace/Eclipse/.
- Click OK.
- Select Finish to import the project.
- Select Project ► Build Project from the menu bar.
The HelloWorld program will be compiled and the HelloWorld executable is built for the target. Then the HelloWorld file is copied to the target using secure copy. After the file has been copied to the target, the program is executed on the target using SSH.
You will see similar content in the Console window:
Warning
If you do not get this result, verify that you have the target connected to your host and that the network has been configured as explained in the foldable QuickStart.
Warning
You have successfully passed the first steps with the Eclipse® IDE. You are now able to import existing projects into the Eclipse® workspace. You can compile an existing project and execute the program on the target.
Creating a New Project
In this section, you will learn how to create a new project with Eclipse® and how to configure the project for use with the GNU C/C++ cross-development toolchain.
- Open Eclipse® if it is not already opened.
- Select File ► New ► Project from the menu bar.
A new dialog opens.
- Select C Project and click Next.
- Enter the project name myHelloWorld and select Linux GCC. Click Finish.
You will see the C/C++ IDE with the myHelloWorld project.
- If the HelloWorld project is not expanded, double-click the HelloWorld project which we have worked with previously.
- Right-click on HelloWorld.c in the HelloWorld project.
- Select Copy.
- Select the myHelloWorld project.
- Right-click the myHelloWorld project.
- Select Paste.
- Double-click HelloWorld.c in the myHelloWorld project.
If Build Automatically from the Project menu is selected, the HelloWorld application will now be compiled and created with the standard GCC C/C++ compiler suitable for your host machine. You will find the executable file, which can only run on your host system, in the workspace/myHelloWorld/Debug directory.
To compile your project for your board instead, you will have to use the GNU C/C++ cross compiler.
- Right-click the myHelloWorld project and choose Properties.
The Properties dialog appears.
- Select C/C++ Build ► Settings.
- Select GCC C Compiler.
- Enter ${CC} into the Command input field.
- Select GCC C Linker.
- Enter ${CC} into the Command input field and add ${LDFLAGS} in the Command line pattern after ${COMMAND}.
- Select GCC Assembler.
- Change the Command input field to ${AS}.
- Click Apply.
- Select the Build Steps tab.
- Enter the following command in the Post-build steps Command input field:
scp ./myHelloWorld root@192.168.3.11:/home/root/. ;ssh root@192.168.3.11 /home/root/myHelloWorld
Warning
Be sure to enter the semicolon before the ssh command. Ensure that the file myHelloWorld on the target has execution rights. Otherwise,ssh will fail.
- Click Apply.
- Click OK.
- Select Project ► Clean from the menu bar.
- Confirm with OK.
The project will be rebuilt.
- Select the Console tab.
If no errors occur while building the project, you will see the following output:
Tip
You have successfully created your own first project with the Eclipse® IDE. You have configured the project to create an application for your target platform.
Modifying the Demo Application
Now we will extend the myHelloWorld application. The extended myHelloWorld application will write output to the first serial interface as well as to the standard output.
- Open Eclipse® if it is not opened yet.
- Double-click HelloWorld.c in the myHelloWorld project.
- First, include the following two additional header files:
#include <unistd.h> #include <fcntl.h>
- Then add the function write_tty(), which writes n bytes to the first serial interface (on our standard modules, is connected to the system console /dev/console):
void write_tty (char *buffer, int count) { int out; out = open ("/dev/console", O_RDWR); write(out, buffer, count); close(out); }
- Enter the following two lines in the main() function to declare the buffer and call the write_tty() function:
char buf [] = { "Welcome to the World of PHYTEC! (serial)\n" }; write_tty(buf, sizeof (buf) - 1);
In the next screenshot, you can see the complete program.
- Save your program after changing the code.
The application will be compiled, built, copied to the target, and executed.
- Click the Microcom icon on the desktop.
- If you are not logged in, enter root and press Enter.
- Type ./myHelloWorld to start the application.
- You will see the following output:
Welcome to the World of PHYTEC! (serial) Welcome to the World of PHYTEC!
- Close Microcom.
When you start the application via an SSH session, you will only see one output line. When you execute the program with Microcom, you will see two output lines.
Tip
The first line is a direct output on the serial interface. You can not see this line in an SSH session, because you are connected over a TCP/IP connection to the target. With Microcom, however, you have direct access to the serial interface, so you can also see the line that is written to the serial console.
Tip
In this section, you have changed an existing application. You also learned how to access the serial interface. You called the function open() on the device /dev/console. The return value of this function was a file descriptor. With the file descriptor, you called the function write() to send n bytes to the device /dev/console. After that, the file descriptor was closed with the function close().
This procedure is quite typical for Linux because Linux treats everything as a file.
Starting a Program on the Target in Eclipse®
In the following section, you will find another method to start an application out of Eclipse®. After compiling a project in Eclipse®, the program is copied to the target and directly executed. A program can also be executed on the target without compiling a project. In the following section, you will learn how to start a program on the target as an external tool.
- Select Run ► External Tools ► External Tools Configurations from the menu bar.
- Double-click Program. A new program configuration will be opened.
- In the Name input field, enter: myHelloWorld Target.
- Enter /usr/bin/ssh in the Location input field.
- Enter root@192.168.3.11 ./myHelloWorld into the Arguments field.
- Select Apply.
- Select Run.
Now the program will execute on the target and you will see the output:
Welcome to the World of PHYTEC!
in the Eclipse® console window and:
Welcome to the World of PHYTEC! (serial)
in the Microcom window.
The next time you want to execute the program, you can use the Run External Programs button from the menu bar.
You have successfully created your own Eclipse® project and you learned how to execute a program on the target.
Debugging and Example Project
In this chapter, you will learn to use the GNU debugger GDB on the host for remote debugging in conjunction with the GDB server on the target. GDB is the symbolic debugger of the GNU project and is arguably the most important debugging tool for any Linux system.
You will configure the Eclipse® platform and start the GNU debugger on the host and GDB Server on the target out of Eclipse® using the Debug view.
The CDT extends the standard Eclipse® Debug view with functions for debugging C/C++ code. The Debug view allows you to manage the debugging and running of a program in the workbench. Using the Debug view, you will be able to set breakpoints/watchpoints in the code and trace variables and registers. The Debug view displays the stack frame for the threads of each target you are debugging. Each thread in your program appears as a node in the tree, and the Debug view displays the process for each target you are running.
The GDB client is running on the host and is used to control the GDB server on the target, which in turn controls the application running on the target. GDB client and GDB server can communicate over a TCP/IP network connection as well as via a serial interface. In this manual, we will only describe debugging via TCP/IP.
Configuring and Starting the Eclispe® Debugger
In this passage, you will learn how to configure your project settings to use Eclipse® with the GNU debugger. After the configuration of your project settings, the GNU debugger will start and connect to the GDB server on the target.
- First, we create a new file .gdbinit to set the correct path to our sysroot. Type in a terminal window:
sudo vi /opt/prj_workspace/Eclipse/myHelloWorld/.gdbinit
- In a second terminal window, enter the path to your sysroot with the following pattern:
set sysroot /opt/phytec-yogurt*/*/sysroots/*phytec-linux*/
Tip
This line depends on your target and PD version. When you start typing the line in your terminal program, the autocomplete function should show you the appropriate path. In the virtual machine, only the correct directory is available.
Examples:
for AM335x: set sysroot /opt/phytec-yogurt/BSP-Yocto-AM335x-PD17.2.1/sysroots/cortexa9hf-neon-phytec-linux-gnueabi/ for i.MX8M: set sysroot /opt/phytec-yogurt-vendor/BSP-Yocto-FSL-i.MX8M-PD19.1.0/sysroots/aarch64-phytec-linux/
- Copy this line in the new .gdbinit file and save it with :x :
- Start Eclipse® if the application is not started yet.
- Clean and build the myHelloWorld project.
- Right-click on the myHelloWorld project in the Navigator window.
- Select Debug As ► Debug Configurations.
A dialog to create, manage, and run applications appears.
- Double-click on C/C++ Remote Application.
- Set Connection to Device.
- Set Remote Absolute File Path to /home/root/myHelloWorld
- Select the Debugger tab.
- Enter arm-phytec-linux-gnueabi-gdb in the GDB Debugger field for imx6 and am335x.
- Enter arch64-phytec-linux-musl-gdb in the GDB Debugger field for imx8m.
- Be sure that in the GDB command field contains .gdbinit.
- Select the Gdbserver Settings tab.
- Make sure that gdbserver is in the Gdbserver path input field and 2345 in the Port number field.
- Click Apply.
- Click Debug.
A new dialog appears.
- Select Yes to switch to the Debug perspective.
The debug perspective opens and the debugger stops automatically at the first line. The host's GDB is now connected to the GDB server on the target.
You have configured your project for remote debugging. You have started the GNU debugger in Eclipse® and connected the host's GDB with the target's GDB server. You can now start to debug the project.
Setting a Breakpoint
Now you will set a breakpoint in your program. The breakpoint will be set on the last line of the function main(). If you resume the application, the debugger will stop at this line.
- Select the last line in main().
- Right-click into the small grey border on the left-hand side and select Toggle Breakpoint to set a new breakpoint.
Stepping Through and Watching Variable Content
In this part, you will step through the example project with the debugger. You will also learn how to check the content of a variable.
- Expand buf in the Variables window.
- Click the Step Over button in the Debug window to step to the next line. You will see the content of the buf variable in the Variables window.
- Click on the variable buf.
- Then click the button Step into to enter the function write_tty().
- The debugger stops in write_tty().
You will see the following variable window:
- Click on the variable buffer.
You will probably see a different address on the buffer pointer. Remember which address is shown in your case, you will need this address later.
Stepping Through and Changing Variable Contents
In this section, you will change the value of a variable. At the end of this part, you will see the effect of this change.
- Select the count variable in the Variables window.
- Double-click in the Value column from count.
- Open Microcom if the application is not already opened.
- Go back to Eclipse®.
- Click the Step Over button twice.
- Switch to Microcom.
Because we changed the count variable to 7, only the first seven characters (Welcome) are displayed in the Microcom console.
Using the Memory Monitor
In the last section of this chapter, you will use the memory monitor to control the content at a memory address.
- Select the Memory tab in the frame where you can find the Console.
- Click + Add Memory Monitor.
- Enter the address of the buffer and click OK. Remember that the variable's address might be different on your system.
- Select the tab + New Renderings.
- Select ASCII and click Add Rendering(s).
- You can see the contents of the variable buffer at address 0xbefffc74 (or at the specific address used on your system).
- Now click the Resume button from the menu bar.
The debugger stops at the breakpoint in the last line of main().
- Click the Resume button to end the application.
Tip
You have successfully passed the debugging chapter. You are now able to configure and use Eclipse® for remote debugging. You can step through a project, watch and change the content of variables, and you can use the memory monitor to view the content at a memory address.
Working with Qt Creator®
In this section, we will learn how to work with Qt Creator®. The Qt® framework provides tools to develop graphical user interfaces. With the help of an example project, we will show you how to compile your own Qt®-based programs and automatically transfer them to the target.
Tip
Qt®, provided by The Qt Company® (a subsidiary of Digia Plc.®), is very commonly used for embedded systems and it is supported by our BSPs. Please visit http://www.qt.io in order to get all the documentation that is available about this powerful cross-platform GUI toolkit. Some demos that show the capabilities of Qt® are included in our BSPs.
Stop the Running Qt®Demo on the Target
A Qt® demo application starts automatically by default after the target has booted completely. Before we start compiling and running our example project out of Qt Creator®, we must first close this Qt® application.
- Open a serial connection with Microcom.
- After the target has booted, log in with root, and enter the following command to stop the Qt® application:
systemctl stop phytec-qtdemo
After the Qt® demo has been stopped with the command above, we can start to use Qt Creator®.
If you want to remove the phytec-qtdemo from the autostart, enter the following command:
systemctl disable phytec-qtdemo
Importing the Demo Application
We start by opening the Qt Creator® in a terminal, otherwise, the correct environment of the toolchain is not set.
- Open a terminal.
- Enter the path to the environment file for cross-compiling, start with:
source /opt/phytec-yogurt...
From here, complete the only path available:
example AM335x: source /opt/phytec-yogurt/BSP-Yocto-AM335x-PD17.2.2/environment-setup-cortexa9hf-neon-phytec-linux-gnueabi example i.MX8M: source /opt/phytec-yogurt-vendor-xwayland/BSP-Yocto-FSL-i.MX8M-PD19.1.0/environment-setup-aarch64-phytec-linux
- Enter the following command in the terminal to start Qt Creator®:
/usr/bin/qtcreator.sh &
Warning
Be sure to start Qt Creator® in a terminal. Otherwise, paths to the correct toolchain will be missing.
The user interface of Qt Creator® appears:
- Now, import the example project by clicking Open Project.
This opens a dialog in which the path to /opt/prj_workspace/Qt is set automatically.
- Double-click the HelloQuick folder.
- Select HelloQuick.pro and click Open.
The HelloQuick project is now imported into your Qt Creator® workspace.
Work with Demo Application
Our example project is a simple Qt Quick Application®. First, take a look at the user interface of our example:
- Expand the folder Resources and all the following under the project sidebar on the left side until you see the MainForm.ui.qml.
- Double-click on MainForm.ui.qml
Qt Creator® opens the design mode and you can see the design of our project, which has one label, two buttons, and one image with a PHYTEC logo inside.
- Right-click the “Hide Logo” button and select Go to Implementation from the context menu.
Now Qt Creator® jumps into the main.qml, where you can find the definition of the function btnHide.onClicked. You can see that clicking this button changes the status of the imgPHYTEC from visible to hidden.
Next, we build and run the example.
Compiling and Running the Demo Application on the Target
Now we want to compile and run the demo application on the target. To carry out the steps described in this section and section Debugging the Demo Application, you need a board with a display and touchscreen. If your kit does not include a display, continue with the next section Compiling and Running the Demo Application on the Host.
The correct Qt® settings are already pre-set in the virtual machine, so the project can be built directly.
Tip
If you want to check the settings, click Tools ► Options… in the menu bar. A new dialog appears. Click Build & Run if it is not already selected. Now, you can select different tabs to see the settings for the workspace, compiler, debugger, Qt® version, and many other options.
Warning
Be sure that the target is connected via Ethernet and is powered on. As described before, do not forget to stop all actually running Qt® applications on the target.
- With only one click the project will be built, deployed to the target, and executed.
- Click the green filled triangle near the bottom of the gray bar on the left.
After the target is successfully deployed onto the target, the Application Output frame is shown in the frame under the mainwindow.cpp source code where you can see the prompt from the target.
On the connected display, you will see the HelloQuick application. Click the buttons to disable and enable the PHYTEC logo.
- To see the different build steps click Compile output which can be found in the bottom menu bar.
The Compile output frame is opened and you can scroll through the compile steps.
- If you want to stop the application on the target switch back to the Application output frame and click the red rectangle there.
Tip
You have successfully imported and built a Qt® project with Qt Creator®. You have also learned how to download and execute your application on the target.
Compiling and Running the Demo Application on the Host
In some cases, you do not want to compile and run the application on the target. For example, if the target is not connected to the host or if you only changed some user interface relevant things and you do not want to copy the application and all the necessary resources to the target. Running the demo application on the host is faster, but features specific to the target do not work.
Warning
Remember that Qt Creator was started after sourcing the target's environment. If you want to debug the application on the host, you must start Qt Creator in a new terminal.
To change the target for downloading and running the application do the following steps:
- In the gray bar on the left, click the button with the small picture of the PHYTEC module.
- In the opened context menu, select Desktop as Kit and Release as Build.
- Click outside of the context menu to close it.
- Now you can start the compilation and execution of the application by clicking the green triangle.
- After the application is compiled, a window opens displaying the application running.
- Close the running application.
Debugging the Demo Application
We will finish the Qt Creator® chapter by showing how to debug the HelloQuick demo application. To carry out the steps described in this section, you need a board with a display and touchscreen.
Using Simple Debugging Messages
In our first debugging step, we will use the JavaScript function console.log() (the Qt/C++ counterpart is qDebug()). This function provides an output stream for debugging information. It is used whenever the developer needs to write out debugging or tracing information to a device, file, string, or console.
In the file main.qml, you will also see two out-commented lines in the signal for btnShow ( btnShow.onClicked: ) which start with a console.log command. This is an example of how to make use of the function.
- Remove the comment flags ( // ) from both "console.log lines" to enable the two debug messages.
- Save the changes with CTRL + S.
- Open the Application Output if it is not already opened.
- Build and run the application on the Desktop with the build configuration Release, as it was shown in the chapter before.
A window with the running application opens.
- Press the Show Logo button.
The logo was visible before we pressed the button so we can see the appropriate message from console.log() in the Application Output.
- Press the Hide Logo button and then the Show Logo button.
Now the logo was hidden before we pressed the Show Logo button again and we can see the appropriate messages from console.log() in the Application Output.
console.log() is a simple way to generate debug information. In the next chapter, we will use the debugger integrated into Qt Creator.
Using the Integrated Qt Creator® Debugger
Before we start the integrated Debugger, we first set a breakpoint where we want the demo application to stop.
- Open the main.qml if it is not already open.
- Right-click in front of line number 20.
- In the context menu, click Set Breakpoint at Line 20 to add a breakpoint.
You can now see a red filled circle with a small hourglass in front of this line. The next step is to change the build configuration from Release to Debug.
- In the gray bar on the left, click the button with the small Desktop icon.
- In the opened context menu select Target as Kit and Debug as Build.
Be sure that the target is connected via Ethernet to the host.
- Start Debugging by clicking on the green filled triangle with the small bug.
The debugger starts and Qt Creator® changes its view to the Debug mode.
The demo application is shown on the connected display.
- In the running demo application click the Hide Logo button.
The debugger stops at the created breakpoint where the function is called. You can now watch the stack, or the Locals and Expressions.
- Continue the stopped application by clicking on Continue.
Now the demo application is continued and waiting for user interactions.
- Stop the Debugger by pressing Stop Debugger.
Tip
You have successfully finished our short introduction to the Debugger from Qt Creator®.
Linux Host PC Setup
This chapter is for developers who want to get a native environment with the same modifications as in our virtual machine hard disk image or for developers who want to use their own existing environment. We will give an overview of the modifications which we made to the Ubuntu version in the virtual machine hard disk image in comparison to the original Ubuntu in this chapter. We also distinguish between optional and essential modifications, so you can easily see which changes are important to execute in this manual in case you do not want to use our modified Ubuntu version. The following step-by-step instruction is based on the use of Ubuntu 18.04.5.
Warning
We can not guarantee that the presented changes are compatible with other distributions or versions. If you want to use another distribution, it might take a lot of individual initiative. We do not support other distributions. You should be sure about what you do.
Essential Settings
In the following section, you will get a short instruction about the important settings which are essential to guarantee the execution of the examples in this manual.
Installing Ubuntu
Warning
We recommend having at least 120 GB of free disk space available.
Before we can start with the modification, we must first install Ubuntu.
- Download Ubuntu 18.04 LTS from http://www.ubuntu.com and create a bootable medium.
- Boot Ubuntu from your created boot medium.
- Select Install Ubuntu in the first Welcome window.
- The Preparing to install Ubuntu... window appears. From Ubuntu, it is advised that you select Download updates while installing and Install this third-party software now.
- Click Continue.
The Installation type window appears. You now have different options on how to install Ubuntu. Depending on your system, you have a number of possibilities that are shown in the dialog.
- Choose one and click Continue.
- The Install Ubuntu... window appears. After you have checked the settings you can click Install now.
When the installation is started Ubuntu asks for your location, keyboard layout along with login and password details.
- Please insert this information and wait until the installation is finished.
- Next, you must restart your system after the installation is finished.
- After that, the system boots up and you can log into Ubuntu.
- Configure your network connection now and connect the target.
Installing Software Packages
First of all, various software packages that are required must be installed using the package manager APT. To gain a better understanding of the packages required, they are installed separately according to their function:
- Packages which are needed for compiling and building the Board Support Package:
sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm
- Packages for development:
sudo apt-get install vim microcom meld
- Eclipse® requirements:
sudo apt-get install openjdk-8-jre-headless
- Packages to set up the TFTP server:
sudo apt-get install xinetd tftpd tftp
During installation, some programs may ask for a license agreement. Just go through the steps shown on the screen. The first preparations are completed. In the next sections, you will proceed with building the Board Support Package installation of Eclipse® and Qt Creator® and the set up of the TFTP server.
Configuring Git
The Board Support Package is heavily based on Git. Git needs some information from you as a user to be able to identify which changes were done by whom. You should set the name and email in your Git configuration, otherwise building the BSP generates many warnings.
- Enter the following two commands to directly set them:
git config --global user.email “your_email@example.com” git config --global user.name “name surname”
Get and Install the SDK
In this chapter, we install the SDK from the Board Support Package.
You can download the SDK-Installer online from our website or you can build the installer for the SDK on your own.
Tip
This step needs 3-5 hours depending on your PC's hardware. You can skip this step and download the prebuild SDK.
First, we create a folder for the BSP. In our example, we use the path as it is in our virtual machine.
- Enter the following commands (depending on your controller):
sudo mkdir -p /opt/PHYTEC_BSPs/<YOURCONTROLLER> sudo chmod -R 777 /opt/PHYTEC_BSPs/ cd /opt/PHYTEC_BSPs/<YOURCONTROLLER>/
- Download the phyLinux script and set execution privileges:
wget https://download.phytec.de/Software/Linux/Yocto/Tools/phyLinux chmod +x ./phyLinux
The phyLinux script is a basic management tool for PHYTEC Yocto BSP releases. It is mainly a tool to get started with the BSP structure. You can get all the BSP sources without the need of interacting with Repo or Git.
- Start the phyLinux script
./phyLinux init
During the execution of the init command, you need to choose your controller platform (e.g. AM335x), PHYTEC's BSP release number (e.g. PD16.1.0), and the hardware you are working on (e.g. phycore-r2-am335x-1).
Tip
If you do not have the standard RDK, you can find the appropriate value for the MACHINE variable on our website at http://www.phytec.de/produkte/software/yocto/phytec-unified-yocto-bsp-releases/. Click the corresponding BSP release and look for the ordering number of your module in the column "Hardware Article Number". Now you can find the correct machine name in the corresponding cell under "Machine Name".
After you have downloaded all the metadata with phyLinux, you have to set up the shell environment variables. This needs to be done every time you open a new shell for starting builds. We use the shell script provided by Poky in its default configuration.
- Type:
source sources/poky/oe-init-build-env
The current working directory of the shell should change to build/.
Now you are ready to build the SDK.
- Build the SDK:
bitbake phytec-qt5demo-image -c populate_sdk
- When the build process is finished, you can find the SDK under the following path:
./deploy/sdk/phytec-yogurt-*.sh
Download the SDK
The prebuild SDK installer can be found on our website:
www.phytec.de
under your specific product in the Download section.
Install the SDK
Depending on your previous method, you can now install the SDK by executing the SDK installer on the command line.
- Go to the path where you can find the installer (Download folder or under /opt/PHYTEC_BSPs/<YOURBSP>/build/deploy/sdk/ )
- Install the SDK into the recommended default directory:
./phytec-yogurt-*.sh
Setting up Eclipse® IDE for C/C++ Developers
The instructions in this chapter show how to setup Eclipse®. With this, you will be able to assign your own programs, written in Eclipse®, to the target.
- Download Eclipse® 2019-06 IDE for C/C++ Developers from the Eclipse® website (www.eclipse.org).
- Unpack the downloaded package to folder /opt/
- Create an Eclipse® executable in /usr/bin:
sudo vi /usr/bin/eclipse
Enter the following lines (depending on your target) to the new file:
#!/bin/bash export ECLIPSE_HOME="/opt/eclipse" $ECLIPSE_HOME/eclipse $*
- Add executable permissions:
sudo chmod +x /usr/bin/eclipse
- First, you have to create a workspace folder, in which you can save your Eclipse® projects. In this example, we create the workspace in the /opt/ directory as it is in the virtual machine:
mkdir -p /opt/prj_workspace/Eclipse sudo chmod -R 777 /opt/prj_workspace/
- Afterward, open Eclipse® and insert the path to the created workspace in the pop-up window:
eclipse
- Enter the path to the created workspace:
/opt/prj_workspace/Eclipse
- After Eclipse® is opened, click on Window -> Preferences
- When the Preferences window is opened, search for Remote Development under this context. Click on Remote Connections.
- Click Add and enter the following new connection settings:
Connection name: Device Host: 192.168.3.11 User: root Select Password based authentication keep the Password field empty
Tip
Congratulations! You have successfully installed Eclipse® and now you can start programming in C/C++. In the next section, you will find a short introduction on how to install and setup the Qt Creator®.
Installing and Setting up Qt Creator
Tip
This guide is using Qt version 5.13.0. If you want to use a newer version, please note that is not been tested.
- Download Qt Creator with the following command:
wget https://download.qt.io/official_releases/qt/5.13/5.13.1/qt-opensource-linux-x64-5.13.1.run
- Set execute privileges:
sudo chmod +x qt-opensource-linux-x64-5.13.1.run
- Run the Qt Creator installation routine:
./qt-opensource-linux-x64-5.13.1.run
This opens a window for the installation.
- Go through the installation and if you are asked, specify the following installation directory:
/opt/Qt
- You can skip the login to Qt Account.
- In the Select Components window, select the entries shown in the picture below and click Next.
- Proceed through the license agreement and start the installation.
- After the installation is finished, make a symbolic link to easily start Qt Creator:
sudo ln -s /opt/Qt/Tools/QtCreator/bin/qtcreator.sh /usr/bin/qtcreator.sh
- Create a workspace for Qt Creator:
mkdir -p /opt/prj_workspace/Qt/
- Start Qt Creator with the following command in a terminal:
/usr/bin/qtcreator.sh
- Add the target as device with the following inputs by opening Tools --> Options --> Devices --> Add --> Generic Linux Device:
Name: ARM IP: 192.168.3.11 Username: root Keep the password empty
- Set the project directory Tools --> Options --> Build & Run --> General.
Projects Directory --> Directory: /opt/prj_workspace/Qt
- Add build/ in the Default build directory after ../
- Select Kits --> Tab Qt Versions and click Add... to add a new one.
Name: ARM_QT qmake Location: /opt/phytec-yogurt<-VENDOR>/<YOURBSP>/sysroots/x86_64*sdk-linux/usr/bin/qt5/qmake
- Select tab Compilers, click Add select GCC and C
Name: ARM_GCC Compiler Path: /opt/phytec-yogurt<-VENDOR>/<YOURBSP>/sysroots/x86_64*sdk-linux/sdk-linux/usr/bin/<YOURARCHITECTURE>-phytec-linux*/<YOURARCHITECTURE>-phytec-linux*-gcc
- Select tab Compilers, click Add select GCC and C++
Name: ARM_GCC Compiler Path: /opt/phytec-yogurt<-VENDOR>/<YOURBSP>/sysroots/x86_64*sdk-linux/sdk-linux/usr/bin/<YOURARCHITECTURE>-phytec-linux*/<YOURARCHITECTURE>-phytec-linux*-gcc
- Select tab Debuggers and click Add:
Name: ARM_GDB Path: /opt/phytec-yogurt<-VENDOR>/<YOURBSP>/sysroots/x86_64*sdk-linux/sdk-linux/usr/bin/<YOURARCHITECTURE>-phytec-linux*/<YOURARCHITECTURE>-phytec-linux*-gdb
- Select tab Kit and click Add:
Name: ARM Device Type: Generic Linux Device Sysroot: /opt/phytec-yogurt<-VENDOR>/<YOURBSP>/sysroots/<YOURARCHITECTURE>-phytec-linux* Compiler C and C++: ARM_GCC Debugger: ARM_GDB Qt version: ARM_QT Qt mkspec: linux-oe-g++ CMake Configuration: CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
- Select Debugger on the left side of the window and click on the GDB tab.
- Enter the following command in the Addition Startup Commands:
set auto-load safe-path / handle SIGILL nostop
- Click Apply and close the window with OK.
Now all configurations are done and you can use this kit to cross-compile your application if you generate a new project too.
Setting up a TFTP Server
In the chapter "Installation of software packages", you installed the required packages to set up a TFTP server. Now we have to change some short settings.
- First, change the file /etc/xinetd.d/tftp as follows:
service tftp { protocol = udp port = 69 socket_type = dgram wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /tftpboot disable = no }
- Then, create a folder called /tftpboot. The TFTP server will access this folder later.
sudo mkdir /tftpboot
- Set the right permissions:
sudo chmod -R 777 /tftpboot sudo chown -R nobody /tftpboot/
- Restart the service to pick-up the configuration changes:
sudo /etc/init.d/xinetd stop sudo /etc/init.d/xinetd start
- Copy the images to the /tftpboot/ directory.
Tip
You have successfully set up the TFTP server. In the future, the target can access to the /tftpboot/ folder to load the images.
Optional Settings
In the following section, we list the optional settings. These settings are not mandatory for the successful operation of this manual. They only simplify the handling and the look of the system. Because of this, the modifications are only listed without further explanation.
- vim, the improved vi editor is installed.
- Desktop-icons for faster and easier start of required programs are created.
- The following modifications were made to the look of Ubuntu:
Other wallpaper and associated options are adjusted with the help of gsettings - The color of the Gnome terminal is changed. - The scrolling log for the Gnome terminal is changed.
- History-search-backward and history-search-forward in /etc/inputrc is activated.
This allows you to search through your history with the entered string.
Tip
Congratulations! You have successfully configured your Ubuntu.
Revision History
Date | Version # | Changes in this manual |
---|---|---|
24.10.2019 | L-833e.A10 |
|
25.07.2019 | L-833e.A9 | - Update Qt to 5.13.0 - Update to Eclipse 2019-6 |
24.07.2018 | L-833e_7 | - Update Qt to 5.11.1 (QtCreator® ) |
15.02.2018 | L-833e_6 | - Update Eclipse® to Oxygen 2 (4.7.2) |
04.08.2017 | L-833e_8 | - This version explains the VMs with included i.MX6-PD18.1.0 and is compatible to BSPs from L-833e_6 |
20.12.2017 | L-833e_5 | - English version updated |
24.11.2017 | L-833e_4 | - Update for AM335x-PD17.1.1, phyBOARD-Segin-Vendor-PD17.1.2, phyCORE-RK3288-PD17.1.1 |
26.07.2017 | L-833e_3 | - Update for phyBOARD-Segin PD17.1.0 |
12.05.2017 | L-833e_2 | - Remove section building the BSP |
11.01.2017 | L-833e_1 | - First draft based on L-779e_7 |