SPI - chipselect 0 already in use - spi_omap2_mcspi

Hi,

I am having troubles trying to load an out-of-tree module from this particular tutorial:
SPI Device Driver Tutorial - Linux Device Driver Tutorial Part 47 (embetronicx.com)

I am getting the error “omap2_mcspi 481a0000.spi: chipselect 0 already in use”
I think that means another driver is using chipselect 0. So, I rebuilt the kernel and made most SPI modules loadable instead of installed <*>. The one that seems to be causing trouble is spi_omap2_mcspi module. When the module is enabled, it seems to be using chipselect 0. When it is disabled, I get “SPI Master not found”. *spidev doesn’t seem to make any difference whether it is loaded or not, and neither do the overlays. I have tried enabling a disabled the overlays. I also noticed that both “spi_omap2_mcspi” and “spidev” have to be loaded in order for the spi devices to show up in /dev/.

I rebuilt the module using the correct kernel headers.
I loading the module using $sudo insmod spissd1306.ko
Loading and unloading modules is as simple as $sudo modprobe and $sudo rmmod

I recently upgrade the Kernel to 5.10.168-ti-r61 and Debian to 11.6 (Bullseye)
I don’t know if that has anything to do with it, but I posted it here anyways.

$ sudo /opt/scripts/tools/version.sh
git:/opt/scripts/:[1b1122751f7051bd8996f353756ba6ff30e71820]
eeprom:[A335BNLT00C03318BBBK16E8]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Buster IoT Image 2020-04-06]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot SPL 2019.04-00002-g07d5700e21 (Mar 06 2020 - 11:24:55 -0600)]:[location: dd MBR]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2019.04-00002-g07d5700e21]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot SPL 2019.04-00002-g07d5700e21 (Mar 06 2020 - 11:24:55 -0600)]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2019.04-00002-g07d5700e21]:[location: dd MBR]
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot-univ.dts]
UBOOT: Loaded Overlay:[AM335X-PRU-RPROC-4-19-TI-00A0]
UBOOT: Loaded Overlay:[BB-ADC-00A0.bb.org-overlays]
UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0.bb.org-overlays]
UBOOT: Loaded Overlay:[BB-SPIDEV0-00A0]
UBOOT: Loaded Overlay:[BB-SPIDEV1-00A0]
kernel:[5.10.168-ti-r61]
nodejs:[v12.22.12]
/boot/uEnv.txt Settings:
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[disable_uboot_overlay_video=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
uboot_overlay_options:[uboot_overlay_addr4=/lib/firmware/BB-SPIDEV0-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr5=/lib/firmware/BB-SPIDEV1-00A0.dtbo]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.14.20210821.0-0~buster+20210821]
pkg:[bb-customizations]:[1.20221108.0-0~buster+20221108]
pkg:[bb-usb-gadgets]:[1.20220816.0-0~buster+20220816]
pkg:[bb-wl18xx-firmware]:[1.20221201.0-0~buster+20221201]
pkg:[kmod]:[28-1]
pkg:[librobotcontrol]:[1.0.5-git20200715.0-0~buster+20200716]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100]
dmesg | grep remote
[   11.101067] remoteproc remoteproc0: wkup_m3 is available
[   49.855158] remoteproc remoteproc0: powering up wkup_m3
[   49.867038] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217148
[   49.902449] remoteproc remoteproc0: remote processor wkup_m3 is now up
[   86.263745] remoteproc remoteproc1: 4a334000.pru is available
[   86.334608] remoteproc remoteproc2: 4a338000.pru is available
dmesg | grep pru
[    0.179277] platform 4a326004.pruss-soc-bus: Cannot lookup hwmod 'pruss'
[   86.263745] remoteproc remoteproc1: 4a334000.pru is available
[   86.334608] remoteproc remoteproc2: 4a338000.pru is available
dmesg | grep pinctrl-single
[    9.431486] pinctrl-single 44e10800.pinmux: 142 pins, size 568
dmesg | grep gpio-of-helper
[    9.433202] gpio-of-helper ocp:cape-universal: Failed to get gpio property of 'P8_03'
[    9.433229] gpio-of-helper ocp:cape-universal: Failed to create gpio entry
<***Removed Pins for brevity ***>
[   12.000132] gpio-of-helper ocp:cape-universal: ready
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END
[

Thank you,

Change these lines in /boot/uEnv.txt:

uboot_overlay_addr4=BB-SPIDEV0-00A0.dtbo
uboot_overlay_addr5=BB-SPIDEV1-00A0.dtbo

Delete this line:

uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo

Upgrade u-boot:

sudo apt update
sudo apt install bb-u-boot-am335x-evm bb-beagle-version
sudo /opt/u-boot/bb-u-boot-am335x-evm/install.sh

Then reboot, and run sudo beagle-version so we can see if everything is correct…

Regards,

Hi Robert,

I tried the changes you suggest, but there is still no change in operation.

$ sudo beagle-version
eeprom:[A335BNLT00C03318BBBK16E8]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Buster IoT Image 2020-04-06]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot SPL 2022.04-gd0771d53 (Jul 21 2022 - 02:13:23 +0000)]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot SPL 2022.04-gd0771d53 (Jul 21 2022 - 02:13:23 +0000)]:[location: dd MBR]
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot-univ.dts]
UBOOT: Loaded Overlay:[BB-ADC-00A0.kernel]
UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0.kernel]
UBOOT: Loaded Overlay:[BB-SPIDEV0-00A0.kernel]
UBOOT: Loaded Overlay:[BB-SPIDEV1-00A0.kernel]
kernel:[5.10.168-ti-r61]
nodejs:[v12.22.12]
/boot/uEnv.txt Settings:
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[disable_uboot_overlay_video=1]
uboot_overlay_options:[enable_uboot_cape_universal=1]
uboot_overlay_options:[uboot_overlay_addr4=BB-SPIDEV0-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr5=BB-SPIDEV1-00A0.dtbo]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]
pkg:[bb-cape-overlays]:[4.14.20210821.0-0~buster+20210821]
pkg:[bb-customizations]:[1.20221108.0-0~buster+20221108]
pkg:[bb-usb-gadgets]:[1.20220816.0-0~buster+20220816]
pkg:[bb-wl18xx-firmware]:[1.20221201.0-0~buster+20221201]
pkg:[kmod]:[28-1]
pkg:[librobotcontrol]:[1.0.5-git20200715.0-0~buster+20200716]
cmdline:[console=ttyS0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100]
dmesg | grep remote
[ 11.021008] remoteproc remoteproc0: wkup_m3 is available
[ 50.219045] remoteproc remoteproc0: powering up wkup_m3
[ 50.234981] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217148
[ 50.275189] remoteproc remoteproc0: remote processor wkup_m3 is now up
[ 87.927601] remoteproc remoteproc1: 4a334000.pru is available
[ 88.013355] remoteproc remoteproc2: 4a338000.pru is available
dmesg | grep pru
[ 87.927601] remoteproc remoteproc1: 4a334000.pru is available
[ 88.013355] remoteproc remoteproc2: 4a338000.pru is available
dmesg | grep pinctrl-single
[ 9.375372] pinctrl-single 44e10800.pinmux: 142 pins, size 568
dmesg | grep gpio-of-helper
<*** Pins removed for brevity ***>
[ 11.920217] gpio-of-helper ocp:cape-universal: ready
dmesg | grep wlcore
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END

  • Just in case
    $ lsmod
    Module Size Used by
    pru_rproc 28672 0
    irq_pruss_intc 20480 0
    pm33xx 20480 0
    pruss 20480 1 pru_rproc
    ti_eqep 16384 0
    counter 24576 1 ti_eqep
    c_can_platform 16384 0
    c_can 24576 1 c_can_platform
    evdev 24576 1
    wkup_m3_ipc 20480 1 pm33xx
    uio_pdrv_genirq 20480 0
    uio 20480 1 uio_pdrv_genirq
    cpufreq_dt 20480 0
    binfmt_misc 24576 1
    squashfs 53248 2
    loop 32768 4
    can_raw 20480 0
    can_dev 28672 1 c_can
    can 20480 1 can_raw
    ip_tables 28672 0
    x_tables 28672 1 ip_tables

Thank you,