[Banana BPI-R4] SPI

GPIO pinout: https://docs.banana-pi.org/en/BPI-R4/BananaPi_BPI-R4

SPI - 1.69inch LCD Module 240x280 pixels, ST7789V2

4=5V, 6=GND, 19=SPI1_MOSI, 21=SPI1_MISO, 23=SPI1_CLK, 24=SPI1_CSB

What's the purpose of this?

Guessing you wanna help here?

With what?

I raised driver bugs...
Yesterday, I performed similar configuration on my orangepi5 plus and all works fine.
Here basic commands produce only kernel panic...

Hi DroZDi have you make any progress?

No :frowning:
SPI under kernel 6.6 fails. Bugs registred but Im basicly ignored.
Wanted to make tests under 6.1 kernel but now Im facing an issue with compailing an openwrt image -> mt76 driver so stuck at all lines :frowning:

:frowning:

can you control the gpios for reset, commandmode and chipselect?

i got a /dev/spidev1.0 but its crash if i try to access

ot@OpenWrt:/# spidev_test  -D /dev/spidev1[   47.371293] SError Interrupt on CPU3, code 0x00000000bf000002 -- SError
[   47.371307] CPU: 3 PID: 4744 Comm: spidev_test Tainted: G           O       6.6.23 #0
[   47.371313] Hardware name: Bananapi BPI-R4 (DT)
[   47.371315] pstate: 40400005 (nZcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   47.371320] pc : mtk_spi_set_cs+0x54/0x80
[   47.371333] lr : spi_set_cs+0x88/0x1dc
[   47.371337] sp : ffffffc084f33c00
[   47.371339] x29: ffffffc084f33c00 x28: ffffff80c161ae00 x27: 0000000000000000
[   47.371347] x26: 0000000000000000 x25: ffffff80c58c3040 x24: ffffff80c58c3008
[   47.371352] x23: ffffff80c4ebe400 x22: 0000000000000000 x21: 0000000000000000
[   47.371357] x20: 0000000000000000 x19: ffffff80c4ebe400 x18: 0000000000000000
[   47.371362] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
[   47.371366] x14: 02d405aed0f4a420 x13: 016a26391234ec20 x12: 00000000016a2639
[   47.371371] x11: 00000000fa83b2da x10: 000000000000b67e x9 : 0000000000000009
[   47.371375] x8 : ffffff80ff7a5400 x7 : ffffff80c01d73d0 x6 : 0000000000000002
[   47.371380] x5 : 00000000eda7f346 x4 : ffffff80c080a800 x3 : 0000000000000000
[   47.371384] x2 : 0000000000000000 x1 : 0000000000000001 x0 : ffffff80c080ad40
[   47.371389] Kernel panic - not syncing: Asynchronous SError Interrupt
[   47.371392] SMP: stopping secondary CPUs
[   47.371397] Kernel Offset: disabled
[   47.371399] CPU features: 0x0,00000000,20000000,1000400b
[   47.371402] Memory Limit: none
[   47.377752] pstore: backend (ramoops) writing error (-28)

so the chipselect crash the kernel
if i do
root@OpenWrt:/# spidev_test --no-cs -D /dev/spidev1.0
i got

[  107.552705] spidev spi1.0: setup: unsupported mode bits 40
.0
can't set spi mode: Invalid argument
Aborted

I compiled new spidev_test but the same
Errors similar:
https://lists.openwall.net/netdev/2024/04/07/61
https://lists.openwall.net/linux-kernel/2024/04/07/417

what happend if u try with "--no-cs" ?

the same as for you

I took spi from kernel 6.9, compiled in 6.6.30 but the issue persists:

root@BPI-R4:/nvme/work/oled# spidev_test -D /dev/spidev1.0 -v
[ 473.465406] SError Interrupt on CPU2, code 0x00000000bf000002 -- SError
[ 473.465421] CPU: 2 PID: 7106 Comm: spidev_test Tainted: G O 6.6.30 #0
[ 473.465427] Hardware name: Bananapi BPI-R4 (DT)
[ 473.465429] pstate: 40400005 (nZcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 473.465434] pc : mtk_spi_set_cs+0x54/0x80
[ 473.465444] lr : spi_set_cs+0xe4/0x2f4
[ 473.465450] sp : ffffffc0896d3ca0
[ 473.465452] x29: ffffffc0896d3ca0 x28: ffffff80c1a6f300 x27: 0000000000000000
[ 473.465459] x26: 0000000000000000 x25: ffffff80c10e5b08 x24: ffffff80c62e4f08
[ 473.465464] x23: ffffff80c10e5b88 x22: 0000000000000000 x21: 0000000000000000
[ 473.465469] x20: ffffff80c10e5b08 x19: ffffff80c10e5800 x18: 0000000000000000
[ 473.465473] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
[ 473.465478] x14: 029320b88d8f25ea x13: 013f77e20bcbd540 x12: 0000000000000002
[ 473.465482] x11: 0000000000000000 x10: 0000000000000400 x9 : 000000035885cc3a
[ 473.465487] x8 : 0000000000000800 x7 : ffffff80c103e850 x6 : 0000000000000000
[ 473.465491] x5 : ffffff80c0daf000 x4 : ffffff80c0daf000 x3 : 0000000000000000
[ 473.465495] x2 : 0000000000000000 x1 : 0000000000000001 x0 : ffffff80c0daf540
[ 473.465501] Kernel panic - not syncing: Asynchronous SError Interrupt
[ 473.465503] SMP: stopping secondary CPUs
[ 473.465512] Kernel Offset: disabled
[ 473.465513] CPU features: 0x0,00000000,20000000,1000400b
[ 473.465517] Memory Limit: none
[ 473.472731] pstore: backend (ramoops) writing error (-28)
PANIC at PC : 0x00000000430048a8

I'm curious if you were able to make any more progress on this. I'm interested in using luma lcd on the SPI1 bus!

As far as I know (I check from time to time new builds), SPI is still broken for Banana BPI-R4

Daniel Golle mentioned elsewhere that a recent fix for SPI was merged:

I will hopefully be able to give this a shot soon.

Interesting :slight_smile: i will check this out

The issue has been fixed, I was able to confirm this today.

check if nothing connected:

root@BPI-R4:~# spidev_test -D /dev/spidev1.0 -v
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 kHz)
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D |......@.........................|
RX | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................................|

short PIN19 and pin21:

root@BPI-R4:~# spidev_test -D /dev/spidev1.0 -v
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 kHz)
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D |......@.........................|
RX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D |......@.........................|
root@BPI-R4:~#

root@BPI-R4:~# spi-config -d /dev/spidev1.0 -q
/dev/spidev1.0: mode=0, lsb=0, bits=8, speed=32000000, spiready=0