Skip to content

Instantly share code, notes, and snippets.

@pdp7
Last active February 12, 2016 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdp7/540d5e33ed0e4cb307e7 to your computer and use it in GitHub Desktop.
Save pdp7/540d5e33ed0e4cb307e7 to your computer and use it in GitHub Desktop.
debian@beaglebone:~$ sudo cat /etc/dogtag 
BeagleBoard.org Debian Image 2015-11-12
debian@beaglebone:~$ uname -a
Linux beaglebone 3.8.13-bone79 #1 SMP Tue Oct 13 20:44:55 UTC 2015 armv7l GNU/Linux
debian@beaglebone:~$ sudo strace -e open -fF python test.py 2>&1 |grep /sys/
open("/sys/devices", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
open("/sys/devices/bone_capemgr.9/slots", O_RDWR|O_LARGEFILE) = 3
open("/sys/devices", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
open("/sys/devices/ocp.3", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
open("/sys/devices/ocp.3/helper.15/AIN0", O_RDONLY) = 3
open("/sys/devices/ocp.3/helper.15/AIN1", O_RDONLY) = 3
open("/sys/devices/ocp.3/helper.15/AIN1", O_RDONLY) = 3
open("/sys/devices/ocp.3/helper.15/AIN1", O_RDONLY) = 3
  • Update to TI 4.1.x kernel
sudo ./update_kernel.sh --ti-channel --lts-4_1
#reboot
debian@beaglebone:~$ uname -a
Linux beaglebone 4.1.15-ti-r40 #1 SMP PREEMPT Fri Jan 8 01:27:33 UTC 2016 armv7l GNU/Linux
  • Attempt to run test in Linux 4.1.15
debian@beaglebone:~$ sudo python ./test.py 
Traceback (most recent call last):
  File "./test.py", line 6, in <module>
    ADC.setup()
RuntimeError: Unable to setup ADC system. Possible causes are: 
  - A cape with a conflicting pin mapping is loaded 
  - A device tree object is loaded that uses the same name for a fragment: helper
  

root@beaglebone:/sys# cat /sys/devices/platform/bone_capemgr/slots
 0: PF----  -1 
 1: PF----  -1 
 2: PF----  -1 
 3: PF----  -1 

root@beaglebone:/sys# grep -v ^# /boot/uEnv.txt |grep -v '^$'
uname_r=4.1.15-ti-r40
cmdline=coherent_pool=1M quiet init=/lib/systemd/systemd cape_universal=enable

root@beaglebone:/sys# find /lib/firmware/|grep -i adc
/lib/firmware/PyBBIO-ADC-00A0.dtbo
/lib/firmware/LICENCE.broadcom_bcm43xx

root@beaglebone:/sys# echo PyBBIO-ADC > /sys/devices/platform/bone_capemgr/slots 

root@beaglebone:/sys# dmesg
[  518.331431] bone_capemgr bone_capemgr: part_number 'PyBBIO-ADC', version 'N/A'
[  518.331533] bone_capemgr bone_capemgr: slot #4: override
[  518.331580] bone_capemgr bone_capemgr: Using override eeprom data at slot 4
[  518.331634] bone_capemgr bone_capemgr: slot #4: 'Override Board Name,00A0,Override Manuf,PyBBIO-ADC'
[  518.347995] bone_capemgr bone_capemgr: slot #4: dtbo 'PyBBIO-ADC-00A0.dtbo' loaded; overlay id #0

root@beaglebone:/sys# cat  /sys/devices/platform/bone_capemgr/slots
 0: PF----  -1 
 1: PF----  -1 
 2: PF----  -1 
 3: PF----  -1 
 4: P-O-L-   0 Override Board Name,00A0,Override Manuf,PyBBIO-ADC

root@beaglebone:/sys# find |grep adc |grep -iv broadcom |grep -iv firmware|grep -v broadcast|less
./bus/platform/devices/44e0d000.tscadc
./devices/platform/ocp/44e0d000.tscadc/driver_override
./devices/platform/ocp/44e0d000.tscadc/modalias
./devices/platform/ocp/44e0d000.tscadc/subsystem
./devices/platform/ocp/44e0d000.tscadc/of_node
./devices/platform/ocp/44e0d000.tscadc/uevent

  • Still get error:
debian@beaglebone:~$ sudo python ./test.py 
Traceback (most recent call last):
  File "./test.py", line 6, in <module>
    ADC.setup()
RuntimeError: Unable to setup ADC system. Possible causes are: 
  - A cape with a conflicting pin mapping is loaded 
  - A device tree object is loaded that uses the same name for a fragment: helper
  • Install bb.org overlays:
debian@beaglebone:~/bb.org-overlays$ git clone https://github.com/beagleboard/bb.org-overlays
debian@beaglebone:~/bb.org-overlays$ sudo ./dtc-overlay.sh 
debian@beaglebone:~/bb.org-overlays$ sudo ./install.sh
debian@beaglebone:~/bb.org-overlays$ sudo reboot
  • Disable cape universal:
debian@beaglebone:~$ cat /sys/devices/platform/bone_capemgr/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

debian@beaglebone:~$ sudo vi /boot/uEnv.txt 
#cmdline=coherent_pool=1M quiet init=/lib/systemd/systemd cape_universal=enable
cmdline=coherent_pool=1M quiet init=/lib/systemd/systemd 

# REBOOT

debian@beaglebone:~$ cat /sys/devices/platform/bone_capemgr/slots
 0: PF----  -1 
 1: PF----  -1 
 2: PF----  -1 
 3: PF----  -1 

debian@beaglebone:~$ sudo /bin/sh -c "echo 'BB-ADC' > /sys/devices/platform/bone_capemgr/slots"

debian@beaglebone:~$ cat /sys/devices/platform/bone_capemgr/slots
 0: PF----  -1 
 1: PF----  -1 
 2: PF----  -1 
 3: PF----  -1 
 4: P-O-L-   0 Override Board Name,00A0,Override Manuf,BB-ADC

debian@beaglebone:~$ sudo python ./test.py 
Traceback (most recent call last):
  File "./test.py", line 6, in <module>
    ADC.setup()
RuntimeError: Unable to setup ADC system. Possible causes are: 
  - A cape with a conflicting pin mapping is loaded 
  - A device tree object is loaded that uses the same name for a fragment: helper

root@beaglebone:~# find /sys |grep -i adc|grep raw
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage0_raw
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage1_raw
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage2_raw
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage3_raw
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage4_raw
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage5_raw
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage6_raw

root@beaglebone:~# dmesg
[  160.855554] bone_capemgr bone_capemgr: part_number 'BB-ADC', version 'N/A'
[  160.855647] bone_capemgr bone_capemgr: slot #4: override
[  160.855695] bone_capemgr bone_capemgr: Using override eeprom data at slot 4
[  160.855748] bone_capemgr bone_capemgr: slot #4: 'Override Board Name,00A0,Override Manuf,BB-ADC'
[  160.880694] bone_capemgr bone_capemgr: slot #4: dtbo 'BB-ADC-00A0.dtbo' loaded; overlay id #0

debian@beaglebone:~$ cat /sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage0_raw
3901

debian@beaglebone:~$ sudo find /sys |grep iio |grep raw|xargs more
::::::::::::::
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage0_raw
::::::::::::::
3927
::::::::::::::
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage1_raw
::::::::::::::
3484
::::::::::::::
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage2_raw
::::::::::::::
3891
::::::::::::::
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage3_raw
::::::::::::::
2185
::::::::::::::
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage4_raw
::::::::::::::
2382
::::::::::::::
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage5_raw
::::::::::::::
2976
::::::::::::::
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage6_raw
::::::::::::::
3149
  • Python test fails because it can not find /slots? Weird...
debian@beaglebone:~$ sudo strace -e open -fF python test.py 2>&1 |tail
open("/etc/localtime", O_RDONLY)        = 3
open("/sys/devices", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
open("/slots", O_RDWR|O_LARGEFILE)      = -1 ENOENT (No such file or directory)
Traceback (most recent call last):
  File "test.py", line 6, in <module>
open("test.py", O_RDONLY|O_LARGEFILE)   = 3
    ADC.setup()
RuntimeError: Unable to setup ADC system. Possible causes are: 
  - A cape with a conflicting pin mapping is loaded 
  - A device tree object is loaded that uses the same name for a fragment: helper
  • try to help the python adafruit_bbio lib to find slots in Linux 4.1.x:
debian@beaglebone:~$ cat /sys/devices/platform/bone_capemgr/slots
debian@beaglebone:~$ cat /sys/devices/bone_capemgr.9/slots
root@beaglebone:~# mkdir -p /sys/devices/bone_capemgr.9/
mkdir: cannot create directory `/sys/devices/bone_capemgr.9/': Operation not permitted
root@beaglebone:~# touch /sys/devices/bone_capemgr.9
touch: cannot touch `/sys/devices/bone_capemgr.9': Permission denied
import Adafruit_BBIO.ADC as ADC
import time
sensor_pin = 'P9_40'
ADC.setup()
while True:
reading = ADC.read(sensor_pin)
print('%f ' % (reading))
time.sleep(1)
@pdp7
Copy link
Author

pdp7 commented Feb 8, 2016

http://forums.adafruit.com/viewtopic.php?f=49&t=88823&p=450814#p450814
[b]An update on using the ADC in Python with Adafruit_BBIO:[/b]
It seems that Adafruit_BBIO does not work correctly with newer Linux kernel such as 4.1.x. This is because the pathname for the the capemgr in /sys has changed. My work in progress is in a [url=https://gist.github.com/pdp7/540d5e33ed0e4cb307e7]GitHub Gist[/url]. I will create a [url=https://github.com/adafruit/adafruit-beaglebone-io-python/]pull request on github[/url] once I have created a fix.

[b]Workaround[/b]: [url=https://groups.google.com/d/msg/beagleboard/LEMjcdgYM50/0wpSu0T_GrcJ]Revert to Linux kernel 3.8[/url] by installing the most recent 3.8 kernel:
[b]
sudo apt-get update
sudo apt-get install linux-image-3.8.13-bone79
[/b]

Now change which kernel will boot:
[b]
sudo vi /boot/uEnv.txt
[/b]

Comment out the 4.1 line and add 3.8 line:
[b]

uname_r=4.1.15-ti-r40

uname_r=3.8.13-bone79
[/b]

Finally reboot:
[b]
sudo reboot
[/b]

@pdp7
Copy link
Author

pdp7 commented Feb 8, 2016

@pdp7
Copy link
Author

pdp7 commented Feb 9, 2016

debian@beaglebone:~/bbio/source$ python
Python 2.7.3 (default, Mar 14 2014, 17:55:54) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.release()
'4.1.15-ti-r40'
import platform
platform.release()

@pdp7
Copy link
Author

pdp7 commented Feb 10, 2016

https://www.mail-archive.com/beagleboard@googlegroups.com/msg34780.html

sudo sh -c "echo 'BB-ADC' > /sys/devices/platform/bone_capemgr/slots"

cat /sys/devices/platform/bone_capemgr/slots
and got this result
P-O-L- 0 Override Board Name,00A0,Override Manuf,cape-universaln
P-O-L- 1 Override Board Name,00A0,Override Manuf,BB-ADC

@pdp7
Copy link
Author

pdp7 commented Feb 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment