SPI in userspace aka spidev

Started by jeroends, February 08, 2013, 10:06:18 AM

Previous topic - Next topic

jeroends

Hello,
I'm trying to enable the spidev driver but I keep getting errors. My spidev is created but nothing is sended through.
This is my setup in the fex file (did also changed the PB02 and PB03 to PE02 and PE03 for the Uext connector):

[spi_devices]
spi_dev_num = 1

[spi1_para]
spi_used = 0
spi_cs0 = port:PG09<2><default><default><default>
spi_cs1 = port:PG13<2><default><default><default>
spi_sclk = port:PG10<2><default><default><default>
spi_mosi = port:PG11<2><default><default><default>
spi_miso = port:PG12<2><default><default><default>

[spi2_para]
spi_used = 1
spi_cs0 = port:PE00<4><default><default><default>
spi_sclk = port:PE01<4><default><default><default>
spi_mosi = port:PE02<4><default><default><default>
spi_miso = port:PE03<4><default><default><default>

[spi_board0]
modalias = "spidev"
max_speed_hz = 20000000
bus_num = 2
chip_select = 0
mode = 3


and the following error keeps bumping in:

[spi]: sw spi init !!
[spi]: sw spi init fetch spi0 uning configuration failed
[spi]: Found 1 spi devices in config files
[spi]: boards num modalias         max_spd_hz       bus_num  cs   mode
[spi]: 0          spidev           20000000         2        0    0x3
[spi]: drivers/spi/spi_sunxi.c(L1872) get spi 2 para failed, err code = -4
[spi]: source = sdram_pll_p, src_clk = 408000000, mclk 102000000
sun5i-spi sun5i-spi.2: master is unqueued, this is deprecated
[spi]: allwinners SoC SPI Driver loaded for Bus SPI-2 with 1 Slaves attached
[spi]: [spi-2]: driver probe succeed, base f1c17000, irq 12, dma_id 2!


I assume I'm looking over something, but I don't know what anymore (same with the imx233, but I edited the dts file and going to try later today, when this fails, the same question will rise over there)

jeroends

Hello,

I just had a logic analyser connected to the board hoping to see something happening on the bus when running the standard spi test. But unfortunatly, it stays dead.

Doesn't anybody have any experience with the spidev?

ps: same with the imx233, spidev created (with some strange high number, but it stays dead)

jwischka

Quote from: jeroends on February 10, 2013, 02:51:05 PM
Hello,

I just had a logic analyser connected to the board hoping to see something happening on the bus when running the standard spi test. But unfortunatly, it stays dead.

Doesn't anybody have any experience with the spidev?

ps: same with the imx233, spidev created (with some strange high number, but it stays dead)

Are you running a kernel with SPI support built-in?


jeroends

idd,
I have them build in (not as module) and made the adjustments in the fex file as listed above (and made it to the script.bin of course).
Spidev2.0 is created, same as the rest:
root@A13Micro:/dev# find / -name "spi*"
/usr/share/vim/vim73/syntax/spice.vim
/usr/share/ca-certificates/spi-inc.org
/usr/share/ca-certificates/spi-inc.org/spi-ca-2003.crt
/usr/share/ca-certificates/spi-inc.org/spi-cacert-2008.crt
/usr/include/linux/spi
/usr/include/linux/spi/spidev.h
/etc/ssl/certs/spi-ca-2003.pem
/etc/ssl/certs/spi-cacert-2008.pem
/sys/bus/spi
/sys/bus/spi/devices/spi2.0
/sys/bus/spi/drivers/spidev
/sys/bus/spi/drivers/spidev/spi2.0
/sys/devices/platform/sun5i-spi.2/spi_master
/sys/devices/platform/sun5i-spi.2/spi_master/spi2
/sys/devices/platform/sun5i-spi.2/spi_master/spi2/spi2.0
/sys/devices/platform/sun5i-spi.2/spi_master/spi2/spi2.0/spidev
/sys/devices/platform/sun5i-spi.2/spi_master/spi2/spi2.0/spidev/spidev2.0
/sys/class/spi_master
/sys/class/spi_master/spi2
/sys/class/spidev
/sys/class/spidev/spidev2.0
/sys/module/spidev
/dev/spidev2.0


jeroends

hello,
made a little progress and seen your post about zeroing out the receiver buffer. That did indeed the trick for sending spi data on the spidev. Now let connect some ws2801 led drivers to it and play :-)

On the other hand, playing with the olinuxino maxi spidev didn't gave a good result, data is beeing send, but doesn't compare. I 'll start a new topic on the imx thread.

Btw isn't the bus full duplex that the rx buffer needed to be zero'ed out?

vinifr

Hi,

Currently there is no support for full duplex in spi_sunxi.c

jeroends

ok, everything works fine (my led's are glowing in the dark) but...
In the debug terminal, the message 'xfer setup" keeps enoying me, is this forgotten to be commented out in the spi_sunxi driver (line 972) or more the way I send my message to the driver?

sorry for the questions, I'm not very formiliar with spi (more like an i2c men  ;) )

BJFreeman

Quote from: jeroends on February 10, 2013, 07:10:12 PM
idd,
I have them build in (not as module) and made the adjustments in the fex file as listed above (and made it to the script.bin of course).
Spidev2.0 is created, same as the rest:
root@A13Micro:/dev# find / -name "spi*"
/usr/share/vim/vim73/syntax/spice.vim
/usr/share/ca-certificates/spi-inc.org
/usr/share/ca-certificates/spi-inc.org/spi-ca-2003.crt
/usr/share/ca-certificates/spi-inc.org/spi-cacert-2008.crt
/usr/include/linux/spi
/usr/include/linux/spi/spidev.h
/etc/ssl/certs/spi-ca-2003.pem
/etc/ssl/certs/spi-cacert-2008.pem
/sys/bus/spi
/sys/bus/spi/devices/spi2.0
/sys/bus/spi/drivers/spidev
/sys/bus/spi/drivers/spidev/spi2.0
/sys/devices/platform/sun5i-spi.2/spi_master
/sys/devices/platform/sun5i-spi.2/spi_master/spi2
/sys/devices/platform/sun5i-spi.2/spi_master/spi2/spi2.0
/sys/devices/platform/sun5i-spi.2/spi_master/spi2/spi2.0/spidev
/sys/devices/platform/sun5i-spi.2/spi_master/spi2/spi2.0/spidev/spidev2.0
/sys/class/spi_master
/sys/class/spi_master/spi2
/sys/class/spidev
/sys/class/spidev/spidev2.0
/sys/module/spidev
/dev/spidev2.0


I don't have these in my Debian distribution, where did you get the files?
Fulltimer since 89

jeroends

do you have a kernel with spi support compiled and made the adjustments in the fex file?

BJFreeman

I have the debian distribution updated to ver 7.
that kernel does not have the SPI support as far as I can tell.
I am looking for the file you list, are they in a repository I can access.
Fulltimer since 89

jeroends

what files do you mean? The spi's in the "/sys"? Those are created by the system itself.
For the debian version, I'm on debian (wheezy) to. I used the debian version available for the micro and compiled then a kernel (3.4.24 at that time) for myself using the guide user "iso9660" wrote (very usefull!).

BJFreeman

Ok did a find

found /data/a13/linux-sunxi/Documentation/spi/spidev_fdx.c
/data/a13/linux-sunxi/drivers/spi/spi_sunxi.c

got a link ?
Fulltimer since 89

jeroends

for the kernel compilation? -> https://www.olimex.com/forum/index.php?topic=790
keep in mind, this is for the MICRO (I think you should use https://www.olimex.com/wiki/Build_Bootable_SD_Card_with_Debian for the MAXI).
Enable the spi driver (incl. spidev), if you are intent to use the spi always, you can build it in the kernel instead of building it as module.
Make also the modifications (as above) to your fex file (and convert the fex). After that you should have your spidev in place.

vinifr

hi,

What code you are using to test spi? Can you post here, please. ;)

jeroends

to test spi output: http://leachy.homeip.net/olinuxino/spi/tst_spi.c
my fex file for the A13 micro: http://leachy.homeip.net/olinuxino/spi/a13.fex

Notice that the spi test program is just the standard test program, the only difference is that the spi receive buffer is zero'd out. The driver doesn't support full duplex communication (sadly).