BPI-R2 SPI Communication

What’s your pinmux in dts? You can add some debug logs in tools/spi/spidev_test.c or find a scope to measure the signal to check what happened here.

Hi. I am using the kernel built by @frank-w and I believe he already use this dts, https://github.com/frank-w/BPI-R2-4.4/blob/master/linux-mt/arch/arm/boot/dts/mt7623n-bpi-r2.dts

The last 4.4.120 uses this dts. Same problem in 4.14. Spidev available but no data send/received.

Did the spidev-test-application send data (which can be looped by wiring mosi to miso) or must this be done externally?

For me, I tested your 4.4.120 kernel and looped MISO & MOSI. No data send/received. BTW, can you look at this link for SPI and anything useful for us?, https://github.com/LeMaker/LNcommon

I am hardly waiting for @linkerosa kernel and he reported the MISO/MOSI loop test successfully.

TIA.

BTW, can you look at this link for SPI and anything useful for us?, https://github.com/LeMaker/LNcommon

i see nothing which will help us getting spi running there

  1. Add a real spi device (panel)
  2. Write/read register via spi transfer
  3. Let’s see what happens

I already tested with real SPI device. No data read/write.

Capture

This is spidev test result on my BPIR2.

Anyway, if you don’t connect anything, you will see something like this:

Capture

@Ryder.Lee looks promising. Please share your kernel. I will test it on my hardware.

TIA.

Which kernel,which patches,which config?

The below link (uImage) is based on kernel 4.4 (boot from emmc): https://drive.google.com/file/d/1v4JoOYsPC5MKN_FVnnyCiVg770jOsnNL/view?usp=sharing

Please test it on your spi0 (0x1axxxxx).

Can you please show diff between original 4.4 and your version? original 4.4 have no spidev…i tried to add it to my repo,but same result as in 4.14

Else please verify, that my dts(i) and config in 4.14 is correct

The only difference is:

CONFIG_SPI=y CONFIG_SPI_MT65XX=y CONFIG_SPI_SPIDEV=y

In official 4.4

In spi0 is disabled

Not enabled and no spidev/pinmux in

in 4.14 i have these options set:

CONFIG_SPI=y CONFIG_SPI_MASTER=y CONFIG_SPI_SPIDEV=m CONFIG_SPI_MT65XX=m

But maybe we have forgot to load spi-MT65XX. @asprakash can you please try it?

@frank-w I can test it out and give you the feedback. May I know which kernel binary I have to use for this testing?.

4.4.120 or 4.14 above 24

strange…that seems not to be the problem:

[16:32] root@bpi-r2:~# modprobe spi                                             
spidev      spi-mt65xx                                                          
[16:32] root@bpi-r2:~# modprobe spi-mt65xx                                      
[16:32] root@bpi-r2:~# modprobe spidev                                          
[16:32] root@bpi-r2:~# ls /dev/spidev0.0                                        
/dev/spidev0.0                                                                  
[16:32] root@bpi-r2:~# ./spidev_test -D /dev/spidev0.0                          
spi mode: 0x0                                                                   
bits per word: 8                                                                
max speed: 500000 Hz (500 KHz)                          
[16:32] root@bpi-r2:~# lsmod                                                    
Module                  Size  Used by                                           
spidev                 20480  0                                                 
mtk_thermal            16384  0                                                 
thermal_sys            61440  1 mtk_thermal                                     
spi_mt65xx             20480  0                                                 
mt6577_auxadc          16384  0                                                 
pwm_mediatek           16384  0                                                 
fuse                  102400  1                                                 
ipv6                  413696  30
[16:33] root@bpi-r2:~# uname -r                                                 
4.14.27-bpi-r2-main

in 4.4.120 i have this build-in SPI_MT65XX [=y]

Linux bpi-r2 4.4.120-BPI-R2-Kernel #26 SMP Mon Mar 12 17:35:53 CET 2018 armv7l  
[16:50] root@bpi-r2:~# modprobe spidev                                          
[16:50] root@bpi-r2:~# ./spidev_test -D /dev/spidev32766.0                      
spi mode: 0x0                                                                   
bits per word: 8                                                                
max speed: 500000 Hz (500 KHz)                                                  
[16:50] root@bpi-r2:~#

did we change anything before (setting the port to SPI-Mode), have you the pinmux added? have i done this right?

Actually, whether you do looptest or not, you should see all of these messages (FF FF FF …) in console. So, I don’t think this is a HW issue

Right

i did in my kernels:

Spi-modules in config

In bpi.dts

  • enable spi0
  • add pinmux

Hi. My test result.

#modprobe spi-mt65xx

Result : lsmod not displayed the spi-mt65xx

#modprobe spidev

Result : lsmod displayed the spidev

#./spidev_test -D /dev/spidev32766.0

spi mode: 0x0

bits per word: 8

max speed: 500000 Hz (500 KHz)

Same result when I looped the MISO/MOSI or not.

@Ryder.Lee I tried to boot your kernel from sdcard. The board is not booting. It should be booted only from mmc?.