0
Serge

NanoPI Neo Core. How to activate a second SPI

Recommended Posts

board: http://nanopi.io/nanopi-neo-core.html

image: Armbian Bionic mainline based kernel 4.19.38 from https://www.armbian.com/nanopi-neo/

There are two SPI separated buses with separated pins on NanoPi Core: SPI0 and SPI1

 

 /boot/armbianEnv.txt:

...

overlay-prefix=sun8i-h3

overlays=analog-codec i2c0 spi-spidev uart1 usbhost3

param_spidev_spi_bus=0

...

/dev/spidev0.0 presents

 

How to activate a SPI1?

Share this post


Link to post
Share on other sites
2 hours ago, Serge said:

How to activate a SPI1?

With the current overlays, you can't have both SPIs at the same time, but you can create a custom SPI overlay that won't need any params and having both enabled by default.

Share this post


Link to post
Share on other sites
40 minutes ago, Serge said:

does it mean the way to ./build/patch/kernel/sunxi-dev/my-super-2spi.patch?

Not necessarily ...

Such overlay could be compiled locally on the nanopi if you install DT compiler there. You can download it from http://ftp.debian.org/debian/pool/main/d/device-tree-compiler/device-tree-compiler_1.4.7-3_armhf.deb

Then, you can have something like this (not tested) :

/dts-v1/;
/plugin/;

/ {
    compatible = "allwinner,sun8i-h3";

    fragment@0 {
	target-path = "/aliases";
	__overlay__ {
            /* Path to the SPI controller nodes */
            spi0 = "/soc@01c00000/spi@01c68000";
            spi1 = "/soc@01c00000/spi@01c69000";
        };
    };
    fragment@1 {
        target = <&spi0>;
        __overlay__ {
            pinctrl-names = "default";
            pinctrl-0 = <&spi0_pins>;
            status = "okay";
            #address-cells = <1>;
            #size-cells = <0>;
            spidev@0 {
                compatible = "spidev";
                reg = <0x0>;
                spi-max-frequency = <500000>;
            };
        };
    };
    fragment@2 {
        target = <&spi1>;
        __overlay__ {
            pinctrl-names = "default";
            pinctrl-0 = <&spi1_pins>;
            status = "okay";
            #address-cells = <1>;
            #size-cells = <0>;
            spidev@0 {
                compatible = "spidev";
                reg = <0x0>;
                spi-max-frequency = <500000>;
            };
        };
    };
};

 

Share this post


Link to post
Share on other sites

martinayotte, I've decompile original ...nanopi-neo.dtb file and found there are both spi's are enabled in .dtb file

the question is about correct parameter in armbianEnv.txt:

param_spidev_spi_bus=0

param_spidev_spi_bus=1

or

param_spidev_spi_bus=0 1 or how?

 

I didn't find any examples for using both SPIs. The most examples about SPI0 only.

 

at present project SPI1 will be used as well (it's a hardware connections of the shield) and SPI0 pins wil be used as GPIO pins.

later, I'd like to have possibility to use SPI0 also.

 

upd.:

param_spidev_spi_bus=1 - doesn't work .....upd2: conflict with serial because pin PA15  already requested by 1c28cc00.serial.....

PA15 is used bu uart3_rts_cts also (according original .dts file) but no UART3 interfaces on pinout:

http://wiki.friendlyarm.com/wiki/index.php/NanoPi_NEO_Core

I'm not going to use uart3 with rts_cts.

 

 

udp3:

I've remove all uart3 sections from decompiled .dts

now "param_spidev_spi_bus=1" is working and I can see /dev/spidev1.0

 

last question: for both SPIs using how I must setup a "param_spidev_bus"?

 

Share this post


Link to post
Share on other sites
2 hours ago, Serge said:

last question: for both SPIs using how I must setup a "param_spidev_bus"?

Unfortunately, as I said before the current overlays and fixup.scr don't support double SPI.

So, use my custom overlay I've provided, compile it and place it into /boot/overlay-user/ along with entry "user_overlays=mydualspi" in /boot/armbianEnv.txt, you don't "param_spidev_bus" anymore with that.

Share this post


Link to post
Share on other sites

martinayotte, I've tried to use a SPI1 only. 

/dev/spidev1.0 presents.

tried to use a standard IO C functions (open(), read()....) and with wiringPI lib - no result

tried to analyse a phisical levels with PulseView - looks like confusion between pins and signals and wrong timing of signal.

checked pins deffinition in .dts file - all according pin names from datasheeet

tried to assign pins in .dts according results of signals from PulseView... no result

because of urgent I wrote SPI "driver" manually - now all works

please advice how to check what's wrong with hardware SPI1?

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
0