# Startup script for raspberrypi3 using yocto?

**URL:** https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201
**Category:** General Discussions
**Created:** [February 2, 2019, 12:40pm UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201 "2019-02-02T12:40:41Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![ram\_zi](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@ram\_zi](https://hub.mender.io/u/ram_zi)
#### Post date: [February 2, 2019, 12:40pm UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/1 "2019-02-02T12:40:41Z")

</div>

Can i run auto startup script for raspberrypi3 using yocto?

---

<div class="post-metadata">

### Author: ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)
#### Post date: [February 2, 2019, 4:50pm UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/2 "2019-02-02T16:50:06Z")

</div>

Yes it is possible but you need to create systemd service which will start your script during boot of system

---

<div class="post-metadata">

### Author: ![ram\_zi](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@ram\_zi](https://hub.mender.io/u/ram_zi)
#### Post date: [February 5, 2019, 6:27am UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/3 "2019-02-05T06:27:12Z")

</div>

Thank you…  
my .bb file is below:

```auto
DESCRIPTON = "Startup scripts"
LICENSE = "CLOSED"
PR = "r0"

SRC_URI = "file://autorun.service \
	   file://autorun.sh \
	  "
inherit update-rc.d systemd

SYSTEMD_PACKAGES = "${PN}"
INITSCRIPT_PACKAGES = "${PN}"

SYSTEMD_SERVICE_${PN} = "autorun.service"
do_install () {
    install -d ${D}${systemd_unitdir}/system/
    install -m 0644 ${WORKDIR}/autorun.service ${D}${systemd_unitdir}/system

    install -d ${D}/${libexecdir}
    install -m 0755 ${WORKDIR}/autorun.sh ${D}/${libexecdir}
}

FILES_${PN} += "${libexecdir}"
FILES_${PN} += "${systemd_system_unitdir}" 

REQUIRED_DISTRO_FEATURES= "systemd"

```

and .service file is below:

```auto
**[Unit]
Description=start initscript upon first boot

[Service]
Type=simple
ExecStart=/usr/libexec/autorun.sh start
ExecStop=/usr/libexec/autorun.sh stop
 
[Install]
WantedBy=multi-user.target

```

This is i want display when it startup automatically script is:

```auto
**#!/bin/sh
logger "starting initscript"

echo " ***********************WEL-COME**********************************"
echo "!!!!!!!!!!!!!!!!!!!!!!!THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "-----------------------WORKED FINE----------------------------------"

logger "initscript work done"

logger "initscript disabled"

```

without buggs this is excuting and i dumped the .sdimg to sdcard but not displaying.  
and my file directory in : sources/poky/meta/recips-support/autorun.!!  
help me out!!..

---

<div class="post-metadata">

### Author: ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)
#### Post date: [February 5, 2019, 7:38am UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/4 "2019-02-05T07:38:05Z")

</div>

Please try to look in this post (there is example systemd service file):  
[https://community.nxp.com/thread/472820](https://community.nxp.com/thread/472820)

Also please if you copy code add “```” at the beginning and the end of sentence to be better readable. Thanks.

---

<div class="post-metadata">

### Author: ![ram\_zi](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@ram\_zi](https://hub.mender.io/u/ram_zi)
#### Post date: [February 5, 2019, 1:05pm UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/5 "2019-02-05T13:05:03Z")

</div>

thank you MarekBelisko  
I followed the link but it is Not working… !!

and my file is in :“sources/poky/meta/recips-core/dl-mgr” and “dl-mgr” is my startup file.  
dl-mgr  
–dl-mgr  
---------dl-mgr.sh  
---------dl.mgr.service  
–dl-mgr\_0.1.bb

finally executing like:bitbake rpi-basic-image

regards  
ram\_zi

---

<div class="post-metadata">

### Author: ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)
#### Post date: [February 5, 2019, 1:16pm UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/6 "2019-02-05T13:16:40Z")

</div>

can you pls share content of dl-mgr\_0.1bb

---

<div class="post-metadata">

### Author: ![ram\_zi](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@ram\_zi](https://hub.mender.io/u/ram_zi)
#### Post date: [February 6, 2019, 4:25am UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/7 "2019-02-06T04:25:35Z")

</div>

dl-mgr\_0.1.bb:

```auto
**DESCRIPTON = "Startup scripts"
#LICENSE = "CLOSED"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

PR = "r0"

SRC_URI = "file://dl-mgr.sh \
           file://dl-mgr.service \
	  "
inherit update-rc.d systemd

SYSTEMD_PACKAGES = "${PN}"
INITSCRIPT_PACKAGES = "${PN}"

SYSTEMD_SERVICE_${PN} = "dl-mgr.service"

do_install(){
             if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
    		  install -d ${D}/etc/systemd/system/multi-user.target.wants
    		install -m 644 ${WORKDIR}/dl-mgr.service ${D}/etc/systemd/system/dl-mgr.service
		## Add following link if you want auto start of service
    		## ln -s /etc/systemd/system/dl-mgr.service ${D}/etc/systemd/system/multi-user.target.wants/dl-mgr.service
fi 
}

do_install () {
            

            install -d ${D}${libexecdir}
		install -m 0755 ${WORKDIR}/dl-mgr.sh ${D}${libexecdir}/dl-mgr.sh
            install -d ${D}${systemd_system_unitdir}
	        install -m 0644 ${WORKDIR}/dl-mgr.service ${D}${systemd_system_unitdir} 
}   

FILES_${PN} += "${libexecdir}/dl-mgr.sh"
FILES_${PN} += "${systemd_system_unitdir}/dl-mgr.service"**

```

And it is in dir:/sources/poky/meta/recipes-core/

---

<div class="post-metadata">

### Author: ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)
#### Post date: [February 6, 2019, 8:23am UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/8 "2019-02-06T08:23:12Z")

</div>

Simple bb recipe which should install stuff should look like this:

```auto
LICENSE="CLOSED"

SRC_URI = "file://dl-mgr.sh \
           file://dl-mgr.service \
	  "

inherit systemd

SYSTEMD_SERVICE_${PN} = "dl-mgr.service"

FILES_${PN} = " ${systemd_unitdir}/system/dl-mgr.service ${sbindir}/dl-mgr/sh"

do_install() {
        install -d ${D}/${sbindir}
        install -m 0755 dl-mgr.sh ${D}/${sbindir}
     
        install -d ${D}${systemd_unitdir}/system
        install -c -m 0644 ${WORKDIR}/dl-mgr.service ${D}${systemd_unitdir}/system
}

```

and service file should look like:

```auto
[Unit]
Description=Test service
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
WorkingDirectory=/usr/sbin
ExecStart=/usr/sbin/dl-mgr.sh start

[Install]
WantedBy=multi-user.target

```

if you have it integrated be sure that files are installed in final rootfs. If you still have an issue pls share systemctl status dl-mgr.service Thanks.

---

<div class="post-metadata">

### Author: ![ram\_zi](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@ram\_zi](https://hub.mender.io/u/ram_zi)
#### Post date: [February 6, 2019, 8:59am UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/9 "2019-02-06T08:59:26Z")

</div>

@MarekBelisko…Actually I am new to yocto .Thanks for ur help…

---

<div class="post-metadata">

### Author: ![ram\_zi](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@ram\_zi](https://hub.mender.io/u/ram_zi)
#### Post date: [February 6, 2019, 9:38am UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/10 "2019-02-06T09:38:17Z")

</div>

@MarekBelisko: I am not getting any output and file directory in :"/sources/poky/meta/recips-core/dl-mgr/ " is this correct???

This is systemctl status:

```
**@osboxes:~/yoctorpi/mender-raspberrypi/build$ systemctl status dl-mgr.service 
Failed to issue method call: No such interface 'org.freedesktop.DBus.Properties' on object at path /org/freedesktop/systemd1/unit/dl_2dmgr_2eservice
**

```

And my dl-mgr.sh file:  
**#!/bin/sh  
logger “starting initscript”  
echo "_WEL-COME_**\*\*\*\*\*\*\*\*\*"  
echo “!!!THANK YOU!!!”  
logger “initscript work done”  
systemctl disable dl-mgr.service  
logger “initscript disabled”``\*\*

---

<div class="post-metadata">

### Author: ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)
#### Post date: [February 6, 2019, 10:02am UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/11 "2019-02-06T10:02:57Z")

</div>

Does final rootfs on device contains:  
ls /lib/systemd/system/dl-mgr.service and also ls /usr/sbin/dl-mgr.sh

Pls update dl-mgr.sh to contains only some echo commands.

Also pls run `systemctl status dl-mgr.service` on board not on hostpc. Are you sure that dl-mgr recipe is added to your final image?

---

<div class="post-metadata">

### Author: ![ram\_zi](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@ram\_zi](https://hub.mender.io/u/ram_zi)
#### Post date: [February 6, 2019, 10:48am UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/12 "2019-02-06T10:48:11Z")

</div>

@MarekBelisko :thansk blush: **systemctl status dl-mgr.service** working fine in board.

Before login i have to get **WEL-COME and THANK you** that is in dl-mgr.sh and how to get that??

finally my question is :if i restart it or powered on it -the script should work ??

---

<div class="post-metadata">

### Author: ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)
#### Post date: [February 6, 2019, 11:21am UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/13 "2019-02-06T11:21:02Z")

</div>

Yes script will be run after every boot/restart.

---

<div class="post-metadata">

### Author: ![ram\_zi](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@ram\_zi](https://hub.mender.io/u/ram_zi)
#### Post date: [February 6, 2019, 12:35pm UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/14 "2019-02-06T12:35:17Z")

</div>

@MarekBelisko Not working!!..after restart/boot

**systemctl status dl-mgr.service** after running this…On board m getting like this and i attached img file …plz check it!

 ![IMG_20190206_174651](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/1X/260b7f0e6a359abd6f79e1f3fb6b08746fa095e4.jpeg)

And my dl-mgr.sh:

**#!/bin/sh**  
**echo "_WEL-COME_** \*\*\*\*\*\*\*\*\*"\*\*  
**echo " "**  
**echo "!!!THANK YOU!!!"**  
**echo " "**

---

<div class="post-metadata">

### Author: ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)
#### Post date: [February 6, 2019, 12:59pm UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/15 "2019-02-06T12:59:10Z")

</div>

@ram_zi sorry but I think this is out of scope of this forum which should focus mostly on mender related topics. I suggest to ask questions related to yocto on yocto mailing list. Thanks for kind understanding.

---

<div class="post-metadata">

### Author: ![ram\_zi](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@ram\_zi](https://hub.mender.io/u/ram_zi)
#### Post date: [February 6, 2019, 1:09pm UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/16 "2019-02-06T13:09:07Z")

</div>

@MarekBelisko thanks 😊

---

<div class="post-metadata">

### Author: ![ram\_zi](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@ram\_zi](https://hub.mender.io/u/ram_zi)
#### Post date: [February 11, 2019, 6:47am UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/18 "2019-02-11T06:47:13Z")

</div>

cleared the error but not working as autorun script

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [February 12, 2019, 7:31am UTC](https://hub.mender.io/t/startup-script-for-raspberrypi3-using-yocto/201/19 "2019-02-12T07:31:42Z")

</div>

As suggested by @MarekBelisko, I would recommend you to bring these type of questions to the [Yocto project mailing lists](https://www.yoctoproject.org/community/mailing-lists/) as the questions are not related to Mender.

I am sure that you will get the help you need there.
