[BBB] trouble enabling spi (yet another thread)

This forum is for supported devices using an ARMv7 Texas Instruments (TI) SoC.

[BBB] trouble enabling spi (yet another thread)

Postby iBaf1824 » Mon Apr 18, 2022 7:08 pm

Hello people,
I'm currently trying to enable the SPI peripheral on my beaglebone black to get access to the /dev/spidev* devices. However all my tries have been unsuccessful so far.

I mainly followed this and this thread.

What seems to work is to apply the device tree overlay BB-SPIDEV0-00A0.dtbo. But the problem is that the corresponding interface under /dev/ doesn't appear. I can see the overlay is applied under /proc/device-tree/chosen/overlays/ and the kernel also loads the spidev kernel module, so that seems to work. Also there are no relevant errors in the U-boot log or the kernel log. There is no mentioning of spi in the kernel log at all. So this is not the issue.

There was also some mentioning of the necessity of disabling the hdmi port in order to use the SPI ports. Reading the elinux wiki it sounds as disabling the hdmi port is only necessary if one wants to use SPI1 but not for SPI0 peripheral. And indeed when I also load the SPI1 overlay, I get some PIN errors in the kernel log.

I also tried to disable HDMI in various different ways, but the SPI device never appeared. One thing I can say is that summers method described here, doesn't work (anymore). I get the following errors in the U-boot log multiple times:
$this->bbcode_second_pass_quote('', 'l')ibfdt fdt_path_offset() returned FDT_ERR_NOTFOUND

I also tried to additionally load the overlay BB-NHDMI-TDA998x-00A0.dtbo according to this thread, which is also supposed to disable the HDMI port, but still no luck.

I honestly don't know what else to try and I'd be very grateful for some advice whats wrong here and how to get the interface working. Thanks!
iBaf1824
 
Posts: 2
Joined: Mon Apr 18, 2022 6:27 pm

Re: [BBB] trouble enabling spi (yet another thread)

Postby summers » Wed Apr 20, 2022 4:17 pm

I don't recall /proc/device-tree/chosen/overlays/ being populated in the mainline way of applying overlays, they are applied in uboot, and didn't think a record was kept - I'll check when I get home.

Can you paste your /boot/boot.txt

You should have a line line: $this->bbcode_second_pass_code('', 'fdt addr ${fdt_addr_r}') - which is all I can thing is giving problems. Also which version of uboot are you using?
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: [BBB] trouble enabling spi (yet another thread)

Postby summers » Wed Apr 20, 2022 8:22 pm

OK - I've tried in /boot/boot.txt:
$this->bbcode_second_pass_code('', '# After modifying, run ./mkscr

if test -n ${distro_bootpart}; then setenv bootpart ${distro_bootpart}; else setenv bootpart 1; fi
part uuid ${devtype} ${devnum}:${bootpart} uuid

setenv bootargs "console=tty0 console=${console} root=PARTUUID=${uuid} rw rootwait"

if load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} /boot/zImage; then
gpio set 54
echo fdt: ${fdtfile}
if load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} /boot/dtbs/${fdtfile}; then
gpio set 55
fdt addr ${fdt_addr_r}
load ${devtype} ${devnum}:${bootpart} 0x88060000 /lib/firmware/BB-SPIDEV0-00A0.dtbo
fdt resize ${filesize}
fdt apply 0x88060000
fdt resize
if load ${devtype} ${devnum}:${bootpart} ${ramdisk_addr_r} /boot/initramfs-linux.img; then
gpio set 56
bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
else
gpio set 56
bootz ${kernel_addr_r} - ${fdt_addr_r};
fi;
fi;
fi
')
And then when running $this->bbcode_second_pass_code('', './mkscr')
and reboot and:
$this->bbcode_second_pass_code('', 'ls /dev/spi*
/dev/spidev0.0 /dev/spidev0.1')
So if you did this - it will work ....
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: [BBB] trouble enabling spi (yet another thread)

Postby iBaf1824 » Thu Apr 21, 2022 4:16 pm

Thanks for the reply, I finally got it working. For preservation reasons I'll quickly write down what was wrong.

So my boot.txt is pretty much the same as yours. After I came across this kernel documentation, I figured out that that I had to manually bind the driver to the device as explained in the kernel doc. So after I did that, the spidev devices magically appeared. To manually enable them I did the following for both devices:
$this->bbcode_second_pass_code('', '
echo spidev > /sys/bus/spi/devices/spiB.C/driver_override
echo spiB.C > /sys/bus/spi/drivers/spidev/bind
')

After further searching around I figured out how to make the kernel automatically bind the driver.
The kernel expects a compatible field in the device tree overlay (in this case in the BB-SPIDEV0-00A0.dts). The dtbo that comes with the arch kernel package uses the deprecated value of compatible = "spidev". Nowadays the kernel expects a specific controller name. So I edited the device tree overlay to include the BBB SPI controller name:
compatible = "spidev,dh2228fv"; (value comes from here)
So now everything works as expected.

@summers just out of curiosity, did you have to do any of the above?
iBaf1824
 
Posts: 2
Joined: Mon Apr 18, 2022 6:27 pm

Re: [BBB] trouble enabling spi (yet another thread)

Postby summers » Thu Apr 21, 2022 8:18 pm

Yes I wondered if my worked because I only update my BBB rarely - as it only has a 1GB on. Anyway updating linux to the latest - and yes you are right /dev/spi* disappear, so something changed in linux in something like the year!

Clue was $this->bbcode_second_pass_code('', '/proc/device-tree/chosen/overlays/BB-SPIDEV0-00A0') that was added to dts about 3 years ago, after I fiddled with this to get it working: https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-SPIDEV0-00A0.dts

The device-tree is set up very different than before. I need to dig into why and whats happened.

You links will be a good read, alas to busy right now - maybe later ...
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: [BBB] trouble enabling spi (yet another thread)

Postby summers » Fri Apr 22, 2022 9:05 am

OK have got to the bottom of it - and yes you have found the source spidev is no longer an acceptable compatible string. So the current overlay https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-SPIDEV0-00A0.dts is not compatible with the modern kernel.

The commit that made this so in the kernel is: https://github.com/torvalds/linux/commit/fffc84fd87d963a2ea77a125b8a6f5a3c9f3192d - seems to make sense.

So yes probably have to get beagleboard (e.g Robert Nelson) to update the overlay ...

[And for what its worth, it worked for me in linux 5.11.2-1 but update to 5.17.1-1 and no longer works there]

Strange thing is, in the device tree where spi is set up https://github.com/torvalds/linux/blob/master/arch/arm/boot/dts/am33xx-l4.dtsi, its given the compatible $this->bbcode_second_pass_quote('', 'c')ompatible = "ti,omap4-mcspi";
- so have to wonder why Robert didn't use that ...
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm


Return to Texas Instruments (TI)

Who is online

Users browsing this forum: No registered users and 8 guests