How to enable automatically can bus on startup

I have to enable can after every boot.
I tried this way link to enable can automatically after boot, but it didn’t work.
The status I get when running the below command:
$ sudo systemctl status systemd-networkd:

Jun 28 10:13:43 trn-desktop systemd[1]: Starting Network Service...
Jun 28 10:13:43 trn-desktop systemd-networkd[8986]: /etc/systemd/network/80-can.network:5: Unknown section 'CAN'. Ignoring.
Jun 28 10:13:43 trn-desktop systemd-networkd[8986]: eth0: Gained IPv6LL
Jun 28 10:13:43 trn-desktop systemd-networkd[8986]: Enumeration completed
Jun 28 10:13:43 trn-desktop systemd[1]: Started Network Service.

hello mojashan,

is the CAN interfaces up after system boot-up? please use ifconfig to list all the interfaces which are up.

is no,
please follow the steps to enable and check CAN on TX2.

  1. enable kernel support for mttcan(Other required modules are already supported)
    CONFIG_MTTCAN = m (Here mttcan is compiled as a module)

  2. Insert CAN BUS subsystem support module.
    modprobe can

  3. Insert Raw CAN protocol module (CAN-ID filtering)
    modprobe can_raw

  4. Real CAN interface support (for our case, it is: mttcan)
    modprobe mttcan (dependent module is can_dev: can driver with netlink support)

  5. CAN interface settings for both the controllers
    ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on
    ip link set up can0
    ip link set can1 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on
    ip link set up can1

No, it is not up.
These steps work but I have to repeat them again after each boot.
I found a way that works.
I wrote a script for these commands and added execute commands to startup applications.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.