Code, deploy and test using welma-update-gen¶
This page will show you how to have short development cycles by creating update artifacts and deploying them onto your device.
Prerequisites:
- a Welma image built and running on your device
See also Deploy your application.
Build the SDK¶
In your Yocto build environment, you first need to build a Software Development Kit (SDK) that will have the Welma tools:
You can then install this SDK:
$ tmp/deploy/sdk/welma-glibc-x86_64-welma-image-headless-dev-*-toolchain-1.1.0.sh
Welma by Witekio SDK installer version 1.1.0
============================================
Enter target directory for SDK (default: /opt/welma/1.1.0):
You are about to install the SDK to "/opt/welma/1.1.0". Proceed [Y/n]?
Extracting SDK...........................................................done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Next, each time you wish to use the SDK in a new shell session, you need to source the environment file in order to develop and compile using the toolchain designed for the target device:
Make the app¶
You are now ready to develop. Let's try to make and compile a simple C app.
Copy this C code to a file myapp.c
:
#include <stdio.h>
#include <unistd.h>
int main() {
// Print "Hello, Welma !" every 3 seconds on stdout
while(1) {
printf("Hello, Welma !\n");
fflush(stdout);
sleep(3);
}
return 0;
}
app
:
Auto launch the app¶
You may want your application to automatically start at boot, as user user
(uid 2000).
Welma uses systemd to start the application, so a service file is required.
First, create the necessary directories:
You need to create this file:
[Unit]
Description = Launch demo application
[Service]
Type = exec
ExecStart = /app/bin/myapp
[Install]
WantedBy = default.target
You also need to create a link to this service file at a specific path formatted like this :
$ ln -s app/lib/systemd/user/myapp.service \
app/user/2000/systemd/user/default.target.wants/myapp.service
Create the update artifact¶
Use welma-update-gen
to create your update artifact :
$ welma-update-gen ./app
INFO: welma-update-gen: Configuration file loaded: default-image.imgconf
INFO: welma-update-gen: Signing verity image with key: /opt/welma/1.1.0/sysroots/x86_64-pokysdk-linux/usr/share/default-image.signkey
INFO: welma-update-gen: Signing swupdate artifact with key: /opt/welma/1.1.0/sysroots/x86_64-pokysdk-linux/usr/share/default-image.signkey
INFO: welma-update-gen: Created: appro-1.0.swu
Transfering and updating the app¶
You need to use either the -dev
or -dbg
welma image (with SSH access).
Link the host machine to the device via ethernet. Transfer the update artifact. Example :
$ sudo ifconfig eth0 169.254.0.2 netmask 255.255.255.0 up
$ scp appro-1.0.swu root@169.254.0.1:/home/root/.
Now we can use updatectl
(as root on the device) to install the app:
# journalctl -f
Oct 28 10:50:07 sm2s-imx8plus-mbep5 myapp[588]: Hello, Welma !
Oct 28 10:50:10 sm2s-imx8plus-mbep5 myapp[588]: Hello, Welma !
Oct 28 10:50:13 sm2s-imx8plus-mbep5 myapp[588]: Hello, Welma !
...
# updatectl confirm
Conclusion¶
Congratulations! You've successfully performed an update using Welma!
And now you can iterate over short code-deploy-and-test cycles.