Skip to menu

Robotics with Object Pascal

All New K2

radxa zero 3w running an app on booting

2025.03.13 21:33

me Views:140

To run an application on boot for a Radxa Zero 3W, you'll need to configure a startup script 

or service to automatically execute the desired application when the device starts. 

 

 
Here's a breakdown of the process:
 
1. Identify the Application:
  • Determine the full path to the executable file of the application you want to run on boot. 
2. Create a Startup Script or Service:
  • Startup Script (e.g., a bash script):
    • Create a new script file (e.g., my_app_startup.sh).
    • Add the following lines to the script, replacing /path/to/your/application with the actual path:
 
     Code
            #!/bin/bash
      /path/to/your/application &
 
  • Make the script executable: sudo chmod +x /path/to/your/my_app_startup.sh. 
  • Systemd Service:
  • Create a new service file (e.g., /etc/systemd/system/my_app_startup.service).
  • Add the following content, replacing /path/to/your/application with the actual path:
 
          Code
 
        [Unit]
        Description=Run my application on startup
        After=multi-user.target

        [Service]
        User=root  # Or the user who will run the application
        WorkingDirectory=/path/to/your/application/  # Or the directory where the application is located
        ExecStart=/path/to/your/application

        [Install]
        WantedBy=multi-user.target
 
 
  • Enable the service: sudo systemctl enable my_app_startup.service. 
  • Start the service: sudo systemctl start my_app_startup.service.
3. Add the Script/Service to Startup:
  • Startup Script:
    • Add the script to a directory that's executed on startup (e.g., /etc/rc.local or /etc/init.d/).
  • Systemd Service:
    • Systemd will automatically handle startup based on the service configuration.
 
4. Important Notes:
  • Permissions: Ensure the application and the script/service have the necessary permissions to run.
  • Dependencies: Make sure all required dependencies for the application are installed.
  • Testing: Thoroughly test the startup process to ensure the application runs as expected.
 
Example using Systemd:
 
    Let's say you want to run a Python script named my_script.py located in /home/user/scripts/.
 
 

    * Create the service file:   sudo nano /etc/systemd/system/my_python_script.service

 

    * Add the following content:

 
    [Unit]
    Description=Run my Python script on startup
    After=multi-user.target

    [Service]
    User=user  # Replace with the actual user
    WorkingDirectory=/home/user/scripts/
    ExecStart=/usr/bin/python3 /home/user/scripts/my_script.py

    [Install]
    WantedBy=multi-user.target
 
 

    * Enable and start the service:

       sudo systemctl enable my_app_startup.service

             sudo systemctl start my_app_startup.service