SJA1000 Setup with Colibri T30

Hi!

I am trying to use an external SJA1000 module with my Colibri T30 module to communicate through CAN bus. I know the T30 has reached end-of-life support, but I would like to know how install the drivers and libraries on Linux.

I have tested my module with WinCE7, and it was straight forward. On Linux, however, it seems to be a bit more complicated. I have seen some guides telling to use the SPI interface (which does run on my T30 under /dev/spidev0.0), but there is also the option to create an interface when building the kernel.

What option would be the easiest and is there an hello world equivalent so I can test my setup?

I am currently using a Iris carrier board, let me know if you need more information.

Thanks,

William

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello William,

Integrating an external SJA1000 CAN controller with the Colibri T30 module on Linux involves a few steps, as the process is indeed more involved compared to WinCE7. Given that the T30 utilizes an NVIDIA Tegra 3 SoC and you’re looking to interface via SPI, you have two primary approaches to consider: using the SPI interface directly or integrating the controller at the kernel level.

Using the SPI Interface

  1. SPI Communication: Since you’ve confirmed /dev/spidev0.0 is available, you can communicate with the SJA1000 module using SPI from user space. This approach requires you to handle the CAN protocol in user space, which can be complex and not as efficient as kernel-level handling.

  2. User Space Libraries: Look into user space libraries that might support the SJA1000 over SPI. Although not common, some specialized libraries or tools could facilitate this.

Integrating at the Kernel Level

  1. Kernel Driver: For kernel-level integration, you would typically need to write or adapt a driver for the SJA1000 that communicates over SPI. This involves understanding the Linux SPI and CAN subsystems.

  2. Device Tree Configuration: The Colibri T30 uses a device tree, so you’ll need to add your SPI-connected SJA1000 to the device tree. This tells the kernel about the device and how it’s connected.

  3. Building the Kernel: After adding support in the device tree and ensuring you have a suitable driver, you’ll need to recompile the Linux kernel for the Colibri T30. This process is well-documented but requires a Yocto Project or Buildroot environment set up for cross-compilation.

Testing Your Setup

  • CAN Utilities: Once you have the driver and device tree set up, you can use the can-utils package to test CAN communication. This package includes tools like cansend and candump which are akin to “Hello World” for CAN networks.

  • Simple Test: A simple loopback test (if supported by your hardware) can verify basic operation. This involves sending a CAN frame and receiving it back on the same device.

Given the complexity and the need for custom development, especially for kernel driver development and device tree modifications, this task requires a good understanding of Linux kernel development and the specifics of the NVIDIA Tegra 3 platform used by the Colibri T30.

Since the Colibri T30 has reached end-of

Please, also check if these links can help you solve your problem:

CAN (Linux) | Toradex Developer Center.

I’m not familiar with the SJA1000 CAN controller, but according to its datasheet:
"The SJA1000 appears to a microcontroller as a memory-mapped I/O device. "

So, I’m confused by your intention to use the SPI interface.
Could you please provide details about how the SJA1000 is connected to the Colibri T30 module?

Thanks for the reply, the SJA1000 is indeed a memory mapped device after all. I think I got confused with the MCP2515.

From my understanding, I have no other choice than to recompile the kernel for my board, since CAN isn’t supported by default? Or is it possible to build the module from the sources and just enable it manually with my current image?

If I recompile the image, I would need to add these parameters to the colibri_t30_defconfig file?

  • CONFIG_CAN
  • CONFIG_CAN_RAW
  • CONFIG_CAN_BCM
  • CONFIG_CAN_DEV (depending on kernel version)
  • CONFIG_CAN_SJA1000
  • CONFIG_CAN_SJA1000_PLATFORM

I appreciate your help, let me know if I understand the process correctly :slight_smile:

Yes, you need to modify the config file to include:

CONFIG_CAN=y
CONFIG_CAN_RAW=y
CONFIG_CAN_BCM=y
CONFIG_CAN_SJA1000=y
CONFIG_CAN_SJA1000_PLATFORM=y

Additionally, you need to modify the Device Tree to provide information about the SJA1000 addresses, IRQ, etc.

sja1000@memory_address {
compatible = “nxp,sja1000”;
reg = <0xmemory_address 0x100>; // Replace memory_address with the actual address and 0x100 with the correct size
interrupt-parent = <&interrupt_controller>;
interrupts = <irq_number IRQ_TYPE_LEVEL_HIGH>; // Replace irq_number with the actual interrupt number
clocks = <&clock_controller clock_id>; // If applicable, replace clock_controller and clock_id
clock-names = “can_clk”;
};