I don’t know if anyone have any experience with it, but I just can’t get the mcp2515 to work with the Mangoh Red over the Rpi SPI port. I tried to assign multiples IRQ, but it won’t work at all.
The purpose of doing this is to have 2 CAN buses connected over SPI, instead of using the CAN IoT board that only has 1 channel.
The first field is chip select. So you will want values of 1 and 2 for your two different chips assuming that you’re using the chip select pins available on the RPi connector.
Can you explain what is a chip selector? What pins are you referring to? Can you point me to something on the documentation that talks about this chip selection?
I really don’t understand the Channel / Chip Select part of this for the CP2130.
In SPI, there is a single pair of data lines (MOSI=master-out-slave-in, MISO=master-in-slave-out). To enable a single master (in our case the CP2130) to talk to multiple slaves, the slaves must know when the master is talking to them. In SPI, this is achieved by the master driving a “chip select” to a predetermined logic level (typically low). Pins 24 and 26 of the Raspberry Pi connector on the mangOH Red correspond to chip select 1 and chip select 2 of the CP2130.
I finally got time to work on this again and this was my progress.
When I try to initialize the can0 interface (ifconfig can0 up) I’m getting the following error logged:
[ 434.037242] spi32766.2 supply vdd not found, using dummy regulator
[ 434.037336] spi32766.2 supply xceiver not found, using dummy regulator
[ 467.034220] gpio_sync_ri: RI owner is Modem
[ 467.034245] gpiod_export: sierra–find GPIO,chipdev = -828217840,chipngpio = 80,chipbase = 0
[ 467.036069] sps:BAM 0x07884000 (va:0xd09c0000) enabled: ver:0x18, number of pipes:24
[ 467.036578] spi1.0 supply vdd not found, using dummy regulator
[ 467.036660] spi1.0 supply xceiver not found, using dummy regulator
[ 467.047547] can_spi_init: mcp2515 (gpio:9 irq:61).
[ 504.152050] mcp251x spi32766.2: failed to acquire irq -930657552
[ 522.002345] mcp251x spi32766.2: failed to acquire irq -930657552
I’m trying to use the module that was already developed for the mangOH board. It already implements the platform_data configuration. I set the interrupt pin to 9, GPIO 22.
The interrupt is not connected to the cp2130, it’s connect directly to one of the processors GPIOs, that’s why I’m using -1 for the IRQ.
I’m using CS2 for this mcp2515 chip. I’m trying to understand what’s the “cs_mode” configuration. I see it as an enable, so I set it to 1, but I see that it accepts the value 2 as well.
I’ve been working intensively on this and still couldn’t get to a solution.
I could adapt the can_iot.c to work with the CP2130 based on the WiFi SPI communication.
I got everything to load perfectly, but I’m still not receiving any CAN message. Tomorrow I’m going to connect a logic analyzer to see what the CP2130 is doing wrong, but I don’t have much knowledge of SPI to be able to troubleshoot at that level.
Here is the adapted CAN module: can1_spi.c (3.5 KB)
I also wrote a script that loads the modules and bring the CAN interface up. You will notice that I’m creating and loading the pdata as suggested by the driver developer using the create_pdata.c located in the CP2130 module folder, but still not working.
Please, advise what should I test next. I have tested this MCP2515 with a Raspberry Pi and it works perfectly. The interface with CP2130 makes everything very hard.
I really need to get 2 CAN buses working on the Mangoh platform. I would appreciate if you could also point someone to help me developing this driver, if you are not available. I’m open to hire a contractor to assist on this development.
I just connected the board to an oscilloscope. I tested the pins using the spidev first to make sure everything was working fine.
Then I went back to try with the mcp2515. I could see an initial count of 2 on the interrupt then I did some tests with the interrupt by manually switching from 0 to 1 to make sure the pins are correct and it is counting.
61: 26 msmgpio 9 mcp251x
I connected the oscilloscope to the Interrupt, SCK, MOSI and MISO. But cannot see any activity.
My guess is that something is wrong on my module code.
output for ip link show can0:
10: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
link/can
Any suggestion where should I look at? Any command or screen that I can share that will help on this?