remopini
Posts: 5
Joined: Sun Apr 17, 2016 9:25 pm

Pi 3 - SPI trouble

Sun Apr 17, 2016 9:30 pm

Hi all

I have a script that runs perfectly well on a Pi2, here's the relevant code:

Code: Select all

use HiPi::Device::SPI qw( :spi );
...
my $dev = HiPi::Device::SPI->new(devicename => '/dev/spidev0.0');
$dev->transfer(pack('H4', '0c01')); # normal ops
$dev->transfer(pack('H4', '0b07')); # enable all digits
$dev->transfer(pack('H4', '0a0f')); # max intensity
$dev->transfer(pack('H4', '09ff')); # bcd for all digits
$dev->transfer(pack('H4', '010f')); # set digit 8 to blank
$dev->transfer(pack('H4', '020f')); # set digit 7 to blank
$dev->transfer(pack('H4', '030f')); # set digit 6 to blank
$dev->transfer(pack('H4', '040f')); # set digit 5 to blank
$dev->transfer(pack('H4', '050f')); # set digit 4 to blank
$dev->transfer(pack('H4', '060f')); # set digit 3 to blank
$dev->transfer(pack('H4', '070f')); # set digit 2 to blank
$dev->transfer(pack('H4', '080f')); # set digit 1 to blank
Now, when I take the same code to a Pi3, there is no activity on the SPI. The kernel modules are loaded and enabled (through raspi-config).

Is there any place I can look for reasons why this might be?

Cheers

Remo

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

Re: Pi 3 - SPI trouble

Mon Apr 18, 2016 12:28 am

Can you post your contents of /boot/config.txt and /etc/modules
And also the output of

Code: Select all

ls /dev/spi*

remopini
Posts: 5
Joined: Sun Apr 17, 2016 9:25 pm

Re: Pi 3 - SPI trouble

Mon Apr 18, 2016 9:53 am

Sure, here you go:

Code: Select all

[email protected]:~# ls -la /dev/spi*
crw-rw---- 1 root spi 153, 0 Apr 17 21:23 /dev/spidev0.0
crw-rw---- 1 root spi 153, 1 Apr 17 21:23 /dev/spidev0.1

Code: Select all

[email protected]:~# more /boot/config.txt
...
# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# NOOBS Auto-generated Settings:
hdmi_force_hotplug=1
dtparam=spi=on
dtparam=i2c_arm=on

Code: Select all

[email protected]:/etc# more modules
# /etc/modules: kernel modules to load at boot time.
...
i2c-dev
There is no "spidev" in /etc/modules.

To test, I added "spidev" to /etc/modules and rebooted.

It still doesn't work and lsmod shows the following:

Code: Select all

[email protected]:~# lsmod
Module                  Size  Used by
bnep                   10336  2
hci_uart               13533  1
btbcm                   4196  1 hci_uart
bluetooth             317981  22 bnep,btbcm,hci_uart
binfmt_misc             6236  1
evdev                  10278  2
brcmfmac              177635  0
brcmutil                5501  1 brcmfmac
cfg80211              407580  1 brcmfmac
rfkill                 16036  4 cfg80211,bluetooth
i2c_bcm2708             4920  0
bcm2835_gpiomem         2860  0
bcm2835_rng             1763  0
snd_bcm2835            19802  0
spi_bcm2835             7074  0
snd_pcm                73474  1 snd_bcm2835
snd_timer              18848  1 snd_pcm
snd                    50779  3 snd_bcm2835,snd_timer,snd_pcm
uio_pdrv_genirq         2944  0
uio                     7753  1 uio_pdrv_genirq
i2c_dev                 5671  2
fuse                   80694  1
ipv6                  338660  48
Weird...

remopini
Posts: 5
Joined: Sun Apr 17, 2016 9:25 pm

Re: Pi 3 - SPI trouble

Mon Apr 18, 2016 10:00 am

Further analysis:

I looked for the kernel modules and this is the situation:

Code: Select all

[email protected]:/lib/modules/4.1.19-v7+/kernel/drivers/i2c# ls
algos  busses  i2c-dev.ko  i2c-mux.ko
[email protected]:/lib/modules/4.1.19-v7+/kernel/drivers/spi# ls
spi-bcm2708.ko  spi-bcm2835.ko
Could it be that i2c-dev is installed by standard Raspbian but spidev isn't?

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

Re: Pi 3 - SPI trouble

Mon Apr 18, 2016 10:03 am

You don't need spidev in /etc/modules - Device Tree takes care of loading it. /dev/spidev0.* wouldn't exist if spidev wasn't present.

Which version of HiPi are you using? The release notes say that version 0.35 (7th March) supports Pi3, which suggests that earlier versions may not.

remopini
Posts: 5
Joined: Sun Apr 17, 2016 9:25 pm

Re: Pi 3 - SPI trouble

Mon Apr 18, 2016 10:06 am

0.49

Code: Select all

cpan[2]> i /HiPi::Device::SPI/
Module id = HiPi::Device::SPI
    CPAN_USERID  MDOOTSON (Mark Dootson <[email protected]>)
    CPAN_VERSION 0.49
    CPAN_FILE    M/MD/MDOOTSON/HiPi-0.49.tar.gz
    UPLOAD_DATE  2016-04-06
    INST_FILE    /usr/local/lib/arm-linux-gnueabihf/perl/5.20.2/HiPi/Device/SPI.pm
    INST_VERSION 0.49


wallasey
Posts: 26
Joined: Fri Nov 16, 2012 5:10 pm

Re: Pi 3 - SPI trouble

Mon Apr 18, 2016 8:00 pm

Hi,

I currently develop the HiPi modules on a Pi 3 using Raspbian Jessie release from 2016-03-18.

I use the SPI device interface quite a lot so I don't think there is anything within the HiPi modules that does not work on a Pi 3.

Setting up the Pi 3, all I had to do was use raspi-config to enable SPI and that was it.

Sorry this isn't more helpful but at least it may point you towards examining other differences between your Pi2 and Pi3 setup more closely.

Regards

Mark

remopini
Posts: 5
Joined: Sun Apr 17, 2016 9:25 pm

Re: Pi 3 - SPI trouble

Tue Apr 19, 2016 9:02 pm

That is good to know... is there any HW difference between the Pi2 and the Pi3 around SPI?

JoernPI
Posts: 9
Joined: Sun May 29, 2016 2:40 pm

Re: Pi 3 - SPI trouble

Sun Jun 05, 2016 8:54 pm

Any progress here?

Also reading a simple RC522 does not work on SPI...

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

Re: Pi 3 - SPI trouble

Sun Jun 05, 2016 9:00 pm

JoernPI wrote:Any progress here?
Progress on what?
AFAIK there is no general problem with SPI on the Pi3B...

Arctem
Posts: 2
Joined: Fri Jun 10, 2016 2:59 pm

Re: Pi 3 - SPI trouble

Fri Jun 10, 2016 3:09 pm

I'm also having some trouble using the RC522 on the Pi 3B. Some other threads have suggested that using older drivers on the Pi 3 might work (viewtopic.php?t=147291&p=979700) but I've had no luck with that. I'm not sure if this is a problem specific with SPI on the Pi 3B or with the RC522, but it does seem that something has broken recently with them. I'm curious if anyone has gotten the RC522 to work on a Pi 3B without having to use some kind of workaround.

Return to “Advanced users”