title: Run application at start up with Yocto Dunfell
body: <p>I have coded a toggle.c application in C that toggles on and off a GPIO of the BeagleBone Black board. Practically it causes an external LED to flash.</p>
  <p>I wish to prepare a Yocto image which includes the executable binary of the application and it launches the application automatically when starting up, thus causing the LED to flash.</p>
  <p>I have followed along the examples I found on the web. My Yocto image includes the compiled binary of the application inside /usr/bin. I can execute it from command line, all fine.</p>
  <p>But my Yocto <strong>generated image does not start the binary automatically</strong>. LED does not flash when starting Yocto generated Linux Image.</p>
  <p>My workflow was:</p>
  <ul>
  <li>create a new layer</li>
  <li>new layer has an automatically generated 'recipes-example' directory</li>
  <li>underneath 'recipes-example' there was a directory which I renamed to 'toggle'</li>
  <li>inside 'toggle' there is the recipe toggle_0.1.bb</li>
  <li>I created a new directory inside 'toggle' that called 'files' where I stored the toggle.c and toggle.service files</li>
  </ul>
  <p>toggle.service file</p>
  <pre><code>[Unit]
  Description= A start script from a toggle.c program
  
  [Service]
  ExecStart=/usr/bin/toggle
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  <p>toggle_0.1.bb</p>
  <pre><code>DESCRIPTION = &quot;This is a program to toggle GPIO  on/off at an interval of 1s&quot;
  PRIORITY = &quot;optional&quot;
  SECTION = &quot;examples&quot;
  LICENSE = &quot;MIT&quot;
  LIC_FILES_CHKSUM = &quot;file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302&quot;
  SRC_URI = &quot;file://toggle.c&quot;
  S = &quot;${WORKDIR}&quot;
  do_compile() {
  ${CC} ${CFLAGS} ${LDFLAGS} toggle.c -o toggle
  }
  do_install() {
  install -d ${D}${bindir}
  install -m 0755 toggle ${D}${bindir}
  }
  
  inherit systemd
  SYSTEMD_AUTO_ENABLE = &quot;enable&quot;
  SYSTEMD_SERVICE_${PN} = &quot;toggle.service&quot;
  
  SRC_URI_append = &quot; file://toggle.service &quot;
  FILES_${PN} += &quot;${systemd_unitdir}/system/toggle.service&quot;
  
  do_install_append() {
    install -d ${D}/${systemd_unitdir}/system
    install -m 064 ${WORKDIR}/toggle.service ${D}/${systemd_unitdir}/system
  }
  </code></pre>
  <p>I tried the same thing with diferent kind of image recipes: core-image-minimal, core-image-base, core-image-full-cmdline. All the same. They do not hold the normal Linux files for executing apps at start-up like /etc/init.d/rc.local.</p>
  <p>Please point me towards a solution that would work for me. Thank you very much.</p>