I'm posting this here hoping to save others some frustration/pain that I've gone through as a noobie trying to get SPI working on the beagle bone black wireless.
The documentation for this is a shambles currently, with conflicting and out of date information all over the internet.
So, for those who find this post via google, let me explain what's going on and how we got to here. SPI on the BBB is actually really easy, it just may not seem like it.
Ok, for starters when you google this, you've probably found a bunch of information on dts, overlays, capemgr, slots, etc...
I'll take a sec to explain the history of this first.
So, linux traditionally used kernel modules (drivers) for every piece of hardware that you might want to use. This strategy didn't work very well when all these ARM devices like the beagle bone started showing up because there were so many devices with different configurations, and it really didn't make sense to add all that to the kernel. As a solution to this, Linus came up with this idea for a level of abstraction called a device tree.
The device tree is basically a way to describe the mapping and purpose of physical hardware to the kernel. This is done via a 'dts' file, which is a source code file that lists the specific properties of the hardware. This source code file is compiled into a binary that the kernel can understand, a 'dtb' or 'dtbo' file. So, early on in beagle bone history, this was how things were done. There were lots of dts and dtbo files that were made for all sorts of different purposes, and you, as the user could swap these out depending on how you want pins configured. You can also create your own. This is where some of the older articles you see that have instructions about creating a dts file and compiling it to enable SPI come from.
Well, that whole thing was pretty spiffy, but there were some drawbacks. One, it wasn't very approachable for new folks. You basically had to learn a new language and toolchain just to configure pins. While better than writing a kernel module, that still wasn't great. Also, all of this configuration happened at boot time, so every time you wanted to make a change you had to reboot. This really doesn't work well for a device where you want to be able to hot swap extension boards and reconfigure things at runtime. Third, this all happened in kernel space, which as an industry we try not to do. It's better to keep as much as possible in user space.
To address those issues: enter the Cape Manager. The cape manager is a pretty fancy piece of kernel module software that has the ability to dynamically load and swap out device tree overlays, and the tools live in userspace. When you see instructions on the web about adding lines to uEnv.txt like:
optargs=quiet drm.debug=7 capemgr.enable_partno=BB-SPIDEV0
This is telling the cape manager to load the SPI device tree overlay at boot time. Everywhere you look on the internet, this is the recommended solution for enabling SPI on 'current' devices. But, it doesn't work.
Why? Well, to explain that requires one more step.
Even though the cape manager is neat software from an engineering perspective, and really accomplished its goals well, it still leaves something to be desired from a new user perspective. Folks who are just getting into the whole maker scene are reasonably confused by all this.
To address that, some new software was created (which is enormously fancy), called universal io.
Basically what this is, is a device tree overlay that's loaded by the cape manager at boot time that has the ability to dynamically configure all of the pins at runtime using a tool called config-pin.
You can see it and read more about it here: https://github.com/cdsteinkuehler/beaglebone-universal-io
So, with this utility all of the pins that aren't reserved for HDMI can be hot configured by using the simple config-pin command, and this includes SPI!
So, finally after that long bit of history, here's how you actually set up and use SPI on a new beagle bone black wireless with a current image:
#data out
config-pin P.18 spi
#clock out
config-pin P.22 spi
Rinse, repeat if you need other pins like CS, or MISO.
After days of learning all of the above, and figuring all this out, I'm finally able to see a beautiful output waveform on my oscope.
I hope this helps someone else new to all this!
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/e15aca05-5d5a-4c4c-8e48-5ed0a9ef0973%40googlegroups.com.--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/RewjY34TPYE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CALHSORp3%3DAsXcvmtMREfRd1H4OKtnOyJQx8jgvB-_h7fayU3Tg%40mail.gmail.com.
Hi William, I got a weird error on my original post, and I couldn't find it anywhere, so I reposted it. If you can find the original, I'll delete one. Thanks!
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/42488410-1f08-42eb-8aa4-30d403225f30%40googlegroups.com.
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/RewjY34TPYE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard+unsubscribe@googlegroups.com.
Hi William, if you could point to an easily discoverable source which says that Universal IO is available in the latest images and encouraged to be used, then you could be correct.Being able to successfully manipulate the SOC multiplexer is fundamental to getting a Beagleboard project off the ground.If there is no such info, which should be right at the top, then Clayton's post is a pretty good version 1.0 guide for newbies.
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/daacf5b9-572f-4fcb-b609-0d598dd2f0e7%40googlegroups.com.
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/d7035e17-09a1-4839-b287-cfcecc60576d%40googlegroups.com.
So, this is what so (fun?) about the BB ecosystem.I'm updating to the most recent image, trying to run code that has been working great for a good long time now, and it fails utterly with the same issue Nuno is experiencing.I understand William Herman's point of view - for him, this is blaringly obvious. Why so hard? I'm sure he wonders. I'm willing to bet that William is an expert at embedded linux, and perhaps does it as a day job. That's admirable, and I think it would be fun to do that too.But I don't.I like making blinky lights. https://www.facebook.com/claytongulick/videos/pcb.10155266610164779/10155266622269779/?type=3&theaterMy point here, is that if the BB community expects folks like me to stick around and not just use a raspberry pi for everything, we need to make this stuff easier.I'm using the same documented SPI pins that Nuno is using, and on the latest image, it just doesn't work. Not only that, but the commands in uEnv.txt have changed.Where is the documentation on this? How are we expected to figure this out?And now, according to Robert, I just simply can't use the pins I was using before without using something called dtb-rebuilder?Look guys, I know this stuff is like breathing to you and not a big deal. But changes like this without clear documentation are going to lose the hobbyist/maker community.Sorry for the rant, I'm a bit frustrated, it's midnight and I've been working on this for hours without success, just to get SPI working the same way it used to.For now, I'm going to revert to an older image. I'd love to update my github doc with some clear instructions on how to get SPI up and going on all of the documented SPI pins if someone can point me to a place where I can figure it out.