How to enable spidev interface on SoC Allwinner?

  • I intend to add support for displays with the spi interface to my OLEDproc add-on.

    I've spent many hours on failed attempts, and now I really don't know what to do next.

    I work with Orange Pi 3 (H6) and Orange Pi PC (H3) boards. Unfortunately, I was not successful with any of them. No /dev/spidevX.X interface appears (I use the ls /dev/sp* command to check).

    At first I tried it with Armbian and I was successful there. I then copied the overlay files (which it worked with in Armbian) to LibreELEC,

    but in LibreELEC these files do not work. There is probably something else here, but I can't find it. Can you help me please ?

    Note:

    1. I'm working on version 10.0.2

    2. In Armbian I used these overlay files: overlays.zip

  • Armbian has a patch that adds "spidev" compatible to the spidev driver. LibreELEC does not, because such patch has no chance of being included in mainline kernel. However, you can still achieve same effect by using one of the compatible strings listed in spidev.c (https://git.kernel.org/pub/scm…spidev.c?h=v5.10.124#n669).


    Edit: It seems that "spidev" compatible is invention by RPi kernel. Please don't rely on it.

  • Thank you very much for your answer. I hope we are going in the right direction, but unfortunately, I still don't have a /dev/spidevX.X device.

    I fixed the overlay - see the attachment, but the result is none. I tried to use the same file in Armbian and it works there.

    Can you please think about what else needs to be done?


    Note:

    As a first attempt, I used the string "ge, achc", but it didn't work in Armbian either. I immediately found out why. I have in Armbian 5.15.43 Linux version and there are compatible strings a little different - "ge, achc" is not there. So I used "dh, dhcom-board" and it is in both version 5.10.76 (my LibreELEC) and version 5.15.43.

    Then it started working in Armbian, but not in LibreELEC.



    Edit:

    I noticed that Linux 5.10.X lacks (as opposed to Linux 5.15.43) the following structure:

    Could it be the problem?




    sun8i-h3-spi-spidev0.dts.zip

    Edited once, last by LuRu: Addition ().

  • I just noticed that CONFIG_SPI_SPIDEV is not even enabled for 32-bit AW SoCs, but it is for 64-bit. So it should work on H6, but not on H3. Not sure what problem you see with compatibles - all 5.10 versions I checked have same compatible array.

  • Not sure what problem you see with compatibles - all 5.10 versions I checked have same compatible array.

    I did not say the opposite. I probably wrote it somehow confused, I'm sorry.

    So once again. I used the string "ge, achc" as the first attempt and it didn't work (in LibreELEC). I wanted to verify that it works at least in Armbian. But it didn't work. That's why I looked at what Linux is in Armbian. There is 5.15.43. So I looked in the appropriate spidev.c file and there I found that the compatible array does not contain the string "ge, achc". So I used the string "dh, dhcom-board", which is found in both versions. Then I tried it in both Armbian and LibreELEC. It worked in Armbian, it didn't work in LibreELEC.

    I just noticed that CONFIG_SPI_SPIDEV is not even enabled for 32-bit AW SoCs, but it is for 64-bit. So it should work on H6, but not on H3.

    How do I understand that? This means that for H3 there is no chance for it to work in LibreELEC (in Armbian it works!).

    I'll try to see if it really works at least on H6.

  • How do I understand that? This means that for H3 there is no chance for it to work in LibreELEC (in Armbian it works!).

    Yes, with current image there is no chance to work. Kernel config file needs to be updated and image rebuild.

  • Above all - thank you for your patience with me.

    In the meantime, I tried a modified overlay (with the string "dh, dhcom-board") on H6. But unfortunately, without success. So CONFIG_SPI_SPIDEV is probably not the only problem.

    Note:

    1) If I do image bulding myself, can I create an image (where CONFIG_SPI_SPIDEV will be allowed) for H3 as well?

    2) In the future - is it possible to enable CONFIG_SPI_SPIDEV for H3 in the official version? It's a pretty common thing to connect a display to Kodi, so why can't it be with a spi interface?

    Not everyone will be able to build a WiFi version.

  • Kernel configuration is already updated for LE10 and LE11 (merged few minutes ago). Either wait for tomorrow LE11 nightly image or build LE10 image for yourself.

  • 1. mount -o remount, rw / flash

    2. I copy the file sun50i-h6-spi-spidev1.dtbo to the directory /flash/overlays

    3. I edit the file /flash/extlinux/extlinux.conf and in the line FDTOVERLAYS I add the parameter /overlays/sun50i-h6-spi-spidev1.dtbo

    4. mount -o remount, ro / flash

    5. reboot


    Note:

    My extlinux.conf file looks like this:


    Code
    LABEL LibreELEC
    LINUX / KERNEL
    FDT /sun50i-h6-orangepi-3.dtb
    FDTOVERLAYS /overlays/sun50i-h6-i2c0.dtbo /overlays/sun50i-h6-spi-spidev1.dtbo
    APPEND boot = UUID = 0908-1419 disk = UUID = 8cd4f88f-17df-48ce-bec6-cca1eb844534 quiet console = ttyS0,115200 console = tty1

    sun50i-h6-spi-spidev1.dtbo.zip

    Edited once, last by LuRu: Typo ().

  • I suppose i2c0 overlay works correctly? Everything looks good, but I'm no expert in overlays, especially with old syntax. Armbian applies much more kernel patches than LE, so that's one possible answer. Another would be kernel config, but that we hopefully fixed adequately.

  • I suppose i2c0 overlay works correctly?

    Yes, it works properly. I have a normally connected LCD display so, but it's disconnected now. Well, we'll see how it works on H3 after build or tomorrow with LE11. It's easier for me to work on H3 at the moment, I have a purely development version with a well-available gpio connector.

  • I report partial success!

    Today's nightly LE11 Orange Pi PC is already working - /dev/spidev0.0 has appeared.

    But on SoC H6 I'm still without spidev. I also tried a fresh installation of LE11 on a clean SD card, but nothing. I even tried it on two boards (Pi 3 and Pi LIte 2), but in vain.

    I also wanted to try my own build LE 10 on the OPi PC, but it won't start at all - see the picture. Until recently, however, I did the building without any problems - I have no idea what is wrong (whether the problem is on my side).

  • There are also LE10 nightly images nowadays: https://test.libreelec.tv/10.0/Allwinner/ Please test if it works for you. If it doesn't, some PR probably caused an issue.


    Do you have serial adapter? If so, please check if U-Boot complains anything about overlays. Another useful thing would be to upload /sys/firmware/fdt somewhere. It is basically dtb file used by the kernel. Decompiling it should show if overlay was applied or not.

  • Do you have serial adapter?

    Yes, I had a serial console connected during boot and it looked like the overlay files were loaded without any problems.

    I'll make more attempts tomorrow.

    Thank you for your help !

  • I have other findings:

    1. I installed nightly OPi-PC-LE10. Result: no spidev

    2. I decompiled the FDT files (they are attached). It looks like it should work, but it doesn't work.

    3. Due to the behavior on OPi-PC (works with nightly LE11, but not with nightly LE10), I also tried a clean installation of nightly LE11 on OPi-3. Result: no spidev


    What are we going to do next?


    OPI-FDT-ALL.zip

  • I have no idea why it doesn't work on LE10 H3 image. Can you confirm that you actually get other issues like those described before?

    I'm sorry, but I don't understand what you mean. To be sure, however, I performed a new clean installation of the latest LE10 nightly and reapplied the overlay. Without success.


    I'm happy to report another partial success:

    With the latest nightly LE11, /dev/spidev1.0 already exists on OPi3 (H6)!

    Conversely, even with the latest nightly LE10, there is no /dev/spidevX.X (neither H3 nor H6).

    It occurred to me that it might help to find the cause when you see the result of the find /sys/ -name '*spi*' command.

    So I did it for all four cases. The result is in the attachment.

    However - it is no longer absolutely necessary to solve it for LE10. I can continue to develop the OLEDproc add-on on LE11. But of course it would be better if it worked for LE10 as well.

    find-sys-name-spi.zip