How to execute >sudo sh -c "echo BB-SPIDEV0 > $SLOTS" from bash?

Hi,

I am setting up SPI0 for read and write from an ADC. To start I tried the loopback spidev_test found in chp08. This test is not working. When debugged found that the device overlay step is not running as expected.

Details:
.profile is set to run in bash shell with exporting SLOTS variable.

export SLOTS=/sys/devices/platform/bone_capemgr/slots

root@beaglebone:/lib/firmware# source ~/.profile

root@beaglebone:/lib/firmware# sudo cat $SLOTS
0: PF---- -1
1: PF---- -1
2: PF---- -1
3: PF---- -1
4: P-O-L- 0 Override Board Name,00A0,Override Manuf,cape-universaln
root@beaglebone:/lib/firmware#

Above shows the BB-SPIDEV0 is missing hence run the below step. It generates sh: echo: I/O error

sudo sh -c “echo BB-SPIDEV0 > $SLOTS”

How can I set the SPIDEV0 overlay to use SPI0?

SPI loopback result shows 0’s. Suppose to match the TX buffer.

root@beaglebone:~/exploringBB/chp08/spi/spidev_test# ./spidev_test
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)
Debug message: Return value = 38

00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00

OS Details:

uname -a

Linux beaglebone 4.1.15-ti-rt-r43 #1 SMP PREEMPT RT Thu Jan 21 20:13:58 UTC 2016 armv7l GNU/Linux

cat /etc/dogtag
BeagleBoard.org Debian Image 2016-01-24

cat /etc/debian_version
8.3

Appreciate if you can help to resolve the issue.

Thanks,
Ram

Hi,

Please ignore my support request. I could resolve it by keeping the env variable after sudo su.

Regards,
Ram