Jump to content
  • 0

Pmod CAN Linux Driver


Ahmer Raza

Question

Posted (edited)

Hello! I am running Debian Linux on an SoC consisting of a Rocket CPU and related peripherals, which is in turn running on the Arty A7-100T board. I wish to add the Pmod CAN peripheral to the FPGA and access the CAN controller through Linux. I have incorporated the Pmod CAN IP in my SoC block design, and was wondering what options for Linux drivers I have.

The drivers provided alongside the IP are, as I understand, baremetal drivers. Qualitatively, how difficult would it be to port the driver to Linux and/or is it even a feasible option?

To the best of my understanding, another option is to simply treat the Pmod as a SPI device and write software to manipulate the CAN controller via SPI. Has this been done before and/or is there any reference code for this?

Most importantly, the Linux kernel has a SPI driver for the MCP25625. Is this driver compatible with the Pmod CAN peripheral?

Thank you in advance!

Edited by Ahmer Raza
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

The Digilent Pmod CAN IP seems to just wrap Xilinx's AXI GPIO and SPI IPs (confirmed here). To the best of my knowledge, since the MCP 25625 can be manipulated over SPI and the GPIO pins are not strictly necessary, and since the PmodCAN directly connects the relevant SPI pins to the board, the MCP 25625 driver is compatible with the Pmod. I will give more info once I try it.

Link to comment
Share on other sites

  • 0

@Ahmer Raza

Quote

To the best of my understanding, another option is to simply treat the Pmod as a SPI device and write software to manipulate the CAN controller via SPI. Has this been done before and/or is there any reference code for this?

That's how it is!

The CAN has its Higher Layers (Drivers) + Data Link layer + Physical Layer (commonly called CAN Transceivers).

https://digilent.com/reference/pmod/pmodcan/start

What the Digilent Pmod CAN offers you is a layer of SPI over the CAN's Physical layer (its just converts the can_tx and can_rx signals to spi signals). The CAN IP core or the Data Link Layer sits itself on the FPGA. So every transaction after the DataLinkLayer needs to be converted to SPI data, moved through the Pmod pin connector and put to the Transceiver side.

Link to comment
Share on other sites

  • 0

@dpaul Thanks for your help! I managed to get the Pmod CAN connected and initialized. The INT pin was mandatory for the Linux driver and I had to connect it.

The Pmod is behaving strangely: when I send a message, I can only send one (which is successfully received by the second node) before I need to reset the CAN bus. If I don't reset it after sending a message, the other node doesn't receive it. Also, no messages can be received at all.

I am very certain that the problem has to do with the interrupt pin (INT). Is it level-triggered or edge-triggered? The datasheet describes it as active-low (INT has a bar over it), which leads me to believe it is level-triggered, but I couldn't confirm this anywhere. I may have overlooked something in the datasheet.

Thanks again for your help!

Link to comment
Share on other sites

  • 0
19 hours ago, Ahmer Raza said:

The INT pin was mandatory for the Linux driver and I had to connect it.

May be, when I said optional, I told it purely from the CAN Data Link layer pov.

19 hours ago, Ahmer Raza said:

The Pmod is behaving strangely

In that case, I think you need to confirm (probably through simulation) that the SPI transactions are correctly taking place.

On 5/29/2024 at 10:04 AM, Ahmer Raza said:

To the best of my understanding, another option is to simply treat the Pmod as a SPI device and write software to manipulate the CAN controller via SPI. Has this been done before and/or is there any reference code for this?

I think this is the way to go!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...