SRegan
Posts: 10
Joined: Sat Feb 20, 2016 2:51 pm

Missing /dev/spi

Sat Feb 20, 2016 3:05 pm

Hi,

I'm running Ubuntu Mate 15.10 on my Raspberry Pi 2. I was attempting to use a Python script that utilizes SPI, but I was getting the error that "/dev/spidev0.0" was not found.

I checked the /dev/ folder and noticed that none of the SPI files are not there. I attempted to add "dtparam=spi=on" to the /boot/config.txt however, this did not fix the problem.

When running:

Code: Select all

gpio load spi
I get an error saying "gpio: unable to load spi_bcm2708"

I can't seem to figure out what's wrong. Any help would be appreciated.


Here is some info:

Code: Select all

#uname -a
Linux sean-desktop 4.1.15-v7+ #830 SMP Tue Dec 15 17:02:45 GMT 2015 armv7l armv7l armv7l GNU/Linux

Code: Select all

# modprobe spi_bcm2708
modprobe: ERROR: could not insert 'spi_bcm2708': No such device

Code: Select all

gpio readall
 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5V      |     |     |
 |   3 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | ALT0 | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 1 | IN   | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | IN   | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |
 |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
 |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+


Code: Select all

#lsmod
Module                  Size  Used by
spi_bcm2835             7216  0
fuse                   82598  3
cfg80211              399468  0
rfkill                 16799  2 cfg80211
8192cu                528485  0
joydev                  9427  0
evdev                  10552  3
bcm2835_gpiomem         3023  0
uio_pdrv_genirq         2986  0
uio                     8228  1 uio_pdrv_genirq
bcm2708_rng              980  0
snd_bcm2835            19739  1
snd_pcm_oss            37082  0
snd_mixer_oss          14348  1 snd_pcm_oss
snd_pcm                75040  2 snd_bcm2835,snd_pcm_oss
snd_seq_dummy           1124  0
snd_seq_oss            31871  0
snd_seq_midi            4472  0
snd_rawmidi            18368  1 snd_seq_midi
snd_seq_midi_event      5383  2 snd_seq_oss,snd_seq_midi
snd_seq                53806  6 snd_seq_midi_event,snd_seq_oss,snd_seq_dummy,snd_seq_midi
snd_seq_device          3650  4 snd_seq,snd_rawmidi,snd_seq_oss,snd_seq_midi
snd_timer              18668  2 snd_pcm,snd_seq
snd                    52620  11 snd_bcm2835,snd_pcm_oss,snd_timer,snd_pcm,snd_seq,snd_rawmidi,snd_seq_oss,snd_seq_device,snd_mixer_oss
ipv6                  343236  62

fsr
Posts: 88
Joined: Wed Jan 13, 2016 2:29 am

Re: Missing /dev/spi

Sat Feb 20, 2016 4:27 pm

Two modules need to be running for the device nodes to appear, the broadcom module (spi_bcm2835) and a module called spidev (which puts the spi devices into userland). I can see spi_bcm2835 in your lsmod, so its probably spidev not running

Check its not blacklisted. (/etc/modprobe.d)

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

Re: Missing /dev/spi

Sat Feb 20, 2016 4:31 pm

I've not heard of a kernel module spidev. spi_bcm2853 should be enough to create the /dev/spi* devices.

DirkS
Posts: 10362
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Missing /dev/spi

Sat Feb 20, 2016 4:38 pm

fsr wrote:Two modules need to be running for the device nodes to appear, the broadcom module (spi_bcm2835) and a module called spidev (which puts the spi devices into userland). I can see spi_bcm2835 in your lsmod, so its probably spidev not running
I think you've got your acronyms mixed up. i2c may need i2c-dev. As joan says, there is no spidev kernel module
Last edited by DirkS on Sat Feb 20, 2016 4:55 pm, edited 1 time in total.

fsr
Posts: 88
Joined: Wed Jan 13, 2016 2:29 am

Re: Missing /dev/spi

Sat Feb 20, 2016 4:44 pm

joan wrote:I've not heard of a kernel module spidev. spi_bcm2853 should be enough to create the /dev/spi* devices.
no you need both
https://github.com/raspberrypi/linux/bl ... spi/spidev

The spidev module (built into the raspian kernel) creates the /dev/spidevx.y device nodes
(now you know why they get called spidev).

fsr
Posts: 88
Joined: Wed Jan 13, 2016 2:29 am

Re: Missing /dev/spi

Sat Feb 20, 2016 4:53 pm

DirkS wrote:there is no spidev kernel module
there most certainly is

Code: Select all

/lib/modules/4.1.13-v7+ $ grep spi modules.builtin
kernel/drivers/spi/spidev.ko

SRegan
Posts: 10
Joined: Sat Feb 20, 2016 2:51 pm

Re: Missing /dev/spi

Sat Feb 20, 2016 4:53 pm

Two modules need to be running for the device nodes to appear, the broadcom module (spi_bcm2835) and a module called spidev (which puts the spi devices into userland). I can see spi_bcm2835 in your lsmod, so its probably spidev not running

Check its not blacklisted. (/etc/modprobe.d)
I looked through all of the blacklist conf files in that directory and didn't see any blacklist for spidev.

The only blacklists that the "blacklist-rpi2.conf" contains are:

Code: Select all

blacklist snd_soc_pcm512x_i2c
blacklist snd_soc_pcm512x
blacklist snd_soc_tas5713
blacklist snd_soc_wm8804

Edit: I checked for:
/lib/modules/4.1.13-v7+ $ grep spi modules.builtin
kernel/drivers/spi/spidev.ko
That file is missing for me.

fsr
Posts: 88
Joined: Wed Jan 13, 2016 2:29 am

Re: Missing /dev/spi

Sat Feb 20, 2016 4:59 pm

your kernel version is probably different
run this instead

Code: Select all

grep spidev /lib/modules/$(uname -r)/modules.builtin
also look for errors with the kernel

Code: Select all

dmesg | grep spi

SRegan
Posts: 10
Joined: Sat Feb 20, 2016 2:51 pm

Re: Missing /dev/spi

Sat Feb 20, 2016 5:07 pm

Code: Select all

#grep spidev /lib/modules/$(uname -r)/modules.builtin
kernel/drivers/spi/spidev.ko

Code: Select all

#dmesg | grep spi
[    6.084983] spi spi0.1: setting up native-CS1 as GPIO 7
[    6.091601] ads7846 spi0.1: touchscreen, irq 505
[    6.093501] input: ADS7846 Touchscreen as /devices/soc/3f204000.spi/spi_master/spi0/spi0.1/input/input3
I should mention that "dmesg | grep spi" reports my ADS7846 touchscreen (and the touchscreen actually functions). However I just plugged that in a few minutes ago so I don't believe that it's related to this issue.

fsr
Posts: 88
Joined: Wed Jan 13, 2016 2:29 am

Re: Missing /dev/spi

Sat Feb 20, 2016 5:23 pm

SRegan wrote:

Code: Select all

/devices/soc/3f204000.spi/
well you anticipated my next question and answered it,
good to see the spi peripheral is showing up in the device tree.

this all points to spidev... since the bcm module is loaded , running and working all spidev does is make a /dev/spidevx.x node and thats the only bit that isn't working...

ok lets check the device tree is properly setup. you'll need to install a little bit of software first:

Code: Select all

sudo apt-get install device-tree-compiler
then run

Code: Select all

dtc -Ifs /proc/device-tree
This will spew out a heap of information, look for a section like this:

Code: Select all

		spi@7e204000 {
			reg = <0x7e204000 0x1000>;
			dmas = <0x7 0x6 0x7 0x7>;
			interrupts = <0x2 0x16>;
			pinctrl-0 = <0xb 0xc>;
			compatible = "brcm,bcm2835-spi";
			cs-gpios = <0xa 0x8 0x1 0xa 0x7 0x1>;
			clocks = <0x6>;
			status = "okay";
			#address-cells = <0x1>;
			phandle = <0x1e>;
			#size-cells = <0x0>;
			dma-names = "tx", "rx";
			pinctrl-names = "default";
			linux,phandle = <0x1e>;

			spidev@0 {
				reg = <0x0>;
				compatible = "spidev";
				spi-max-frequency = <0x7a120>;
				#address-cells = <0x1>;
				#size-cells = <0x0>;
			};

			spidev@1 {
				reg = <0x1>;
				compatible = "spidev";
				spi-max-frequency = <0x7a120>;
				#address-cells = <0x1>;
				#size-cells = <0x0>;
			};
		};
The bit we are interested in is the two 'spidev@' sections - this is the glue that triggers the loading of spidev when the spi module loads (one each for CS0 & CS1) . If its there, then we'll have to dig deeper. getting late for me now so might have to call it a night.


I haven't yet spun up ubuntu mate (lost interest in ubuntu when they brought in unity but thats another story) but its on my list of things to do this week so I'll find out for myself soon enough what they've done! :)

SRegan
Posts: 10
Joined: Sat Feb 20, 2016 2:51 pm

Re: Missing /dev/spi

Sat Feb 20, 2016 5:32 pm

Here's the spi@7e20400 section:

Code: Select all

	spi@7e204000 {
			reg = <0x7e204000 0x1000>;
			dmas = <0x5 0x6 0x5 0x7>;
			interrupts = <0x2 0x16>;
			pinctrl-0 = <0x8>;
			compatible = "brcm,bcm2835-spi";
			cs-gpios = <0x0 0x0>;
			clocks = <0x4>;
			status = "okay";
			#address-cells = <0x1>;
			phandle = <0x18>;
			#size-cells = <0x0>;
			dma-names = "tx", "rx";
			pinctrl-names = "default";
			linux,phandle = <0x18>;

			spidev@0 {
				reg = <0x0>;
				compatible = "spidev";
				spi-max-frequency = <0x7a120>;
				status = "disabled";
				#address-cells = <0x1>;
				#size-cells = <0x0>;
			};

			spidev@1 {
				reg = <0x1>;
				compatible = "spidev";
				spi-max-frequency = <0x7a120>;
				status = "disabled";
				#address-cells = <0x1>;
				#size-cells = <0x0>;
			};

			ads7846@1 {
				reg = <0x1>;
				interrupts = <0x19 0x2>;
				ti,x-plate-ohms = [01 90];
				pinctrl-0 = <0x2e>;
				compatible = "ti,ads7846";
				pendown-gpio = <0xf 0x19 0x0>;
				spi-max-frequency = <0xc350>;
				phandle = <0x2f>;
				ti,pressure-max = [ff ff];
				ti,pressure-min = [00 00];
				pinctrl-names = "default";
				linux,phandle = <0x2f>;
				interrupt-parent = <0xf>;
				ti,x-max = [0f ff];
				ti,x-min = [00 00];
				ti,y-max = [0f ff];
				ti,y-min = [00 00];
			};
		};




fsr
Posts: 88
Joined: Wed Jan 13, 2016 2:29 am

Re: Missing /dev/spi

Sat Feb 20, 2016 5:39 pm

SRegan wrote:

Code: Select all

			spidev@0 {
				reg = <0x0>;
				compatible = "spidev";
				spi-max-frequency = <0x7a120>;
				status = "disabled";
				#address-cells = <0x1>;
				#size-cells = <0x0>;
			};
now we re getting somewhere - they are both disabled! (status = disabled)

have a good read of /boot/overlays/README. there might be something extra you need to do on Ubuntu to enable them

SRegan
Posts: 10
Joined: Sat Feb 20, 2016 2:51 pm

Re: Missing /dev/spi

Sat Feb 20, 2016 5:53 pm

Here's the relevant information from that file:
In /boot you will find a .dtb for each base platform. This describes the
hardware that is part of the Raspberry Pi board. The loader (start.elf and its
siblings) selects the .dtb file appropriate for the platform by name, and reads
it into memory. At this point, all of the optional interfaces (i2c, i2s, spi)
are disabled, but they can be enabled using Device Tree parameters:

dtparam=i2c=on,i2s=on,spi=on

However, this shouldn't be necessary in many use cases because loading an
overlay that requires one of those interfaces will cause it to be enabled
automatically, and it is advisable to only enable interfaces if they are
needed.

Configuring additional, optional hardware is done using Device Tree overlays
(see below).

raspi-config
============

The Advanced Options section of the raspi-config utility can enable and disable
Device Tree use, as well as toggling the I2C and SPI interfaces. Note that it
is possible to both enable an interface and blacklist the driver, if for some
reason you should want to defer the loading.
I already tried adding "dtparam=spi=on" to the config.txt. I also just added "dtparam=i2c=on,i2s=on,spi=on" to the bottom and rebooted. But, this didn't fix the issue.

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

Re: Missing /dev/spi

Sat Feb 20, 2016 6:04 pm

If Ubuntu Mate is built without SPI support you may be wasting your time.

Have you tried?

sudo modprobe spidev

DirkS
Posts: 10362
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Missing /dev/spi

Sat Feb 20, 2016 6:06 pm

joan wrote:If Ubuntu Mate is built without SPI support you may be wasting your time.idev
I would expect it to be there; they added several spi related packages to 15.10

SRegan
Posts: 10
Joined: Sat Feb 20, 2016 2:51 pm

Re: Missing /dev/spi

Sat Feb 20, 2016 6:18 pm

Code: Select all

Have you tried?

sudo modprobe spidev
Nothing is returned when I run that, not even an error message. I'm pretty sure I read somewhere that SPIDev was added in 15.04. Also, the release notes for 15.10 (https://ubuntu-mate.org/raspberry-pi/) mention "python-spidev and python3-spidev" support.

I just ran "dtc -Ifs /proc/device-tree" without the screen attached and this time it seems that instead of spidev@0 and spidev@1 being disabled, the entire SPI is disabled (probably because it didn't find an SPI device during boot).

Is there anyway to force it on regardless if a device is attached?

Here's the output:

Code: Select all

spi@7e204000 {
			reg = <0x7e204000 0x1000>;
			dmas = <0x5 0x6 0x5 0x7>;
			interrupts = <0x2 0x16>;
			pinctrl-0 = <0x8>;
			compatible = "brcm,bcm2835-spi";
			cs-gpios = <0x0 0x0>;
			clocks = <0x4>;
			status = "disabled";
			#address-cells = <0x1>;
			phandle = <0x18>;
			#size-cells = <0x0>;
			dma-names = "tx", "rx";
			pinctrl-names = "default";
			linux,phandle = <0x18>;

			spidev@0 {
				reg = <0x0>;
				compatible = "spidev";
				spi-max-frequency = <0x7a120>;
				#address-cells = <0x1>;
				#size-cells = <0x0>;
			};

			spidev@1 {
				reg = <0x1>;
				compatible = "spidev";
				spi-max-frequency = <0x7a120>;
				#address-cells = <0x1>;
				#size-cells = <0x0>;
			};
		};




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

Re: Missing /dev/spi

Sat Feb 20, 2016 6:41 pm

Did you check to see if /dev/spi* existed after you did the modprobe?

I know little of device tree, certainly not enough to comment on fragments.

As an aside my pigpio library side steps this issue by directly talking to the SPI hardware (as does the bcm2835 library).

SRegan
Posts: 10
Joined: Sat Feb 20, 2016 2:51 pm

Re: Missing /dev/spi

Sat Feb 20, 2016 9:26 pm

I just tried switching over to Raspbian. I've enabled SPI through the raspi-config menu. However, I am still having the same issue, both spidev@1 and spidev@2 are saying disabled.

"dmesg | grep spi" is still listing the ADS7846 even-though it's not attached right now. Is it possible that the ADS7846 is reserving the SPI despite not being connected? Also, will the SPIdev device's show up even when nothing is currently connected to the SPI GPIO (I haven't actually connected the MFRC522 yet)?

DirkS
Posts: 10362
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Missing /dev/spi

Sat Feb 20, 2016 9:29 pm

do you have overlays loaded in config.txt for the touch controller?
Can you post your config.txt

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

Re: Missing /dev/spi

Sat Feb 20, 2016 9:31 pm

SRegan wrote:I just tried switching over to Raspbian. I've enabled SPI through the raspi-config menu. However, I am still having the same issue, both spidev@1 and spidev@2 are saying disabled.

"dmesg | grep spi" is still listing the ADS7846 even-though it's not attached right now. Is it possible that the ADS7846 is reserving the SPI despite not being connected? Also, will the SPIdev device's show up even when nothing is currently connected to the SPI GPIO (I haven't actually connected the MFRC522 yet)?
It's almost certainly the ADS7846 blob screwing up your system. Simplest check is to comment out the overlay and reboot.

SRegan
Posts: 10
Joined: Sat Feb 20, 2016 2:51 pm

Re: Missing /dev/spi

Sun Feb 21, 2016 12:00 am

Hi guys,


So I found a "dtparam" for the screen in the config.txt so I commented it out. I hooked up the screen using dupont cables so I could connect only the pins I need for powering the screen. This did the trick, the screen worked (without its touch which I don't need) and the spidev devices are now showing up.


Thanks everyone I appreciate your help.

fsr
Posts: 88
Joined: Wed Jan 13, 2016 2:29 am

Re: Missing /dev/spi

Sun Feb 21, 2016 1:24 am

joan wrote:It's almost certainly the ADS7846 blob screwing up your system
Yep, thats right
The overlay disables spidev on spi0 https://github.com/raspberrypi/linux/bl ... verlay.dts

anurudhya_31
Posts: 4
Joined: Sun Jan 28, 2018 3:15 pm

Re: Missing /dev/spi

Mon Jan 29, 2018 7:28 am

SRegan wrote:
Sun Feb 21, 2016 12:00 am
Hi guys,


So I found a "dtparam" for the screen in the config.txt so I commented it out. I hooked up the screen using dupont cables so I could connect only the pins I need for powering the screen. This did the trick, the screen worked (without its touch which I don't need) and the spidev devices are now showing up.


Thanks everyone I appreciate your help.
Hi, can you explain me which one did you comment in config.txt file. Currently the overlay which I am using is waveshare35a. The overlay that belongs to ads7846 is commented out. Will there be a problem with this overlay?

umerbiomedical
Posts: 7
Joined: Wed Feb 13, 2019 9:05 pm

Re: Missing /dev/spi

Wed Feb 13, 2019 9:12 pm

fsr wrote:
Sun Feb 21, 2016 1:24 am
joan wrote:It's almost certainly the ADS7846 blob screwing up your system
Yep, thats right
The overlay disables spidev on spi0 https://github.com/raspberrypi/linux/bl ... verlay.dts
Hi, can you explain me which one did you comment in config.txt file.

Return to “General discussion”