Add Packages and Services on eLxr
The Modalix image is built on eLxr, a Debian-derived distribution. You add
software to a board the Debian way: as packages that you install with apt.
This page shows how to install a package, how to package your own service, and
what a firmware update does to your changes.
This page is written from the public SiMa.ai repositories. The example package was built and installed in a Debian container. The steps have not been run on a board as they are written here.
Install a Package
-
Connect the board to a network that reaches the package repositories.
-
Update the package lists:
sima@modalix:~$ sudo apt update -
Install the package. For example, to install the I2C tools:
sima@modalix:~$ sudo apt install i2c-tools
SiMa.ai delivers its own software to the board as Debian packages. To list the SiMa.ai packages on a board:
sima@modalix:~$ dpkg -l | grep simaai
Package Your Own Service
To run your own program as a service, build a Debian package for it. The
package installs the files, and its post-installation script enables the
service. This example packages a program named my-app.
-
On your build host, create this directory tree. Put your program in
usr/bin/my-app. It must run on the board, so build it for arm64. See Build the BSP from Source for the build container.my-app/├── DEBIAN/│ ├── control│ └── postinst├── lib/systemd/system/my-app.service└── usr/bin/my-app -
Write
DEBIAN/control.Dependslists the packages that your program needs:Package: my-appVersion: 1.0.0Section: utilsPriority: optionalArchitecture: arm64Depends: python3Maintainer: Your Name <you@example.com>Description: Example service for a Modalix board -
Write the unit file,
lib/systemd/system/my-app.service:[Unit]Description=My applicationAfter=network.target[Service]Type=simpleExecStart=/usr/bin/my-appRestart=on-failureRestartSec=5[Install]WantedBy=multi-user.target -
Write
DEBIAN/postinst. It enables and starts the service when the package is installed:#!/bin/shset -eif [ -d /run/systemd/system ]; thensystemctl daemon-reloadsystemctl enable my-app.servicesystemctl restart my-app.servicefi -
Make the script and the program executable, and build the package:
sima-user@sima-user-machine:~$ chmod 0755 my-app/DEBIAN/postinst my-app/usr/bin/my-appsima-user@sima-user-machine:~$ dpkg-deb --root-owner-group --build my-app my-app_1.0.0_arm64.deb -
Copy the package to the board and install it.
aptalso installs the packages that it depends on:sima-user@sima-user-machine:~$ scp my-app_1.0.0_arm64.deb sima@<board-ip>:/tmp/sima@modalix:~$ sudo apt install /tmp/my-app_1.0.0_arm64.deb -
Check that the service runs, and read its log:
sima@modalix:~$ systemctl status my-app.servicesima@modalix:~$ journalctl -u my-app.service
For a complete package of this kind, see the MIPI camera utility in the SiMa.ai Insight repository.
What a Firmware Update Does to Your Changes
sima-cli update works differently in each release line, so your packages are
treated differently.
| Platform release | What the update does | Your packages and services |
|---|---|---|
| 2.1 | Upgrades the SiMa.ai packages in place. It does not write a new image. | Not confirmed. Check them after an update. |
| 3.0 and later | Writes a complete root filesystem to the inactive slot, and boots from it. | Kept in an overlay on /data, unless the update clears the overlay. If it does, install them again. |
- In release 2.1, the update resets the U-Boot environment. Set
dtbosand any other variable that you changed again after the update. - Recovering a board, or writing a complete image to it, removes your packages in every release.
- Keep your
.debfiles and a list of what you installed, so that you can install them again. - In release 3.0 and later,
sima-cli update --inspectshows what the overlay holds.
Platform release 3.0 is not released yet. Its behavior is described here from
the system update guide
of sima-cli, and can change.
Not Covered
- Building a complete eLxr image that already contains your packages. See eLxr or Yocto.
- Publishing your packages in your own package repository.
Next Steps
- Build the BSP from Source: build the kernel, U-Boot, and device trees.
- Device Trees and Overlays: describe new hardware to the kernel.
- Firmware Update: update a board with a SiMa.ai image.