python-3.xgoogle-coral

How do I run a python script on boot on Google Coral?


I have written a simple test code in python to toggle two of the I/O pins on and off every few seconds. I would like to be able to run this code whenever the board powers on so that I don't need to bring a keyboard, mouse, and monitor everywhere I want to run the simple test. How do I do this on Mendel OS on a google coral?


Solution

  • On Mendel OS, your systemd service should look like this:

    myservice.service:

    [Unit]
    Description=Example systemd service.
    After=weston.target
    
    [Service]
    Environment=DISPLAY=:0
    PAMName=login
    Type=simple
    User=mendel
    WorkingDirectory=/home/mendel
    ExecStart=/bin/bash /usr/bin/test_service.sh
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    

    Regarding how to create a service and how to deploy it, you can follow this article.

    Change 'ExecStart' line with your python file that you want to get executed.