A question about systemd services on an image built with yocto angstrom-lxde-image

This is probably not a Toradex specific question, but I am wondering about it in a Toradex specific context.

I will be building a custom OS install over the course of the next few months for a product we are making, but in the meantime we are trying to put some development boards into a field situation for the purpose of instrument testing (Toradex imx7D is used as an “edge interface /signal processor” for the instrument so is not being tested.)

The application that we are using has multiple parts at the moment, and we must ensure that the appropriate parts are running in the appropriate sequence, and so I am using systemd services to ensure that all pieces are started and restarted in a specific sequence. All of this is working appropriately, but… and this brings me to my question.

Does anyone know how, I can enable a systemd service such that when a new imx7 SOC is flashed with the generated openembedded built OS, that systemd service is already enabled and started on first boot?

I have found a way to do it by mounting a root filesystem, without booting from said filesystem, but I am unclear how this can work with the image created by the openembedded build in my cross compilation environment.

  • I want to emphasize, I do know how to do it after I boot the device, but I’m trying to automate the flashing of our unit as much as possible, as some installs may be done by technicians not familiar with systemd or our software.*

Please have a look at the recipe and unit file examples given here.

At least since jethro you can enable a service using the variable SYSTEMD_AUTO_ENABLE (when using the systemd.class). The variable is also described in the Yocto Project Reference Manual.