Startup script for raspberrypi3 using yocto?

Can i run auto startup script for raspberrypi3 using yocto?

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

Thank you…
my .bb file is below:

DESCRIPTON = "Startup scripts"
PR = "r0"

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


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}/ ${D}/${libexecdir}

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


and .service file is below:

Description=start initscript upon first boot

ExecStart=/usr/libexec/ start
ExecStop=/usr/libexec/ stop

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

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!!..

Please try to look in this post (there is example systemd service file):

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

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.

finally executing like:bitbake rpi-basic-image


can you pls share content of dl-mgr_0.1bb

**DESCRIPTON = "Startup scripts"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

PR = "r0"

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


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

             if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
    		  install -d ${D}/etc/systemd/system/
    		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/

do_install () {

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

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

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

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


SRC_URI = "file:// \
           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 ${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:

Description=Test service

ExecStart=/usr/sbin/ start


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.

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

@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 file:
logger “starting initscript”
echo "WEL-COME
echo “!!!THANK YOU!!!”
logger “initscript work done”
systemctl disable dl-mgr.service
logger “initscript disabled”``**

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

Pls update 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?

@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 and how to get that??

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

Yes script will be run after every boot/restart.

@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!

And my

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

@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.

@MarekBelisko thanks :blush:

cleared the error but not working as autorun script

As suggested by @MarekBelisko, I would recommend you to bring these type of questions to the Yocto project mailing lists as the questions are not related to Mender.

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