This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM6442: Automatically bring up CAN network interfaces on boot

Part Number: AM6442

Tool/software:

Hi TI support,

I am using AM6442 SK and I have enable CAN in Linux Kernel, but every time I reboot, I have to bring up the network interfaces manually, e.g.:

- ip link set can0 up type can bitrate 500000

What is the best way to set up the CAN interfaces on startup? Kind of like starting up ethernet 
Thanks
  • Hi,

    In order to automate the process, you can use systemd service in linux to automatically run the required commands for establishing CAN communication.

    An example: 
    
    Unit
    Description=My Server
    StartLimitIntervalSec=0
    
    Service
    Type=Simple
    ExecStart=/usr/sbin/1.sh
    Restart=always
    RestartSec=20
    
    Install
    WantedBy=multi-user.target
    
    1.sh →
                
    #!/bin/bash
    <insert commands> 
    reboot
    sleep 1000
    echo `date` >> /tmp/2

    Regards,
    Aparna

  • Hi ,

    Can you show me how to add this to the yocto build?

    Thanks!

  • Hi,

    You don't need to add this into an Yocto build.

    1. Please add your .service file into the following location:

    root@am62xx-evm:/etc/systemd/system# ls                                         
    basic.target.wants                      graphical.target.wants                  
    bluetooth.target.wants                  local-fs.target.wants                   
    ctrl-alt-del.target                     multi-user.target.wants                 
    dbus-org.bluez.service                  network-online.target.wants             
    dbus-org.freedesktop.Avahi.service      sockets.target.wants                    
    dbus-org.freedesktop.network1.service   sync-clocks.service                     
    dbus-org.freedesktop.resolve1.service   sysinit.target.wants                    
    dbus-org.freedesktop.timesync1.service  systemd-hostnamed.service               
    dbus.service                            systemd-random-seed.service.wants       
    default.target                          systemd-udevd.service                   
    getty.target.wants                      timers.target.wants                     
    root@am62xx-evm:/etc/systemd/system# 
    

    Then, you can auto run your service routine, by using the commands:

    2. Now that the service file is in /etc/systemd/system folder, run the
    following command to update System Daemon.
    systemctl daemon-reload


    3. To test that System Daemon, start the service by use the
    following command:
    systemctl start <name-of-sevice>.service


    4. After test works, make the service autostart by using the following command:
    systemctl enable <name-of-sevice>.service

    Regards,
    Aparna

  • Hi ,

    Thank you for your answer!

    But I have a large number of products, so I want to include it in the build so I can program it once into the product.