Issues with Enabling SPIDev on Beaglebone Black

I’m trying to enable SPI on boot up on my Beaglebone Black. I followed the wiki link below under the title

SPI1 D1 Output and D0 Input

I created the .dts file and compiled it. I then moved it to /lib/firmware/ and then enabled the device overlay tree. Finally, I changed the uenv.txt file by adding the text shown and I removed a pound sign at the end of the document. I did this because the boot command to enable the SPI wasn’t working and I thought it wasn’t reading the last command because of the pound sign. Unfortunately, now that I removed it, I reset my Beaglebone Black and it gets stuck in a state with the Power LED and USR0,USR1, USR2, and USR3 all stuck on. No blinking and my computer doesn’t recognize its there. I’m powering through the USB port and have tried resetting and powering down numerous times. This same state keeps coming up. Can anyone help?

Tutorial Link:
http://elinux.org/BeagleBone_Black_Enable_SPIDEV

There is a bug in recent kernels that makes the “capemgr.enable_partno=BB-SPI1-01” part not work. It has something to do with the filesystem not being available during boot up (I don’t pretend to know the exact technical reasons why).

I have been able to load the SPI device overlay during boot up by adding this line in the /etc/rc.local file (before the exit 0 line):

echo BB-SPI1-01 > /sys/devices/bone_capemgr.9/slots

You may have to replace 9 with the number of your particular cape manager. Using the * symbol does not work here for some reason.

Hope this helps.

Brendan, what media were you using when this problem happened ? sdcard, or eMMC ? How did you make these changes ? This is important, since if you used a Windows machine to make changes to your uEnv.txt file. uboot does not like Windows line feeds ( \r \n ).

If eMMC, you can download, and setup an sdcard to boot, then mount the eMMC, and revert the changes to your uEnv.txt file.

If sdcard, then you could mount the sdcard in an x86 / x86-64 system running linux, and revert the changes in the uEnv.txt file. Then reinsert the sdcard into the beaglebone black, and power it up. It should then boot, so long as you did not make any other changes to the file.

@emile

There is a bug in recent kernels that makes the “capemgr.enable_partno=BB-SPI1-01” part not work. It has something to do with the filesystem not being available during boot up (I don’t pretend to know the exact technical reasons why).

Well . . . capemgr.enable= is only meant to work with 3.8.x kernels. 3.14.x kernels do not have capemgr, and kernels 4.0.x use a different keyword. I believe it is bone_capemgr.enable=.

Anyway the point is, things are different between different major kernel releases. And we would need to know which kernel was being used before making this assumption.

Had a similar problem following the same tutorial, used Emile’s answer, the DT overlay loads every time.
To check:

cat /sys/devices/bone_capemgr.*/slots

root@beaglebone:~# cat /sys/devices/bone_capemgr.*/slots
0: 54:PF—
1: 55:PF—
2: 56:PF—
3: 57:PF—
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O-L Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
8: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-SPI0-01

  1. Another solution is also simple, just include the line “CAPE=ADAFRUIT-SP0” in /etc/default/capemgr file. Then reboot and all should work fine.

Vinay is right, tried it out on a new BBB I just got, enabled UART1,2,4 and 5 plus ADAFRUIT-SPI0 by adding CAPE=BB-UART1,BB-UART2,BB-UART4,BB-UART5,ADAFRUIT-SPI0
to /ect/default/capemgr and rebooted.

I can’t load ADAFRUIT-SPI1 using the same method even though I have disabled HDMI and HDMIN

Vinay, have you been able to enable SPI1?

root@beaglebone:/sys/devices/bone_capemgr.9# cat slots
0: 54:PF—
1: 55:PF—
2: 56:PF—
3: 57:PF—
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART1
8: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART2
9: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART4
10: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART5
11: ff:P-O-L Override Board Name,00A0,Override Manuf,ADAFRUIT-SPI0
root@beaglebone:/sys/devices/bone_capemgr.9#

Ok, compiled my own device tree overlays for SPI0, SPI1 and added CAPE=BB-UART1,BB-UART4,BB-UART5,BB-SPI0-01,BB-SPI1-01 to the /etc/default/capemgr file and it works.
Thanks for posting that Vinay!

Just a note to my previous post UART2 and SPI0 share the same pins.

Here is the link for SPI the device tree overlays I compiled, hopefully it will help someone out that is getting started with both the SPI’s on the BBB:
https://drive.google.com/drive/folders/0B_aq4xH2lZ0WVElpWWRLNW1uSGM

After downloading: (these steps will enable SPI0 and SPI1)

  1. Disable HDMI, pins are used by SPI1: root@beaglebone:~# vim /boot/uEnv.txt
  2. Remove # from line: cape_disable=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN
  3. Put the .dtbo files you downloaded from the link above in /lib/firmware on your BBB
  4. Add CAPE=BB-SPI0-01,BB-SPI1-01 to /etc/default/capemgr file: root@beaglebone:~# vim /etc/default/capemgr
  5. Reboot the BBB
  6. root@beaglebone:/sys/devices/bone_capemgr.*
  7. root@beaglebone:/sys/devices/bone_capemgr.9# cat slots
    You should see:
    ff:P-O-L Override Board Name,00A0,Override Manuf,BB-SPI0-01
    ff:P-O-L Override Board Name,00A0,Override Manuf,BB-SPI1-01
    Now you’re good to go with both SPI’s :smiley:

Hi Rudy,

I am trying to enable SPI0 in BBB. I cannot access the link you gave. I would appreciate if you could update the link or post the file in another way.

p.s. - I am using the kernel 4.4.8 and cannot find capemgr things…

Step 1 : Go to root@beaglebone: /boot#
Step 2 : Open uEnv.txt file
Step 3 : Inside the file

You will find these lines, so do the following: In case If you dont find these lines for your kernel, then just append the line “cape_enable=bone_capemgr.enable_partno=BB-SPIDEV0” to the end of the file.

##Example v4.1.x
#cape_disable=bone_capemgr.disable_partno=
cape_enable=bone_capemgr.enable_partno=BB-SPIDEV0

Step 4 : Reboot your BBB
Step 5 : Go to /sys/devices/platform/bone_capemgr# cat slots or dmesg to check.

Then check if your SPI device has been loaded.

This works with Linux beaglebone kernel 4.1.18-ti-r53

Hello all, I am new to BBB. My eventual aim is to use the BBB to flash a rom with libreboot on my Lenovo Thinkpad. I am using this guide at eLinux. It says that I need to disable HDMI before I can enable SPI.

I couldn’t locate the uEnv.txt file at first, because there isn’t a /lib/ directory. It was found in /boot/

But when I do this, ie reboot and look, it seems that the HDMI is still there:

root@beaglebone:/var/lib/cloud9# cat /sys/devices/bone_capemgr.*/slots
0: 54:PF—
1: 55:PF—
2: 56:PF—
3: 57:PF—
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
root@beaglebone:/var/lib/cloud9#

Auto Generated Inline Image 1.png

Auto Generated Inline Image 1.png

Hello all, I am new to BBB and using it to flash the ROM on my Lenovo Thinkpad T400 with Libreboot, using these instructions on eLinux.

I disabled HDMI on the Beaglebone by opening vi and removing the comment from the line that says it disables HDMI.

I couldn’t locate the uEnv.txt file at first, because there isn’t a /lib/ directory. It was found in /boot/

But when I did this, ie reboot and look, it seems that the HDMI is still there:

root@beaglebone:/var/lib/cloud9# cat /sys/devices/bone_capemgr.*/slots
0: 54:PF—
1: 55:PF—
2: 56:PF—
3: 57:PF—
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
root@beaglebone:/var/lib/cloud9#

Can you provide info about the kernel your using?

Whats crack’n Vinay!! Looks to me like Wheezy.

Hey Will,
5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN

The L in P-O-L means loaded, so in the case above it’s telling you that the HDMI hasn’t been loaded. So you’ve successfully disabled it.

When you do this
“Another solution is also simple, just include the line “CAPE=ADAFRUIT-SP0” in /etc/default/capemgr file. Then reboot and all should work fine”

You’ll have to do both, disable the HDMI like you’ve done (if you want to use SPI1) and load the SPI dtbo like in the step above.
You should then see it loaded when you cat the slots. Below is what mine looks like (I have a few different things loaded, but you can see that the HDMI has been disabled and both SPI’s loaded)

root@beaglebone:/sys/devices# cd /sys/devices/bone_capemgr.*
root@beaglebone:/sys/devices/bone_capemgr.9# cat slots
0: 54:PF—
1: 55:PF—
2: 56:PF—
3: 57:PF—
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-SPI0-01
8: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-SPI1-01
9: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART1
10: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART4
11: ff:P-O-L Override Board Name,00A0,Override Manuf,AEI-UART5
12: ff:P-O-L Override Board Name,00A0,Override Manuf,bspm_P8_32_f
13: ff:P-O-L Override Board Name,00A0,Override Manuf,am33xx_pwm
14: ff:P-O-L Override Board Name,00A0,Override Manuf,bone_pwm_P9_16
root@beaglebone:/sys/devices/bone_capemgr.9#

check for ‘spidev1.x’ in /dev
e.g

root@beaglebone:~# cd /dev
root@beaglebone:/dev# ls

If spidev is in there, you successfully loaded the SPI

This is the version of linux I’m running on my BBB

root@beaglebone:~# uname -a
Linux beaglebone 3.8.13-bone79 #1 SMP Tue Oct 13 20:44:55 UTC 2015 armv7l GNU/Linux

I’ve attached the SPI device tree files I used.

Hope this help ya out!!

BB-SPI1-01-00A0.dts (1.19 KB)

spi0.dts (1.02 KB)

BB-SPI1-01-00A0.dtbo (942 Bytes)

BB-SPI0-01-00A0.dtbo (946 Bytes)

Thank you Vinay and Rudy for your replies. I am using the Kernel

Version 3.8.13-bone79.

I realised about the L thing after my last post - thank you Rudy, that

is encouraging that I have successfully disabled HDMI. I have added

the suggested line in /etc/default/capemgr

(CAPE=ADAFRUIT-SP0). Following earlier advice the only other line I

have in this file is:

CAPE=BB-SP1-01.

Is this correct for my purpose (ie simply and only to use the BBB to

flash the Lenovo ROM)?

After adding the line you suggested, I rebooted and this is what I now get

in /sys/devices/bone_capemgr.9/slots:

0: 54:PF—

1: 55:PF—

2: 56:PF—

3: 57:PF—

4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G

5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI

6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN

7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-SPI1-01

I am using the guide at

https://libreboot.org/docs/install/bbb_setup.html. In "Setting up

spidev on the BBB" it advises:

Log on as root on the BBB, using either SSH or a serial console as

defined in #bbb_access. Make sure that you have internet access on

your BBB.

Follow the instructions at

http://elinux.org/BeagleBone_Black_Enable_SPIDEV#SPI0 up to (and

excluding) the point where it tells you to modify uEnv.txt

I did this, entering the .dtbo in the recommended location (for

SP01). Here is my uEnv.txt:

Hi, Rudy,

Nothing much, Just hooked to my CC3200 LP.

Will, looking at the slots, I can say that you have loaded the spi dev 1 successfully. For your kernel version, adding CAPE**=BB-SPI0-01** in the file in “/etc/default/capemgr” is sufficient . To cross check the active spi devices use " ls -al /dev/spidev*", it will show you which spi devices are currently active and can be used. There nothing more to install or load, you have one spi device now active and can use it for your application. However, if I were you, I would first do a loop back test on the spi module to check if its functioning using the code in Roberts blog SPI Test Utility Code. And about your last side question, I think that is the size of image that is currently running on your BBB

Hey Will!!

My responses are in green

I am not clear from the guide what SPI things to install. SP0 &

SP1-01? or just one of them?

From your comments it looks like you just need to talk out of 1 spi so my answers are for SPI0.

Also should the optargs entry and the capemgr.enable_partno=BB-SP1-01

be present in that file, or removed?
Replace it with BB-SPI0-01

Thank you Rudy for your files. I am not sure what to do with them. Given what I have detailed above, do I need to do anything with them?

Put BB-SPI0-01-00A0.dtbo in /lib/firmware on your BBB

.dts files are the pre compiled device tree files (human readable form)
You create a .dtbo file by compiling a .dts file
.dbto are files that the BBB will use (machine readable form)

And a side-question about the slots listing at the top of this post,

number 4… why does it say 2Gb not 4Gb? I’m pretty sure I have the

4Gb. Is it that there are 2x2?

Not sure, as far as I can tell it doesn’t affect my 4G BBB in any way

Reboot your BBB and cat the slots again you should see BB-SPI0-01 loaded

root@beaglebone:/# cd /dev

root@beaglebone:/dev# ls
Check that spidev1.0 is in there

IMPORTANT!!! Make sure that the Lenovo SPI is 3.3v and not 5v. If it’s 5v you’ll probably blow those pins on your BBB.

Do you have a program that can send the data out of the SPI?

Thank you Rudy and Vinay for your replies.

I have been reading the blog you recommended. He says:

Hello everyone
I am working on Kernel version 4.4 and I have tried all the mentioned solutions in this discussion but still I can’t add SPI0 or SPI1, If anyone have used this type of kernel please help.

بتاريخ الثلاثاء، 16 يونيو، 2015 8:09:14 م UTC+5:30، كتب Brendan Merna: