Bananian

SPI

6 5474
pgk  
Anyone had any luck interfacing SPI?

Using wiringPI or spidev_test.c (from the linux source) or rolling my own, ends up always getting an "invalid argument" failure when trying to write and read data.

Seems pretty similar to this on Raspbian - http://forum.lemaker.org/viewthread.php?tid=1572&highlight=SPI
Did you load the spi driver???
modprope spi-sun7i

I have tested the wiringPi modified for Banana Pi. Worked well

pgk  
Post Last Edited by pgk at 2014-8-26 04:11

I used "gpio load spi", looking in dmesg it shows:
  1. [52967.503541] [spi-inf] Found 2 spi devices in config files
  2. [52967.510346] [spi-inf] boards num modalias         max_spd_hz       bus_num  cs   mode
  3. [52967.514225] [spi-inf] spi_board0 irq gpio not used
  4. [52967.521197] [spi-inf] 0          spidev           12000000         0        0    0x3
  5. [52967.525026] [spi-inf] spi_board1 irq gpio not used
  6. [52967.531997] [spi-inf] 1          spidev           12000000         0        1    0x3
  7. [52967.539174] [spi-inf] sun7i_spi_probe: spi0 dma type: normal
  8. [52967.542924] [spi-inf] bus num = 0, spi used = 3
  9. [52967.547382] [spi-inf] sun7i_spi_probe: spi0 cs bitmap: 0x3
  10. [52967.557797] [spi-inf] sun7i_spi_set_mclk: spi0 source = sdram_pll_p, src_clk = 432000000, mclk 86400000
  11. [52967.564446] sun7i-spi sun7i-spi.0: master is unqueued, this is deprecated
  12. [52967.574540] [spi-inf] sun7i_spi_probe: reuuimlla's SoC SPI Driver loaded for Bus SPI0 with 2 Slaves at most
  13. [52967.584037] [spi-inf] sun7i_spi_probe: spi0 driver probe succeed, base f1880000, irq 42, dma_id_rx 24, dma_id_tx 24
Copy the Code
So that's the driver it's loading.  For WiringPI, I can run
  1. wiringPISetup(0,500000)
Copy the Code
and that correctly returns me a filehandle. It's when I try and run
  1.         int ret = wiringPiSPIDataRW(channel, command, len);          printf("\nRC :%d\n",ret);        if (ret == -1) {                printf("SPIWRITE failed: %s\n",             strerror(errno));        }
Copy the Code
That fails with with the invalid argument errno.


Also as I said it's not just wiring PI which is failing. I tried https://github.com/LeMaker/linux ... n/spi/spidev_test.c, compiled and run:
  1. root@(none) ~/test # ./a.out -D /dev/spidev0.0
  2. spi mode: 0
  3. bits per word: 8
  4. max speed: 500000 Hz (500 KHz)
  5. can't send spi message: Invalid argument
  6. [1]    5120 abort (core dumped)  ./a.out -D /dev/spidev0.0
Copy the Code
Looking through the code for that compared to the messages means it's got through all the setup etc. and is again failing on the IOCTL to do the actual data transfer. (The core dump is a result of the program calling abort() on failure).

pgk  
Well having now built the kernel from source, this is working, so I guess bananian has an older kernel image.

Yes, the kernel will be upgraded with our 14.09 release.

Kitsok  
Hello all!

Well, I'm having the same "Invalid argument" error on the IOCTL call (transfer).
The spidev0.0 is in place, there are no errors in the logfile, the device is Banana PI, the kernel is 3.4.112-sun7i
Here is the log:
  1. [    1.112738] [spi-inf] Found 2 spi devices in config files
  2. [    1.119521] [spi-inf] boards num modalias         max_spd_hz       bus_num  cs   mode
  3. [    1.123311] [spi-inf] spi_board0 irq gpio not used
  4. [    1.130265] [spi-inf] 0          spidev           12000000         0        0    0x3   
  5. [    1.134031] [spi-inf] spi_board1 irq gpio not used
  6. [    1.140984] [spi-inf] 1          spidev           12000000         0        1    0x3   
  7. [    1.145090] [spi-inf] sun7i_spi_probe: sun7i spi probe
  8. [    1.149715] [spi-inf] sun7i_spi_probe: spi0 dma type: normal
  9. [    1.153310] [spi-inf] bus num = 0, spi used = 3
  10. [    1.157748] [spi-inf] sun7i_spi_probe: spi0 cs bitmap: 0x3
  11. [    1.166351] [spi-inf] sun7i_spi_set_mclk: spi0 source = sdram_pll_p, src_clk = 432000000, mclk 86400000
  12. [    1.172285] sun7i-spi sun7i-spi.0: master is unqueued, this is deprecated
  13. [    1.178390] [spi-inf] sun7i_spi_setup: enter, bpw: 8, mshz: 12000000, mode: 3
  14. [    1.184594] [spi-inf] sun7i_spi_setup: enter, bpw: 8, mshz: 12000000, mode: 3
  15. [    1.193355] [spi-inf] sun7i_spi_probe: reuuimlla's SoC SPI Driver loaded for Bus SPI0 with 2 Slaves at most
  16. [    1.202760] [spi-inf] sun7i_spi_probe: spi0 driver probe succeed, base f05ca000, irq 42, dma_id_rx 24, dma_id_tx 24
  17. [   70.756894] [spi-inf] sun7i_spi_setup: enter, bpw: 8, mshz: 12000000, mode: 0
  18. [   70.763670] [spi-inf] sun7i_spi_setup: enter, bpw: 8, mshz: 12000000, mode: 0
  19. [   70.769659] [spi-inf] sun7i_spi_setup: enter, bpw: 8, mshz: 500000, mode: 0
Copy the Code


Here is actual FEX:

  1. [spi0_para]
  2. spi_used = 1
  3. spi_cs_bitmap = 3
  4. spi_cs0 = port:PI10<2><default><default><default>
  5. spi_cs1 = port:PI14<2><default><default><default>
  6. spi_sclk = port:PI11<2><default><default><default>
  7. spi_mosi = port:PI12<2><default><default><default>
  8. spi_miso = port:PI13<2><default><default><default>
  9. [spi_devices]
  10. spi_dev_num = 2

  11. [spi_board0]
  12. modalias = "spidev"
  13. max_speed_hz = 12000000
  14. bus_num = 0
  15. chip_select = 0
  16. mode = 3
  17. full_duplex = 1
  18. manual_cs = 0

  19. [spi_board1]
  20. modalias = "spidev"
  21. max_speed_hz = 12000000
  22. bus_num = 0
  23. chip_select = 1
  24. mode = 3
  25. full_duplex = 1
  26. manual_cs = 0

Copy the Code


I've tried to modify full_duplex - same problem.
Whan am I doing wrong?

Thank you!

swipon  

You have to log in before you can reply Login | Sign Up

Points Rules