No SPI output when using spidev with ioctl()

Hello,

I have been attempting to write C code for using SPI with the BBB. I am manipulating spidev (in my case spidev1.0) with ioctl() however I am unable to get SPI working. All of the libraries I have tried to use with a similar method also don’t seem to work (e.g. https://github.com/deeplyembeddedWP/BeagleBone-SPI-Library, https://github.com/photomankc/BeagleBone-Black-Robot-Library/blob/master/motors/l6470.h). When I hook up the BBB SPI1 pins to the scope, there is no output.

I have disabled the HDMI boot overlays (audio and video) and enabled the SPI1 overlay. I am able to see signals on the scope with the Python Adafruit_BBIO.SPI library but with this method I have been unsuccessful. Is there something else to setup?

uname -r:
4.14.71-ti-r80

Thanks!

Please share your uEnv and code. An output of the console during boot would be helpful as well. I am struggling with the same problem on the Octavo Red development board (a PocketBeagle with more stuff). Oscilloscope hooked up to SPI_CS1. No pulses when doing a transfer and the signal is low…should be high with no activity. I don’t believe the pins are mux’d correctly. Or, clocks are not being provided to the peripheral. I am used to working with QNX using register level operations to mux the pins, turn on the clocks and control the SPI bus. That works. Trying out Linux at the moment as an experiment.

For code, I was using the example Main.c from this library: https://github.com/deeplyembeddedWP/BeagleBone-SPI-Library/tree/master/Example

uEnv.txt:

#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0

uname_r=4.14.71-ti-r80

#uuid=

#dtb=

###U-Boot Overlays###

###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays

###Master Enable

enable_uboot_overlays=1

Here is console log for my system. Not dmesg. You need an FTDI TTL3V3 to USB connected to the 5 pin header to see this. Note lines highlighted in red showing that the SPI overlay loaded.

U-Boot SPL 2017.09-rc2-00002-g7c9353e752 (Aug 31 2017 - 09:25:14)
Trying to boot from MMC2

U-Boot 2017.09-rc2-00002-g7c9353e752 (Aug 31 2017 - 09:25:14 -0500), Build: jenkins-github_Bootloader-Builder-596

CPU : AM335X-GP rev 2.1
I2C: ready
DRAM: 512 MiB
No match for driver ‘omap_hsmmc’
No match for driver ‘omap_hsmmc’
Some drivers were not found
Reset Source: Global warm SW reset has occurred.
Reset Source: Power-on reset has occurred.
MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
Using default environment

Board: BeagleBone Black
not set. Validating first E-fuse MAC
BeagleBone Black:
BeagleBone: cape eeprom: i2c_probe: 0x54:
BeagleBone: cape eeprom: i2c_probe: 0x55:
BeagleBone: cape eeprom: i2c_probe: 0x56:
BeagleBone: cape eeprom: i2c_probe: 0x57:
Net: eth0: MII MODE
Could not get PHY for cpsw: addr 0
cpsw
Press SPACE to abort autoboot in 2 seconds
board_name=[A335BNLT] …
board_rev=[BBNR] …
Card did not respond to voltage select!
mmc_init: -95, time 12
Card did not respond to voltage select!
mmc_init: -95, time 13
Card did not respond to voltage select!
mmc_init: -95, time 13
gpio: pin 56 (gpio 56) value is 0
gpio: pin 55 (gpio 55) value is 0
gpio: pin 54 (gpio 54) value is 0
gpio: pin 53 (gpio 53) value is 1
Card did not respond to voltage select!
mmc_init: -95, time 12
Card did not respond to voltage select!
mmc_init: -95, time 12
switch to partitions #0, OK
mmc1(part 0) is current device
Scanning mmc 1:1…
gpio: pin 56 (gpio 56) value is 0
gpio: pin 55 (gpio 55) value is 0
gpio: pin 54 (gpio 54) value is 0
gpio: pin 53 (gpio 53) value is 1
switch to partitions #0, OK
mmc1(part 0) is current device
gpio: pin 54 (gpio 54) value is 1
Checking for: /uEnv.txt …
Checking for: /boot.scr …
Checking for: /boot/boot.scr …
Checking for: /boot/uEnv.txt …
gpio: pin 55 (gpio 55) value is 1
2102 bytes read in 17 ms (120.1 KiB/s)
Loaded environment from /boot/uEnv.txt
debug: [dtb=osd3358-bsm-refdesign.dtb] …
Using: dtb=osd3358-bsm-refdesign.dtb …
Checking if uname_r is set in /boot/uEnv.txt…
gpio: pin 56 (gpio 56) value is 1
Running uname_boot …
loading /boot/vmlinuz-4.9.45-ti-r57 …
9464664 bytes read in 620 ms (14.6 MiB/s)
uboot_overlays: dtb=osd3358-bsm-refdesign.dtb in /boot/uEnv.txt, unable to use [uboot_base_dtb=am335x-boneblack-uboot.dtb] …
loading /boot/dtbs/4.9.45-ti-r57/osd3358-bsm-refdesign.dtb …
64053 bytes read in 126 ms (496.1 KiB/s)
uboot_overlays: [fdt_buffer=0x60000] …
uboot_overlays: loading /lib/firmware/AM335X-20-00A0.dtbo …
378 bytes read in 807 ms (0 Bytes/s)
uboot_overlays: loading /lib/firmware/BB-SPIDEV1-00A0.dtbo …
1523 bytes read in 382 ms (2.9 KiB/s)
uboot_overlays: loading /lib/firmware/BB-BONE-eMMC1-01-00A0.dtbo …
1440 bytes read in 746 ms (1000 Bytes/s)
uboot_overlays: uboot loading of [/lib/firmware/BB-HDMI-TDA998x-00A0.dtbo] disabled by /boot/uEnv.txt [disable_uboot_overlay_video=1]…
uboot_overlays: loading /lib/firmware/BB-ADC-00A0.dtbo …
711 bytes read in 362 ms (1000 Bytes/s)
uboot_overlays: loading /lib/firmware/AM335X-PRU-UIO-00A0.dtbo …
883 bytes read in 169 ms (4.9 KiB/s)
uboot_overlays: cape universal disabled, external cape enabled or detected…
loading /boot/initrd.img-4.9.45-ti-r57 …
6154201 bytes read in 407 ms (14.4 MiB/s)
debug: [console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk1p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet] …
debug: [bootz 0x82000000 0x88080000:5de7d9 88000000] …

Flattened Device Tree blob at 88000000

Booting using the fdt blob at 0x88000000
Loading Ramdisk to 8fa21000, end 8ffff7d9 … OK
reserving fdt memory region: addr=88000000 size=70000
Loading Device Tree to 8f9ae000, end 8fa20fff … OK

Starting kernel …

[ 0.001156] clocksource_probe: no matching clocksources found
[ 2.307503] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle
[ 2.440981] cpu cpu0: “ti,syscon-efuse” is missing, cannot use OPPv2 table.
[ 2.531883] ti_emif_sram 4c000000.emif: Unable to get sram pool for ocmcram data
[ 2.549968] omap_voltage_late_init: Voltage driver support not added
[ 2.559195] PM: Cannot get wkup_m3_ipc handle
[ 2.811784] bone_capemgr bone_capemgr: slot #0: auto loading handled by U-Boot
[ 2.819219] bone_capemgr bone_capemgr: slot #1: auto loading handled by U-Boot
[ 2.826815] bone_capemgr bone_capemgr: slot #2: auto loading handled by U-Boot
[ 2.834184] bone_capemgr bone_capemgr: slot #3: auto loading handled by U-Boot
rootfs: clean, 124733/962880 files, 897291/3846144 blocks

Debian GNU/Linux 9 beaglebone ttyS0

BeagleBoard.org Debian Image 2017-08-31

Support/FAQ: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian

default username:password is [debian:temppwd]

beaglebone login: [ 23.246254] pinctrl-single 44e10800.pinmux: pin PIN100 already requested by 48038000.mcasp; cannot claim for 481a0000.spi
[ 23.955982] pinctrl-single 44e10800.pinmux: pin-100 (481a0000.spi) status -22
[ 24.279949] pinctrl-single 44e10800.pinmux: could not request pin 100 (PIN100) from group pinmux_bb_spi1_pins on device pinctrl-single
[ 24.867834] omap2_mcspi 481a0000.spi: Error applying setting, reverse things back

Here is my uEnv

ebian@beaglebone:~$ cat /boot/uEnv.txt
#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0

uname_r=4.9.45-ti-r57
#uuid=
dtb=osd3358-bsm-refdesign.dtb
#dtb=osd335x-lesson2-tfp.dtb

###U-Boot Overlays###
###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays
###Master Enable
enable_uboot_overlays=1

spi-cs.jpg