C
AWS EC2 Quick Start Guide
Qt offers all the necessary tools to design, develop, build, and deploy your application onto the target.
This guide describes how to use the GUIs of Qt tools to develop Linux applications on an AWS (Amazon Web Services) instance in the cloud. It describes the overall process and provides step-by-step instructions for the following tasks:
- Designing a simple UI using Qt Design Studio.
- Creating a project in Qt Creator and using a Qt Board Support Package (QBSP) for the AWS Graviton instance.
- Building and debugging the project on the target device.
Note: Qt for Device Creation requires a license. If you don't have one, you can request a free trial.
Overview
The figure below illustrates the simplified development process using Qt tools and QBSP for the AWS Graviton target instance.
- Development host is a development computer running Qt tools on Windows, Linux, or Mac.
- Qt tools includes development tools such as Qt Creator and Qt Design Studio, and quality assurance (QA) tools such as Squish.
- QBSP SDK contains a cross-compilation toolchain that is integrated into Qt Creator.
- Upload and debug an application using Qt Creator.
- Launch AWS instance to run Boot to Qt image on cloud.
- Remote connection to application via VNC provides a remote connection to target instance.
- AWS instance is an EC2 instance that runs your embedded Linux application.
- QBSP image is an AWS Graviton device image that can be used to boot your device using the Boot to Qt Software Stack.
Boot to Qt on AWS
For use on Amazon Elastic Compute Cloud (EC2), a Boot to Qt image has been created targeting the Graviton ARM processor core used by AWS. This image is packaged as an Amazon Machine Image (AMI) file that is available for deployment from the AWS Marketplace.
This virtual Qt target device can be used in the same manner as a physical hardware device; the full development tools suite from Qt can be used for design, development and testing of applications on the AWS cloud.
The tools suite includes Qt Design Studio, Qt Creator, Squish GUI Tester, and Axivion Suite. Further, the Qt tools can be run on either a physical development desktop or on a virtual workstation at AWS WorkSpaces.
Using the Boot to Qt EC2 instance
You need a commercial Qt for Device Creation license to install the Qt development tools. The Qt tools can be installed on a physical on-premises workstation, or on a virtual workbench hosted on AWS WorkSpaces. The installation process is the same for both, and fully described on this page.
Applicable AWS Target Instances
Instructions in this guide apply to the following AWS Graviton target instances:
- t4g.nano
- t4g.micro
- t4g.small
- t4g.medium
- t4g.large
- t4g.2xlarge
- g5g.large
- g5g.2xlarge
- g5g.4xlarge
Note: For more details on the supported target instances and development hosts, see Supported Target Devices and Development Hosts.
Installing Qt
Follow the procedures in this guide to get all the required resources, including Qt Creator and Qt Design Studio.
- Sign in to Qt Customer Portal to download Qt Online Installer.
- The installer is available for the following hosts:
- Linux on ARM
- Linux x86
- macOS
- Windows
Download the installer package that matches your host.
- Open the installer.
- Continue to Installation Folder and select Custom installation.
- Select Next.
- In Select Components, select Qt 6.9.0. The required developer and designer tools (such as Qt Creator and Qt Design Studio) are preselected in the installer.
- Select Next.
- Continue to Ready to Install and select Install.
Note: If you have Qt already installed, use Qt Maintenance Tool to install the missing tools.
Installing Boot to Qt Software Stack Using Qt Maintenance Tool
To install Boot to Qt Software Stack for an AWS Graviton instance, do the following:
- Open Qt Maintenance Tool.
- Continue to Select Components and open the top-level Boot to Qt Software Stack dropdown menu.
- Open the correct Qt release-specific Boot to Qt Software Stack dropdown menu.
- Select AWS EC2 ARM64.
- Continue to Ready to Install and select Install.
Overview of Instantiating Boot to Qt AMI
You have three options to choose from: Instantiate Boot to Qt AMI from AWS Marketplace, upload the AMI installed from QBSP, or build and upload a custom AMI. You need to configure AWS according to your chosen installation method.
For more information on building and uploading a custom AMI, see Customizing Boot to Qt for an AWS device.
Launching Boot to Qt AMI from AWS Marketplace
To launch a Boot to Qt instance from AWS Marketplace, follow these steps:
- Open the Amazon EC2 console.
- On the EC2 console dashboard, in the Launch instance box, select Launch instance.
- Under Name and tags, for Name, enter a name for your instance.
- Under Application and OS Images (Amazon Machine Image), do the following:
- Search Boot to Qt in the search field and then select it in AWS Marketplace AMIs results. This is the operating system (OS) for your instance.
- Under Instance type, from the Instance type list, you can select the hardware configuration for your instance. Choose either t4g or g5g; the default choice is g5g.large. G5g offers GPU support and higher performance. T4g offers software rendering but doesn't support hardware acceleration.
- Under Key pair (login), for Key pair name, choose the key pair that you created when getting set up.
Warning: Do not choose Proceed without a key pair (Not recommended). If you launch your instance without a key pair, you can't connect to it.
- In Network settings, choose Edit. For Security group name, you'll see that the wizard created and selected a security group for you. You can use this security group, or alternatively you can select the security group that you created when getting set up using the following steps:
- Choose Select existing security group.
- From Common security groups, choose your security group from the list of existing security groups.
- Keep the default selections for the other configuration settings for your instance.
- Review a summary of your instance configuration in the Summary panel, and when you're ready, choose Launch instance.
- A confirmation page lets you know that your instance is launching. Choose View all instances to close the confirmation page and return to the console.
- On the Instances screen, you can view the status of the launch. It takes a short time for an instance to launch. When you launch an instance, its initial state is
pending
. After the instance starts, its state changes torunning
and it receives a public DNS name.Note: If the Public IPv4 DNS column is hidden, choose the settings icon in the top-right corner, toggle on Public IPv4 DNS, and choose Confirm.
- It can take a few minutes for the instance to be ready for you to connect to it. Check that your instance has passed its status checks; you can view this information in the Status check column.
Uploading Boot to Qt AMI from QBSP
Before uploading you might also need to configure your AWS account. Please see AWS documentation for details. However, here are some tips.
- Open your account's security credentials.
- Select Create access key.
- Check the box that acknowledges root access is not best practice.
- Select Create access key.
- Copy or download the generated Access Key and the Secret Access Key.
- Configure AWS cmd line tools. From a cmd line, run
aws configure
- When prompted, supply the Access Key and Secret Access Key obtained above.
- When prompted for region, supply the desired region.
- When prompted for default output format, leave it blank.
- Create an aws-bucket for AMI upload.
- Start by opening the AWS S3 Console.
- In the left-hand panel select Buckets and then Create Bucket.
- Provide a unique name for the bucket and select the desired region.
- Scroll down and select Create Bucket.
See AWS instructions for uploading image to AWS.
The upload script expects to find build aggregates at fixed path. Download the upload script and also copy Boot to Qt build aggregates to correct path so that create-ec2-ami.sh
can find them.
curl -L https://raw.githubusercontent.com/aws4embeddedlinux/meta-aws/master/scripts/ec2-ami/create-ec2-ami.sh --create-dirs --output sources/meta-aws/scripts/ec2-ami/create-ec2-ami.sh && chmod +x "${_}" mkdir -p build/tmp/deploy/images/aws-ec2-arm64/ cp <Qt-install-path>/<version>/Boot2Qt/aws-ec2-arm64/images/* build/tmp/deploy/images/aws-ec2-arm64/
Now you have sources/
and build/
folders so you can run the script to upload the AMI image. You need to replace <aws-bucket> with your AWS bucket name.
sources/meta-aws/scripts/ec2-ami/create-ec2-ami.sh <aws-bucket> 8 b2qt-embedded-qt6-image aws-ec2-arm64
Update your AWS permissions by following steps 1, 2, 3, and 6 in Required service role.
Note: The steps in this document require you to replace disk-image-file-bucket with the S3 Bucket's name you created in the previous step.
Launching Boot to Qt AMI as EC2 Instance
After successful upload the script reports AMI ID, which you can find and launch as an EC2 instance at AWS > EC2 > AMIs as follows:
Note: Make sure that SSH port 22 is open for incoming SSH traffic. You can add a new security group to cover this, if necessary.
- Select the uploaded AMI and then select Launch instance from AMI.
- Enter Name and Key pair for SSH login, then select Launch instance.
- Wait for the instance to pass Status checks.
- Connect to instance over SSH client as user.
Note: Root login is disabled by default. Instead, you can log in as user
.
The IP address of the instance changes on every reboot. To keep IP address fixed go to EC2 > Elastic IPs and select Associate Elastic IP address to AMI Instance.
Open EC2 > AMI Catalog and launch Boot to Qt AMI. Then connect to instance over SSH client.
Connecting the Target Device
A Boot to Qt device can be connected via network.
After the target device is connected and has a public IP address, you can set it up to Qt Creator with the following steps:
- Open Qt Creator.
- Select Edit > Preferences.
- In the Preferences window:
- Select Devices.
- Select Add > Boot2Qt Device > Start Wizard.
- In the Boot2Qt Network Device Setup window:
- Enter the Device name.
- Enter the Host name (IP address of the AWS Graviton device).
- Select Specific key.
- Select Finish.
- On the Devices tab:
- Select OK.
Note: Qt Creator uploads the application over the IP network, so the AWS Graviton device has to be in the same network as your development host PC.
Creating an Application UI in Qt Design Studio
You can use Qt Design Studio to create a cross-platform UI, also for embedded Linux applications.
- Open Qt Design Studio.
- Select Create Project.
- In Presets, select General.
- Name your project (also notice the project path to open it with Qt Creator).
- Adjust display resolution and orientation to suit your display.
- Make sure your Target Qt Version matches the version of Qt installed on your machine.
- Select Create.
- Select File > Export Project > Enable CMake Generator. With the resulting CMakeLists.txt file, you can open your project via Qt Creator.
Now you can modify your UI as you wish. Once it's ready, select Save All to make sure that you can open your UI project in Qt Creator.
Configuring and Building an Application in Qt Creator
- Open Qt Creator.
- Navigate to the project you created with Qt Design Studio.
- Select CMakeLists.txt to open the project.
- In the Configure Project window:
- Select your AWS EC2 ARM64 kit.
- Select Configure Project.
Finally, select Build > Build Project to build the project you configured.
Running an Application on the Instance
After setting up your device, you can upload and start your application on the AWS Graviton instance.
- Open Qt Creator.
- Select File > Open File or Project.
- Navigate to the project you configured earlier and select Open.
- In the Projects window:
- Edit the Run Settings if necessary.
- Select Run.
Note: To make changes to your application, you can update it on the device simply by running it again.
Note: Qt Creator examples are uploaded to /usr/examples by default but "user" has no access to that folder, so you need to change install directory in Qt Creator or simply create that folder for "user", for example
sudo mkdir /usr/examples sudo chown user /usr/examples
You can set up application graphics in two different ways based on EC2 Instance capabilities.
1. Using EC2 Instance with GPU
EGLFS and Wayland are supported on EC2 Instances with NVIDIA GPU. To use EGLFS, set QT_QPA_PLATFORM=eglfs
or use the parameter '-platform eglfs'
and add VncItem under Qml Window of your application or Wayland compositor, for example as follows:
import QtVncServer Window { ... VncItem { id : vncItem anchors.fill: parent }
For more information on QtVncServer, see Qt VNC Server.
To use Wayland, start Wayland compositor with EGLFS as above. Then use '-platform wayland-egl'
in Wayland client to connect it to Wayland compositor.
At the moment, you also need to modify main.cpp to add
{QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true)}
and remove
{QSurfaceFormat::setDefaultFormat(QQuick3D::idealSurfaceFormat())}
if it exists, to use NVIDIA GPU drivers.
2. Using EC2 Instance without GPU
Qt VNC plugin can be used on EC2 Instances without GPU. To use Qt VNC plugin, set QT_QPA_PLATFORM=vnc
or use the parameter '-platform vnc'
when starting the application.
Connecting User Interface to EC2 Instance via VNC
Open SSH tunnel from your local host to your instance, for example as follows:
ssh -i <ami-key.pem> -L 5900:localhost:5900 user@ec2-<ami-ip-address>.compute-1.amazonaws.com
Note: Root login is disabled over SSH but you can use sudo after you're logged in.
Root and password login are disabled by default so you need to log in over SSH as "user". Also note that login key as in ssh -i <key>.pem
must have access rights set only for user, for example on Linux chmod 400 <key>.pem
.
Note: You need to have Qt application running before connecting via VNC because Qt application starts Qt VNC server.
Open VNC viewer and connect to your instance over the SSH tunnel:
Protocol: VNC Host: localhost:5900
Note: If VNC viewer gives an error about mismatching security types, try a different VNC viewer.
Debugging an Application
To enable debugging on Boot to Qt AMI, open TCP port 10000 in AMIs > Security group > Edit inbound rules.
For more information on using Qt Creator to debug an application, see Debugging.
Customizing Boot to Qt for an AWS device
Boot to Qt for embedded Linux is built using the tools and resources from the Yocto Project. For more information on how to set up a building environment for building Boot to Qt, see Setting Up Environment for Building Boot to Qt.
This section provides an example on how to build Boot to Qt for an AWS Graviton instance.
For more information on how to create a custom Boot to Qt image, see How to Create Boot to Qt Image.
- Initialize the build environment from the manifest repository.
cd <BuildDir> repo init -u https://code.qt.io/yocto/boot2qt-manifest -m aws/v6.9.0.xml repo sync
Note: In the example above
6.9.0.xml
refers to a specific Boot to Qt version, but you can use any version that is compatible with your target device. - Configure the build environment for Linux.
export MACHINE=aws-ec2-arm64 && source ./setup-environment.sh
- To use NVIDIA GPU in the AWS instance with this Boot2Qt AMI, you first need to download the NVIDIA driver package Then, set NVIDIA_DEVNET_MIRROR variable in your
local.conf
to point to the download directory. To find the currently supported driver version, refer to this README file in code.qt.io. - Start building a QBSP for Boot to Qt.
bitbake meta-b2qt-embedded-qbsp
After the build has been completed, you can find the QBSP file at
boot2qt/build-aws-ec2-arm64/tmp/deploy/qbsp/meta-b2qt-embedded-qbsp-x86_64-aws-ec2-arm64-6.9.0.qbsp
.
Troubleshooting
If you have any issues with your instance, see Amazon documentation.
For more information on troubleshooting Boot to Qt, see Troubleshooting.
Available under certain Qt licenses.
Find out more.