Page 1 of 1

SPI communication trouble

Posted: 2025-10-08 9:30
by luckdog322
Hello!
Got some troubles with spi communication with two luckfox pico pro max boards.
1. spi master
2. spi slave
both were configured according to the manual: https://wiki.luckfox.com/Luckfox-Pico-P ... munication
the code was taken from the same place
logs from slave side:

Code: Select all

---------Receive 255 bytes of data  max speed:49000000 Hz---------
SPI RX: 0x00000000: 38 CB FE A6 70 EF FE A6 5C 0F FC A6 90 C4 FE A6
SPI RX: 0x00000010: 00 00 00 00 70 EF FE A6 A4 CC 95 AE 50 B0 FD A6
SPI RX: 0x00000020: 48 03 01 00 18 40 FC A6 F0 03 01 00 00 00 00 00
SPI RX: 0x00000030: 00 00 00 00 FF 00 00 00 03 00 00 00 FF 00 00 00
SPI RX: 0x00000040: 00 00 00 00 7C 5A F9 A6 58 0C FC A6 F4 CD 95 AE
SPI RX: 0x00000050: 01 00 00 00 08 05 01 00 5C 5F F6 A6 70 58 FA A6
SPI RX: 0x00000060: 48 03 01 00 18 40 FC A6 F0 03 01 00 00 00 00 00
SPI RX: 0x00000070: 00 00 00 00 00 00 00 00 70 EF FE A6 00 00 00 00
SPI RX: 0x00000080: B0 CC 95 AE 38 5A F9 A6 00 00 00 00 00 00 00 00
SPI RX: 0x00000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SPI RX: 0x000000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SPI RX: 0x000000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SPI RX: 0x000000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SPI RX: 0x000000D0: 20 8B FD A6 E0 86 FD A6 00 00 00 00 00 00 00 00
SPI RX: 0x000000E0: 00 00 00 00 96 04 00 00 10 00 00 00 00 00 00 00
SPI RX: 0x000000F0: 00 00 00 00 87 04 00 00 00 00 00 00 00 00 00
---------Receive 255 bytes of data  max speed:49000000 Hz---------
SPI RX: 0x00000000: 38 CB FE A6 70 EF FE A6 5C 0F FC A6 90 C4 FE A6
SPI RX: 0x00000010: 00 00 00 00 70 EF FE A6 A4 CC 95 AE 50 B0 FD A6
SPI RX: 0x00000020: 48 03 01 00 18 40 FC A6 F0 03 01 00 00 00 00 00
SPI RX: 0x00000030: 00 00 00 00 FF 00 00 00 03 00 00 00 FF 00 00 00
SPI RX: 0x00000040: 00 00 00 00 7C 5A F9 A6 58 0C FC A6 F4 CD 95 AE
SPI RX: 0x00000050: 01 00 00 00 08 05 01 00 5C 5F F6 A6 70 58 FA A6
SPI RX: 0x00000060: 48 03 01 00 18 40 FC A6 F0 03 01 00 00 00 00 00
SPI RX: 0x00000070: 00 00 00 00 00 00 00 00 70 EF FE A6 00 00 00 00
SPI RX: 0x00000080: B0 CC 95 AE 38 5A F9 A6 00 00 00 00 00 00 00 00
SPI RX: 0x00000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SPI RX: 0x000000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SPI RX: 0x000000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SPI RX: 0x000000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SPI RX: 0x000000D0: 20 8B FD A6 E0 86 FD A6 00 00 00 00 00 00 00 00
SPI RX: 0x000000E0: 00 00 00 00 96 04 00 00 10 00 00 00 00 00 00 00
SPI RX: 0x000000F0: 00 00 00 00 87 04 00 00 00 00 00 00 00 00 00
Here's this instead of the sequence from the example.
also slave side logs:

Code: Select all

[root@luckfox soft]# cat /var/log/messages  | grep "spi" 
Jan  1 12:00:01 luckfox kern.warn kernel: [    0.084604] rockchip-spi ff500000.spi: no high_speed pinctrl state
Jan  1 12:00:01 luckfox kern.err kernel: [    0.084942] spi_slave spi0: /spi@ff500000/spidev@0 is not called 'slave'
Jan  1 12:00:01 luckfox kern.warn kernel: [    0.084970] spi_slave spi0: Failed to create SPI device for /spi@ff500000/spidev@0
Jan  1 12:00:01 luckfox kern.err kernel: [    0.084992] spi_slave spi0: /spi@ff500000/fbtft@0 is not called 'slave'
Jan  1 12:00:01 luckfox kern.warn kernel: [    0.085003] spi_slave spi0: Failed to create SPI device for /spi@ff500000/fbtft@0
Jan  1 12:00:01 luckfox kern.info kernel: [    0.085462] rockchip-spi ff500000.spi: probed, poll=0, rsd=0
Jan  1 12:00:01 luckfox kern.info kernel: [    0.086842] spi-nand spi2.0: Winbond SPI NAND was found.
Jan  1 12:00:01 luckfox kern.info kernel: [    0.086863] spi-nand spi2.0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 128
Jan  1 12:00:01 luckfox kern.notice kernel: [    0.088066] 7 cmdlinepart partitions found on MTD device spi-nand0
Jan  1 12:00:01 luckfox kern.notice kernel: [    0.088086] Creating 7 MTD partitions on "spi-nand0":
Jan  1 12:06:05 luckfox kern.err kernel: [  365.399011] rockchip-spi ff500000.spi: state=3
Jan  1 12:06:05 luckfox kern.err kernel: [  365.399034] rockchip-spi ff500000.spi: tx_left=0
Jan  1 12:06:05 luckfox kern.err kernel: [  365.399043] rockchip-spi ff500000.spi: rx_left=0
Jan  1 12:06:05 luckfox kern.err kernel: [  365.399142] spi_slave spi0: failed to transfer one message from queue
Jan  1 12:10:25 luckfox kern.err kernel: [  625.587708] rockchip-spi ff500000.spi: state=3
Jan  1 12:10:25 luckfox kern.err kernel: [  625.587731] rockchip-spi ff500000.spi: tx_left=0
Jan  1 12:10:25 luckfox kern.err kernel: [  625.587740] rockchip-spi ff500000.spi: rx_left=0
Jan  1 12:10:25 luckfox kern.err kernel: [  625.587836] spi_slave spi0: failed to transfer one message from queue
Jan  1 12:13:37 luckfox kern.err kernel: [  817.683719] rockchip-spi ff500000.spi: state=3
Jan  1 12:13:37 luckfox kern.err kernel: [  817.683740] rockchip-spi ff500000.spi: tx_left=0
Jan  1 12:13:37 luckfox kern.err kernel: [  817.683750] rockchip-spi ff500000.spi: rx_left=0
Jan  1 12:13:37 luckfox kern.err kernel: [  817.683846] spi_slave spi0: failed to transfer one message from queue
Jan  1 12:29:38 luckfox kern.err kernel: [ 1778.724856] rockchip-spi ff500000.spi: state=3
Jan  1 12:29:38 luckfox kern.err kernel: [ 1778.724879] rockchip-spi ff500000.spi: tx_left=0
Jan  1 12:29:38 luckfox kern.err kernel: [ 1778.724888] rockchip-spi ff500000.spi: rx_left=0
Jan  1 12:29:38 luckfox kern.err kernel: [ 1778.724986] spi_slave spi0: failed to transfer one message from queue
[root@luckfox soft]# 

Re: SPI communication trouble

Posted: 2025-10-09 3:27
by Crocodile
Hello, from your log, it seems that the slave machine did not receive the data correctly. First, check if your wiring is correct; second, on the slave side, modify the device tree directly in rv1106-luckfox-pico-pro-max-ipc.dtsi for the spi0 node, and remove the unused spidev@0 and fbtft@0 nodes.

Re: SPI communication trouble

Posted: 2025-10-09 7:20
by luckdog322
Crocodile wrote: 2025-10-09 3:27 Hello, from your log, it seems that the slave machine did not receive the data correctly. First, check if your wiring is correct; second, on the slave side, modify the device tree directly in rv1106-luckfox-pico-pro-max-ipc.dtsi for the spi0 node, and remove the unused spidev@0 and fbtft@0 nodes.
Checked the wiring. It's correct.
MOSI - MOSI
MISO - MISO
CLK - CLK
CS - CS
edited device tree in rv1106-luckfox-pico-pro-max-ipc.dtsi for the slave side. This is how it looks in both files (rv1106-luckfox-pico-pro-max-ipc.dtsi and rv1106g-luckfox-pico-pro-max.dts)

Code: Select all

/**********SPI**********/
&spi0 {
    status = "okay";
    spi-slave;
    slave {
        compatible ="rockchip,spidev";
        reg = <0>;
        id = <0>;
    };
};
Neither of the two files contained any mention of spidev@0 or fbtft@0.
I am attaching both files.
and logs from the slave side after editing rv1106-luckfox-pico-pro-max-ipc.dtsi

Code: Select all

---------Receive 255 bytes of data  max speed:49000000 Hz---------
SPI RX: 0x00000000: 38 9B FF A6 70 BF FF A6 5C DF FC A6 90 94 FF A6
SPI RX: 0x00000010: 00 00 00 00 70 BF FF A6 A4 1C E8 AE 50 80 FE A6
SPI RX: 0x00000020: 48 03 01 00 18 10 FD A6 F0 03 01 00 00 00 00 00
SPI RX: 0x00000030: 00 00 00 00 FF 00 00 00 03 00 00 00 FF 00 00 00
SPI RX: 0x00000040: 00 00 00 00 7C 2A FA A6 58 DC FC A6 F4 1D E8 AE
SPI RX: 0x00000050: 01 00 00 00 08 05 01 00 5C 2F F7 A6 70 28 FB A6
SPI RX: 0x00000060: 48 03 01 00 18 10 FD A6 F0 03 01 00 00 00 00 00
SPI RX: 0x00000070: 00 00 00 00 00 00 00 00 70 BF FF A6 00 00 00 00
SPI RX: 0x00000080: B0 1C E8 AE 38 2A FA A6 00 00 00 00 00 00 00 00
SPI RX: 0x00000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SPI RX: 0x000000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SPI RX: 0x000000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SPI RX: 0x000000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SPI RX: 0x000000D0: 20 5B FE A6 E0 56 FE A6 00 00 00 00 00 00 00 00
SPI RX: 0x000000E0: 00 00 00 00 96 04 00 00 10 00 00 00 00 00 00 00
SPI RX: 0x000000F0: 00 00 00 00 87 04 00 00 00 00 00 00 00 00 00
[  177.750824] rockchip-spi ff500000.spi: state=3
^C[  177.750845] rockchip-spi ff500000.spi: tx_left=0

[  177.750854] rockchip-spi ff500000.spi: rx_left=0
[root@luckfox soft]# [  177.750870] regs 00000000: 00102c01 000000fe 00000001 00000000
[  177.750881] regs 00000010: 00000006 00000000 0000001f 00000020
[  177.750891] regs 00000020: 00000000 00000069 00000000 00000040
[  177.750902] regs 00000030: 00000000 00000000 00000000 00000003
[  177.750911] regs 00000040: 0000001f 00000000 00110002
[  177.750954] spi_slave spi0: failed to transfer one message from queue
^C

[root@luckfox soft]# cat /var/log/messages  | grep "spi"
Jan  1 00:37:04 luckfox kern.warn kernel: [    0.086065] rockchip-spi ff500000.spi: no high_speed pinctrl state
Jan  1 00:37:04 luckfox kern.info kernel: [    0.086851] rockchip-spi ff500000.spi: probed, poll=0, rsd=0
Jan  1 00:37:04 luckfox kern.info kernel: [    0.088098] spi-nand spi2.0: Winbond SPI NAND was found.
Jan  1 00:37:04 luckfox kern.info kernel: [    0.088122] spi-nand spi2.0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 128
Jan  1 00:37:04 luckfox kern.notice kernel: [    0.089213] 7 cmdlinepart partitions found on MTD device spi-nand0
Jan  1 00:37:04 luckfox kern.notice kernel: [    0.089232] Creating 7 MTD partitions on "spi-nand0":
Jan  1 00:39:26 luckfox kern.err kernel: [  142.976316] rockchip-spi ff500000.spi: state=3
Jan  1 00:39:26 luckfox kern.err kernel: [  142.976337] rockchip-spi ff500000.spi: tx_left=0
Jan  1 00:39:26 luckfox kern.err kernel: [  142.976347] rockchip-spi ff500000.spi: rx_left=0
Jan  1 00:39:26 luckfox kern.err kernel: [  142.976447] spi_slave spi0: failed to transfer one message from queue
Jan  1 00:40:01 luckfox kern.err kernel: [  177.750824] rockchip-spi ff500000.spi: state=3
Jan  1 00:40:01 luckfox kern.err kernel: [  177.750845] rockchip-spi ff500000.spi: tx_left=0
Jan  1 00:40:01 luckfox kern.err kernel: [  177.750854] rockchip-spi ff500000.spi: rx_left=0
Jan  1 00:40:01 luckfox kern.err kernel: [  177.750954] spi_slave spi0: failed to transfer one message from queue
[root@luckfox soft]# 


Re: SPI communication trouble

Posted: 2025-10-18 9:14
by Crocodile
Please check if the GND connections of the two devices are correct.

Re: SPI communication trouble

Posted: 2025-10-20 6:51
by luckdog322
Crocodile wrote: 2025-10-18 9:14 Please check if the GND connections of the two devices are correct.
Checked again.
GND connections are correct.

Re: SPI communication trouble

Posted: 2025-10-21 9:42
by Crocodile
My actual test was without any issues.
Here is my slave's boot.img file.
Downloaded 155 times
You can replace it for testing to eliminate the problem caused by the device tree configuration.
On the master side, you can use luckfox-config to open the SPI configuration.
If communication still fails, try to lower the .speed_hz configuration of the application and conduct a SPI loopback test to determine if the pins are okay.

Re: SPI communication trouble

Posted: 2025-10-22 14:16
by luckdog322
Crocodile wrote: 2025-10-21 9:42 My actual test was without any issues.
Here is my slave's boot.img file.
luckfox_pico_pro_max_spislave_bootimg.zip
You can replace it for testing to eliminate the problem caused by the device tree configuration.
On the master side, you can use luckfox-config to open the SPI configuration.
If communication still fails, try to lower the .speed_hz configuration of the application and conduct a SPI loopback test to determine if the pins are okay.
Just tried everything you suggested.
I used your boot.img for my slave device with partition image flashing method described in your guide via windows SocToolKit flashing tool.
Tried to decrease the communication speed to 1000000hz but it had no effect. Using luckfox-config on the master side didn't help at all.
After that i conducted spi loopback test in my master device. It was OK. So the problem is on the slave side.

This is how I connect 2 devices:
SLAVE-MISO(16pin)<->MASTER-MISO(16pin)
SLAVE-MOSI(15pin)<->MASTER-MOSI(15pin)
SLAVE-CLK(14pin)<->MASTER-CLK(14pin)
SLAVE-CS0(12pin)<->MASTER-CS0(12pin)

Both devices are powered by a single laboratory power supply and are connected to pins 39(+) and 38(-)
therefore, they have common GND.

Re: SPI communication trouble

Posted: 2025-10-28 13:40
by Crocodile
All the problems that could be eliminated have been eliminated. I have conducted multiple tests on the software and found no issues.
If your test was conducted without using luckfox-config, you can attach the boot.img files of the master and slave machines to facilitate others in attempting to reproduce your issue.

It is recommended that you perform data loopback tests on both boards, or swap the master and slave units; if you have an oscilloscope, you can determine whether the waveforms are as expected, especially for the SCLK pin.