[LS1028a]: How to enable auto boot of application executable files after linux boot up ?.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[LS1028a]: How to enable auto boot of application executable files after linux boot up ?.

2,381 Views
Amit_Keshri
Contributor III

Dear NXP Support Team,

I want to run my application executable file automatically just after Linux boot up.

Please tell me how i can enable auto boot of any executable file ?.

Regards,

Amit Keshri

0 Kudos
14 Replies

2,342 Views
Amit_Keshri
Contributor III

Hi @yipingwang ,

I have created autoboot_app.sh file in etc/init.d/ directory and written below script in autoboot_app.sh file but after linux boot up neither our application SMSAppV0p4 is running nor echo command print is coming.

#! /bin/sh
echo"*******Auto-Boot Enable****************"
root
PATH:/usr/sbin
#./usr/sbin/SMSAppV0p4 &
echo "Running executable SMSAppV0p4 after linux bootup"

chmod a+x /usr/sbin/SMSAppV0p4
cd /usr/sbin/

./SMSAppV0p4 &

 

same script i wrote in etc/profile but here also i am not observing any print.

Why any script is not getting executed from my RFS.

Please help me on this.

 

Regards,

Amit Keshri

0 Kudos

2,320 Views
yipingwang
NXP TechSupport
NXP TechSupport

Please refer to this step by step user guide

https://linuxconfig.org/how-to-run-script-on-startup-on-ubuntu-22-04-jammy-jellyfish-server-desktop

I have verified this method on the target board, it works.

0 Kudos

2,295 Views
Amit_Keshri
Contributor III

Hi @yipingwang ,

Thank you for your reply .

I will check above point and update you soon.

Regards,

Amit Keshri

0 Kudos

2,287 Views
Amit_Keshri
Contributor III

Hi @yipingwang ,

As per your reply i go through below link :

https://linuxconfig.org/how-to-run-script-on-startup-on-ubuntu-22-04-jammy-jellyfish-server-desktop

and did below things to enable autoboot of application.

1.Created autoboot.sh script file under flexbuild_lsdk2012/packages/rfs/initrd/YoctoRfsTiny/etc/systemd/system directory and wrote below script in autoboot.sh:

--------------------------------------------------------

[Unit]
After=network.target

[Service]
ExecStart=/flexbuild_lsdk2012/packages/rfs/initrd/YoctoRfsTiny/etc/init.d/autoboot_sms.sh

[Install]
WantedBy=default.target

---------------------------------------------------------

2.Created autoboot_sms.sh file in  /flexbuild_lsdk2012/packages/rfs/initrd/YoctoRfsTiny/etc/init.d/ to run the application and written below things inside autoboot_sms.sh:

--------------------------------------------------

#!/bin/bash
echo "*******Auto-Boot Enable****************"
User=root
PATH:/usr/sbin

chmod a+x /usr/sbin/SMSAppV0p4
cd /usr/sbin/

./SMSAppV0p4 &

----------------------------------------------------

3.Change the file permissions for both, the Systemd service unit and script::


sudo chmod 777 rfs/initrd/YoctoRfsTiny/etc/systemd/system/autoboot.sh

sudo chmod 777 rfs/initrd/YoctoRfsTiny/etc/init.d/autoboot_sms.sh

4.enable the service unit:

 sudo systemctl daemon-reload

sudo systemctl enable autoboot_sms.sh

After this changes i generated linux images and loaded in board and observed that no script is getting executed so no echo print was observed.

But manually when i executed this script ,application was running.

Apart from this i have also created script in etc/rcS.d, etc/rc5.d, and etc/profile and added print using echo command but after loading i did not observed any prints.

Where i am doing wrong ??

Why any script under RFS is not getting executed??

 

Regards,

Amit Keshri

 

0 Kudos

2,277 Views
yipingwang
NXP TechSupport
NXP TechSupport

Please refer to the following procedure.

1.Created autoboot.service script file under flexbuild_lsdk2012/packages/rfs/initrd/YoctoRfsTiny/etc/systemd/system directory and wrote below script in autoboot.service:

--------------------------------------------------------

[Unit]
After=network.target

[Service]
ExecStart=/etc/init.d/autoboot_sms.sh

[Install]
WantedBy=default.target

---------------------------------------------------------

2.Created autoboot_sms.sh file in  /flexbuild_lsdk2012/packages/rfs/initrd/YoctoRfsTiny/etc/init.d/ to run the application and written below things inside autoboot_sms.sh:

--------------------------------------------------

#!/bin/bash
echo "*******Auto-Boot Enable****************" > /root/autoboot.txt
User=root
PATH:/usr/sbin

chmod a+x /usr/sbin/SMSAppV0p4
cd /usr/sbin/

./SMSAppV0p4 &

----------------------------------------------------

3.Change the file permissions for both, the Systemd service unit and script::


sudo chmod 777 rfs/initrd/YoctoRfsTiny/etc/systemd/system/autoboot.service

sudo chmod 777 rfs/initrd/YoctoRfsTiny/etc/init.d/autoboot_sms.sh

4.enable the service unit:

 sudo systemctl daemon-reload

sudo systemctl enable autoboot.service

5. Please boot rootfs on the target board and check the output in file /root/autoboot.txt.

0 Kudos

2,272 Views
Amit_Keshri
Contributor III

Hi @yipingwang ,

Thank you for your quick reply.

I will check above points and share the result with you.

Regards,

Amit Kumar Keshri

0 Kudos

2,225 Views
Amit_Keshri
Contributor III

Hi @yipingwang ,

As per your suggestion i did above things in my RFS and i am able to see my application SMSAppV0p4,when i typed ps command after linux bootup but my application is not running so i could not able to see any print which i have added i my application SMSAppV0p4.

I am able to run application manually and prints are coming as shown in attached log files. 

But why my application is not running after Linux boot up??

Please find the log file for your reference.

Regards,

Amit Keshri

 

0 Kudos

2,213 Views
yipingwang
NXP TechSupport
NXP TechSupport

Please use this method in yocto:tiny rootfs

Please rename your boot up script autoboot_app.sh as "S100autoboot_app.sh" and add execution mode and put it folder /flexbuild_lsdk2012/packages/rfs/initrd/YoctoRfsTiny/etc/rcS.d/

Then regenerate the itb image, S100autoboot_app.sh will be executed automatically when linux booting up.

0 Kudos

2,219 Views
yipingwang
NXP TechSupport
NXP TechSupport

The Ubuntu main system is based on Systemd hence the simplest and recommended way to run a script on startup is to create a systemd service script.

I assumed that you are using Ubuntu main rootfs previously. In fact, you are using yocto tiny rootfs which doesn't support systemd.

Would you please use Ubuntu main rootfs? Or you must use Yocto tiny rootfs in your products?

0 Kudos

2,164 Views
Amit_Keshri
Contributor III

Hi @yipingwang ,

Thank you very much for your reply.

As per your suggestion i added S100autoboot_app.sh in /flexbuild_lsdk2012/packages/rfs/initrd/YoctoRfsTiny/etc/rcS.d/ directory and changed file permission ,which contains below script:

#!/bin/bash
echo "*******Auto-Boot Enable****************" > /root/autoboot.txt
User=root
PATH:/usr/sbin

chmod a+x /usr/sbin/SMSAppV0p4
cd /usr/sbin/

SMSAppV0p4 

After loading .itb file with above modification i observed that linux is not booting completely and getting stuck before login option and when i disabled SMSAppV0p4 as #SMSAppV0p4 in S100autoboot_app.sh then Linux is booting completely.

Coming to your Question :

From beginning we are using yocto tiny rootfs only.

Do we need to change our rootfs file system ??.

Can you provide any link to download Ubuntu main rootfs,which is compitable with flexbuild based SDK for LS1028A processor??.

Thanks & Regards,

Amit Keshri

0 Kudos

2,157 Views
yipingwang
NXP TechSupport
NXP TechSupport
0 Kudos

2,071 Views
Amit_Keshri
Contributor III

Hi @yipingwang ,

I have download Ubuntu main rootfs from above link and did below things:

1.Created autoboot.service script file under flexbuild_lsdk2012/packages/rfs/etc/systemd/system directory and wrote below script in autoboot.sh:

----------------------------------------------------------------------------------------------

[Unit]
Description=Auto Launch of app after Linux boot up
#After=syslog.target
[Service]
Type=simple
ExecStart=/flexbuild_lsdk2012/packages/newrfs/etc/init.d/S100autoboot_app.sh
[Install]
WantedBy=sysinit.target.wants
#WantedBy=default.targ

-----------------------------------------------------------------------------------------

2.Created S100autoboot_sms.sh file in  /flexbuild_lsdk2012/packages/rfs/etc/init.d/ to run the application and written below things inside S100autoboot_sms.sh:

3.Change the file permissions for both, the Systemd service unit and script:

sudo chmod 777 /rfs/etc/systemd/system/autoboot.service

sudo chmod 777 /rfs/etc/init.d/S100autoboot_sms.sh

4.enable the service unit:

 sudo systemctl daemon-reload

sudo systemctl enable autoboot.service

----------------------------------------------------------------------------------

But after sudo systemctl enable autoboot.service command ,it is showing below ERROR:

Failed to enable unit: Unit file autoboot.service does not exist.

But when i enable WantedBy=default.targe in autoboot.service file then sudo systemctl enable autoboot.service command is getting executed but it is taking default.target from /etc/systemd/system from ubuntu server  path not instead of rfs/etc/systemd/system path.

Please help us on this.

Regards,

Amit Kumar Keshri

0 Kudos

2,060 Views
yipingwang
NXP TechSupport
NXP TechSupport

Would you please boot the target board with rootfs rootfs_lsdk2012_ubuntu_main_arm64.tgz?

Then on the target board do the following configuration.

1. Created autoboot.service script file in /etc/systemd/system directory and wrote below script in autoboot.service:

--------------------------------------------------------

[Unit]
After=network.target

[Service]
ExecStart=/etc/init.d/autoboot_sms.sh

[Install]
WantedBy=default.target

---------------------------------------------------------

2. Created autoboot_sms.sh file in /etc/init.d/ to run the application and wrote below things inside autoboot_sms.sh:

--------------------------------------------------

#!/bin/bash
echo "*******Auto-Boot Enable****************" > /root/autoboot.txt
User=root
PATH:/usr/sbin

chmod a+x /usr/sbin/SMSAppV0p4
cd /usr/sbin/

./SMSAppV0p4 &

----------------------------------------------------

3. Change the file permissions for both, the Systemd service unit and script::

chmod 777 /etc/systemd/system/autoboot.service

chmod 777 /etc/init.d/autoboot_sms.sh

4. Enable the service unit:

 systemctl daemon-reload

systemctl enable autoboot.service

5. Please reboot rootfs on the target board and check the output in file /root/autoboot.txt.

0 Kudos

2,057 Views
Amit_Keshri
Contributor III

Thank You for quick reply.

I will load in board and update you the result.

Regards,

Amit  Keshri

0 Kudos