We have custom kernel for 5.15.95-bone-rt-r34 Beaglebone black, I’m enabling spi1 through our dtsi file and it is detected under /dev/spidev1.0.
But when i try to write any values using Adafruit_BBIO.SPI library it is always writing zeros.
I’m disabling HDMI by uncommenting below two lines in /boot/uEnv.txt
Even if i use BB-SPIDEV1-00A0.dtbo overlay, it is not writing the values what i’m writing it is always zero.
Can you please let us know what i’m missing while enabling the SPI in kernel and why it is writing zeros
I believe older version of uboot did not support devicetree overlays, but if the above is loading then your uboot should work.
Are you using the standard BBB devicetree or have you modified it in any way ?
Check your kernel config options against a stand BBB to make sure you have all the required serial bits.
If you have a DSO it is probably easier to just check for signals. If you have a clock and CS going, then probably nothing wrong with the kernel build. It would be down to the DTS. IF you have nothing it could be the kernel or devicetree still.
If you run a normal BBB kernel does the spi work then ? If yes then certainly for kernel config, if no it is devicetree.
Make sure you have nothing else trying to configure the same pin. This can be time consuming as you will need to check all DTS files that get pulled in.
Are you using the standard BBB devicetree or have you modified it in any way ?
– Yes, we have done the modification based on our requirements. I’ve attached our .dtsi file for refference
If you have a DSO it is probably easier to just check for signals. If you have a clock and CS going, then probably nothing wrong with the kernel build. It would be down to the DTS. IF you have nothing it could be the kernel or devicetree still.
– I checked clock and CS pins using DSO, it is not giving any signal. Clock is always low.
The adafruit library is pretty old and I don’t think maintained so may be an issue. There is at least one spidev python library which you can try.
In your device tree I see you have compatible = "linux,spidev"; As I understand it you need to modify the spidev kernel driver if you use this. Most of the time compatible = "rohm,dh2228fv"; is used as this does not require any changes. However this is done in the BB-SPI overlay so probably not the cause.
Can you load up a default BBB 5 kernel image with working SPI and dump the kernel config and compare it against your custom config. This might point to differences in the kernel.
Can you load up a default BBB 5 kernel image with working SPI and dump the kernel config and compare it against your custom config. This might point to differences in the kernel.
– are you saying that we need to check with latest demo image of beaglebone black?
(Latest Software Images - BeagleBoard)
If it is that, We’ll not get access to dtsi files in demo images right.
If it is not that, Can you please help by sharing the steps or any links to dump the kernel config for BBB 5 kernel image with working SPI for our reference.
No, if you download a 5.x BBB image and flash it to an sd card (no need to flash to emmc), once booted you can do
zcat /proc/config.gz
This will list all the kernel options used to build the kernel. You can then compare it against what you are building. You need as close to your custom kernel version wise, but anything with a 5 kernel will probably do.
You haven’t said if the spidev kernel module is loaded. This is not loaded automatically.
Did you enable the spidev module when compiling the kernel ?
— Yes it is enabled.
#
# SPI Protocol Masters
#
CONFIG_SPI_SPIDEV=y
# CONFIG_SPI_LOOPBACK_TEST is not set
# CONFIG_SPI_TLE62X0 is not set
CONFIG_SPI_SLAVE=y
CONFIG_SPI_SLAVE_TIME=m
CONFIG_SPI_SLAVE_SYSTEM_CONTROL=m
# CONFIG_SPMI is not set
# CONFIG_HSI is not set
CONFIG_PPS=y
# CONFIG_PPS_DEBUG is not set
In that structure have you got an entry for compatible = "linux,spidev"; ?
The compatible you have in the spidev node in the device tree must match an entry in that structure or the spidev driver won’t load. At least as of the 5.10 kernel I have source for, that is not the case. This could be why modprobe is failing.
Yes any in that list is fine to use in the devicetree. Also I see that in your custom kernel the spidev driver is compiled in, so no need for modprobe.
So that pretty much leaves the devicetree as the reason you have no output.
Let me just grab a recent BBB image and try it out on my BBB
Ok, so installing Debian 11 from March this year and just adding BB-SPIDEV1-00A0.dtbo to uEnv.txt, no other changes and installing the python spidev module and it appears to work fine.
So are you adding your custom kernel to an already installed Debian image, or are you building the whole from scratch.
What other DTS files have you modified ?
– No. I’ve only modified am335x-bone-common.dtsi that is also for enabling I2C1, I2C2, UART1, UART2, UART4, LCD.
Are you loading any other overlays ?
– No, I’m not adding any other overlays except SPIDEV1
/boot/uEnv.txt