BPI-R2 SPI Communication

Hello everyone.

I want to use SPI port of BPI-R2. I saw wiringPi support for BPI-M2 kernel. Is the kernel compatible with BPI-R2? How Can I use the Spi on BPI-R2 with C++ Spidev. I mean How can I install or enable SPI driver on DPI-R2? Is there anybody have an idea?

Thanks for all answers.

non-bpi-r2-kernel does not work on bpi-r2 because its a different SOC

default kernel do not have spi-support afaik. you can try to build your own and test it…

you need the SPI-Module and the dts-nodes for SPI enabled. you can try it with my 4.14 kernel, SPI-module is enabled, you have to activate the SPI-Node(s) in bananapi-r2.dts and build again

Thanks for quick answer.

Where can I find your kernel 4.14 for BPI-R2? As I understand, If I load the your kernel 4.14 to my BPI_R2, The SPI module will be enabled on this kernel and I will see the /dev/spidev0.0 on userspace. Am I right?

ok, i see, that i have enabled the node before:

i have not tested SPI you must look in your bootlog how the device is named (dmesg in debian/ubuntu)

as of the nodes are enabled you can also use one of my precompiled kernels

https://drive.google.com/open?id=1EGN1TvqCpDHdOAS-mjRg9ipi0kahnOUV

Okay. Thanks for info and kernel. I will try this.

kernel-packages have version and branch-name…main is the right one :slight_smile:

if it does not work you have to build it by yourself…please give me feedback if you’ve got it running and how

Okay. I will turn back you after trying.

added spi-dev as module to 4.14.15-main…

https://drive.google.com/open?id=1EGN1TvqCpDHdOAS-mjRg9ipi0kahnOUV

Hi. Thanks for helps.

I use kernel 4.4.xx . Also, I activated the device -> driver->SPI support from kernel menuconfig. I compiled the kernel gcc-arm-linux-gnueabihf-6. It compiled succesfully. gcc-7 gives errors.

I still don’t see spidev0 or spidev1 driver in /dev directory.

Which one of the device driver Should I activate from ./build.sh option 4 for spidev?

spidev is under spi-support names somehow user-driver or similar…you can search in menuconfig with / for spidev

I have activeted all of SPI Support subheaders including spi user interface. But, I didn,t see /dev/spidev.

Is it necessary to enable or install spi after buildg kernel?

I don’t know which spi should be found…do you use gpio-spi or inside your camera? If using gpio you have to enanle it in dts(i)

I am using gpio spi. where can I enable dts?

Here i wrote the steps for enabling spi in dts: SPI touchscreen ads7846 (xpt2046) on UBUNTU images (BPI-R2)

The kernel which you sent me, is not booting? I have merged the compiled BPI_BOOT and BPI_ROOT directories with SD card but, it didn’t boot.

Or it has not hdmi support?

Kernel 4.14 has no no working hdmi yet…see the issue on github.

But you can use the nodes in dts and kernel-options from 4.14 to extend 4.4

We plan to send HDMI related patches to mainline late this month and will add MIPI support if we have time to do that.

If you want to use spi0: spi@1100a000 you should enable it, add the correct pinmux setting and add a device which is connected to spi0.

There are many examples in /arch/arm//boot/dts/* (for more details please grep ‘spi’ ).

Thanks

Hi Ryder. I have editted mt7623.dtsi following;

         spi0: spi@1100a000 {
                compatible = "mediatek,mt7623-spi",
                             "mediatek,mt2701-spi";
                #address-cells = <1>;
                #size-cells = <0>;
                reg = <0 0x1100a000 0 0x100>;
                interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_LOW>;
                clocks = <&topckgen CLK_TOP_SYSPLL3_D2>,
                         <&topckgen CLK_TOP_SPI0_SEL>,
                         <&pericfg CLK_PERI_SPI0>;
                clock-names = "parent-clk", "sel-clk", "spi-clk";
                status = "disabled";
        };

Also, I added like this mt7623n_bpi_r2.dts file;

spi0_pins_a: spi0@0 {
		pins_spi {
			pinmux = <MT7623_PIN_53_SPI0_CSN_FUNC_SPI0_CS>,
				<MT7623_PIN_54_SPI0_CK_FUNC_SPI0_CK>,
				<MT7623_PIN_55_SPI0_MI_FUNC_SPI0_MI>,
				<MT7623_PIN_56_SPI0_MO_FUNC_SPI0_MO>;
			bias-disable;
		};
	};

I have checked gpio of spi are correct. But, I couldn’t see /dev/spidev.0.0 after rebuilding kernel.

Did you enable it : "status = “okay”?

Please type this command: find /sys/bus | grep spi