hhh321
Posts: 17
Joined: Fri Apr 22, 2016 12:41 pm

Enabling SPI by raspi-config

Fri May 20, 2016 10:14 am

Hello,
I try to enable SPI by raspi-config in terminal. After confirming my choice there are two messages. At first it prompt "The SPI interface is enabled" info, but then after pressing "OK" it brings
There was an error running option A5 SPI
. After closing raspi-config I've got some information in terminal window :

Code: Select all

/usr/bin/raspi-config: 611: /usr/bin/raspi-config: dtparam: not found
I've got
dtparam=spi=on
in my /boot/config.txt so i don't undestand this message. I'm using RPi3 with kernel version :
Linux pi 4.4.10-v7+ #885 SMP Fri May 13 15:44:27 BST 2016 armv7l GNU/Linux
Could you please tell me what's wrong?

User avatar
joan
Posts: 14688
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Enabling SPI by raspi-config

Fri May 20, 2016 10:16 am

It may just be an incorrect error message.

Do /dev/spidev* exist?

hhh321
Posts: 17
Joined: Fri Apr 22, 2016 12:41 pm

Re: Enabling SPI by raspi-config

Fri May 20, 2016 10:19 am

Yes it exist, all looks fine but i need to be sure that this message is just wrong.

User avatar
joan
Posts: 14688
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Enabling SPI by raspi-config

Fri May 20, 2016 10:24 am

Try using SPI. If it works the message is wrong.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2587
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Enabling SPI by raspi-config

Fri May 20, 2016 10:25 am

raspi-config is now using the dynamic Device Tree features of the 4.4 kernel to apply that parameter immediately without the need for a reboot (as well as adding the usual config.txt setting for the next time). These features are made available to users via the "dtoverlay" and "dtparam" commands.

For some reason raspi-config was unable to locate the dtparam command; it should have been installed in /opt/vc/bin, with a symbolic link in /usr/bin to put it in the path of the root user.

1) Do these commands exist on your card?

2) Which distribution are you running, and what is your upgrade history?

hhh321
Posts: 17
Joined: Fri Apr 22, 2016 12:41 pm

Re: Enabling SPI by raspi-config

Fri May 20, 2016 10:37 am

1) dtparam exist in /opt/vc/bin but I can't see link to this at /usr/bin
2) I'm running Raspbian. After installation i had 4.1.19... kernel version - then I run rpi-update so it bringed me to 4.4.10-v7+

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2587
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Enabling SPI by raspi-config

Fri May 20, 2016 11:04 am

It sounds like the update didn't do all that was required. For now, try creating the symlinks manually:

Code: Select all

for a in dtparam dtoverlay dtoverlay-pre dtoverlay-post; do
    sudo ln -s /opt/vc/bin/$a /usr/bin/$a
done

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6183
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Enabling SPI by raspi-config

Fri May 20, 2016 1:06 pm

You would see this error if you didn't run 'sudo apt-get update && sudo apt-get dist-upgrade'.

bytesandbolts
Posts: 2
Joined: Thu Mar 19, 2015 3:53 pm

Re: Enabling SPI by raspi-config

Sun May 22, 2016 12:02 am

After dist-upgrade and rpi-update today (4.4.y) my /usr/bin/dtparm points to /opt/vc/bin/dtoverlay. Just wondering if that's correct.

I came across this thread as my PiCan CAN-bus shield has stopped working.
My config.txt has the relevant info appended to the bottom of config.txt and worked fine in 4.1.y.

Code: Select all

dtparam=spi=on 
dtoverlay=mcp2515-can0-overlay,oscillator=16000000,interrupt=25 
dtoverlay=spi-bcm2835-overlay

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2587
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Enabling SPI by raspi-config

Sun May 22, 2016 8:51 am

After dist-upgrade and rpi-update today (4.4.y) my /usr/bin/dtparm points to /opt/vc/bin/dtoverlay. Just wondering if that's correct.
Yes, there is so much commonality between the two commands that one is implemented by the other - the role being played is worked out by looking at the name used to invoke the command; Busybox uses the same trick.

Code: Select all

dtparam=spi=on 
dtoverlay=mcp2515-can0-overlay,oscillator=16000000,interrupt=25 
dtoverlay=spi-bcm2835-overlay
Remove the "-overlay" parts and it will work. As of 4.4 "-overlay" isn't part of the filename and should be removed - it was never needed or recommend. You also don't need the spi-bcm2835 overlay anymore since that it is the default. And SPI is enabled implicitly by the mcp2515 overlay (all overlays that require an interface - spi, i2c etc. - will enable it). With those changes applied, what you end up with is:

Code: Select all

dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25 

bytesandbolts
Posts: 2
Joined: Thu Mar 19, 2015 3:53 pm

Re: Enabling SPI by raspi-config

Sun May 22, 2016 1:34 pm

Yes, there is so much commonality between the two commands that one is implemented by the other - the role being played is worked out by looking at the name used to invoke the command; Busybox uses the same trick.
Thanks for clearing that up, glad to know everything is in order after the update.
Remove the "-overlay" parts and it will work. As of 4.4 "-overlay" isn't part of the filename and should be removed - it was never needed or recommend.
I also had a reply from product support saying exactly the same, removing the "-overlay" parts and rebooting fixed the CAN shield, it's now working again!
You also don't need the spi-bcm2835 overlay anymore since that it is the default. And SPI is enabled implicitly by the mcp2515 overlay (all overlays that require an interface - spi, i2c etc. - will enable it).
What do you by the spi-bcm2835 is the default out of interest, a default overlay included within 4.4.y?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2587
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Enabling SPI by raspi-config

Sun May 22, 2016 3:17 pm

There are two driver modules for the SPI interface(s). spi_bcm2708 is the original driver. It is in the Raspberry Pi kernel tree but not part of standard Linux (it hasn't been "upstreamed"). There has been an effort to write new drivers, following best practises (e.g. making more use of Device Tree), and spi_bcm2835 is one of the results. It has been accepted into Linux - it is an upstream driver.

We've been trying to make more use of upstream drivers, but this isn't a change that should be made overnight, so the spi-bcm2835 overlay was created to allow people to try out the new driver on a voluntary basis. With the switch to the 4.4 kernel we made spi_bcm2835 the default driver, so the overlay is no longer necessary. On the whole the switchover has gone smoothly, but some users are reporting problems with some devices that used to work in the 4.1 kernel, so as a short-term measure we may end up writing an spi-bcm2708 overlay to switch back, but at the moment the old driver has been removed from the tree.

Return to “Troubleshooting”