How to enable SPI devices on BBAI-64?

I’m trying to get SPI working on the BBAI-64. By default, two SPI devices exist under /dev/spidev0.0 and /dev/spidev0.1. I enabled the SPI pins in /opt/source/dtb-5.10-ti-arm64/src/arm64/k3-j721e-beagleboneai64.dts: (P9_17_spi_pin, P9_18_spi_pin, P9_21_spi_pin, P9_22_spi_pin, P9_23_spi_pin). However, when I try writing to either of these devices using a SPI utility (C or Python), the SPI pins on P9 do nothing.

A couple of errors are reported in dmesg | grep spi:

[    3.825090] spi-nor spi1.0: unrecognized JEDEC id bytes: ff ff ff ff ff ff
[    3.831973] spi-nor: probe of spi1.0 failed with error -2
[    8.696154] gb_spilib: module is from the staging directory, the quality is unknown, you have been warned.
[    9.055009] gb_spi: module is from the staging directory, the quality is unknown, you have been warned.
[    9.068654] gb_gbphy: registered new driver spi

I tried adding the BONE-SPI0_0 and BONE-SPI0_1 overlays to extlinux.conf, but this causes /dev/spidev0.0 and /dev/spidev0.1 to disappear after rebooting.

I also noticed that the main_spi6_pins are set to INPUT_DISABLE in k3-j721e-beagleboneai64.dts:

        main_spi6_pins_default: main-spi6-pins-default {
                pinctrl-single,pins = <
                        J721E_IOPAD(0x74, INPUT_DISABLE, 4) /* (AC21) PRG1_PRU1_GPO7.SPI6_CS0 */
                        J721E_IOPAD(0x28, INPUT_DISABLE, 4) /* (AG20) PRG1_PRU0_GPO9.SPI6_CS1 */
                        J721E_IOPAD(0x9c, INPUT_DISABLE, 4) /* (AC22) PRG1_PRU1_GPO17.SPI6_CLK */
                        J721E_IOPAD(0xa0, INPUT_DISABLE, 4) /* (AJ22) PRG1_PRU1_GPO18.SPI6_D0 */
                        J721E_IOPAD(0xa4, PIN_INPUT, 4) /* (AH22) PRG1_PRU1_GPO19.SPI6_D1 */
                >;
        };

I tried changing these to PIN_INPUT’s but it seemed to have no effect. What do I need to do to get SPI working?

Here’s how I did it (Not sure if this is the best way yet):

Added BONE-SPI0_0 overlay to extlinux.conf:

debian@BeagleBone:~/src/spi_test$ sudo beagle-version | grep -i UBOOT
UBOOT: Booted Device-Tree:[k3-j721e-beagleboneai64.dts]
UBOOT: Loaded Overlay:[BONE-SPI0_0.kernel]

Loaded kernel driver:

debian@BeagleBone:~/src/spi_test$ sudo insmod /lib/modules/5.10.153-ti-arm64-r84/kernel/drivers/spi/spidev.ko.xz
debian@BeagleBone:~/src/spi_test$ ls /dev/bone/
pwm spi uart
debian@BeagleBone:~/src/spi_test$ tree /dev/bone/spi
/dev/bone/spi
└── 0.0 → …/…/spidev9.0

0 directories, 1 file

Tested:

debian@BeagleBone:~/src/spi_test$ sudo ./spidev_test --device /dev/spidev9.0 -v
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D | …@…�…�.
RX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D | …@…�…�.
debian@BeagleBone:~/src/spi_test$

As a remotely related aside: I really like how we have to manually load the kernel driver. I am planning to use the SPI devices from a dedicated baremetal R5F core. From what I see here, I think this indicates that the overlay system has pinmuxed the device correctly and Linux has no idea it’s there …so it will not mess with it.

Second remotely related aside: I am hoping to see BONE-SPI1_0 and BONE-SPI1_1 overlays so I can have two independent SPI channels.

1 Like

Thanks @FredEckert, that worked for me!