Start application at boot-up linux imx7

Hi,
I want to start my application just after login at boot-up : root
I did below as I followed How to Autorun Application at the Start up in Linux

vi /etc/systemd/system/autostartup.service
[Unit]
Description=autostartup service
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/agv_test

[Install]
WantedBy=multi-user.target

systemctl --system daemon-reload
systemctl enable autostartup.service
systemctl start autostartup.service
root@colibri-imx7-emmc:~#  systemctl status autostartup.service

autostartup.service - autostartup service
Loaded: loaded (/etc/systemd/system/autostartup.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2020-02-14 09:52:18 UTC; 5min ago
Process: 526 ExecStart=/usr/bin/agv_test (code=exited, status=1/FAILURE)
Main PID: 526 (code=exited, status=1/FAILURE)

Feb 14 09:52:17 colibri-imx7-emmc systemd[1]: Started autostartup service.
Feb 14 09:52:18 colibri-imx7-emmc agv_test[526]: Bad home directory.
Feb 14 09:52:18 colibri-imx7-emmc systemd[1]: autostartup.service: Main process exited, code=ex
Feb 14 09:52:18 colibri-imx7-emmc systemd[1]: autostartup.service: Unit entered failed state.
Feb 14 09:52:18 colibri-imx7-emmc systemd[1]: autostartup.service: Failed with result 'exit-cod
root@colibri-imx7-emmc:~# ls /usr/bin/agv*
/usr/bin/agv_test

root@colibri-imx7-emmc:~#

Could you please help me identifying issue?

Thank you
Neeraj

Your agv_test is started but returns a error code. That’s why systemd reports a failure. You have to debug your agv_test.

Hi @alex.tx ,
Executable is working code, once it was almost ready to release/tested, then only I decided to add on boot-up. Booting agv_test log for your ref.

root@colibri-imx7-emmc:~# /usr/bin/agv_test 
sysinfo_main() called thread ID: 0
System Time:i2c_main() called thread ID: 1
i2c_dev_open() called bus_num: 0
i2c_dev_open() called bus_num: 2
i2c_dev_open() called bus_num: 3
timer_main() called thread ID: 5
camera_main() called thread ID: 6
motor_main() called thread ID: 7
diags_main() called thread ID: 8
sensor_main() called thread ID: 9
wifi_main() called thread ID: 10
rtc_main() called thread ID: 11
usb_main() called thread ID: 12
ps_main() called thread ID: 13
indicator_main() called thread ID: 14
...

Could you please help me on this? let me know if you need any more details.

Thank you
Neeraj

Your app may work OK when started form CLI but it doesn’t work when you starting it as a service. May be it relay on some environment variables which does not exists when systemd launch it. Or something else. Unfortunately I can’t debug your app.

Hi @alex.tx
I understand what you say. Let me make one test code just having void main(void) and print, return 0. and update you my findings.
and then I can debug more on what are the dependencies my app has.

Thank you
Neeraj

Hi @alex.tx ,
I verified with my test code and noticed as soon as I login and type anything. my executable launches. is that the right behavior?

The Angstrom Distribution colibri-imx7-emmc ttymxc0
Angstrom v2017.12 - Kernel
Colibri-iMX7-eMMC_Console-Image 2.8b6 20191122
colibri-imx7-emmc login: root
Last login: Tue Feb 18 11:56:26 UTC 2020 on ttymxc0
root@colibri-imx7-emmc:~#
root@colibri-imx7-emmc:~# ls /usr/bin
main() started…

Thank you
Neeraj

It depends on your test app. Are you trying to interact with default console? Change you test app for just creating a file and check if file is created. Use an absolute path for file location please.

Hi @alex.tx
Thank you for help on this.

Hi
You are welcome.