-
Notifications
You must be signed in to change notification settings - Fork 5.2k
mcp2515 overlay support to SPI bus 1 on RPI 3 #1804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That's would make sense if you meant "spi0.0", due to
You will need to disable the spidev associated with spi1.0 - you can do this with an overlay parameter:
Also, fragment 0 is unnecessary because loading the spi1-3cs overlay enables spi1. In summary:
However, see #1484 - it seems that there are interrupt problems when various Aux peripherals (SPI1, SPI2 and UART1) are used together. You may have to disable (or not enable) UART1 - put I'm hoping to look at the Aux interrupt issue today. |
This is incredibly awesome @pelwell . Thank you very much. I had now SPI0 along with SPI1 working without any issues and i did not disable the UART at all. For the moment i don't need either UART1 or the Blutooth. I have tested also the mcp2515 Transceiver on the whole chip selects of SPI1 with different overlays and it worked fine. Just a matter of curiosity, you mentioned SPI2 but actually the SPI 2 bins are assigned to bins which don't exist for the 40 bins RPI3, is this considered for future RPI versions? I am grateful to your help and Thank you again ! Regards |
SPI2 can be used on a Compute Module on GPIOs 40-45, but sadly the SPI2 function isn't available on GPIOS 0-27. |
Thank you ! |
Hi ahmedawad1 |
It is exactly as what what @pelwell mentioned in the summary steps. Follow the dts source code in the first comment, and make the required modifications. Then use a dtc compiler to compile from .dts to dtb or .dtbo according to the Raspbian kernel version that you use. You can see this post on the Raspberry Forum to get to know how to compile it from .dts source file. here |
I make mcp2515-can2-overlay.dts /*
/ {
}; on RPi
sudo cp mcp2515-can2.dtbo /boot/overlays in /boot/config.txt CAN2 was not created. sudo /sbin/ip link set can2 up type can bitrate 500000 |
need |
your .dts source file looks ok but I think you are missing in the config.txt :
Try it! |
I have only one SPI1.0 |
@karu2003 |
Thanks, it works. CAN0 is better. :) |
Hello , I'm trying to do the same - connect the Canbus to SPI1 - I think I did everything written here - but it doesn't work, dtparam=i2c_arm=on the connection are: but I can't see the can0 why? Thanks, |
Shouldn't that be:
? |
And I don't know what spi1-bcm2835 is supposed to do, but it shouldn't be necessary. |
this is what I have now : dtparam=i2c_arm=on still doesn't work maybe my cable connection is wrong? also I only change the the config.txt - do I need to download something? |
Let's debug this systematically. Step 1 - is the spi1-1cs overlay working? Comment out the mcp2515 dtoverlay line and add the cs0_spidev parameter to the spi1-1cs overlay:
After rebooting, confirm that /dev/spidev1.0 exists. |
yes , |
Step 2 - see if the hardware responds.
and report the output. |
You may also need:
|
question : |
Yes - jump straight to 2. |
this is the output: another small question : Thanks , |
It's just a simple script that tries to read from various addresses on the device. It should show some kind of life from most devices. The fact that the output isn't all 00s or ffs suggests that the wiring might be OK. Step 3 - enable the driver. i. Remove the cs0_spidev parameter and uncomment the mcp2515-can1 overlay.
|
this is the config now: and after reboot this is what I get: |
And with the mcp2515-can1 overlay? |
Nevermind - that's for spi0.1, not spi1.0. You'll need a custom overlay... |
when I use this command this is the output I get: |
There's a potentially suitable overlay (mcp2515-can1-0.dtbo) here. |
what to do with this dtbo file? |
Copy it into /boot/overlays, and use:
|
when I try I get permission deny... |
|
does it mean its working? pi@raspberrypi:~ $ dmesg | grep -i -E "(mcp|spi)" |
I think so. From the error message I would guess that you haven't removed the cs0_spidev parameter:
|
I will check and let you know if it;s working well , but the config.txt is this : dtparam=i2c_arm=on dtoverlay=spi1-1cs |
Oh, that's a shame - it defaults to enabled, so you'll have to explicitly disable it:
|
it's seem that you did a GRAET job! Thanks again! |
Unfortunately there is no easy way to make an overlay work with more than one of the many combinations of SPI interfaces and chip selects, so a new combination often runs into problems like this. The larger number of wires compared to I2C makes a wiring fault more likely, and differences in the protocol (again compared to I2C) make it harder to tell a configuration error from a hardware issue. |
Hello, |
It is the wrong topic - try the Raspberry Pi Forums. But here's a starting point: https://en.wikipedia.org/wiki/SocketCAN |
Hello,
I tried the test script on SPI2 and got all zeros: The result on SPI0 is OK: This means SPI0 works OK but SPI2 doesn't.
From the results above, SPI2 just doesn't work, is there any reason that may lead to this problem? By the way , here are my configuration:
|
Fragment 3 looks wrong - you've chosen the 1cs version of the spi2 overlay, but Also note that fragment 0 is redundant - without the |
Thank you very much for the correction! I have succeeded read data from can bus(can1) with SPI2! can0 and can1 work fine but the message still exists: |
Hey, so I'm trying to use the SPI1.0 and SPI1.1 for a project with CAN bus.
When I now type
Can you tell me why this happens and how to actually disable spidev for both? |
The "-cs" suffix indicates how many chip selects to enable, not which chip select to enable. Loading the second overlay overwrites the first and reactivates spidev1.0. I think what you want is:
By the way, |
Yes, that managed to fix my issue. Thank you very much for the help! |
Hi there, Here is my pin map : (verified multiple times)
i used the dtbo you provided here and it is in the /boot/overlay folder on my raspberry
The output of the python script looked fine with only 00s here is my config.txt file :
Tho i dont know what this error is and how to solve it:
ps : it worked once yesterday, i turned it off and today it wasn't working anymore, i just re made all the steps from the start, but nothing helps |
See #4183, which suggests it is a wiring/hardware problem. |
ok, i have tried a few more things From there i re did all the steps :
and when i enable the mcp overlay i get this error :
UPDATE : from my testing a rebooted a few times without changing anything and i got the 110 error message too |
I've modified the
I've done some testing with 2 mcp2515 but it would be better if more people could test it. |
Thanks to all of you guys. I have been working on getting the mcp2515 on spi4 and with the tips in this post finally it works!! |
I tested the additional spi bus 1 on RPI3 after enabling the overlay in config.txt file
the 3 chip selects spi1.0 / spi1.1 / spi1.2, all works fine with an mcp3008 ADC chip, so there is no problem at all with this bus and its corresponding chip selects.
Now, I wanted to write .dts source that supports the functionality of mcp2515 on this additional SPI bus. Very similar to what a contributor before did @petit_miner to the overlay mcp2515-can1-overlay.dts but i changed every spi0 to spi1, the mcp2515 worked but spi0.1 disappeared and the chipselects of "SPI 1" were not properly functioning, that is if connecting the mcp2515 module to spi1.0 or spi1.1 they both works which is not right.
here is my trial, i didn't change much except using spi1 instead of spi0.
the original dts file is found on your repository rpi-4.4.y , this is what i used to modify and recompile
My modifications are:
`
`
please what i am doing wrong or what needs to be changed in order to have the mcp2515 overlay correctly uses the spi1.0 / spi1.1 / spi1.2 overlays.
Thanks
I am using Raspbian: Linux raspberrypi 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux
The text was updated successfully, but these errors were encountered: