Jump to content

How enable SPI slave mode?


Recommended Posts

Armbianmonitor:

Hi

 

I want use spi in slave mode, how i can enable slave?

cat /boot/armbianEnv.txt
verbosity=1
console=serial
overlay_prefix=sun50i-h5
overlays=spi-add-cs1 spi-jedec-nor spi-spidev
param_spidev_spi_bus=0
param_spidev_max_freq=100000000
rootdev=UUID=47313251-44b3-4a77-aef5-c53397e3a685
rootfstype=ext4
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

 

 

 

Link to comment
Share on other sites

27 minutes ago, martinayotte said:

Unfortunately, although the H5 hardware is capable, Linux kernel driver doesn't support slave mode.

Thanks, i don't knows it.

On first at this topic, sfx2000 say about rebuild kernel...

 

I readed this link and check my kernel config, so i have this options

CONFIG_SPI_SUN4I=y
CONFIG_SPI_SUN6I=y
CONFIG_SPI=y
CONFIG_SPI_MASTER=y
CONFIG_EXPERIMENTAL=y
CONFIG_SPI_SPIDEV=y

CONFIG_SPI_SLAVE=y
CONFIG_SPI_SLAVE_TIME=m
CONFIG_SPI_SLAVE_SYSTEM_CONTROL=m

it's ok.

 

But next, i dont't understund...

Yes, i have /dev/spidev1.0 and /sys/class/spi_slave

So, how i can use my /dev/spidev1.0 as slave?

I try change my dts: (convert /boot/sun50i-h5-nanopi-neo-core2.dtb to /boot/sun50i-h5-nanopi-neo-core2.dts, edit, and compile again to dtb)

In dts i added "spi-slave;"

                        spi0 {
                                pins = "PC0", "PC1", "PC2", "PC3";
                                function = "spi0";
                                linux,phandle = <0x21>;
                                phandle = <0x21>;
                                spi-slave;
                        };

                        spi1 {
                                pins = "PA15", "PA16", "PA14", "PA13";
                                function = "spi1";
                                linux,phandle = <0x23>;
                                phandle = <0x23>;
                                spi-slave;
                        };

But i can't see anything change in my system.

martinayotte, tell me please,  how i can reconfigure or rebuild linux kernel driver to support slave?

Link to comment
Share on other sites

13 minutes ago, RuslanGennadievich said:

how i can reconfigure or rebuild linux kernel driver to support slave?

As I said, kernel driver for AllWinner SoC doesn't support "slave" mode.

 

8 minutes ago, RuslanGennadievich said:

My ultimate goal is to test SPI baud rate :)

What do you mean by testing baud rate ?

If you wish to measure/verify the clock, you can take a oscilloscope...

Link to comment
Share on other sites

1 minute ago, martinayotte said:

As I said, kernel driver for AllWinner SoC doesn't support "slave" mode.

Maybe you know how add slave support to driver?

 

Quote

If you wish to measure/verify the clock, you can take a oscilloscope...

Yes, on oscilloscope i verify clock line on "slave soc" and see some signal, but in slave mode it's wrong

Link to comment
Share on other sites

2 minutes ago, RuslanGennadievich said:

Maybe you know how add slave support to driver?

No, it is too complex task ...

 

2 minutes ago, RuslanGennadievich said:

Yes, on oscilloscope i verify clock line on "slave soc" and see some signal, but in slave mode it's wrong

I don't understand what you mean ...

Link to comment
Share on other sites

33 minutes ago, RuslanGennadievich said:

If i have /sys/class/spi_slave on Armbian, does this mean that the kernel has support spi slave?

From my knowledge/understanding, it only mean that kernel has been compiled with CONFIG_SPI_SLAVE enabled, but no hardware is attached to it since neither drivers/spi/spi-sun4i.c and drivers/spi/spi-sun6i.c provide such functionalities.

 

EDIT: you have probably seen that this /sys/class/spi_slave folder is empty ...

Link to comment
Share on other sites

On 3/18/2020 at 7:47 AM, RuslanGennadievich said:

My ultimate goal is to test SPI baud rate :)

 

SPI on most SoC's - it's pretty much what the vendor qualifies - it's when one is in a mixed environment where things get interesting - master determines the rate based on the periphs configured.

 

There are a lot of things that can be on the SPI bus, so sit back and consider what peripherals are in use on your circuit design.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines