Enable SPI BeagleBone Black Yocto (kirkstone)

Hello!

I am working on a project using Yocto Poky (kirkstone) for BeagleBone Black. The layers included are:

poky/meta
poky/meta-poky
meta-arm/meta-arm
meta-arm/meta-arm-toolchain
meta-ti/meta-ti-bsp
meta-ti/meta-ti-extras

I have built the minimal core image with bitbake using the command bitbake core-image-minimal. This successfully creates a working BeagleBone Black with Yocto. However, in the “/dev” directory, SPI is not present, which means I need to enable it somehow.

I’ve done some research and looked at previous forum discussions about enabling SPI. Some suggest modifying the uEnv.txt file, but I can’t find this file anywhere. Additionally, I followed an informative video from Digi-Key (https://www.youtube.com/watch?v=srM6u8e4tyw). At the 13:45 mark, the presenter enables I2C, but I don’t find an equivalent “status = ‘disabled’” line in the “am33xx.dtsi” file (or any other included files) for SPI.

I also came across a suggestion about using menuconfig to activate it, but I haven’t found a clear description of how to do this.

i’m working we a bit older Yocto version, dunfell
there are no spi enabled, spi0 pins are used for mmc
take a look at am335x-pdu001.dts, spi1 is configured there, you should be able to copy paste what ya need. i’d recommend patching am335x-bone-common.dtsi or create a .dtsi and include it in am3335x-boneblack.dts (also would required being patched then)

Hello! Thanks for your response!
Began with Yocto just a week ago, so now to familiar with it.

In am335x-pdu001.dts I see this:

&spi1 {
	pinctrl-names = "default";
	pinctrl-0 = <&spi1_pins>;
	ti,pindir-d0-out-d1-in;
	status = "okay";

	display-controller@0 {
		compatible = "orisetech,otm3225a";
		reg = <0>;
		spi-max-frequency = <1000000>;
		// SPI mode 3
		spi-cpol;
		spi-cpha;
		status = "okay";
	};
};

Would it be possible to just copy this part and paste it to the bottom of am335x-bone-common.dtsi?
Can this be done just as it is or do I have to create a patch file first? Would prefer to directly edit am335x-bone-common.dtsi if possible.

After this (wheter patch or directly edit), can I just do
bitbake core-image-minimal

In the poky directory or do I have to make other changes or maybe use a different image?

you will also need the ‘spi1_pins’ part also
you do not need the display-controller part, this would be replaced with the driver/sensor/whatever you need spi for
Yocto is a beast, there is a learning curve (i had to say this, :wink: )
i would recommend the patch, since if you delete the temp directory, ya loss all your work
if you go with just changing the file, then: bitbake virtual/kernel -c compile
just copy the new dtb to your SBC, use dtc to decompile the dtb and verify your spi changes are there.

I stumpled across something on google telling me to add

CORE_IMAGE_EXTRA_INSTALL += " kernel-modules"

To local.conf (poky/build/conf).

Then I did bitbake with

bitbake core-image-full-cmdline

Now on my BBB I did:
"
root@beaglebone:~# lsmod
Not tainted
spidev 24576 0 - Live 0xbf0e4000

"

And when I do

modprobe spidev

It does look successful.
But in /dev, spidev can not be found.

(I have not done the change in the *common.dtsi file now).

When I add:

spi1_pins: pinmux_spi1_pins {
	pinctrl-single,pins = <
		AM33XX_PADCONF(AM335X_PIN_MCASP0_ACLKX, PIN_OUTPUT, MUX_MODE3)	/* mcasp0_aclkx.spi1_sclk */
		AM33XX_PADCONF(AM335X_PIN_MCASP0_FSX, PIN_OUTPUT, MUX_MODE3)	/* mcasp0_fsx.spi1_d0 */
		AM33XX_PADCONF(AM335X_PIN_MCASP0_AXR0, PIN_INPUT_PULLDOWN, MUX_MODE3)	/* mcasp0_axr0.spi1_d1 */
		AM33XX_PADCONF(AM335X_PIN_MCASP0_AHCLKR, PIN_OUTPUT, MUX_MODE3)/* mcasp0_ahclkr.spi1_cs0 */
	>;
};

&spi1 {
	pinctrl-names = "default";
	pinctrl-0 = <&spi1_pins>;
	ti,pindir-d0-out-d1-in;
	status = "okay";
};

And then

danne@dendanne:~/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/poky$ bitbake virtual/kernel -c compile
Loading cache: 100% |##############################################################| Time: 0:00:00
Loaded 1841 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION           = "2.0.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "arm-poky-linux-gnueabi"
MACHINE              = "beaglebone"
DISTRO               = "poky"
DISTRO_VERSION       = "4.0.14"
TUNE_FEATURES        = "arm armv7a vfp thumb neon callconvention-hard"
TARGET_FPU           = "hard"
meta                 
meta-poky            = "kirkstone:a171408008bfbb89446112f3dbc543f35f76b335"
meta-arm             
meta-arm-toolchain   = "kirkstone:b187fb9232ca0a6b5f8f90b4715958546fc41d73"
meta-ti-bsp          
meta-ti-extras       = "kirkstone:9efb0c6fc4f5089f4f2a305c2823dba311505487"

WARNING: /home/danne/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/meta-ti/meta-ti-bsp/recipes-kernel/linux/linux-bb.org_git.bb:do_compile is tainted from a forced run
Initialising tasks: 100% |#########################################################| Time: 0:00:00
Sstate summary: Wanted 0 Local 0 Mirrors 0 Missed 0 Current 93 (0% match, 100% complete)
NOTE: Executing Tasks
ERROR: linux-bb.org-6.1.33+gitAUTOINC+feb1c153a9-r0 do_compile: oe_runmake failed
ERROR: linux-bb.org-6.1.33+gitAUTOINC+feb1c153a9-r0 do_compile: ExecutionError('/home/danne/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/poky/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-bb.org/6.1.33+gitAUTOINC+feb1c153a9-r0/temp/run.do_compile.549246', 1, None, None)
ERROR: Logfile of failure stored in: /home/danne/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/poky/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-bb.org/6.1.33+gitAUTOINC+feb1c153a9-r0/temp/log.do_compile.549246
.
.
.

ERROR: Task (/home/danne/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/meta-ti/meta-ti-bsp/recipes-kernel/linux/linux-bb.org_git.bb:do_compile) failed with exit code '1'

Hello!

I tried the direct change of am335x-bone-common.dtsi

I added this to the bottom of the file:

spi1_pins: pinmux_spi1_pins {
	pinctrl-single,pins = <
		AM33XX_PADCONF(AM335X_PIN_MCASP0_ACLKX, PIN_OUTPUT, MUX_MODE3)	/* mcasp0_aclkx.spi1_sclk */
		AM33XX_PADCONF(AM335X_PIN_MCASP0_FSX, PIN_OUTPUT, MUX_MODE3)	/* mcasp0_fsx.spi1_d0 */
		AM33XX_PADCONF(AM335X_PIN_MCASP0_AXR0, PIN_INPUT_PULLDOWN, MUX_MODE3)	/* mcasp0_axr0.spi1_d1 */
		AM33XX_PADCONF(AM335X_PIN_MCASP0_AHCLKR, PIN_OUTPUT, MUX_MODE3)/* mcasp0_ahclkr.spi1_cs0 */
	>;
};

&spi1 {
	pinctrl-names = "default";
	pinctrl-0 = <&spi1_pins>;
	ti,pindir-d0-out-d1-in;
	status = "okay";
};

The common file is at

~/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/poky/build/tmp/work-shared/beaglebone/kernel-source/arch/arm/boot/dts

Then I went to the poky directory

danne@dendanne:~/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/poky$ ls
bitbake               LICENSE.MIT     meta-selftest       README.OE-Core.md
build                 MAINTAINERS.md  meta-skeleton       README.poky.md
contrib               Makefile        meta-yocto-bsp      README.qemu.md
documentation         MEMORIAM        oe-init-build-env   scripts
LICENSE               meta            README.hardware.md  SECURITY.md
LICENSE.GPL-2.0-only  meta-poky       README.md

Then I did the

bitbake virtual/kernel -c compile

(in poky directory)

danne@dendanne:~/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/poky$ bitbake virtual/kernel -c compile
Loading cache: 100% |############################################| Time: 0:00:00
Loaded 1841 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION           = "2.0.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "arm-poky-linux-gnueabi"
MACHINE              = "beaglebone"
DISTRO               = "poky"
DISTRO_VERSION       = "4.0.14"
TUNE_FEATURES        = "arm armv7a vfp thumb neon callconvention-hard"
TARGET_FPU           = "hard"
meta                 
meta-poky            = "kirkstone:a171408008bfbb89446112f3dbc543f35f76b335"
meta-arm             
meta-arm-toolchain   = "kirkstone:b187fb9232ca0a6b5f8f90b4715958546fc41d73"
meta-ti-bsp          
meta-ti-extras       = "kirkstone:9efb0c6fc4f5089f4f2a305c2823dba311505487"

Initialising tasks: 100% |#######################################| Time: 0:00:00
Sstate summary: Wanted 0 Local 0 Mirrors 0 Missed 0 Current 93 (0% match, 100% complete)
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 417 tasks of which 417 didn't need to be rerun and all succeeded.

As you can see, it looks like the change did not have an effect since “Attempted 417 tasks of which 417 didn’t need to be rerun”.

Am I missing something?

try adding ‘-f’
bitbake -f virtual/kernel -c compile

also, bitbake virtual/kernel -f -c deploy

the spi1_pins code need to go with the other pinmux code, i missed this earlier.

I did the change you suggested, in
&am33xx_pinmux {
I added

	spi1_pins: pinmux_spi1_pins {
		pinctrl-single,pins = <
			AM33XX_PADCONF(AM335X_PIN_MCASP0_ACLKX, PIN_OUTPUT, MUX_MODE3)	/* mcasp0_aclkx.spi1_sclk */
			AM33XX_PADCONF(AM335X_PIN_MCASP0_FSX, PIN_OUTPUT, MUX_MODE3)	/* mcasp0_fsx.spi1_d0 */
			AM33XX_PADCONF(AM335X_PIN_MCASP0_AXR0, PIN_INPUT_PULLDOWN, MUX_MODE3)	/* mcasp0_axr0.spi1_d1 */
			AM33XX_PADCONF(AM335X_PIN_MCASP0_AHCLKR, PIN_OUTPUT, MUX_MODE3)/* mcasp0_ahclkr.spi1_cs0 */
		>;
	};

to the bottom of it.

And then in the bottom of the file:

&spi1 {
	pinctrl-names = "default";
	pinctrl-0 = <&spi1_pins>;
	ti,pindir-d0-out-d1-in;
	status = "okay";
};

Then

 bitbake -f virtual/kernel -c compile

Did not get any error when compiling.

danne@dendanne:~/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/poky$ bitbake virtual/kernel -f -c deploy
Loading cache: 100% |#################################################################| Time: 0:00:00
Loaded 1841 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION           = "2.0.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "arm-poky-linux-gnueabi"
MACHINE              = "beaglebone"
DISTRO               = "poky"
DISTRO_VERSION       = "4.0.14"
TUNE_FEATURES        = "arm armv7a vfp thumb neon callconvention-hard"
TARGET_FPU           = "hard"
meta                 
meta-poky            = "kirkstone:a171408008bfbb89446112f3dbc543f35f76b335"
meta-arm             
meta-arm-toolchain   = "kirkstone:b187fb9232ca0a6b5f8f90b4715958546fc41d73"
meta-ti-bsp          
meta-ti-extras       = "kirkstone:9efb0c6fc4f5089f4f2a305c2823dba311505487"

NOTE: Tainting hash to force rebuild of task /home/danne/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/meta-ti/meta-ti-bsp/recipes-kernel/linux/linux-bb.org_git.bb, do_deploy
WARNING: /home/danne/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/meta-ti/meta-ti-bsp/recipes-kernel/linux/linux-bb.org_git.bb:do_deploy is tainted from a forced run
Initialising tasks: 100% |############################################################| Time: 0:00:00
Sstate summary: Wanted 1 Local 0 Mirrors 0 Missed 1 Current 143 (0% match, 99% complete)
Removing 1 stale sstate objects for arch beaglebone: 100% |###########################| Time: 0:00:00
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 636 tasks of which 635 didn't need to be rerun and all succeeded.

Summary: There was 1 WARNING message.

But still, only when lsmod I can see spidev, but not in /dev

have you ever heard of KISS, I failed on this one, this time.
root@beaglebone:~# ls /dev/spi*
/dev/spidev0.0 /dev/spidev1.0

undo (remove) all changes to am335x-boneblack-common.dtsi

i’m working with Linux beaglebone 5.7.11, but the following should apply unless the included dtsi files do not exist

required (thank you)
CORE_IMAGE_EXTRA_INSTALL += " kernel-modules"

in am335x-boneblack.dts
add:
#include “bbb-spi0-spidev.dtsi”
#include “bbb-spi1-spidev.dtsi”

do
bitbake core-image-minimal
bitbake virtual/kernel -f -c compile
bitbake virtual/kernel -f -c deploy
should be good to go after this,

Hello again!
I think we are getting closer to a solution!

 bitbake virtual/kernel -f -c compile

fails with:

kernel-source/arch/arm/boot/dts/am335x-boneblack.dts:11:10: fatal error: bbb-spi0-spidev.dtsi: No such file or directory
|    11 | #include "bbb-spi0-spidev.dtsi"
|       |          ^~~~~~~~~~~~~~~~~~~~~~

And when I do

danne@dendanne:~/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2$ ls
copies  meta-arm  meta-ti  openembedded-core  poky
danne@dendanne:~/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2$ find -type f -name 'bbb-spi1-spidev.dtsi'

As you can see, the file is not in the project.

I notice in this:

danne@dendanne:~/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/poky/build/tmp/work-shared/beaglebone/kernel-source/arch/arm/boot/dts/overlays$ find -name '*SPI*'./BB-SPIDEV0-00A0.dts
./BB-SPIDEV1-00A0.dts

Are these files maybe relevant? But they are not dtsi files. Maybe the naming is different with my Yocto version? Or I need to obtain the file somehow?

My version:

danne@dendanne:~/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/poky/build$ bitbake -e virtual/kernel | grep "^PV"
PV="6.1.33+gitAUTOINC+feb1c153a9"
PV:aarch64="6.1.46+gitAUTOINC+feb1c153a9"
PV:armv7a="6.1.33+gitAUTOINC+feb1c153a9"
PVR_DISPLAY_CONTROLLER_ALIAS="tilcdc"

With Kirkstone as said before.

Also, I do not have uEnv.txt in my Yocto project for some reason.
I’ll try your version.

I previously documented how I got the exact project, here it is:
First, the repository with the latest long-term support was cloned.


git clone -b kirkstone git://git.yoctoproject.org/poky.git

In bblayers.conf, this line was removed:


poky/meta-yocto-bsp \

meta-ti is a repository from Texas Instruments that contains a configuration file for BeagleBone Black (BBB has TI chip).

meta-ti was cloned, and then checked out on kirkstone.

If you go to meta-ti-bsp/conf and then look at the layer.conf file, you can see the dependencies for this package:


LAYERDEPENDS_meta-ti-bsp = " \

core \

meta-arm \

"

It’s core and meta-arm. Core already exists, but meta-arm must be cloned (and checked out on kirkstone).

Similarly, in meta-arm, you can check its configuration file:


LAYERDEPENDS_meta-arm = " \

core \

arm-toolchain \

"

and so on… with the toolchain (it stops there).

So, the bblayers.conf becomes:


BBLAYERS ?= " \

/home/danne/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/poky/meta \

/home/danne/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/poky/meta-poky \

/home/danne/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/meta-arm/meta-arm \

/home/danne/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/meta-arm/meta-arm-toolchain \

/home/danne/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/meta-ti/meta-ti-bsp \

/home/danne/Desktop/emlin/emlin_daniel_git/yocto/yocto_test_2/meta-ti/meta-ti-extras \

"

To determine which machine to use in local.conf, you need to find the configuration.

In this directory:


/meta-ti/meta-ti-bsp/conf/machine

there is beaglebone.conf, so the machine name becomes beaglebone, like this:


MACHINE ?= "beaglebone"

In local.conf, add:


CORE_IMAGE_EXTRA_INSTALL += " kernel-modules"

Then, to build an image (a runnable system), the following commands were used:


source oe-init-build-env

bitbake core-image-minimal

things have really changed, building now

finally got a build, ran out of disk space
what did ya have to do to get tmp/deploy/images/beaglebone
all i get are rpm file. a lot seems to have changed. so back to a learning curve.

ok, found it
deploy-ti/images/beaglebone/

Hello again! Really thanks for your effort!
Wish my answers would be posted immediately and not having to wait for approval for 3 hours :smiley:

the files are in deploy-ti/images/beaglebone
the older version of yocto had them in tmp/deploy/images/beaglebone
so loading the sd card with everything like i did with dunfell, does not boot, no serial com output either
ya, beagleboard response is slow, if you reply to my email address, i think it’s faster.
being it’s Friday, my day is over. will look at it over the weekend.
how are you doing the sd card ??

test, sent from email at 3pm on Friday, when do you get this message ??

Now it looks like the post finally got posted immediately! :smiley:

Yea, the files are at poky/build/deploy-ti/images/beaglebone

Before loading to SD-card, I unmount, remove partitions.

lsblk
sda           8:0    1  29,2G  0 disk 
├─sda1        8:1    1    32M  0 part /media/danne/boot   <-- Old partition
└─sda2        8:2    1  31,4M  0 part /media/danne/root  <-- Old partition
nvme0n1     259:0    0 476,9G  0 disk 
├─nvme0n1p1 259:1    0   260M  0 part /boot/efi
├─nvme0n1p2 259:2    0    16M  0 part 
├─nvme0n1p3 259:3    0 289,1G  0 part 
├─nvme0n1p4 259:4    0  1000M  0 part 
└─nvme0n1p5 259:5    0 186,5G  0 part /var/snap/firefox/common/host-hunspell
                                      /
danne@dendanne:~/Desktop/emlin/emlin_daniel_git/checkpoints$ sudo umount /dev/sda1
[sudo] password for danne: 
danne@dendanne:~/Desktop/emlin/emlin_daniel_git/checkpoints$ sudo umount /dev/sda2

Remove partitions:

danne@dendanne:~/Desktop/emlin/emlin_daniel_git/checkpoints$ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): d
Partition number (1,2, default 2): 1

Partition 1 has been deleted.

Command (m for help): d
Selected partition 2
Partition 2 has been deleted.

Command (m for help): 2
2: unknown command

Command (m for help): p

Disk /dev/sda: 29,16 GiB, 31312576512 bytes, 61157376 sectors
Disk model: SD Card Reader  
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9adac3bd

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

This is the command I ran to get it to the SD-card:

sudo xzcat core-image-minimal-beaglebone.wic.xz | sudo dd of=/dev/sda bs=4M status=progress

(Live in Europe, now 21:40 UTC)

1 Like