Configuring SPI pins in Beaglebone AI

Hi,
I am working on Beaglebone AI with the Desktop version and I am trying to interface SPI Hardware with BB AI. I have flashed the latest image from this link (https://rcn-ee.net/rootfs/bb.org/testing/2021-11-29/buster-lxqt/am57xx-debian-10.11-lxqt-armhf-2021-11-29-4gb.img.xz) and edited the uEnv.txt to change the dtb to am5729-beagleboneai-roboticscape.dtb. Thereby in /dev/ folder spidev1.0 and spidev1.1 is available and Using config-pin, I configured Pin P9.28 to P9.31 for SPI. SPI 1.0 is getting open, but writing and reading into SPI is not happening. Please do the needful.

Few BB-AI board information:

root@beaglebone:~# uname -a
Linux beaglebone 4.19.94-ti-r68 #1buster SMP PREEMPT Thu Sep 16 15:32:31 UTC 2021 armv7l GNU/Linux

root@beaglebone:~# sudo /opt/scripts/tools/version.sh
git:/opt/scripts/:[1583f354594aabfaff08dee2a4aabdfe61433024]
model:[BeagleBoard.org_BeagleBone_AI]
dogtag:[BeagleBoard.org Debian Buster LXQt Image 2021-11-29]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot SPL 2021.04-g702ea30b (Nov 19 2021 - 00:11:11 +0000)]:[location: dd MBR]
UBOOT: Booted Device-Tree:[am5729-beagleboneai-roboticscape.dts]
UBOOT: Loaded Overlay:[BBORG_FAN-A000.kernel]
kernel:[4.19.94-ti-r68]
nodejs:[v10.24.0]
device-tree-override:[dtb=am5729-beagleboneai-roboticscape.dtb]
/boot/uEnv.txt Settings:
uboot_overlay_options:[enable_uboot_overlays=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]
pkg:[bb-cape-overlays]:[4.14.20210821.0-0~buster+20210821]
pkg:[bb-customizations]:[1.20210810.1-0~buster+20210810]
pkg:[bb-usb-gadgets]:[1.20211012.0-0~buster+20211012]
pkg:[bb-wl18xx-firmware]:[1.20210922.2-0~buster+20211007]
pkg:[kmod]:[26-1]
pkg:[librobotcontrol]:[1.0.5-git20200715.0-0~buster+20200716]
pkg:[firmware-ti-connectivity]:[20190717-2rcnee1~buster+20200305]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal input bluetooth netdev gpio admin tisdk weston-launch cloud9ide]
cmdline:[console=ttyS0,115200n8 root=/dev/mmcblk1p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 rng_core.default_quality=100 quiet]
dmesg | grep remote
[ 20.952934] remoteproc remoteproc0: 58820000.ipu is available
[ 20.955997] remoteproc remoteproc0: Direct firmware load for dra7-ipu1-fw.xem4 failed with error -2
[ 20.956017] remoteproc remoteproc0: powering up 58820000.ipu
[ 20.956061] remoteproc remoteproc0: Direct firmware load for dra7-ipu1-fw.xem4 failed with error -2
[ 20.956073] remoteproc remoteproc0: request_firmware failed: -2
[ 20.983450] remoteproc remoteproc1: 55020000.ipu is available
[ 21.013618] remoteproc remoteproc2: 40800000.dsp is available
[ 21.014491] remoteproc remoteproc3: 41000000.dsp is available
[ 21.025969] remoteproc remoteproc1: powering up 55020000.ipu
[ 21.025993] remoteproc remoteproc1: Booting fw image dra7-ipu2-fw.xem4, size 3751356
[ 21.026257] remoteproc remoteproc2: Direct firmware load for dra7-dsp1-fw.xe66 failed with error -2
[ 21.026283] remoteproc remoteproc2: powering up 40800000.dsp
[ 21.026351] remoteproc remoteproc2: Direct firmware load for dra7-dsp1-fw.xe66 failed with error -2
[ 21.026366] remoteproc remoteproc2: request_firmware failed: -2
[ 21.038552] remoteproc remoteproc3: Direct firmware load for dra7-dsp2-fw.xe66 failed with error -2
[ 21.038673] remoteproc remoteproc3: powering up 41000000.dsp
[ 21.038717] remoteproc remoteproc3: Direct firmware load for dra7-dsp2-fw.xe66 failed with error -2
[ 21.038730] remoteproc remoteproc3: request_firmware failed: -2
[ 21.304562] remoteproc remoteproc1: registered virtio0 (type 7)
[ 21.304577] remoteproc remoteproc1: remote processor 55020000.ipu is now up
[ 31.309416] remoteproc remoteproc1: crash detected in 55020000.ipu: type watchdog
[ 31.317024] remoteproc remoteproc1: crash detected in 55020000.ipu: type watchdog
[ 31.324681] remoteproc remoteproc1: handling crash #1 in 55020000.ipu
[ 31.331579] remoteproc remoteproc1: recovering 55020000.ipu
[ 31.358121] remoteproc remoteproc1: stopped remote processor 55020000.ipu
[ 31.358136] remoteproc remoteproc1: powering up 55020000.ipu
[ 31.373879] remoteproc remoteproc1: Booting fw image dra7-ipu2-fw.xem4, size 3751356
[ 31.467380] remoteproc remoteproc1: registered virtio0 (type 7)
[ 31.467394] remoteproc remoteproc1: remote processor 55020000.ipu is now up
[ 38.588851] remoteproc remoteproc4: 4b234000.pru is available
[ 38.589463] remoteproc remoteproc5: 4b238000.pru is available
[ 38.591880] remoteproc remoteproc6: releasing 4b2b4000.pru
[ 38.592065] remoteproc remoteproc6: releasing 4b2b8000.pru
[ 38.717818] remoteproc remoteproc6: releasing 4b2b4000.pru
[ 38.718351] remoteproc remoteproc6: releasing 4b2b8000.pru
[ 38.724092] remoteproc remoteproc6: releasing 4b2b4000.pru
[ 38.724641] remoteproc remoteproc6: releasing 4b2b8000.pru
dmesg | grep pru
[ 36.227007] pruss_uio_shmem 4b200000.pruss_shmem: Allocating gdev
[ 36.227022] pruss_uio_shmem 4b200000.pruss_shmem: Allocating info
[ 36.239131] pruss_uio_shmem 4b200000.pruss_shmem: Requesting resource
[ 36.239164] pruss_uio_shmem 4b200000.pruss_shmem: Mapping resource
[ 36.239205] pruss_uio_shmem 4b200000.pruss_shmem: Registering with uio driver
[ 36.239521] pruss_uio_shmem 4b200000.pruss_shmem: Saving platform data
[ 36.241661] pruss_uio_shmem 4b280000.pruss_shmem: Allocating gdev
[ 36.241671] pruss_uio_shmem 4b280000.pruss_shmem: Allocating info
[ 36.241681] pruss_uio_shmem 4b280000.pruss_shmem: Requesting resource
[ 36.241703] pruss_uio_shmem 4b280000.pruss_shmem: Mapping resource
[ 36.241721] pruss_uio_shmem 4b280000.pruss_shmem: Registering with uio driver
[ 36.242013] pruss_uio_shmem 4b280000.pruss_shmem: Saving platform data
[ 38.509299] pruss 4b280000.pruss: platform_get_irq_byname failed for host8 : -6
[ 38.588851] remoteproc remoteproc4: 4b234000.pru is available
[ 38.588962] pru-rproc 4b234000.pru: PRU rproc node pru@4b234000 probed successfully
[ 38.589463] remoteproc remoteproc5: 4b238000.pru is available
[ 38.589554] pru-rproc 4b238000.pru: PRU rproc node pru@4b238000 probed successfully
[ 38.591880] remoteproc remoteproc6: releasing 4b2b4000.pru
[ 38.592065] remoteproc remoteproc6: releasing 4b2b8000.pru
[ 38.717818] remoteproc remoteproc6: releasing 4b2b4000.pru
[ 38.718351] remoteproc remoteproc6: releasing 4b2b8000.pru
[ 38.724092] remoteproc remoteproc6: releasing 4b2b4000.pru
[ 38.724641] remoteproc remoteproc6: releasing 4b2b8000.pru
dmesg | grep pinctrl-single
[ 1.207172] pinctrl-single 4a003400.pinmux: 282 pins, size 1128
[ 1.576805] pinctrl-single 4a003400.pinmux: pin PIN231 already requested by 44000000.ocp:P8_03_pinmux; cannot claim for rcleds
[ 1.588285] pinctrl-single 4a003400.pinmux: pin-231 (rcleds) status -22
[ 1.594958] pinctrl-single 4a003400.pinmux: could not request pin 231 (PIN231) from group cape_pins_rc on device pinctrl-single
dmesg | grep gpio-of-helper
[ 1.219301] gpio-of-helper 44000000.ocp:cape-universal: ready
lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END

Thanks and Regards,
Mahaboob

1 Like

Hello @Mahaboob ,

Seth here. I think that config-pin does not work on the BBAI. I could be wrong currently but last I recall, config-pin did not work on the am5729.

Also…if you have an overlay that enables the SPI devices on the AI, one would think, me for instance, using them would be accessible.

I tried to use GPIO on the AI before today. I was successful for a while. Things changed. I also got PWM to work but things changed again.

So, where I stand…

  • config-pin is not a solution from what I understand

  • If you want to show off the current set up of your .dts file for the RoboticsCape, please do

This .dts will give some insight as to how we can further go about this idea.

If you are only looking to get SPI working on the AI, I can try and then return service.

Seth

P.S. I found this idea online a while back: BeagleBone AI P9 Header - Google Sheets and there is also a P8 Header I found reasonably set up!

Hello Again,

I see here, BeagleBoard-DeviceTrees/bbai-bone-buses.dtsi at 97a6f0daa9eab09633a2064f68a53b107d6e3968 · lorforlinux/BeagleBoard-DeviceTrees · GitHub , that the SPI (0, 1) are set up but that is in kernel 5.10.x which is the kernel I am using.

I will search the RobiticsCape overlay in the 4.19.x kernel and get back to you.

Seth

P.S. So, CS is not available on the .dtsi I found for the roboticsCape (so far). We may need to type it up, i.e. here is that link which shows MOSI/MISO and SSI (I do not know what SSI is as of now): BeagleBoard-DeviceTrees/am335x-roboticscape.dtsi at v4.19.x-ti-overlays · beagleboard/BeagleBoard-DeviceTrees · GitHub

Hello @Seth,

Thanks for the replay. In existing flashed image am5729-beagleboneai-roboticscape.dts file consists of below SPI lines.

&dra7_pmx_core {
	cape_pins_rc: cape_pins_rc {
		pinctrl-single,pins = <
			.
			.
			.
			DRA7XX_CORE_IOPAD(0x37CC, PIN_INPUT | MUX_MODE14) /* B24: P9.17a: spi2_cs0.gpio7_17 */
			DRA7XX_CORE_IOPAD(0x36B8, PIN_INPUT_PULLUP | SLEWCONTROL | MUX_MODE10) /* F12: P9.17b: mcasp1_axr1.i2c5_scl - I2C1_SCL */
			DRA7XX_CORE_IOPAD(0x37C8, PIN_INPUT | MUX_MODE14) /* G17: P9.18a: spi2_d0.gpio7_16 */
			DRA7XX_CORE_IOPAD(0x36B4, PIN_INPUT_PULLUP | SLEWCONTROL | MUX_MODE10) /* G12: P9.18b: mcasp1_axr0.i2c5_sda - I2C1_SDA */
			DRA7XX_CORE_IOPAD(0x3440, PIN_INPUT | MUX_MODE7) /* R6: P9.19a: gpmc_a0.i2c4_scl - I2C2_SCL */
			DRA7XX_CORE_IOPAD(0x357C, PIN_INPUT | MUX_MODE12 ) /* F4: P9.19b: vin2a_d5.pr1_pru1_gpi2 */
			DRA7XX_CORE_IOPAD(0x3444, PIN_INPUT | MUX_MODE7) /* T9: P9.20a: gpmc_a1.i2c4_sda - I2C2_SDA */
			DRA7XX_CORE_IOPAD(0x3578, PIN_INPUT | MUX_MODE12) /* D2: P9.20b: vin2a_d4.pr1_pru1_gpi1 */
			DRA7XX_CORE_IOPAD(0x34F0, MUX_MODE15) /* AF8: P9.21a: vin1a_vsync0.off */
			DRA7XX_CORE_IOPAD(0x37C4, PIN_OUTPUT | MUX_MODE1) /* B22: P9.21b: spi2_d1.uart3_txd - UART2_TX */
			DRA7XX_CORE_IOPAD(0x369C, MUX_MODE15) /* B26: P9.22a: xref_clk2.off */
			DRA7XX_CORE_IOPAD(0x37C0, PIN_INPUT | MUX_MODE1) /* A26: P9.22b: spi2_sclk.uart3_rxd - UART2_RX */
			DRA7XX_CORE_IOPAD(0x37B4, PIN_OUTPUT | MUX_MODE14) /* A22: P9.23: spi1_cs1.gpio7_11 - SPI1_SS2 */
			DRA7XX_CORE_IOPAD(0x368C, PIN_OUTPUT | MUX_MODE3) /* F20: P9.24: gpio6_15.uart10_txd - UART1_TX */
			DRA7XX_CORE_IOPAD(0x3694, PIN_INPUT | MUX_MODE14) /* D18: P9.25: xref_clk0.gpio6_17 - IMU_INT */
			DRA7XX_CORE_IOPAD(0x3688, PIN_INPUT | MUX_MODE3) /* E21: P9.26a: gpio6_14.uart10_rxd - UART1_RX */
			DRA7XX_CORE_IOPAD(0x3544, MUX_MODE15) /* AE2: P9.26b: vin1a_d20.off */
			DRA7XX_CORE_IOPAD(0x35A0, PIN_INPUT | MUX_MODE10) /* C3: P9.27a: vin2a_d14.eQEP3B_in - QEP0B */
			DRA7XX_CORE_IOPAD(0x36B0, MUX_MODE15) /* J14: P9.27b: mcasp1_fsr.off */
			DRA7XX_CORE_IOPAD(0x36E0, PIN_OUTPUT | MUX_MODE3) /* A12: P9.28: mcasp1_axr11.spi3_cs0 - SPI1_SS1 */
			DRA7XX_CORE_IOPAD(0x36D8, PIN_INPUT | MUX_MODE3) /* A11: P9.29a: mcasp1_axr9.spi3_d1 - SPI1_MISO */
			DRA7XX_CORE_IOPAD(0x36A8, MUX_MODE15) /* D14: P9.29b: mcasp1_fsx.off */
			DRA7XX_CORE_IOPAD(0x36DC, PIN_OUTPUT | MUX_MODE3) /* B13: P9.30: mcasp1_axr10.spi3_d0 - SPI1_MOSI */
			DRA7XX_CORE_IOPAD(0x36D4, PIN_OUTPUT | MUX_MODE3) /* B12: P9.31a: mcasp1_axr8.spi3_sclk - SPI1_SCK */
			.
			.
			.
		>;
	};
};


&mcspi1 {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	cs-gpios = <0>, <&gpio7 11 0>;

	channel@0 {
		#address-cells = <1>;
		#size-cells = <0>;
		compatible = "spidev";
		reg = <0>;
		spi-max-frequency = <24000000>;
	};

	channel@1 {
		#address-cells = <1>;
		#size-cells = <0>;
		compatible = "spidev";
		reg = <1>;
		spi-max-frequency = <24000000>;
	};
};
1 Like

Hello,

You have blown my mind, man. I cannot read the highlighted text in your answer.

Anyway…so. Wozzers. I have the BBAI w/ a incorrect image then. Anyway, um, find a spidev lib. to use.

Seth

P.S. Or if you are daring, write it up! I cannot write it up completely to help you. I am still programming hardware that I made up or that ends poorly. But! Let me look around online for a spidev lib. and I may return service.

@Mahaboob ,

Check this popular one out: spidev · PyPI .

Seth

Hi @Seth

Once again thanks for the replay. I used spidev · PyPI library and when writing data into the SPI interface, Actually the data written is zero. The same case happened with my own C library for SPI, Writing, and reading is also zero.
I verified the SPI hardware by interfacing with BBB and it is working fine with my C library. SPI Settings used are SPI_BUS 2, SPI_DEVICE 0, SPI_MODE 1, SPI_BITSPERWORD 8, SPI_SPEED 1000000, SPI_LSBSETTING 0, and SPI_DELAY 0.
It seems I need to revisit the BB-AI device tree again and I need your valuable inputs on this. Please do the needful.

Mahaboob

Hello @Mahaboob ,

So, can you please tell me which CS, CLK, MOSI, MISO pins are in use, and if you are powering this device separately?

Seth

P.S. I can then look up ideas and research the way to go about it.

Hello @Seth

In BB-AI, P9.28 to P9.31 is used.
P9.28 : mcasp1_axr11.spi3_cs0 - SPI1_SS1
P9.29a: mcasp1_axr9.spi3_d1 - SPI1_MISO
P9.30 : mcasp1_axr10.spi3_d0 - SPI1_MOSI
P9.31a: mcasp1_axr8.spi3_sclk - SPI1_SCK

SPI Hardware is powered(3.3V and GND) from BB-AI itself. I have tried SPI Hardware by powering by 5V too, because it is capable(Min Voltage - 2V to Max Voltage - 5.5V).

1 Like

Okay…

So, me, I think that the CS, CLK, and MOSI/MISO have to be declared. I have a board somewhere w/ the SPI lines being used on it. I will track it down and get the recommended .dts file being used as a .dtbo in the uEnv.txt file in the /boot dir.

Then, I can figure out exactly what we need to be looking through when trying to promote the SPI devices in /dev/spidev0.1 or /spidev1.0 or /spidev1.1 or /spidev0.0.

Please excuse my elongated ideas of understanding exactly how I should be helping you.

Seth

P.S. @Mahaboob , I also think that w/out the proper understanding, we may both be having to dive deeper than expected due to the lack of ideas out there for this specific SPI routine. Maybe another person will jump in before I can have time to figure things out but until then, I will do what I said I would do. I can flash a new image to the AI too. Who knows what is available in the form of .dts file these days?

@Mahaboob ,

Look here: BeagleBoard-DeviceTrees/BBAI-SPI0_1.dts at v4.19.x-ti-overlays · beagleboard/BeagleBoard-DeviceTrees · GitHub

Do you see anything of interest?

Seth

P.S. I am currently researching the BeagleBoard.org ideas and coming to a conclusion: BeagleBoard-DeviceTrees/bbai-bone-buses.dtsi at ffcabc2269d70f1057a9689bdb80a3302746dc71 · beagleboard/BeagleBoard-DeviceTrees · GitHub .

There are many files associated w/ this specific instance. Hopefully, we can configure it correctly one day.

Hello @Mahaboob ,

I am sorry. My BBAI is not booting w/ that specific .dtb installed in /boot/uEnv.txt.

I tried kernel 4.19.x and kernel 5.10.x. Both are disabling my board so far when I add the .dtb for the roboticsCape into /boot/uEnv.txt.

Seth

P.S. I will keep trying but this may be getting phased out for some reason.

Okay…so this is what is going on when compiling the .dtb in BeagleBoard-DeviceTrees w/ make:


  DTC     src/arm/am5729-beagleboneai-roboticscape.dtb
src/arm/am5729-beagleboneai-roboticscape.dtb: Warning (graph_child_address): /ocp/dss@58000000/ports: graph node has single child node 'port', #address-cells/#size-cells are not necessary
src/arm/am5729-beagleboneai-roboticscape.dtb: Warning (graph_port): /ocp/dss@58000000/ports/port: graph node unit address error, expected "0"

So, we need to alter this file or these specific files. This may be causing some issues w/ what the .org has created so far to help people jump on the right steps.

Hi @Seth,

That’s okay, I had looked at the same specific .dts file earlier. Anyway, I am also trying to recompile the am5729-beagleboneai-roboticscape.dts file with the SPI.

Thanks and Regards,
Mahaboob

Hello…I have not found out the exact way to configure the am5729-beagleboneai-roboticscape.dtb file just yet.

Anyway…I am sure this will be a long process. So, if you find something, please reply. Once I figure out more info. and ideas, I will report back.

Seth

1 Like

Hello @Mahaboob ,

I think the file in /lib/firmware/ is there already and currently works w/ the 4.19.x kernel.

Seth

P.S. I do not think you need the .dtb listed in the /boot/uEnv.txt file. There was something a while back w/ the .org and GSoC. It was, to my knowledge, a working rendition of people congregating to make the source work, Capes and other tools, on the BBAI. They may have skipped the necessary steps for the RoboticsCape though. Sadly, I am not a member of GSoC or the .org. So, I have limited info. on what they do w/ their source and boards.

Hi @Seth

When I flash the latest BB-AI(LXQT version) image from this link (https://rcn-ee.net/rootfs/bb.org/testing/2021-11-29/buster-lxqt/am57xx-debian-10.11-lxqt-armhf-2021-11-29-4gb.img.xz), SPI was not available in the /dev/ folder. Even BB-SPIDEV0-00A0.dtbo and BB-SPIDEV1-00A0.dtbo is available in /lib/firmware.
After editing the dtb = am5729-beagleboneai-roboticscape.dtb in /boot/uEnv.txt file, SPI is available in /dev/ folder as spidev1.0 and spidev1.1. I am trying and need to enable the SPI bus in LXQT version of AI.

Hello and Oh,

Okay…so. Here are ideas on my end of things outside of you having SPI working in a Linux file/directory system:


debian@beaglebone:~/BeagleBoard-DeviceTrees/src/arm/overlays$ ls
AM335X-PRU-RPROC-4-19-TI-00A0.dtbo  BB-BONE-eMMC1-01-00A0.dtbo  BBAI-PR2_UART0.dtbo      BBAI-PRU_eCAP.dtbo  BBB-eCAP2.dtbo         BONE-CAN0.dtbo       BONE-PWM0.dtbo         BONE-TIMER_PWM_3.dtbo  BONE-eQEP0.dtbo
AM335X-PRU-RPROC-4-19-TI-00A0.dts   BB-BONE-eMMC1-01-00A0.dts   BBAI-PR2_UART0.dts       BBAI-PRU_eCAP.dts   BBB-eCAP2.dts          BONE-CAN0.dts        BONE-PWM0.dts          BONE-TIMER_PWM_3.dts   BONE-eQEP0.dts
BB-ADC-00A0.dtbo                    BB-CAPE-DISP-CT4-00A0.dtbo  BBAI-PRUIN_PRU1_0.dtbo   BBAI-SPI0_1.dtbo    BBORG_COMMS-00A2.dtbo  BONE-CAN1.dtbo       BONE-PWM1.dtbo         BONE-TIMER_PWM_4.dtbo  BONE-eQEP1.dtbo
BB-ADC-00A0.dts                     BB-CAPE-DISP-CT4-00A0.dts   BBAI-PRUIN_PRU1_0.dts    BBAI-SPI0_1.dts     BBORG_COMMS-00A2.dts   BONE-CAN1.dts        BONE-PWM1.dts          BONE-TIMER_PWM_4.dts   BONE-eQEP1.dts
BB-BBBW-WL1835-00A0.dtbo            BB-CTAG-SW-8CH-00A0.dtbo    BBAI-PRUIN_PRU1_1.dtbo   BBAI-eCAP1.dtbo     BBORG_FAN-A000.dtbo    BONE-I2C1.dtbo       BONE-PWM2.dtbo         BONE-TIMER_PWM_5.dtbo  BONE-eQEP2.dtbo
BB-BBBW-WL1835-00A0.dts             BB-CTAG-SW-8CH-00A0.dts     BBAI-PRUIN_PRU1_1.dts    BBAI-eCAP1.dts      BBORG_FAN-A000.dts     BONE-I2C1.dts        BONE-PWM2.dts          BONE-TIMER_PWM_5.dts   BONE-eQEP2.dts
BB-BBGG-WL1835-00A0.dtbo            BB-HDMI-TDA998x-00A0.dtbo   BBAI-PRUIN_PRU2_0.dtbo   BBAI-eCAP2.dtbo     BBORG_LOAD-00A2.dtbo   BONE-I2C2.dtbo       BONE-SPI0_0.dtbo       BONE-UART1.dtbo        BONE-eQEP2A.dtbo
BB-BBGG-WL1835-00A0.dts             BB-HDMI-TDA998x-00A0.dts    BBAI-PRUIN_PRU2_0.dts    BBAI-eCAP2.dts      BBORG_LOAD-00A2.dts    BONE-I2C2.dts        BONE-SPI0_0.dts        BONE-UART1.dts         BONE-eQEP2A.dts
BB-BBGW-WL1835-00A0.dtbo            BB-SPIDEV0-00A0.dtbo        BBAI-PRUIN_PRU2_1.dtbo   BBAI-eCAP2A.dtbo    BBORG_MOTOR-00A2.dtbo  BONE-I2C2A.dtbo      BONE-SPI1_0.dtbo       BONE-UART2.dtbo        BW-ICE40Cape-00A0.dtbo
BB-BBGW-WL1835-00A0.dts             BB-SPIDEV0-00A0.dts         BBAI-PRUIN_PRU2_1.dts    BBAI-eCAP2A.dts     BBORG_MOTOR-00A2.dts   BONE-I2C2A.dts       BONE-SPI1_0.dts        BONE-UART2.dts         BW-ICE40Cape-00A0.dts
BB-BONE-4D4C-01-00A1.dtbo           BB-SPIDEV1-00A0.dtbo        BBAI-PRUOUT_PRU1_0.dtbo  BBAI-eCAP3.dtbo     BBORG_RELAY-00A2.dtbo  BONE-I2C3.dtbo       BONE-SPI1_1.dtbo       BONE-UART3.dtbo        BW-ICE40Cape-00A0_LKM.dtbo
BB-BONE-4D4C-01-00A1.dts            BB-SPIDEV1-00A0.dts         BBAI-PRUOUT_PRU1_0.dts   BBAI-eCAP3.dts      BBORG_RELAY-00A2.dts   BONE-I2C3.dts        BONE-SPI1_1.dts        BONE-UART3.dts         BW-ICE40Cape-00A0_LKM.dts
BB-BONE-4D5R-01-00A1.dtbo           BBAI-4D4C-00A1.dtbo         BBAI-PRUOUT_PRU1_1.dtbo  BBAI-eCAP3A.dtbo    BBORG_SERVO-00A2.dtbo  BONE-LED_P8_03.dtbo  BONE-TIMER_PWM_0.dtbo  BONE-UART4.dtbo        M-BB-BBG-00A0.dtbo
BB-BONE-4D5R-01-00A1.dts            BBAI-4D4C-00A1.dts          BBAI-PRUOUT_PRU1_1.dts   BBAI-eCAP3A.dts     BBORG_SERVO-00A2.dts   BONE-LED_P8_03.dts   BONE-TIMER_PWM_0.dts   BONE-UART4.dts         M-BB-BBG-00A0.dts
BB-BONE-LCD4-01-00A1.dtbo           BBAI-AUDI-02-00A0.dtbo      BBAI-PRUOUT_PRU2_0.dtbo  BBB-PRU_eCAP.dtbo   BONE-ADC.dtbo          BONE-LED_P9_11.dtbo  BONE-TIMER_PWM_1.dtbo  BONE-UART5.dtbo        M-BB-BBGG-00A0.dtbo
BB-BONE-LCD4-01-00A1.dts            BBAI-AUDI-02-00A0.dts       BBAI-PRUOUT_PRU2_0.dts   BBB-PRU_eCAP.dts    BONE-ADC.dts           BONE-LED_P9_11.dts   BONE-TIMER_PWM_1.dts   BONE-UART5.dts         M-BB-BBGG-00A0.dts
BB-BONE-NH7C-01-A0.dtbo             BBAI-PR1_UART0.dtbo         BBAI-PRUOUT_PRU2_1.dtbo  BBB-eCAP0.dtbo      BONE-BACKLIGHT.dtbo    BONE-PRU_eCAP.dtbo   BONE-TIMER_PWM_2.dtbo  BONE-eMMC.dtbo         Makefile
BB-BONE-NH7C-01-A0.dts              BBAI-PR1_UART0.dts          BBAI-PRUOUT_PRU2_1.dts   BBB-eCAP0.dts       BONE-BACKLIGHT.dts     BONE-PRU_eCAP.dts    BONE-TIMER_PWM_2.dts   BONE-eMMC.dts
debian@beaglebone:~/BeagleBoard-DeviceTrees/src/arm/overlays$ pwd
/home/debian/BeagleBoard-DeviceTrees/src/arm/overlays

If you look at those folders and files and directories, one would assume that you can adjust your image accordingly.

I have not been able to test it yet.

I am not going to add the .dtb yet b/c my image does not boot once I add it and I am currently using this image:

4.19.94-ti-r68 is the kernel.

and…

BeagleBoard.org Debian Buster Console Image 2021-12-01 is the image in question for me…

Seth

P.S. Anyway, are you just looking for some source?

Also…it seems that there is a lib. I found a while back via DigiKey Tech Forum about a FLIR Lepton module. Here: LeptonModule/software/beagleboneblack_video at master · groupgets/LeptonModule · GitHub . There is a " simple " example on SPI in that listed amount of source on github.com.

I feel like I am giving too many resources and not knowing enough about what exactly you are trying to do.

If you do not mind, please try to answer these questions:

  1. Did you look through how Linux handles SPI devices, i.e. Serial Peripheral Interface (SPI) — The Linux Kernel documentation ?
  2. Do you just need source to test your SPI device with the RoboticsCape on the BBAI?

and…

  1. Oh and the two headers on the AI are not quite what the BBB are now. Are you aware of the different ideas relating to the BBAI and the attachment(s) of the Cape to the BBAI?

I am asking these questions to get a better background on ideas. I know you just want it to work. No issue w/ me. I would love for it to work too. But…it takes time and effort. All of which I currently have now but a defined answer is not what I can give right now. So, if someone else gets tired of seeing our names jump in their email boxes, okay. They may be able to answer swiftly and accurately. Me, me, on the other hand thinks we should work on it. Time and patience!


debian@beaglebone:/dev$ ls -l spidev1.1
crw------- 1 root root 153, 0 Dec 10 06:45 spidev1.1

So, it seems I can read and write to this character device in Linux already. I will get the pin names soon and test it. I do not have time this morning. But, just shoot over another reply of ideas and I can crack this case open w/ newer, more updated ideas and proven oomph.

Hello @Mahaboob ,

So, a loopback test will ensure you have your two /dev/spidevN.N devices working. Look here: spidev_test.c - tools/spi/spidev_test.c - Linux source code (v4.19.220) - Bootlin .

There are some informative ideas online to handle such a test on specific hardware. I am still trying to hunt down the ideas w/ the BBB or BBAI for a loopback test.

Seth

P.S. Also, SS(n) is slave select and not chip select. You will need CS(n) instead. If you connect MOSI to MISO and run the spidev command for testing the SPIDEV instance on the Linux kernel, you can see if it is already set up. Do not quote me and be careful. I saw some errors in learning about this idea. So, I will test it and get back to you. In any case, you can use this idea: spidev_test -D /dev/spidev0.0 -v . Where, and I am sure you already know, /dev/spidev0.0 is the SPIDEV instance you are using.

@Mahaboob ,

Hey. Seth here. Um, did you get your loopback test working yet? I got the loopback test to work. Here is the output:


debian@beaglebone:~$ sudo ./spidev_test -D /dev/spidev1.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  |......@.........................|

So, there is a bit of change in the way to the source from the kernel and it needs to be approached w/out octal in the source for whatever reason. I still have not figured out why octal is so detrimental here.

Anyway…that loopback test is for the MOSI/MISO on P9.18 and P9.21 on the AI.

Seth

P.S. Here is another idea online that I found that may help you on your journey: https://elinux.org/images/1/1e/I2C-SPI-ELC-2020.pdf .

Hi @Seth

Sorry for the delay in the replay. In this Image file system (https://rcn-ee.net/rootfs/bb.org/testing/2021-11-29/buster-lxqt/am57xx-debian-10.11-lxqt-armhf-2021-11-29-4gb.img.xz), the overlays present in the folder(/opt/source/dtb-4.19-ti/src/arm/overlays). Need to add/edit in the /boot/uEnt.txt file and let me check whether SPI is working.

root@beaglebone:/opt/source/dtb-4.19-ti/src/arm/overlays# ls
AM335X-PRU-RPROC-4-19-TI-00A0.dts BBAI-PR1_UART0.dts BBB-PRU_eCAP.dts BONE-LED_P8_03.dts BONE-UART3.dts
BB-ADC-00A0.dts BBAI-PR2_UART0.dts BBB-eCAP0.dts BONE-LED_P9_11.dts BONE-UART4.dts
BB-BBBW-WL1835-00A0.dts BBAI-PRUIN_PRU1_0.dts BBB-eCAP2.dts BONE-PRU_eCAP.dts BONE-UART5.dts
BB-BBGG-WL1835-00A0.dts BBAI-PRUIN_PRU1_1.dts BBORG_COMMS-00A2.dts BONE-PWM0.dts BONE-eMMC.dts
BB-BBGW-WL1835-00A0.dts BBAI-PRUIN_PRU2_0.dts BBORG_FAN-A000.dts BONE-PWM1.dts BONE-eQEP0.dts
BB-BONE-4D4C-01-00A1.dts BBAI-PRUIN_PRU2_1.dts BBORG_LOAD-00A2.dts BONE-PWM2.dts BONE-eQEP1.dts
BB-BONE-4D5R-01-00A1.dts BBAI-PRUOUT_PRU1_0.dts BBORG_MOTOR-00A2.dts BONE-SPI0_0.dts BONE-eQEP2.dts
BB-BONE-LCD4-01-00A1.dts BBAI-PRUOUT_PRU1_1.dts BBORG_RELAY-00A2.dts BONE-SPI1_0.dts BONE-eQEP2A.dts
BB-BONE-NH7C-01-A0.dts BBAI-PRUOUT_PRU2_0.dts BBORG_SERVO-00A2.dts BONE-SPI1_1.dts BW-ICE40Cape-00A0.dts
BB-BONE-eMMC1-01-00A0.dts BBAI-PRUOUT_PRU2_1.dts BONE-ADC.dts BONE-TIMER_PWM_0.dts BW-ICE40Cape-00A0_LKM.dts
BB-CAPE-DISP-CT4-00A0.dts BBAI-PRU_eCAP.dts BONE-BACKLIGHT.dts BONE-TIMER_PWM_1.dts M-BB-BBG-00A0.dts
BB-CTAG-SW-8CH-00A0.dts BBAI-SPI0_1.dts BONE-CAN0.dts BONE-TIMER_PWM_2.dts M-BB-BBGG-00A0.dts
BB-HDMI-TDA998x-00A0.dts BBAI-eCAP1.dts BONE-CAN1.dts BONE-TIMER_PWM_3.dts Makefile
BB-SPIDEV0-00A0.dts BBAI-eCAP2.dts BONE-I2C1.dts BONE-TIMER_PWM_4.dts
BB-SPIDEV1-00A0.dts BBAI-eCAP2A.dts BONE-I2C2.dts BONE-TIMER_PWM_5.dts
BBAI-4D4C-00A1.dts BBAI-eCAP3.dts BONE-I2C2A.dts BONE-UART1.dts
BBAI-AUDI-02-00A0.dts BBAI-eCAP3A.dts BONE-I2C3.dts BONE-UART2.dts
root@beaglebone:/opt/source/dtb-4.19-ti/src/arm/overlays# pwd
/opt/source/dtb-4.19-ti/src/arm/overlays

Response to your questions:

  1. Yes I have an idea about Serial Peripheral Interface mandatory parameters, but not fully.

  2. I have my own SPI ‘C’ code and it is working with BBB and BBBW.

  3. Yes I am aware of the different ideas relating to the BBAI and BBB.

root@beaglebone:/dev# ls -l spidev1.1
crw-rw---- 1 root gpio 153, 1 Nov 29 17:17 spidev1.1

So, it seems I can also read and write to this character device.

Okay, Let me check by including Overlay in uEnt.txt as well as do SPI loopback test and come back to you.

Thanks and Regards,

Mahaboob

1 Like