Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How enable SPI slave mode?

Featured Replies

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

 

 

 

  • Author
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?

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...

  • Author
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

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 ...

  • Author
On 3/18/2020 at 5:10 PM, martinayotte said:

No, it is too complex task ...

 

I don't understand what you mean ...

Ok thankyou, and last question

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

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 ...

  • Author
2 hours ago, martinayotte said:

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

Yes, you are right. My /sys/class/spi_slave folder is empty ...
Okey, thankyou for help!

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.

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.