Jump to content

Cannot obtain spidevX.Y on BananaPi M1+


Riccardo

Recommended Posts

Hi, I am trying to use the SPI interface on the board GPIOs of a BananaPi M1+. I have started the latest version of Armbian available for this board (Armbian_19.11.6_Bananapi_bionic_current_5.4.8) and after the initial configuration the "/boot/armbianEnv.txt" file has the following added lines:

	fdtfile=sun7i-a20-bananapi-m1-plus.dtb
	overlays=spi-add-cs1 spi-spidev
	param_spidev_spi_bus=0

I have rebooted but I am unable to use the spidevX.Y under the "/dev" folder. What am I missing? 

NOTE: I have tried several combinations of values on the armbianEnv.txt configuration file (ie: using only overlays flags without the other ones, using only the spi-spidev flag, etc...), none succeeded. 

Link to comment
Share on other sites

Hi everybody,

 

I'm stuck with the same problem as Riccardo: same Armbian version, same kernel and even same name :D.
Only difference is my board is M1 and I'm not using "spi-add-cs1" overlay.

- I confirm configuration is OK and loaded as per boot logs: "Applying kernel provided DT overlay sun7i-a20-spi-spidev.dtbo".

- I've also try loading module "spidev" with modprobe command.
- I've also confirm files exist.

 

Before updating to Armbian (I was in Lubuntu), I used spi bus without any problems with NRF24L01+ transcevier and NRF24 library.

 

Another problem found after updating is, I'm not able to create and udev rule for launching scripts when switching to battery or ac: any of the values found by "udevadm info /sys/class/power_supply/axp20x-usb" doesn't change when switching power sources.  Values found by "udevadm info /sys/power/axp_pmu/" are useless for an udev rule. Only workaround is a cron+script reading files /sys/power/axp_pmu/ac but this is not practical.

 

Hope you can help me. Thanks in advance.

Link to comment
Share on other sites

This is the boot log with the most recent version of Armbian, this log is without the fdtfile in the armbianEnv.txt file.

 

Furthermore another try is with the following lines on the armbianEnv.txt and this is the updated log.

verbosity=1
logo=disabled
console=both
disp_mode=1920x1080p60
overlay_prefix=sun7i-a20
rootdev=UUID=c763af3a-602f-4526-a9a8-7c8516acaffd
rootfstype=ext4
overlays=i2c2 spi-spidev
param_spidev_spi_bus=0
fdtfile=sun7i-a20-bananapi-m1-plus.dtb
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

 

 

Link to comment
Share on other sites

18 hours ago, martinayotte said:

You will need to check boot logs from Serial Debug. Maybe some hint will be shown there ...

 

Already check and stated in my first post:

 

On 1/19/2020 at 12:35 AM, playrich said:

- I confirm configuration is OK and loaded as per boot logs: "Applying kernel provided DT overlay sun7i-a20-spi-spidev.dtbo".

 

Naturally, I've read full instructions on Armbian's docs Allwinner DT overlays before posting.

Link to comment
Share on other sites

54 minutes ago, playrich said:

Also tried, no matches found.

Which kernel version do you have ? Do "uname -a" to figure out ...

Because overlays doesn't exist in Legacy ...

Maybe you should provide both dmesg and u-boot log captured from Serial Debug port.

Link to comment
Share on other sites

As stated at the begining, same kernel as Riccardo posted: Armbian_19.11.6_Bananapi_bionic_current_5.4.8

 

I've also moved to Armbian Booster but same problem persists. The only workaround is moving back to Lubuntu.

 

Find posted my serial boot , dmesg and kernel: Linux bananapi 5.4.20-sunxi #20.02.1 SMP Mon Feb 17 02:09:41 CET 2020 armv7l GNU/Linux

for Armbian Booster.

 

Hope this helps. Thanks in advance.

Link to comment
Share on other sites

55 minutes ago, playrich said:

Find posted my serial boot

Those errors in your boot log seems to be the culprit :

libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND

Maybe something missing in Banana-M1 DTB that prevent resolving SPIDEV overlay.

I will look into it when I get chance...

Link to comment
Share on other sites

22 hours ago, playrich said:

Find posted my serial boot

 

Ok ! I've figured it out !

 

The fixup scripts /boot/dtb/overlay/sun7i-a20-fixup.scr, /boot/dtb/overlay/sun5i-a13-fixup.scr and /boot/dtb/overlay/sun4i-a10-fixup.scr are all using "soc@1c00000" node instead of plain "soc" node, while the script /boot/dtb/overlay/sun8i-h3-fixup.scr is already using the good node naming.

The reason is because in the old days of 4.x.y, the node was named "soc@1c00000" while in 5.x.y it is the shorter version.

I will fix that in Armbian patches later ...

In the meantime, you can do backup of /boot/dtb/overlay/sun7i-a20-fixup.scr, copy it also as /root/sun7i-a20-fixup.cmd, edit it, remove the binary header until "# overlays fixup script" header, search all "soc@1c00000" and replace by plain "soc", save the file, and finally convert it again in script file using "mkimage -C none -A arm -T script -d  /root/sun7i-a20-fixup.cmd /boot/dtb/overlay/sun7i-a20-fixup.scr"

 

EDIT: Commit done ! https://github.com/armbian/build/commit/ca24fd20e48ff6e004279b0cb14dca746231e648

Link to comment
Share on other sites

Hi Martin. Thank you for your patience. Now I see /dev/spidev0.0

 

However now the problem is I can't use NRF24L01+ transceiver with RF24 library. I'm using "gettingstarted" test program and I get the following error:

root@bananapi:/home/bananapi/rf24libs/RF24/examples_linux# ./gettingstarted
RF24/examples/GettingStarted/
terminate called after throwing an instance of 'GPIOException'
  what():  can't access /sys/class/gpio/gpio%d/direction GPIO pin. check access rights
Aborted

I chmoded 777 /dev/spidev0.0 and lauched program with root. Compiling didn't return errors. Pin layout is the same as I had working with Lubuntu and described at bottom page of RF24 library for RPi.

It reminds me the same problem I have when using batteries: this kernel has modified the hierarchy on /sys/class therefore programs expecting the old hierarchy (ACPI, udev, RF24, etc) don't work.

 

I don't want to bother you any more with this issue, so I assume the limitations of these releases and I move back to Lubuntu.

 

Thank you for the given support.

Link to comment
Share on other sites

22 minutes ago, playrich said:

can't access /sys/class/gpio/gpio%d/direction GPIO pin. check access rights

It seems a trouble accessing a specific GPIO, not related to SPI, but message with %d is not meanful.

To get it more meanful, you need to fix it there :

https://github.com/nRF24/RF24/blob/master/utility/SPIDEV/gpio.cpp#L48

It should probably be instead :

throw GPIOException("can't access /sys/class/gpio/gpio%d/direction GPIO pin. check access rights", port);

You can also check if the previous "export" worked by looking at "ls -l /sys/class/gpio/" to seen if the specific GPIO been exported.

Maybe the GPIO is already in use, you can verify that by doing "cat /sys/kernel/debug/gpio" ...

Link to comment
Share on other sites

On 3/20/2020 at 1:51 PM, martinayotte said:

throw GPIOException("can't access /sys/class/gpio/gpio%d/direction GPIO pin. check access rights", port);

 

Tried but compiler returns the following error: 

Quote

arm-linux-gnueabihf-g++ -fPIC -Ofast -Wall -pthread  -c utility/SPIDEV/gpio.cpp
utility/SPIDEV/gpio.cpp: In static member function ‘static void GPIO::open(int, int)’:
utility/SPIDEV/gpio.cpp:48:116: error: no matching function for call to ‘GPIOException::GPIOException(const char [76], int&)’
  access /sys/class/gpio/gpio%d/direction GPIO pin. check access rights", port);
                                                                              ^
In file included from utility/SPIDEV/gpio.cpp:13:0:
utility/SPIDEV/gpio.h:22:14: note: candidate: GPIOException::GPIOException(const string&)
     explicit GPIOException(const std::string& msg)
              ^~~~~~~~~~~~~
utility/SPIDEV/gpio.h:22:14: note:   candidate expects 1 argument, 2 provided
utility/SPIDEV/gpio.h:20:7: note: candidate: GPIOException::GPIOException(const GPIOException&)
 class GPIOException : public std::runtime_error {
       ^~~~~~~~~~~~~
utility/SPIDEV/gpio.h:20:7: note:   candidate expects 1 argument, 2 provided
utility/SPIDEV/gpio.h:20:7: note: candidate: GPIOException::GPIOException(GPIOException&&)
utility/SPIDEV/gpio.h:20:7: note:   candidate expects 1 argument, 2 provided
Makefile:54: recipe for target 'gpio.o' failed
make: *** [gpio.o] Error 1

 

However I added a printf of variable "port" on line 37. Prints "22", matching SPI_DEV Constructor RF24 radio(22,0), therefore expanding path to "sys/class/gpio/gpio22..." which doesn't exist:

Quote

ls -lh /sys/class/gpio
total 0
--w------- 1 root root 4.0K May  9 12:36 export
lrwxrwxrwx 1 root root    0 May  9 11:31 gpiochip0 -> ../../devices/platform/soc/1c20800.pinctrl/gpio/gpiochip0
lrwxrwxrwx 1 root root    0 May  9 11:31 gpiochip413 -> ../../devices/platform/soc/1c2ac00.i2c/i2c-1/1-0034/axp20x-gpio/gpio/gpiochip413
--w------- 1 root root 4.0K May  9 11:31 unexport

 

I've also desperately tried unsucessfully:

Any ideas?

Link to comment
Share on other sites

Some new hints:

  • Using pin 0 in constructor RF24 radio(0,0) finally starts the program but hangs the system. I've changed frequency param_spidev_max_freq=12000000 as per Lubuntu dmesg without success.
  • This is a software problem. On Lubuntu with kernel 3.4.103 and same pinout works like a charm. Some of the traces I took from Lubuntu:
    Quote

    bananapi@lemaker:~/rtl-sdr/build$ ls -lh /sys/class/gpio
    total 0
    --w------- 1 root root 4.0K May 17 04:58 export
    lrwxrwxrwx 1 root root    0 May 17 04:58 gpio22 -> ../../devices/platform/gpio-sunxi/gpio/gpio22
    lrwxrwxrwx 1 root root    0 Jan  1  2010 gpiochip1 -> ../../devices/platform/gpio-sunxi/gpio/gpiochip1
    --w------- 1 root root 4.0K Jan  1  2010 unexport

     

    Linux lemaker 3.4.103 #1 SMP PREEMPT Thu Dec 18 13:07:12 CST 2014 armv7l armv7l armv7l GNU/Linux

     

    [  374.890808] [spi-inf] Found 2 spi devices in config files
    [  374.898773] [spi-inf] boards num modalias         max_spd_hz       bus_num  cs   mode
    [  374.902606] [spi-inf] spi_board0 irq gpio not used
    [  374.909587] [spi-inf] 0          spidev           12000000         0        0    0x3
    [  374.913401] [spi-inf] spi_board1 irq gpio not used
    [  374.920359] [spi-inf] 1          spidev           12000000         0        1    0x3
    [  374.926206] [spi-inf] sun7i_spi_probe: spi0 dma type: normal
    [  374.930358] [spi-inf] bus num = 0, spi used = 3
    [  374.940105] [spi-inf] sun7i_spi_probe: spi0 cs bitmap: 0x3
    [  374.948819] [spi-inf] sun7i_spi_set_mclk: spi0 source = sdram_pll_p, src_clk = 432000000, mclk 86400000
    [  374.955418] sun7i-spi sun7i-spi.0: master is unqueued, this is deprecated
    [  374.964965] [spi-inf] sun7i_spi_probe: reuuimlla's SoC SPI Driver loaded for Bus SPI0 with 2 Slaves at most
    [  374.981842] [spi-inf] sun7i_spi_probe: spi0 driver probe succeed, base f02ee000, irq 42, dma_id_rx 24, dma_id_tx 24

     

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines