BBAI-64 BONE-SPI1_0 overlay development and debug

Hello all,

I decided to try to implement the BONE-SPI1_0 overlay. I have the overlay loading but when I run the spidev_test program I get the following output:

debian@BeagleBone:~/src/spi_test$ sudo ./spidev_test --device /dev/spidev1.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 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  | ................................

Any ideas on what could be wrong?

Here are the details of what I have done so far:

git clone -b v5.10.x-ti-arm64 https://github.com/beagleboard/BeagleBoard-DeviceTrees/

Edited k3-j721e-main.dtsi adding main_spi7 just below main_spi6:

	main_spi6: spi@2160000 {
		compatible = "ti,omap4-mcspi";
		reg = <0x0 0x2160000 0x0 0x400>;
		interrupts = <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>;
		#address-cells = <1>;
		#size-cells = <0>;
		clock-names = "fck";
		clocks = <&k3_clks 272 1>;
		power-domains = <&k3_pds 272 TI_SCI_PD_EXCLUSIVE>;
	};

	main_spi7: spi@2170000 {
                compatible = "ti,omap4-mcspi";
                reg = <0x0 0x2170000 0x0 0x400>;
                interrupts = <GIC_SPI 191 IRQ_TYPE_LEVEL_HIGH>;
                #address-cells = <1>;
                #size-cells = <0>;
                clock-names = "fck";
                clocks = <&k3_clks 273 1>;
                power-domains = <&k3_pds 273 TI_SCI_PD_EXCLUSIVE>;
	};

Edited k3-j721e-beagleboneai64-bone-buses.dtsi adding bone_spi_1 just below bone_spi_0:

bone_spi_0: &main_spi6 {
};

bone_spi_1: &main_spi7 {
};

Created BONE-SPI1_0.dts:

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2023 BeagleBoard.org - https://beagleboard.org/
 *
 * https://elinux.org/Beagleboard:BeagleBone_cape_interface_spec#SPI
 */

/dts-v1/;
/plugin/;

/*
 * Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
 */
&{/chosen} {
        overlays {
                BONE-SPI1_0.kernel = __TIMESTAMP__;
        };
};

&bone_spi_1 {
        /* TODO test with: sudo ./spidev_test -v --device /dev/spidev1.0 */
        pinctrl-names = "default";
                &P9_28_spi_pin /* spi7_cs0 */
                &P9_31_spi_pin /* spi7_clk */
                &P9_30_spi_pin /* spi7_d0 */
                &P9_29_spi_pin /* spi7_d1 */
        >;
        ti,spi-num-cs = <1>;
        ti,pindir-d0-out-d1-in;

        status = "okay";

        spidev@1 {
                symlink = "bone/spi/1.0";
                compatible = "rohm,dh2228fv";
                reg = <0>;      /* CE0 */
                #address-cells = <1>;
                #size-cells = <0>;
                spi-max-frequency = <125000000>;
        };
};

make all
sudo make install

Added new BONE-SPI1_0.dtbo to extlinux.conf

label Linux microSD
    kernel /Image
    append console=ttyS2,115200n8 earlycon=ns16550a,mmio32,0x02800000 root=/dev/mmcblk1p2 ro rootfstype=ext4 rootwait net.ifnames=0 quiet
    fdtdir /
    fdtoverlays /overlays/BONE-SPI0_0.dtbo /overlays/BONE-SPI0_1.dtbo /overlays/BONE-SPI1_0.dtbo
    initrd /initrd.img

rebooted and confirmed spi overlays loaded:

sudo beagle-version | grep UBOOT
UBOOT: Booted Device-Tree:[k3-j721e-beagleboneai64.dts]
UBOOT: Loaded Overlay:[BONE-SPI0_0.kernel]
UBOOT: Loaded Overlay:[BONE-SPI0_1.kernel]
UBOOT: Loaded Overlay:[BONE-SPI1_0.kernel]

loaded kernel driver:

sudo insmod /lib/modules/5.10.153-ti-arm64-r87/kernel/drivers/spi/spidev.ko.xz

tested:

debian@BeagleBone:~/src/spi_test$ ls /dev/bone/
pwm  spi  uart
debian@BeagleBone:~/src/spi_test$ tree /dev/bone/
/dev/bone/
├── pwm
├── spi
│   ├── 0.0 -> ../../spidev0.0
│   ├── 0.1 -> ../../spidev0.1
│   └── 1.0 -> ../../spidev1.0
└── uart
    └── 0 -> ../../ttyS2

3 directories, 4 files

debian@BeagleBone:~/src/spi_test$ sudo ./spidev_test --device /dev/spidev0.0 -v
[sudo] password for debian: 
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$ sudo ./spidev_test --device /dev/spidev0.1 -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$ sudo ./spidev_test --device /dev/spidev1.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 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  | ................................

NOTE1: If i run the test on BONE-SPI0_0 with the loopback unplugged I see:

debian@BeagleBone:~/src/spi_test$ sudo ./spidev_test --device /dev/spidev0.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 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  | ................................

NOTE2: Not sure about the data in structure main_spi7 in the k3-j721e-main.dtsi. I used an educated guess on that.

showpins.pl output:

P9.11                      1 AC23 @11c004 00050007  nom tx rx         m7  gpio0_1
P9.13                      2 AG22 @11c008 00050007  nom tx rx         m7  gpio0_2
P8.17                      3 AF22 @11c00c 00050007  nom tx rx         m7  gpio0_3
P8.18                      4 AJ23 @11c010 00050007  nom tx rx         m7  gpio0_4
P8.22                      5 AH23 @11c014 00050007  nom tx rx         m7  gpio0_5
P8.24                      6 AD20 @11c018 00050007  nom tx rx         m7  gpio0_6
P8.34                      7 AD22 @11c01c 00050007  nom tx rx         m7  gpio0_7
P8.36                      8 AE20 @11c020 00050007  nom tx rx         m7  gpio0_8
P8.38b                     9 AJ20 @11c024 00050007  nom tx rx         m7  gpio0_9
P9.23                     10 AG20 @11c028 00010004  nom tx            m4  spi6_cs1         spi@2160000 (pinmux_P9_23_spi_pin)
P8.37b                    11 AD21 @11c02c 00050007  nom tx rx         m7  gpio0_11
P9.26b                    12 AF24 @11c030 00050007  nom tx rx         m7  gpio0_12
P9.24b                    13 AJ24 @11c034 00050007  nom tx rx         m7  gpio0_13
P8.08                     14 AG24 @11c038 00050007  nom tx rx         m7  gpio0_14
P8.07                     15 AD24 @11c03c 00050007  nom tx rx         m7  gpio0_15
P8.10                     16 AC24 @11c040 00050007  nom tx rx         m7  gpio0_16
P8.09                     17 AE24 @11c044 00050007  nom tx rx         m7  gpio0_17
P9.42b                    19 AJ21 @11c04c 00050007  nom tx rx         m7  gpio0_18
P8.03                     21 AH21 @11c054 00050007  nom tx rx         m7  gpio0_20
P8.35a                    25 AD23 @11c064 00050007  nom tx rx         m7  gpio0_24
P8.33a                    26 AH24 @11c068 00050007  nom tx rx         m7  gpio0_25
P8.32a                    27 AG21 @11c06c 00050007  nom tx rx         m7  gpio0_26
P9.17a                    29 AC21 @11c074 00050007  nom tx rx         m7  gpio0_28
P8.21                     31 AF21 @11c07c 00050007  nom tx rx         m7  gpio0_30
P8.23                     32 AB23 @11c080 00050007  nom tx rx         m7  gpio0_31
P8.31a                    33 AJ25 @11c084 00050007  nom tx rx         m7  gpio0_32
P8.05                     34 AH25 @11c088 00050007  nom tx rx         m7  gpio0_33
P8.06                     35 AG25 @11c08c 00050007  nom tx rx         m7  gpio0_34
P8.25                     36 AH26 @11c090 00050007  nom tx rx         m7  gpio0_35
P9.22a                    39 AC22 @11c09c 00010004  nom tx            m4  spi6_clk         spi@2160000 (pinmux_P9_22_spi_pin)
P9.21a                    40 AJ22 @11c0a0 00010004  nom tx            m4  spi6_d0          spi@2160000 (pinmux_P9_21_spi_pin)
P9.18a                    41 AH22 @11c0a4 00050004  nom tx rx         m4  spi6_d1          spi@2160000 (pinmux_P9_18_spi_pin)
P9.28b                    44 AF28 @11c0b0 00050007  nom tx rx         m7  gpio0_43         spi@2170000 (pinmux_P9_28_spi_pin)
P9.30b                    45 AE28 @11c0b4 00050007  nom tx rx         m7  gpio0_44         spi@2170000 (pinmux_P9_30_spi_pin)
P9.12                     46 AE27 @11c0b8 00050007  nom tx rx         m7  gpio0_45
P9.27a                    47 AD26 @11c0bc 00050007  nom tx rx         m7  gpio0_46
P9.15                     48 AD25 @11c0c0 00050007  nom tx rx         m7  gpio0_47
P8.04                     49 AC29 @11c0c4 00050007  nom tx rx         m7  gpio0_48
P9.33b                    51 AC28 @11c0cc 00050007  nom tx rx         m7  gpio0_50
P8.26                     52 AC27 @11c0d0 00050007  nom tx rx         m7  gpio0_51
P9.31b                    53 AB26 @11c0d4 00050007  nom tx rx         m7  gpio0_52         spi@2170000 (pinmux_P9_31_spi_pin)
P9.29b                    54 AB25 @11c0d8 00050007  nom tx rx         m7  gpio0_53         spi@2170000 (pinmux_P9_29_spi_pin)
P9.39b                    55 AJ28 @11c0dc 00050007  nom tx rx         m7  gpio0_54
P9.35b                    56 AH27 @11c0e0 00050007  nom tx rx         m7  gpio0_55
P9.36b                    57 AH29 @11c0e4 00050007  nom tx rx         m7  gpio0_56
P9.37b                    58 AG28 @11c0e8 00050007  nom tx rx         m7  gpio0_57
P9.38b                    59 AG27 @11c0ec 00050007  nom tx rx         m7  gpio0_58
P8.12                     60 AH28 @11c0f0 00050007  nom tx rx         m7  gpio0_59
P8.11                     61 AB24 @11c0f4 00050007  nom tx rx         m7  gpio0_60
P8.15                     62 AB29 @11c0f8 00050007  nom tx rx         m7  gpio0_61
P8.16                     63 AB28 @11c0fc 00050007  nom tx rx         m7  gpio0_62
P8.31b                    64 AE29 @11c100 00050007  nom tx rx         m7  gpio0_63
P8.32b                    65 AD28 @11c104 00050007  nom tx rx         m7  gpio0_64
P8.43                     66 AD27 @11c108 00050007  nom tx rx         m7  gpio0_65
P8.44                     67 AC25 @11c10c 00050007  nom tx rx         m7  gpio0_66
P8.41                     68 AD29 @11c110 00050007  nom tx rx         m7  gpio0_67
P8.42                     69 AB27 @11c114 00050007  nom tx rx         m7  gpio0_68
P8.39                     70 AC26 @11c118 00050007  nom tx rx         m7  gpio0_69
P8.40                     71 AA24 @11c11c 00050007  nom tx rx         m7  gpio0_70
P8.27                     72 AA28 @11c120 00050007  nom tx rx         m7  gpio0_71
P8.28                     73  Y24 @11c124 00050007  nom tx rx         m7  gpio0_72
P8.29                     74 AA25 @11c128 00050007  nom tx rx         m7  gpio0_73
P8.30                     75 AG26 @11c12c 00050007  nom tx rx         m7  gpio0_74
P8.14                     76 AF27 @11c130 00050007  nom tx rx         m7  gpio0_75
P8.20                     77 AF26 @11c134 00050007  nom tx rx         m7  gpio0_76
P9.20b                    78 AE25 @11c138 00050007  nom tx rx         m7  gpio0_77
P9.19b                    79 AF29 @11c13c 00050007  nom tx rx         m7  gpio0_78
P8.45                     80 AG29 @11c140 00050007  nom tx rx         m7  gpio0_79
P8.46                     81  Y25 @11c144 00050007  nom tx rx         m7  gpio0_80
P9.40b                    82 AA26 @11c148 00050007  nom tx rx         m7  gpio0_81
P8.19                     89  V29 @11c164 00050007  nom tx rx         m7  gpio0_88
P8.13                     90  V27 @11c168 00050007  nom tx rx         m7  gpio0_89
P9.21b                    91  U28 @11c16c 00050007  nom tx rx         m7  gpio0_90         spi@2160000 (pinmux_P9_21_spi_pin)
P9.22b                    92  U29 @11c170 00050007  nom tx rx         m7  gpio0_91         spi@2160000 (pinmux_P9_22_spi_pin)
P9.14                     94  U27 @11c178 00050007  nom tx rx         m7  gpio0_93
P9.16                     95  U24 @11c17c 00050007  nom tx rx         m7  gpio0_94
P9.25b                   105  W26 @11c1a4 00050007  nom tx rx         m7  gpio0_104
P8.38a                   106  Y29 @11c1a8 00050007  nom tx rx         m7  gpio0_105
P8.37a                   107  Y27 @11c1ac 00050007  nom tx rx         m7  gpio0_106
P8.33b                   112  AA2 @11c1c0 00050007  nom tx rx         m7  gpio0_111
P9.17b                   116  AA3 @11c1d0 00050007  nom tx rx         m7  gpio0_115
P8.35b                   117   Y3 @11c1d4 00050007  nom tx rx         m7  gpio0_116
P9.26a                   119   Y1 @11c1dc 00050007  nom tx rx         m7  gpio0_118
P9.24a                   120   Y5 @11c1e0 00050007  nom tx rx         m7  gpio0_119
P9.18b                   121   Y2 @11c1e4 00050007  nom tx rx         m7  gpio0_120        spi@2160000 (pinmux_P9_18_spi_pin)
P9.42a                   124  AC2 @11c1f0 00050007  nom tx rx         m7  gpio0_123
P9.27b                   125  AB1 @11c1f4 00050007  nom tx rx         m7  gpio0_124
P9.25a                   128  AC4 @11c200 00050007  nom tx rx         m7  gpio0_127
P9.41                    129  AD5 @11c204 00050007  nom tx rx         m7  gpio1_0
P9.19a                   130   W5 @11c208 00050007  nom tx rx         m7  gpio1_1
P9.20a                   131   W6 @11c20c 00050007  nom tx rx         m7  gpio1_2
P9.28a                   140   U2 @11c230 00010006  nom tx            m6  spi7_cs0         spi@2170000 (pinmux_P9_28_spi_pin)
P9.31a                   141   U3 @11c234 00010006  nom tx            m6  spi7_clk         spi@2170000 (pinmux_P9_31_spi_pin)
P9.30a                   142   V6 @11c238 00010006  nom tx            m6  spi7_d0          spi@2170000 (pinmux_P9_30_spi_pin)
P9.29a                   143   V5 @11c23c 00010006  nom tx            m6  spi7_d1          spi@2170000 (pinmux_P9_29_spi_pin)

EDIT: Noticed that spi6_cs0 is not in the listing. Maybe I have an old showpins script.

Have you added pull-up resistors to the I2C lines ?

Is this something I can do in the device tree overlay?

I am wanting to use three off-the-shelf Mikro SPI devices with an off-the-shelf MikroBUS cape. It now seems like this may not be possible. SPI6 CS0 works fine in cape header “host 3” but, CS1 is not brought out to a header. SPI7 is brought out to cape headers “host 1”, “host 2”, and “host 4” but from what I can tell, it looks like CS1 for SPI7 is not brought out to a pin.

NOTE: For header “host 3” on the MikroBUS cape 0 ohm resistors for host 3 must be moved from UART to SPI for SPI6 CS0 (using BONE-SPI0_0) to work. See MikroBUS cape “host 3” documented here for details.

My desired setup is:

  1. Click DAC 13 on BONE-SPI0_0 (cape host3)
  2. Click DAC 13 on BONE-SPI1_0 (cape host1)
  3. Click ADC 18 on BONE-SPI1_1 (cape host2)

OK ignore my previous post, for some reason I thought you were using I2C.

SPI6 CS1 is on P9-23 as far as I can see. But no SPI7 CS1

There are 4 CS lines for SPI6, can’t you just use all of those ?

I suppose I can work with that but, I won’t be able to use the off-the-shelf MikroBUS cape.

I still need to get SPI7 CS0 working.

Setup would be:

  1. DAC on BONE-SPI0_0
  2. DAC on BONE-SPI1_0
  3. ADC on BONE-SPI0_1

While the BBAI-64 may have the same cape dimensions, the same pin functionality can not be assumed.

Could you use GPIO pins as chip selects ? Would mean enabling the CS in code before reading/writing the SPI bus. That way you may still be able to use the cape.

Or you could always do a custom cape with the correct pinout. That will probably cost a little more than the standard cape though.

Could you use GPIO pins as chip selects ? Would mean enabling the CS in code before reading/writing the SPI bus. That way you may still be able to use the cape.

Good point. This could likely work.

Definitely need BONE-SPI0_0 and BONE-SPI1_0 outputting data at the same time.

Looking to have simultaneous update on two DAC channels.

I think I see the problem:

P9.18a                    41 AH22 @11c0a4 00050004  nom tx rx         m4  spi6_d1          spi@2160000 (pinmux_P9_18_spi_pin)
P9.29a                   143   V5 @11c23c 00010006  nom tx            m6  spi7_d1          spi@2170000 (pinmux_P9_29_spi_pin)

Will try to fix it later tonight.

Will also try to figure out spi6_cs0:

P9.17a                    29 AC21 @11c074 00050007  nom tx rx         m7  gpio0_28

Fix to get SPI7 working:

File: k3-j721e-beagleboneai64-bone-buses.dtsi
Line: 1132

-       BONE_PIN(P9_29, spi,       P9_29A(PIN_OUTPUT, 6) P9_29B(PIN_INPUT, 7))  /* spi7_d1 */
+       BONE_PIN(P9_29, spi,       P9_29A(PIN_INPUT, 6) P9_29B(PIN_INPUT, 7))   /* spi7_d1 (tested PIN_INPUT) */

Initial Test looks good:

debian@BeagleBone:~/src/spi_test$ sudo ./spidev_test --device /dev/spidev1.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  | ......@....�..................�.

@benedict.hewson thank you for all the help.

@RobertCNelson would it help if I clean this up and get it over to you?

2 Likes

Awesome job @FredEckert , just do a pull request to: Files · v5.10.x-ti-unified · BeagleBoard.org / BeagleBoard-DeviceTrees · GitLab and it’ll get merged asap…

I’ve been Merging in TI’s 8.06’s kernel changes, so it’ll get pushed out today…

Regards,

1 Like