The app creation process of AsteroidOS needs a Software Development Kit generated by OpenEmbedded. With the SDK installed on your computer, you can develop and compile applications for watches.
Note: If you intend to build apps that will run on the emulator, those applications will need to be compiled with a different version of the SDK. Both versions of the SDK can be installed on the same computer at the same time, since they do not interfere with each other. See below for how to obtain, build, install and use that version of the SDK.
You can either grab a prebuilt SDK from the nightlies here and install it on your system or you can build it yourself as described below. Be aware that building it yourself will require a lot of time, internet access and disk space (over 150GiB is not unusual).
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:
git clone https://github.com/AsteroidOS/asteroid cd asteroid/
Then, build the cross compilation toolchain with:
source ./prepare-build.sh dory bitbake meta-toolchain-qt5
Assuming you already prepared a docker or podman build environment like in: Building AsteroidOS.
sudo docker rm -f asteroidos-toolchain 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"
podman run --rm -it \ -v "$(pwd)":/asteroid:z \ --userns keep-id asteroidos-toolchain \ bash -c "source ./prepare-build.sh dory && bitbake meta-toolchain-qt5"
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
tmp-glibc/deploy/sdk/, you can run it as follows:
This script will install the cross-compiler and ARM libraries in
/usr/local/oecore-x86_64 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:
source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi cmake -B build cmake --build build
Before running QtCreator you must run the previously mentioned script:
source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi qtcreator
One other environment variable needs to be set to work seamlessly with AsteroidOS:
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
Now that you are in QtCreator go to
- 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.
Kits add a kit with the previously defined device:
Generic Linux Device.
- Set the
- Set the sysroot to
- In the CMake generator change the
System CMake at /usr/local/oecore-x86_64/usr/bin/cmake
- Clear the
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.
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/ 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.
Open the project as described in the previous sections.
- Click on the
Projectsbutton on the left sidebar.
- Under the
Build & Runsection click on the
Runconfiguration. This opens all run settings.
- Scroll down to the
Change the following
- Set the
Custom Executable (on AsteroidOS Watch).
- Set the
invoker. Add the
--single-instance --type=qtcomponents-qt5 /usr/local/bin/asteroid-helloworldcommand line arguments.
Change the following
XDG_RUNTIME_DIRand set its value to
/run/user/1000. So that the invoker works under the root user.
- (Optional) Add
1. 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 invoker:
invoker --type=qtcomponents-qt5 /usr/bin/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
The primary difference between the two versions of the SDK are that the real watches use an ARM processor, while the emulator uses a simulated x86 processor. This allows the emulator to run much faster on computers based on the x86 architecture than if they had to emulate an ARM processor.
You can either download a prebuilt emulator SDK from the nightlies here and install it on your system or you can build it yourself in a process very similar to that described above for creating the watch version of the SDK.
The only difference between building the SDK for the emulator is that instead of using
./prepare-build.sh dory one uses
./prepare-build qemux86. Installation is also largely the same except for a small difference in the command used to install. Installing the emulator version of the SDK is done with this command:
As the emulator installer itself describes when it is first installed,
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. $ . /usr/local/oecore-x86_64/environment-setup-core2-32-oe-linux
Integration with QtCreator is not explicitly described here, but again, the process is very similar to the process for using QtCreator with the watch version of the SDK.
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.
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:
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
. 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.
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.
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.
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.