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"
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:
**[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:
**#!/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!!..
Please try to look in this post (there is example systemd service file):
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.
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
can you pls share content of dl-mgr_0.1bb
dl-mgr_0.1.bb:
**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/
Simple bb recipe which should install stuff should look like this:
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:
[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.
@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 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”``**
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?
@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 ??
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 dl-mgr.sh:
#!/bin/sh
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
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.