Creating an Asteroid app: Difference between revisions

From AsteroidOS
(added category)
 
(20 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:Developers]]
[[Category:Developers]]
= Using QtCreator =
Creating an AsteroidOS app can be fun and rewarding.  Creating an app requires the installation of the Software Development Kit (SDK) as described in [[Installing the SDK]].  The rest of this page assumes that you already have the SDK installed.
QtCreator is an integrated development environment for making Qt QML applications.


== Getting the Cross Compilation Toolchain ==
= Building from the command line =
Generally, to build a CMake project from the command line, use this:


The app creation process of AsteroidOS needs a Software Development Kit generated by OpenEmbedded. You can either grab a prebuilt SDK for the nightlies [https://release.asteroidos.org/nightlies/sdk/oecore-x86_64-armv7vehf-neon-toolchain-nodistro.0.sh here] and install it on your system or you can build it yourself as follows:
<pre>
export CMAKE_PROGRAM_PATH=/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi/usr/bin/
source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
cmake -B build
cmake --build build
</pre>


== Building the Cross Compilation Toolchain ==
If you're building for the [[Emulator]], use this instead:
<pre>
export CMAKE_PROGRAM_PATH=/usr/local/oecore-x86_64/sysroots/core2-32-oe-linux/usr/bin
source /usr/local/oecore-x86_64/environment-setup-core2-32-oe-linux
cmake -B build
cmake --build build
</pre>


Alternatively you can also build the toolchain from source. If you’ve already got an OpenEmbedded build directory via the [[Building AsteroidOS]] page, cd to that directory. Else, create one with:
== Example project ==
A example project, asteroid-helloworld is available as both an example and a template for new software.  To fetch it from <code>git</code> and build it, use the following:


=== Build without containers ===
<pre>
git clone https://github.com/AsteroidOS/asteroid-helloworld.git
cd asteroid-helloworld
export CMAKE_PROGRAM_PATH=/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi/usr/bin/
source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
cmake -B build -DCMAKE_INSTALL_PREFIX:PATH=/usr
cmake --build build --target package
</pre>


<code>
If everything was successful, you should now have a new library named <code>asteroid-helloworld.so</code> in the <code>build</code> directory. You should also have an <code>.ipk</code> file in the build directory.  If the watch is connected via USB to the host computer, you can copy this to the watch and then install it with:
git clone https://github.com/AsteroidOS/asteroid
cd asteroid/
</code>


Then, build the cross compilation toolchain with:
<pre>
scp build/asteroid-helloworld*.ipk root@192.168.2.15:.
ssh root@192.168.2.15 "opkg install asteroid-helloworld*.ipk"
</pre>


<code>
Note that we specify the <code>CMAKE_INSTALL_PREFIX</code> in the commands above. This is to assure that the package is built to install the software in <code>/usr/lib/</code> rather than <code>/usr/local/lib/</code> which would otherwise be the default.  The <code>--target package</code> instructs CMake to build a package the <code>.ipk</code> file in our case.
source ./prepare-build.sh dory
bitbake meta-toolchain-qt5
Once the software is installed, it should show up as the last item on the launcher page.  Pressing the icon should show an orange background with the words "Hello World!" in white.  You should make sure all of this works before going further with development.
</code>


=== Build with containers ===
= Using QtCreator =


Assuming you already prepared a docker or podman build environment like in: [[Building AsteroidOS]].
QtCreator is an integrated development environment for making Qt QML applications.  Previous versions of QtCreator allowed the use of passwords on the watch, but more recent versions require using SSH certificates.  For this reason, the first thing to do is to prepare the watch to allow logging in using certificates.


<code>
==Prepare the watch to use certificates==
sudo docker rm -f asteroidos-toolchain
By default, there are two configured users on the watch: <code>root</code> and <code>ceres</code> both without passwords. The first step in deploying is to set up passwords for both users. This can be done by logging into the watch as each user and then running the <code>passwd</code> command to change the password. Remember each password because they will be needed later.
sudo docker run -it \
  --name asteroidos-toolchain \
  -v /etc/passwd:/etc/passwd:ro \
  -u "$(id -u):$(id -g)" \
  -v "$HOME/.gitconfig:/$HOME/.gitconfig:ro" \
  -v "$(pwd):/asteroid" asteroidos-toolchain \
  bash -c "source ./prepare-build.sh dory && bitbake meta-toolchain-qt5"


</code>
The next step is to modify the <code>/etc/ssh/sshd_config</code> file on the watch.  The two settings to modify are:


or
<pre>
PubkeyAuthentication yes
PermitEmptyPasswords no
</pre>


<code>
Once this is done, log out and then try to log back in via <code>ssh</code>. You should be asked for the password.  If so, then type in the password you just set and verify that things work.
podman run --rm -it \
  -v "$(pwd)":/asteroid:z \
  --userns keep-id asteroidos-toolchain \
  bash -c "source ./prepare-build.sh dory && bitbake meta-toolchain-qt5"


</code>
The next step is to generate and copy a public key from your Linux computer to the watch.  Although this can, in theory, be done from within QtCreator, doing so can be difficult to debug if things don't work perfectly.  For that reason, this guide will only describe the command-line method. 


== Install the SDK ==
First generate a key pair *on the host Linux computer* if there isn't already one there.  This is typically done by running <code>ssh-keygen</code>.  Different kinds of keys may be generated, but this example assumes an RSA key is generated.  Once the key pair is created, you can deploy the public key to the watch:


If you downloaded a prebuilt SDK, run the downloaded script. If you followed the previous steps, this will have generated the same installation script in <code>tmp-glibc/deploy/sdk/</code>, you can run it as follows:
<pre>
ssh-copy-id -i ~/.ssh/id_rsa.pub ceres@192.168.2.15
</pre>


<code>
==Install additional packages==
./tmp-glibc/deploy/sdk/oecore-x86_64-armv7vehf-neon-toolchain-nodistro.0.sh
Two other software packages must be installed on the watch for QtCreator's "Test" to pass.  They are <code>base64</code> and <code>rsync</code>.  The <code>base64</code> software is part of the <code>coreutils</code> package and can be installed with this command as the <code>root</code> user on the watch:
</code>


This script will install the cross-compiler and ARM libraries in <code>/usr/local/oecore-x86_64</code> by default, along with a script that needs to be sourced before every build. If you want to build a simple project via the terminal, this can be done like that:
<pre>
opkg install coreutils
</pre>


<code>
The <code>rsync</code> package is, at this time, not built as part of the packages, and so it must be built using <code>bitbake</code> as described [[https://wiki.asteroidos.org/index.php/Building_AsteroidOS]].  Instead of <code>bitbake asteroid-image</code>, one can just build the <code>rsync</code> package with <code>bitbake rsync</code>.
source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
cmake -B build
cmake --build build
</code>


==Configure QtCreator for cross compilation==


== Configure QtCreator for cross compilation ==
Before running QtCreator you must run the previously mentioned script and set up the <code>CMAKE_PROGRAM_PATH</code>.


Before running QtCreator you must run the previously mentioned script:
<pre>
 
export CMAKE_PROGRAM_PATH=/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi/usr/bin/
<code>
source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
qtcreator
qtcreator
</code>
</pre>
One other environment variable needs to be set to work seamlessly with AsteroidOS:
 
<code>
export CMAKE_PROGRAM_PATH=/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi/usr/bin/
</code>


This can be done automatically by prepending <code>source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi</code> and the export command before <code>#!/bin/sh</code> in <code>/usr/bin/qtcreator.sh</code>
This can be done automatically by prepending <code>source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi</code> and the export command before <code>#!/bin/sh</code> in <code>/usr/bin/qtcreator.sh</code>


Now that you are in QtCreator go to <code>Tools</code> &rarr; <code>Options</code> &rarr; <code>Devices</code>
Now that you are in QtCreator go to <code>Edit</code> &rarr; <code>Preferences</code> &rarr; <code>Devices</code>
 
- Add a new Generic Linux Device.
- Name it "AsteroidOS Watch".
- Choose 192.168.2.15 as IP address.
- Use root as user.
- Choose Password authentication and leave the password field empty.
 


<ul>
  <li>Add a new Remote Linux Device</li>
  <li>Name it "AsteroidOS Watch"</li>
  <li>Choose 192.168.2.15 as IP address</li>
  <li>Choose 22 as the port</li>
  <li>Use ceres as user</li>
</ul>
<br>
Under the <code>Kits</code> add a kit with the previously defined device:
Under the <code>Kits</code> add a kit with the previously defined device:
- Set <code>Device type</code> to Generic Linux Device.
<ul>
- Set the <code>Device</code> to AsteroidOS Watch.
  <li>Set <code>Device type</code> to Remote Linux Device</li>
- Set the sysroot to <code>/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi/</code>.
  <li>Set the <code>Device</code> to AsteroidOS Watch</li>
- In the CMake generator change the <code>Generator</code> to <code>Unix Makefiles</code>.
  <li>Set the sysroot to <code>/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi/</code></li>
- Change <code>Qt version</code> to <code>None</code>.
  <li>In the CMake generator change the <code>Generator</code> to <code>Unix Makefiles</code></li>
- Change <code>C</code> compiler to <code><No compiler></code>.
  <li>Change <code>Qt version</code> to <code>None</code></li>
- Change <code>C++</code> compiler to <code><No compiler></code>.
  <li>Change <code>C</code> compiler to <code><No compiler></code></li>
- Change <code>CMake Tool</code> to System CMake at /usr/local/oecore-x86_64/usr/bin/cmake
  <li>Change <code>C++</code> compiler to <code><No compiler></code></li>
- Clear the <code>CMake Configuration</code> fields.
  <li>Change <code>CMake Tool</code> to "AsteroidOS CMake" at <code>/usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/cmake</code></li>
  <li>Clear the <code>CMake Configuration</code> fields</li><li>Add a CMake variable: </li>
</ul><code>OE_QMAKE_PATH_EXTERNAL_HOST_BINS:STRING=%{Env:OE_QMAKE_PATH_HOST_BINS}</code>


Note that if these steps are not done *in this order*, QtCreator will not let you change both the <code>C</code> compiler and <code>C++</code> compiler to <code><No compiler></code>.  Specifically, setting Qt version to <code>None</code> must be done first.
Note that if these steps are not done *in this order*, QtCreator will not let you change both the <code>C</code> compiler and <code>C++</code> compiler to <code><No compiler></code>.  Specifically, setting Qt version to <code>None</code> must be done first.


= First app =
= First app=


[https://github.com/AsteroidOS/asteroid-helloworld Asteroid-helloworld] can act as a cool QML demo app to make your first steps into AsteroidOS development easier. You can clone it, build it, install it and then modify it to follow your needs:
[https://github.com/AsteroidOS/asteroid-helloworld Asteroid-helloworld] can act as a cool QML demo app to make your first steps into AsteroidOS development easier. You can clone it, build it, install it and then modify it to follow your needs:


<code>
<pre>
git clone https://github.com/AsteroidOS/asteroid-helloworld
git clone https://github.com/AsteroidOS/asteroid-helloworld
cd asteroid-helloworld/
cd asteroid-helloworld/
export CMAKE_PROGRAM_PATH=/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi/usr/bin/
source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
qtcreator CMakeLists.txt
qtcreator CMakeLists.txt
</code>
</pre>


Try to build and deploy the app. If it wasn’t already installed, a new icon should have already appeared on asteroid-launcher.
Try to build and deploy the app. If it wasn’t already installed, a new icon should have already appeared on asteroid-launcher.
Line 121: Line 129:
You can start by modifying occurrences of “asteroid-helloworld” to your app’s name. Then you can change the *.desktop file which describes the icon on the apps launcher. Then modify main.qml to describe your UI. To get started with QML development you can read the [http://doc.qt.io/qt-5/qml-tutorial.html official tutorial].
You can start by modifying occurrences of “asteroid-helloworld” to your app’s name. Then you can change the *.desktop file which describes the icon on the apps launcher. Then modify main.qml to describe your UI. To get started with QML development you can read the [http://doc.qt.io/qt-5/qml-tutorial.html official tutorial].


== Deploy an app from QtCreator ==  
==Deploy an app from QtCreator==  


Open the project as described in the previous sections.
Open the project as described in the previous sections.
<ul>
  <li>Click on the <code>Projects</code> button on the left sidebar</li>
  <li>Under the <code>Build & Run</code> section click on the <code>Run</code> configuration. This opens all run settings</li>
  <li>Scroll down to the <code>Run</code> settings</li>
</ul>


- Click on the <code>Projects</code> button on the left sidebar.
- Under the <code>Build & Run</code> section click on the <code>Run</code> configuration. This opens all run settings.
- Scroll down to the <code>Run</code> settings.


Change the following <code>Run</code> settings:
Change the following <code>Run</code> settings:
- Set the <code>Run configuration</code> to <code>Custom Executable (on AsteroidOS Watch)</code>.
<ul>
- Set the <code>Remote executable</code> to <code>invoker</code>. Add the <code>--single-instance --type=qtcomponents-qt5 /usr/local/bin/asteroid-helloworld</code> command line arguments.
  <li>Set the <code>Run configuration</code> to <code>Custom Executable (on AsteroidOS Watch)</code></li>
  <li>Under "Files to deploy" select "Override deployment data from build system"</li>
  <li>Set the <code>Remote executable</code> to <code>asteroid-helloworld</code><br></li></ul>Under <code>Environment</code> select "Fetch Device Environment"
<ul>
<li>Change <code>XDG_RUNTIME_DIR</code> and set its value to <code>/run/user/1000</code>. So that the invoker works under the root user</li>
<li>Add <code>QT_QPA_PLATFORM</code> and set its value to <code>wayland</code></li>
<li>(Optional) Add <code>QT_WAYLAND_DISABLE_WINDOWDECORATION</code> with value <code>1</code>to make the app full screen and hide the titlebar</li>
</ul>
Your app should now be able to run from the application when you click the start button in the bottom left sidebar.  Make sure you have the display on to be able to see the app.  If you have "Tap-to-wake" turned on in the "Display" settings on the watch, tapping the display to wake up the screen before running the application should work.


Change the following <code>Environment</code> variables:
=Tips and tricks=
- Add <code>XDG_RUNTIME_DIR</code> and set its value to <code>/run/user/1000</code>. So that the invoker works under the root user.
- (Optional) Add <code>QT_WAYLAND_DISABLE_WINDOWDECORATION</code> with value <code>1</code>. To make the app full screen and hide the titlebar.


Your app should now be able to run from the application when you click the start button in the bottom left sidebar.
If you want to start your app from the command line, open a shell with [[SSH]], connect to ceres and use the shell script which, in turn, calls invoker:
 
= Tips and tricks =
 
If you want to start your app from the command line, open a shell with [[SSH]], connect to ceres and use invoker:


<code>
<code>
invoker --type=qtcomponents-qt5 /usr/bin/asteroid-stopwatch
asteroid-stopwatch
</code>
</code>


Line 152: Line 164:
mcetool -D on
mcetool -D on
</code>
</code>
= Troubleshooting =
 
Don't forget to turn it back off when you are done to avoid draining the battery.
=Troubleshooting=


The most common problems stem from not following these directions *exactly*.  QtCreator helpfully tries to find compilers and set variables, but tends to set things up for the desktop as the target rather than AsteroidOS, so it often gets things wrong.  The first step for troubleshooting with QtCreator is to go very carefully over each of the steps listed above and verify that they all match exactly.
The most common problems stem from not following these directions *exactly*.  QtCreator helpfully tries to find compilers and set variables, but tends to set things up for the desktop as the target rather than AsteroidOS, so it often gets things wrong.  The first step for troubleshooting with QtCreator is to go very carefully over each of the steps listed above and verify that they all match exactly.


== Could not find a package configuration file provided by "ECM" ==
==Could not find a package configuration file provided by "ECM" ==


This is most often caused not having the environment variables set up as shown above under the topic of [[#Configure QtCreator for cross compilation | configuring QtCreator]].  The environment variables must all be set and then you must lauch <code>qtcreator</code> *in the same shell*.  If you're not sure you've done this, an easy way to check is to try this command from the command line:
This is most often caused not having the environment variables set up as shown above under the topic of [[#Configure QtCreator for cross compilation | configuring QtCreator]].  The environment variables must all be set and then you must lauch <code>qtcreator</code> *in the same shell*.  If you're not sure you've done this, an easy way to check is to try this command from the command line:
Line 175: Line 189:
This is not really an error but a warning.  It's the result of having correctly chosen <code><No compiler></code> as per the instructions above and may safely be ignored.
This is not really an error but a warning.  It's the result of having correctly chosen <code><No compiler></code> as per the instructions above and may safely be ignored.


== file INSTALL cannot find ... .desktop ==
== file INSTALL cannot find ... .desktop==


This is probably the result of a missing <code>CMAKE_PROGRAM_PATH</code>.  As mentioned above, this must be set in order for a script that generates the desktop file to be correctly found and uses.
This is probably the result of a missing <code>CMAKE_PROGRAM_PATH</code>.  As mentioned above, this must be set in order for a script that generates the desktop file to be correctly found and uses.


== Remote process crashed ==
==Remote process crashed==


One possibility is that your software has a bug, but another is that the <code>XDG_RUNTIME_DIR</code> is not set to <code>/run/user/1000</code> as mentioned above.
One possibility is that your software has a bug, but another is that the <code>XDG_RUNTIME_DIR</code> is not set to <code>/run/user/1000</code> as mentioned above.


== "I fixed it but I get the same error!" ==
=="I fixed it but I get the same error!"==


This most often happens when something was originally wrong with the configuration, but a CMake scan was made and a possibly faulty Makefile from an earlier attempt still exists.  To fix this, choose <code>Build</code> from the menu, and then <code>Rescan project</code>.  This will run CMake again, ignoring existing cached values and forcing the recreation of a Makefile.
This most often happens when something was originally wrong with the configuration, but a CMake scan was made and a possibly faulty Makefile from an earlier attempt still exists.  To fix this, choose <code>Build</code> from the menu, and then <code>Rescan project</code>.  This will run CMake again, ignoring existing cached values and forcing the recreation of a Makefile.

Latest revision as of 23:13, 16 November 2024

Creating an AsteroidOS app can be fun and rewarding. Creating an app requires the installation of the Software Development Kit (SDK) as described in Installing the SDK. The rest of this page assumes that you already have the SDK installed.

Building from the command line

Generally, to build a CMake project from the command line, use this:

export CMAKE_PROGRAM_PATH=/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi/usr/bin/
source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
cmake -B build
cmake --build build

If you're building for the Emulator, use this instead:

export CMAKE_PROGRAM_PATH=/usr/local/oecore-x86_64/sysroots/core2-32-oe-linux/usr/bin
source /usr/local/oecore-x86_64/environment-setup-core2-32-oe-linux
cmake -B build
cmake --build build

Example project

A example project, asteroid-helloworld is available as both an example and a template for new software. To fetch it from git and build it, use the following:

git clone https://github.com/AsteroidOS/asteroid-helloworld.git
cd asteroid-helloworld
export CMAKE_PROGRAM_PATH=/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi/usr/bin/
source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
cmake -B build -DCMAKE_INSTALL_PREFIX:PATH=/usr
cmake --build build --target package

If everything was successful, you should now have a new library named asteroid-helloworld.so in the build directory. You should also have an .ipk file in the build directory. If the watch is connected via USB to the host computer, you can copy this to the watch and then install it with:

scp build/asteroid-helloworld*.ipk root@192.168.2.15:.
ssh root@192.168.2.15 "opkg install asteroid-helloworld*.ipk"

Note that we specify the CMAKE_INSTALL_PREFIX in the commands above. This is to assure that the package is built to install the software in /usr/lib/ rather than /usr/local/lib/ which would otherwise be the default. The --target package instructs CMake to build a package the .ipk file in our case.

Once the software is installed, it should show up as the last item on the launcher page. Pressing the icon should show an orange background with the words "Hello World!" in white. You should make sure all of this works before going further with development.

Using QtCreator

QtCreator is an integrated development environment for making Qt QML applications. Previous versions of QtCreator allowed the use of passwords on the watch, but more recent versions require using SSH certificates. For this reason, the first thing to do is to prepare the watch to allow logging in using certificates.

Prepare the watch to use certificates

By default, there are two configured users on the watch: root and ceres both without passwords. The first step in deploying is to set up passwords for both users. This can be done by logging into the watch as each user and then running the passwd command to change the password. Remember each password because they will be needed later.

The next step is to modify the /etc/ssh/sshd_config file on the watch. The two settings to modify are:

PubkeyAuthentication yes
PermitEmptyPasswords no

Once this is done, log out and then try to log back in via ssh. You should be asked for the password. If so, then type in the password you just set and verify that things work.

The next step is to generate and copy a public key from your Linux computer to the watch. Although this can, in theory, be done from within QtCreator, doing so can be difficult to debug if things don't work perfectly. For that reason, this guide will only describe the command-line method.

First generate a key pair *on the host Linux computer* if there isn't already one there. This is typically done by running ssh-keygen. Different kinds of keys may be generated, but this example assumes an RSA key is generated. Once the key pair is created, you can deploy the public key to the watch:

ssh-copy-id -i ~/.ssh/id_rsa.pub ceres@192.168.2.15

Install additional packages

Two other software packages must be installed on the watch for QtCreator's "Test" to pass. They are base64 and rsync. The base64 software is part of the coreutils package and can be installed with this command as the root user on the watch:

opkg install coreutils

The rsync package is, at this time, not built as part of the packages, and so it must be built using bitbake as described [[1]]. Instead of bitbake asteroid-image, one can just build the rsync package with bitbake rsync.

Configure QtCreator for cross compilation

Before running QtCreator you must run the previously mentioned script and set up the CMAKE_PROGRAM_PATH.

export CMAKE_PROGRAM_PATH=/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi/usr/bin/
source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
qtcreator

This can be done automatically by prepending source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi and the export command before #!/bin/sh in /usr/bin/qtcreator.sh

Now that you are in QtCreator go to EditPreferencesDevices

  • Add a new Remote Linux Device
  • Name it "AsteroidOS Watch"
  • Choose 192.168.2.15 as IP address
  • Choose 22 as the port
  • Use ceres as user


Under the Kits add a kit with the previously defined device:

  • Set Device type to Remote Linux Device
  • Set the Device to AsteroidOS Watch
  • Set the sysroot to /usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi/
  • In the CMake generator change the Generator to Unix Makefiles
  • Change Qt version to None
  • Change C compiler to <No compiler>
  • Change C++ compiler to <No compiler>
  • Change CMake Tool to "AsteroidOS CMake" at /usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/cmake
  • Clear the CMake Configuration fields
  • Add a CMake variable:

OE_QMAKE_PATH_EXTERNAL_HOST_BINS:STRING=%{Env:OE_QMAKE_PATH_HOST_BINS}

Note that if these steps are not done *in this order*, QtCreator will not let you change both the C compiler and C++ compiler to <No compiler>. Specifically, setting Qt version to None must be done first.

First app

Asteroid-helloworld can act as a cool QML demo app to make your first steps into AsteroidOS development easier. You can clone it, build it, install it and then modify it to follow your needs:

git clone https://github.com/AsteroidOS/asteroid-helloworld
cd asteroid-helloworld/
export CMAKE_PROGRAM_PATH=/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi/usr/bin/
source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
qtcreator CMakeLists.txt

Try to build and deploy the app. If it wasn’t already installed, a new icon should have already appeared on asteroid-launcher.

You can start by modifying occurrences of “asteroid-helloworld” to your app’s name. Then you can change the *.desktop file which describes the icon on the apps launcher. Then modify main.qml to describe your UI. To get started with QML development you can read the official tutorial.

Deploy an app from QtCreator

Open the project as described in the previous sections.

  • Click on the Projects button on the left sidebar
  • Under the Build & Run section click on the Run configuration. This opens all run settings
  • Scroll down to the Run settings


Change the following Run settings:

  • Set the Run configuration to Custom Executable (on AsteroidOS Watch)
  • Under "Files to deploy" select "Override deployment data from build system"
  • Set the Remote executable to asteroid-helloworld

Under Environment select "Fetch Device Environment"

  • Change XDG_RUNTIME_DIR and set its value to /run/user/1000. So that the invoker works under the root user
  • Add QT_QPA_PLATFORM and set its value to wayland
  • (Optional) Add QT_WAYLAND_DISABLE_WINDOWDECORATION with value 1to make the app full screen and hide the titlebar

Your app should now be able to run from the application when you click the start button in the bottom left sidebar. Make sure you have the display on to be able to see the app. If you have "Tap-to-wake" turned on in the "Display" settings on the watch, tapping the display to wake up the screen before running the application should work.

Tips and tricks

If you want to start your app from the command line, open a shell with SSH, connect to ceres and use the shell script which, in turn, calls invoker:

asteroid-stopwatch

If you want to disable screen locking for easier development you can enable the demo mode of mce as root with:

mcetool -D on

Don't forget to turn it back off when you are done to avoid draining the battery.

Troubleshooting

The most common problems stem from not following these directions *exactly*. QtCreator helpfully tries to find compilers and set variables, but tends to set things up for the desktop as the target rather than AsteroidOS, so it often gets things wrong. The first step for troubleshooting with QtCreator is to go very carefully over each of the steps listed above and verify that they all match exactly.

Could not find a package configuration file provided by "ECM"

This is most often caused not having the environment variables set up as shown above under the topic of configuring QtCreator. The environment variables must all be set and then you must lauch qtcreator *in the same shell*. If you're not sure you've done this, an easy way to check is to try this command from the command line:

echo $CC

This should result in a line like this: arm-oe-linux-gnueabi-gcc -march=armv7ve -mfpu=neon -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi

If instead you get an empty line or some other non-ARM compiler, you may have made an error. One common error is to run the script directly instead of running it using source (or . on some Linux distributions). Another common error that causes the error about not finding ECM is if, in the Kit, the system CMake is used instead of the one for the AsteroidOS SDK.

= warning: The project contains C++ source files, but the currently active kit has no C++ compiler. The code model will not be fully functional.

This is not really an error but a warning. It's the result of having correctly chosen <No compiler> as per the instructions above and may safely be ignored.

file INSTALL cannot find ... .desktop

This is probably the result of a missing CMAKE_PROGRAM_PATH. As mentioned above, this must be set in order for a script that generates the desktop file to be correctly found and uses.

Remote process crashed

One possibility is that your software has a bug, but another is that the XDG_RUNTIME_DIR is not set to /run/user/1000 as mentioned above.

"I fixed it but I get the same error!"

This most often happens when something was originally wrong with the configuration, but a CMake scan was made and a possibly faulty Makefile from an earlier attempt still exists. To fix this, choose Build from the menu, and then Rescan project. This will run CMake again, ignoring existing cached values and forcing the recreation of a Makefile.