Skip to main content
2 of 2
edited tags
Ingo
  • 42.6k
  • 20
  • 85
  • 205

SystemD unit dependencies to start wiringPi GPIO application

I want to start an application on system boot as early as possible. I am using Debian jessie. The application makes use of GPIO pins with the help of the wiringPi library.

When using the following SystemD unit file to start the application gpio-test, it starts correctly but very late in the boot process (later than with a /etc/rc.local script):

[Unit]
Description=GPIO Test
Requires=local-fs.target

[Service]
Type=oneshot
User=root
Group=root
ExecStart=/opt/gpio-test
Restart=no

[Install]
WantedBy=basic.target

So I tried to optimize the startup time by changing the WantedBy= directive to WantedBy=sysinit.target but then the application never gets started. After logging in via ssh I got this:

$ sudo service gpio_test status
● gpio_test.service - GPIO Test
   Loaded: loaded (/lib/systemd/system/gpio_test.service; enabled)
   Active: inactive (dead)

So the application never got started?

What is the correct SystemD Requires= directive(s) for using GPIO pins? And what would be a good WantedBy= directive to allow an early start of the application?