How to enable SPI on PocketBeagle2

Hi guys,

I received my pocketbeagle2 today, flashed the PocketBeagle 2 Debian 12.10 2025-03-18 Minimal.
The board is working fine, I just don’t know how to enable the SPI devices - I tried to load the spidev module, loading the module I’m not seen any spi devices.
How can I enable the spi bus ?

Congrats on your little new device!

You need to read up on device-tree overlays and do some general searching.
There’s no insmod’ding spidev any more.

Take a look at extlinux.conf under /boot for inspiration.

First, run lsmod. Do you see the “spidev” driver loaded? If needed run sudo modprobe spidev to load the driver.

Next you need to figured out overlays and muxing…

Here’s what I have for the AI64, maybe it could help guide you down a good direction.

https://github.com/kevinacahalan/BeagleBoneAI64_Heterogeneous_App_Example?tab=readme-ov-file#walkthrough-of-process-to-figure-out-muxing

For reference start from here https://github.com/beagleboard/BeagleBoard-DeviceTrees/blob/v6.12.x-Beagle/src/arm64/overlays/k3-j721e-beagleboneai64-spi-mcspi6-cs0-cs1.dtso

And then maybe use sysconfig to figure out the pinmuxing. SYSCONFIG IDE, configuration, compiler or debugger | TI.com

And then there is the whole thing of figuring out SoC pads that share the same board header pins. For example with the AI64 you got P9_22a and P9_22b. It’s best you figure out these conflicts and disable the SoC pads that conflict/share board header pins with what you want. Most of the time you cant probably just skip this step, and live with what TI SYSCONFIG gives you. TI SYSCONFIG assumes you don’t have SoC pads sharing header pins…which is not always the case.

There are not many overlays at all for the PB2. Here’s one I made for spidev on McSPI2, which I made by hand based on older ones. For some reason it shows up as /dev/spidev0.0 instead of /dev/spidev2.0 , but it works well for me.

This uses <&P1_06_E19_spi>, <&P1_08_spi>, <&P1_10_B19_spi>, <&P1_12_A19_spi>

PB2-SPIDEV2.dtso (1.3 KB)

To use it, cd to the folder /opt/source/dtb-* matching your kernel version, then place this in src/arm64/overlays and do sudo ./build_n_install.sh. Then edit extlinux.conf to load this.

1 Like
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2022 BeagleBoard.org - https://beagleboard.org/
 *
 * https://docs.beagleboard.io/latest/boards/capes/cape-interface-spec.html#i2c
 */

#include <dt-bindings/gpio/gpio.h>
#include "ti/k3-pinctrl.h"

/dts-v1/;
/plugin/;

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

// many definitions from pinmux/board/pocketbeagle2/pocketbeagle2-pinmux.dts
&main_pmx0 {
	P1_06_E19_spi: P1-06-E19-spi-pins {
		pinctrl-single,pins = <
			AM62X_IOPAD(0x01AC, PIN_INPUT, 1) /* (E19) MCASP0_AFSR.SPI2_CS0 */
		>;
	};
	P1_08_spi: P1-08-spi-pins {
		pinctrl-single,pins = <
			AM62X_IOPAD(0x01B0, PIN_INPUT, 1) /* (A20) MCASP0_ACLKR.SPI2_CLK */
		>;
	};
	P1_10_B19_spi: P1-10-B19-spi-pins {
		pinctrl-single,pins = <
			AM62X_IOPAD(0x0194, PIN_INPUT, 1) /* (B19) MCASP0_AXR3.SPI2_D0 */
		>;
	};
	P1_12_A19_spi: P1-12-A19-spi-pins {
		pinctrl-single,pins = <
			AM62X_IOPAD(0x0198, PIN_INPUT, 1) /* (A19) MCASP0_AXR2.SPI2_D1 */
		>;
	};
};

&main_spi2 {
	pinctrl-names = "default";
	pinctrl-0 = <&P1_06_E19_spi>, <&P1_08_spi>, <&P1_10_B19_spi>, <&P1_12_A19_spi>;
	status = "okay";
	#address-cells = <1>;
	#size-cells = <0>;
	ti,spi-num-cs = <1>; /* this is 1 CS, that CS is CS0 */
	ti,pindir-d0-out-d1-in;
	spidev@0 {
		symlink = "bone/spi/2.0";
		compatible = "rohm,dh2228fv";
		reg = <0>;
		spi-max-frequency = <24000000>;
	};
};

I added a few things. Should place symlink at /dev/bone/spi/2.0. Does it work?

i don’t think spi symlink ever worked…

But i’m thinking we should force this default aliases:

		spi0 = &main_spi2; (P1_6/....)
		spi1 = &main_spi0; (P2_/...)

Just comparing with PocketBeagle

SPI0 was P1_6/8/10/12
SPI1 was P2_25/27/29/31

Final edit: Okay this should work for everyone and be compatible with PocketBeagle am335x software: https://openbeagle.org/beagleboard/BeagleBoard-DeviceTrees/-/commit/0419c2891aa7fe2e051323e884ce9c2057a00fb9 (/dev/spidev0…/dev/spidev1)

Regards,

spi0 = &main_spi2;
spi1 = &main_spi0;

Is this supposed to have any effects on /dev/spidev numbering? As a user, I would prefer that numbering to match main_spiX numbering, or to be able to set or at least see those mappings explicitly, rather than adding an additional layer of abstraction ‘this should be spidev0 because it used to be like this in some old board which you may have never seen before’.

Correct it does… spi0 will turn into /dev/spidev0…

Yeap @jkridner goal with the PocketBeagle2, where ever we can make it compatible with PocketBeagle1 userspace…

Regards,

This can get very confusing. When I refer to spi0, am I referring to MCSPI0 or MCSPI2? I argue it’s best to force people to change their code when switching between boards.

As i work on an spi overlay… yeah i’ll revert this…

		spi0 = &main_spi0;
		spi2 = &main_spi2;

Hi guys,

thanks for all the answers, I will try and update you :slight_smile:
My idea is to enable some devices like spi, gpio, can, i2c :slight_smile: but lets start with the spi :smiley:

Pretty sure this has working spi, need to find my wiz module… src/arm64/overlays/k3-am62-pocketbeagle2-spi2-eth-wiz-click.dtso · v6.12.x-Beagle · BeagleBoard.org / BeagleBoard-DeviceTrees · GitLab

Hi @RobertCNelson

based on your dtso and @giuliomoro I create a file with the spi0.
I could create the spi0.0 but not the spi0.1
this is what I wrote
&main_spi0 {
pinctrl-names = “default”;
pinctrl-0 = <&P2_25_A14_spi>,<&P2_27_B13_spi>,<&P2_29_B14_spi>,<&P2_31_A13_spi>,<&P2_36_C13_spi>;
status = “okay”;
#address-cells = <1>;
#size-cells = <0>;
num-chipselects = <2>;

    channel@0 {
            compatible = "rohm,dh2228fv";
            reg = <0>;
            spi-max-frequency = <24000000>;
    };
    channel@1 {
            compatible = "rohm,dh2228fv";
            reg = <1>;
            spi-max-frequency = <24000000>;
    };

};

But I’m having this on the syslog:
dmesg |grep spi
[ 1.469883] SPI driver tps6594 has no spi_device_id for ti,tps6594-q1
[ 1.469902] SPI driver tps6594 has no spi_device_id for ti,tps6593-q1
[ 1.469906] SPI driver tps6594 has no spi_device_id for ti,lp8764-q1
[ 1.469910] SPI driver tps6594 has no spi_device_id for ti,tps65224-q1
[ 1.779295] omap2_mcspi 20100000.spi: cs1 >= max 1
[ 1.779316] spi_master spi0: spi_device register error /bus@f0000/spi@20100000/channel@1
[ 1.779345] spi_master spi0: Failed to create SPI device for /bus@f0000/spi@20100000/channel@1

What I’m doing wrong? My idea is to use the spi0 with 2 CS to connect 2 sensors.

thanks

It’s kinda tellin ya at [1.779295]; the kernel driver only supports one channel…

Take a look at the kernel source and see if there’s any way around it.
I’m thinking GPIO chip selects…

to get more than one CS
change from
ti,spi-num-cs = <1>; /* this is 1 CS, that CS is CS0 */
to
ti,spi-num-cs = <3>;

make sure the spi cs is not being used by some other device.

tested with two spi eeproms.

Hi @amf99,

perfect :slight_smile:
thanks a lot :slight_smile:

hi guys,
I’m facing another problem.
I’m using a ICM20948 and BMP280 - imu and baro.
With pocketbeagle2 the reading is not happening, and the same sensors in bbb is working fine.
There is a difference between the dts, in bbb I’m using in the dts for spi compatible = “spidev”; meanwhile in the pocketbeagle2 I’m using compatible = “rohm,dh2228fv”;
This can cause this difference ? any clue of what can be happening?

You’re probably also using a much older kernel. If you look at spidev.c with Blame On, you can see when they decided on the change. The new kernel wants to move away from the generic spidev in device-tree.