Skip to content
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

SPI stopped working on Rpi B1 from 4.9.43+ onwards #161

Open
ghost opened this issue Nov 7, 2017 · 8 comments
Open

SPI stopped working on Rpi B1 from 4.9.43+ onwards #161

ghost opened this issue Nov 7, 2017 · 8 comments

Comments

@ghost
Copy link

ghost commented Nov 7, 2017

Hello,
SPI stopped working for me in the latest Raspbian stretch update. So I went back through the kernel versions here bisecting until I found the latest working version.
Latest working version for me is 4.9.41+, it does not work in 4.9.43+ anymore.
Is there a benign explanation? Did I miss a required configuration change?
Best regards,
Max

@pelwell
Copy link
Collaborator

pelwell commented Nov 7, 2017

File this in https://github.com/raspberrypi/linux/issues and I'll be happy to help.

@pelwell
Copy link
Collaborator

pelwell commented Nov 7, 2017

Giving the timing I think you have been negatively affected by this commit: raspberrypi/linux@3b1e49b

Unfortunately the SPI subsystem doesn't allow a default value to be specified - the maximum is used instead - so increasing the maximum has also increased the default.

Which SPI library are you using? Whichever it is, it is failing to choose a sensible bus speed.

@ghost
Copy link
Author

ghost commented Nov 7, 2017

I followed the instructions here years ago
https://www.raspberrypi-spy.co.uk/2014/08/enabling-the-spi-interface-on-the-raspberry-pi/
and also remember using this one
https://github.com/lthiery/SPI-Py.git
but I am not actually sure.
Which SPI library is recommended or up to date?

@pelwell
Copy link
Collaborator

pelwell commented Nov 7, 2017

Some application must be failing, otherwise you wouldn't know that SPI is broken. Which application is it?

@ghost
Copy link
Author

ghost commented Nov 7, 2017

pip install spidev -U
updated to latest version 3.2
Still not working.

It is a simple python script reading from mcp3008 A/D chip


import spidev
import time
import os

# Open SPI bus
spi = spidev.SpiDev()
spi.open(0,0)

# Function to read SPI data from MCP3008 chip
# Channel must be an integer 0-7
def ReadChannel(channel):
  adc = spi.xfer2([1,(8+channel)<<4,0])
  data = ((adc[1]&3) << 8) + adc[2]
  return data

....

@pelwell
Copy link
Collaborator

pelwell commented Nov 7, 2017

Add:

spi.max_speed_hz = 500000

after spi.open to restore the old default/maximum speed.

@ghost
Copy link
Author

ghost commented Nov 7, 2017

That fixed it. Thank you!

@Ruffio
Copy link

Ruffio commented Aug 26, 2020

This issue has been resolved and the GitHug user account has been deleted, therefore it says @ghost.
Please close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants