Search code examples
androidadbdevice-driverspi

Accessing SPI driver with ADB


I have a SPI channel ennabled on my Android Eval board. With ADB, I get to

# adb shell cat /sys/bus/spi/devices/spi0.0/uevent
DRIVER=spidev
OF_NAME=device
OF_FULLNAME=/soc/spi@07575000/device@0
OF_COMPATIBLE_0=spidev
OF_COMPATIBLE_N=1
MODALIAS=spi:spidev

I searched the web but did not found how to write to this SPI channel in debug (A.K.A adb) without an external driver/application. I'd like to send dummy data on this SPI to know if my pins are correctly configured.

My question is: Which command would get me to send data on SPI with ADB?


Solution

  • As you have the driver running, you can write raw bytes to spi driver file directly using adb shell echo command or dd. For example in my device the power button device file is \dev\input\event0, The raw data to be send to hardware to turn off display(single press) is \012-

    adb shell echo echo -e "\012" > /dev/input/event0

    Also if you have the data to be written as binary file you can do dd

    adb shell dd if=./record1 of=/dev/input/event0

    you need to know your hardawre in \dev\ and use above commands.