PINE64
Is SPI Working? - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PINE A64(+) (https://forum.pine64.org/forumdisplay.php?fid=4)
+--- Forum: Pine A64 Hardware, Accessories and POT (https://forum.pine64.org/forumdisplay.php?fid=32)
+---- Forum: POT modules (https://forum.pine64.org/forumdisplay.php?fid=8)
+---- Thread: Is SPI Working? (/showthread.php?tid=1297)

Pages: 1 2 3 4 5 6 7


RE: Is SPI Working? - martinayotte - 07-19-2016

@alevecchio, it is not the overlay templates that are complex, it is the configfs kernel driver that need to be back ported which is complex, because it relies on on sysfs and other stuff that are different between both kernels. Without it, we can't push overlays in the /sys/kernel/config/device-tree/overlays/ folder.

(07-19-2016, 06:37 AM)adamw Wrote: Great work guys!
Just so I'm clear, will both SPI0 and SPI1 be working in the next kernel or only SPI0?

I presume longsleep will leave UART3/UART4 enabled by default, this means that SPI1 will be disabled.
But it pretty easy to switch that back and forth.


RE: Is SPI Working? - alevecchio - 07-19-2016

(07-19-2016, 08:15 AM)martinayotte Wrote: @alevecchio, it is not the overlay templates that are complex, it is the configfs kernel driver that need to be back ported which is complex, because it relies on on sysfs and other stuff that are different between both kernels. Without it, we can't push overlays in the /sys/kernel/config/device-tree/overlays/ folder.


Sorry @martinayotte. I think i was not so clear. I just want to try to enable the SPI before the next release. I am not sure how long we will need to wait for this release and i want to start to work.

I found the DTB file on /boot/pine64/sun50i-a64-pine64-plus.dtb so in theory i know where to put the compiled file. 
Checking the DTS file on Github now i saw the file was updated. Thanks Longsleep. So i believe i can use as source. https://github.com/longsleep/build-pine64-image/blob/master/blobs/pine64.dts

Is just this? Compile the dts to dto and replace the file on /boot ?

Checking the spi@01c68000 now on the DTS file on github i found
status = "disabled";
Does it need to be enabled?


RE: Is SPI Working? - martinayotte - 07-19-2016

Yes the file is /boot/pine64/sun50i-a64-pine64-plus.dtb
First, backup that file somewhere, then decompile it :

dtc -I dtb -O dts -o file.dts /boot/pine64/sun50i-a64-pine64-plus.dtb

Edit it to place status = "okay", but you need to fix also the buggy 0x40000 in eth with the good value 0x10000.

Recompile it :

dtc -I dts -O dtb -o /boot/pine64/sun50i-a64-pine64-plus.dtb file.dts


RE: Is SPI Working? - User 3332 - 07-19-2016

(07-19-2016, 11:51 AM)martinayotte Wrote: Yes the file is /boot/pine64/sun50i-a64-pine64-plus.dtb
First, backup that file somewhere, then decompile it :

dtc -I dtb -O dts -o file.dts /boot/pine64/sun50i-a64-pine64-plus.dtb

Edit it to place status = "okay", but you need to fix also the buggy 0x40000 in eth with the good value 0x10000.

Recompile it :

dtc -I dts -O dtb -o /boot/pine64/sun50i-a64-pine64-plus.dtb file.dts

In the file.dts I found the following, do we need to edit anything with that also? (says "io_disabled")

  spi0@2 {
                                allwinner,pins = "PC3", "PC2", "PC0", "PC1";
                                allwinner,function = "io_disabled";
                                allwinner,muxsel = <0x7>;
                                allwinner,drive = <0x1>;
                                allwinner,pull = <0x0>;
                                linux,phandle = <0x55>;
                                phandle = <0x55>;
                        };


RE: Is SPI Working? - martinayotte - 07-19-2016

You don't need to touch that part. I presume, to my understanding, that this is used when the SPI is actually "disabled".
When set to "okay", it is using the following :

spi0@0 {
linux,phandle = <0xa7>;
phandle = <0xa7>;
allwinner,pins = "PC3";
allwinner,function = "spi0";
allwinner,pname = "spi0_cs0";
allwinner,muxsel = <0x4>;
allwinner,pull = <0x1>;
allwinner,drive = <0xffffffff>;
allwinner,data = <0xffffffff>;
};

spi0@1 {
linux,phandle = <0xa8>;
phandle = <0xa8>;
allwinner,pins = "PC2", "PC0", "PC1";
allwinner,function = "spi0";
allwinner,pname = "spi0_sclk", "spi0_mosi", "spi0_miso";
allwinner,muxsel = <0x4>;
allwinner,pull = <0xffffffff>;
allwinner,drive = <0xffffffff>;
allwinner,data = <0xffffffff>;
};

If you look at other peripherals, such uarts or i2c, there are always 2 definitions where one is "io_disabled". In fact, I've never since such "io_disabled" definition on other platforms, such beaglebone/raspberrypi/orangpi.


RE: Is SPI Working? - alevecchio - 07-19-2016

Should spidev0.0 apear in my /dev folder? Because it's not there. Even after what Martin say to do about the dts file.


RE: Is SPI Working? - martinayotte - 07-19-2016

Did you have your own kernel built with CONFIG_SPI_SPIDEV=m ?
Otherwise you will have to wait next Longsleep built where he added this flag to the build.


RE: Is SPI Working? - alevecchio - 07-20-2016

(07-19-2016, 07:48 PM)martinayotte Wrote: Did you have your own kernel built with CONFIG_SPI_SPIDEV=m ?
Otherwise you will have to wait next Longsleep built where he added this flag to the build.

Do you think it will work if i follow the Longsleep instructions it will work? 
https://github.com/longsleep/build-pine64-image/tree/master/kernel


I checked the spidev option and it is already there. But i am not sure about what "To compile, you need a properly set up gcc-aarch64-linux-gnu toolchain. The recommended version to compile the Kernel is 5.3." means. So i am playing with it.


RE: Is SPI Working? - martinayotte - 07-21-2016

Yes ! longsleep has added the "CONFIG_SPI_SPIDEV=m" few days ago.

I don't know if you have already some experience in building your own kernel, if you don't have any, it can become a big challenge.
For the gcc-aarch64-linux-gnu toolchain, this is use when doing cross-compiling on a PC to produce A64 binaries.
If you compile directly on the PineA64 itself, you should only needs "build-essential"


RE: Is SPI Working? - alevecchio - 07-21-2016

(07-21-2016, 08:46 AM)martinayotte Wrote: Yes ! longsleep has added the "CONFIG_SPI_SPIDEV=m" few days ago.

I don't know if you have already some experience in building your own kernel, if you don't have any, it can become a big challenge.
For the gcc-aarch64-linux-gnu toolchain, this is use when doing cross-compiling on a PC to produce A64 binaries.
If you compile directly on the PineA64 itself, you should only needs "build-essential"

Martin, I really thank you for all your support but i am giving up. I was able to compile the kernel and put it in /boot/pine64 folder. Its working and when i check the version it was changed to 3.10.102 (without longsleep...) so it's here and loaded. 
The main problem is when i compile the modules, i don't know where the files are and how to put them in place. 

I think it's better to wait for the next kernel and put the project on hold. Or really to buy a Rasp3 because it's working out of the box.
I still have the feeling that a spent money on two ferraris but the engine is not ready yet. Maybe someday.

Thank you.