0

I am working to enable spi on my beaglebone black (Angstrom distribution), using instructions here.

I am at the point where i need to add BB-SPI1-01 to /sys/devices/bone_capemgr.*/slots to enable the drivers.

issuing the command echo BB-SPI1-01 > /sys/devices/bone_capemgr.*/slots or echo BB-SPI1-01 >> /sys/devices/bone_capemgr.*/slots, however, yields the error echo: Write error: file exists

Trying to edit in the line with nano also fails. I'm able to open the file and edit it, but when I save it gives me Error writing slots: no such file or directory

I've set permissions on the file to 777.

Does anybody know why I cannot edit the file? if it's not possible, is there a workaround?

5 Answers 5

2

I, too have battled with this dilemma while trying to port ILI9340C display stuff to Beaglebone Black. The way /dev/devices/bone_capemgr.* works is that anything which you echo to its slots directory it goes and searches for a Device Tree overlay for that device, a new thing in Linux Kernel 3.0 and higher. For anyone who does not know (it took me forever to find this) Device Trees are basically a driver that tells Linux how to deal with a device, but instead of containing any code, they are simply a configuration file, per-se, that tells Linux what to put where in order to talk to a device, and what to expect in return. That being said, BB-SPIx-01 is a compiled Device Tree file, a .dts in /lib/firmware/ which points to the SPI device, and tells spidev what to do with it.

BB-SPI1-01 happens to be connected to the HDMI port already for some audio thing (I think) and, therefore, unless you disable HDMI entirely, SPI1 is always tied up by the HDMI framer. This explains why writing BB-SPI1-01 to /sys/devices/bone_capemgr.*/slots fails. This is a special file, and when you write to it, a kernel process reads your input and proceeds to attempt to make a 'device' file elsewhere, and since BB-SPI1-01 is already enabled, that file already exists, and so the kernel process that handles those things returns an error and pipes it through whatever process initiated it, in this case, you, the user, typing echo BB-SPI1-01 > /sys/devices/bone_capemgr.*/slots.

On the bright side, SPI0 is left unused. Therefore, in order to use it, all you have to do is enable it in userland. To do that, (and you have figured this out already, but for everyone else) type echo BB-SPI0-01 > /sys/devices/bone_capemgr.*/slots at the command line, and then just to be sure that spidev is running, type modprobe spidev as root. Now, to verify, type ls /dev | grep spi and see what comes up. /dev/spidevX.Y is your SPI bus, for me that would be /dev/spidev1.0.

I'm sorry that was really long winded, but I'm culminating my research thus far into one spot in the hopes that it will help someone.

If you have any questions, please feel free to ask!

1
  • 1
    FYI dmsg has some error messages for the matter, for example in my case it was: [ 1213.370642] bone-capemgr bone_capemgr.8: slot #8: beagleback-01 conflict P8.45 (#5:BB-BONELT-HDMI) [ 1213.380306] bone-capemgr bone_capemgr.8: slot #8: Failed verification and it caused "write error: File exists"
    – Mixaz
    Apr 27, 2014 at 19:45
1

For those who are curious, while I haven't found the exact answer, I did find some more information.

The SPI1 interface on the beaglebone black can't be enabled unless the hdmi interface has been turned off, which I have not done. I'm instead using the SPI0 interface now. Interestingly, that same command works if BB-SPI0-01 is used instead of BB-SPI1-01. Therefore the error in question is probably not coming from the base command, but rather the system in response to the command (which can't allocate the resources requested due to conflicts with hdmi).

While I haven't tested SPI1 with hdmi turned off, I can only assume that my errors would go away.

0

Might it be because you're trying to access more than one file at a time with echo BB-SPI1-01 > /sys/devices/bone_capemgr.*/slots ?

Try selecting single path to the slots file and see if that works

1
  • There is in fact only one possible replacement for the wild card in the path (8), so multiple paths isn't an issue, but i tried it anyways. No dice. Jul 18, 2013 at 17:27
0

Based on PyroAVR's answer, here is the concrete solution. You need to disable HDMI, that's easily done by editing the following file: /boot/uEnv.txt

You can uncomment the line which causes HDMI to be disabled by running the following command as root:

sed -i.bck '/cape_disable=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN$/ s/^#//' /boot/uEnv.txt
0

as Mixaz mentioned in a comment, the real errors are found in the dmesg output; "no such file or directory" is a red herring, and even strace doesn't give any clues as to the real problem. in my case I found:

[26858.517893] bone_capemgr bone_capemgr: slot #5: override
[26858.517937] bone_capemgr bone_capemgr: Using override eeprom data at slot 5 
[26858.517986] bone_capemgr bone_capemgr: slot #5: 'Override Board Name,00A0,Override Manuf,jc_gpio_test'
[26924.230357] bone_capemgr bone_capemgr: part_number 'jc_gpio_test', version 'N/A'

from that I guessed that it didn't like "0000" as a version number, changed to "00A0" and recompiled, then it worked.

here's the Makefile I wrote to help automate the process, in case it helps.

%.install: %-00A0.dtbo
    cp -f $< /lib/firmware
    echo $* > /sys/devices/platform/bone_capemgr/slots
%-00A0.dtbo: %.dts
    dtc -O dtb -o $@ -b 0 -@ $<

use it as: make jc_gpio_test.install, assuming your .dts file name is jc_gpio_test.dts.


it turns out, my guess was probably wrong. the change that more likely fixed it was adding the -00A0 part to the dtbo file. apparently the "dash-versionnumber" is required by the slot loader.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.