SPI not working on beaglebone

Hi all,

I’m running Nerves on a BeagleBone Black and trying to use SPI from Circuits.SPI.

I can see the devices in /dev:

/dev/spidev0.0
/dev/spidev0.1
/dev/spidev1.0
/dev/spidev1.1

But I’m having trouble confirming which header pins (P9/P8) are actually mapped to these devices under Nerves.

Questions:

  1. What is the correct mapping between /dev/spidev0.0 and BeagleBone header pins when using Nerves?
  2. How can I verify from the Nerves IEx console (using only File.read!, /proc/device-tree, or /sys/devices) that a given pin is really configured for SPI mode?
  3. Is there a recommended way to enable or switch pinmux for SPI pins under Nerves since config-pin is not available?

So far, I’ve opened SPI in IEx like this:

iex(1)> {:ok, ref}=Circuits.SPI.open("spidev0.0", speed_hz: 1_000_000, mode: 3)
{:ok, #Reference<0.2697461337.148504581.45500>}                                                                          
iex(2)> Circuits.SPI.transfer(ref, <<0x80, 0x00>>)
{:ok, <<0, 0>>}  

I’m not getting any response from the SPI slave. I’m using ADXL345 sensor expecting 0xE5 for above read operation

Example wiring to ADXL345 (3.3V SPI sensor)

  • P9_17 (CS0)** → **ADXL345 CS
  • P9_22 (SCLK)** → **ADXL345 SCL
  • P9_18 (MOSI)** → **ADXL345 SDA (data in)
  • P9_21 (MISO)** → **ADXL345 SDO (data out)

Am I Connecting to correct pins? Or pin mapping is different for spidev0.0

Thanks in advance.