root@beaglebone:~# uname -a
Linux beaglebone 4.1.17-ti-rt-r46 #1 SMP PREEMPT RT Fri Feb 5 17:13:30 UTC 2016 armv7l GNU/Linux
root@beaglebone:~# cat /etc/dogtag
BeagleBoard.org Debian Image 2016-02-07
root@beaglebone:~# python -c "import Adafruit_BBIO.ADC as ADC; ADC.setup();"
DEBUG: LINUX_VERSION_CODE=0x31007
DEBUG: KERNEL_VERSION(4,1,0)=0x40100
DEBUG: not define BBBVERSION41
Traceback (most recent call last):
File "<string>", line 1, in <module>
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
-
-
Save pdp7/193cb6252440850926297ac79ed39acc to your computer and use it in GitHub Desktop.
diff --git a/source/c_adc.c b/source/c_adc.c | |
index dc2a142..a9f770f 100644 | |
--- a/source/c_adc.c | |
+++ b/source/c_adc.c | |
@@ -21,6 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
SOFTWARE. | |
*/ | |
+#include <linux/version.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/types.h> | |
@@ -50,7 +51,10 @@ int initialize_adc(void) | |
return 1; | |
} | |
+ printf("DEBUG: LINUX_VERSION_CODE=0x%x\n", LINUX_VERSION_CODE); | |
+ printf("DEBUG: KERNEL_VERSION(4,1,0)=0x%x\n", KERNEL_VERSION(4,1,0)); | |
#ifdef BBBVERSION41 | |
+ printf("DEBUG: BBBVERSION41 is defined\n"); | |
if (load_device_tree("BB-ADC")) { | |
strncat(adc_prefix_dir, "/sys/bus/iio/devices/iio:device0/in_voltage", sizeof(adc_prefix_dir)); | |
snprintf(test_path, sizeof(test_path), "%s%d_raw", adc_prefix_dir, 1); | |
@@ -66,6 +70,7 @@ int initialize_adc(void) | |
return 1; | |
} | |
#else | |
+ printf("DEBUG: not define BBBVERSION41\n"); | |
if (load_device_tree("cape-bone-iio")) { | |
build_path("/sys/devices", "ocp.", ocp_dir, sizeof(ocp_dir)); | |
build_path(ocp_dir, "helper.", adc_prefix_dir, sizeof(adc_prefix_dir)); |
pdp7
commented
May 27, 2016
•
sudo apt-get remove linux-headers-4.1.17-ti-rt-r46
sudo apt-get install linux-headers-4.1.17-ti-rt-r46
The situation I'm seeing with Debian Jessie is that linux-libc-dev package is 3.16.7-ckt25-2. I'm going to check with Robert C. Nelson if he has any ideas of how to make LINUX_VERSION_CODE reflect the actual installed kernel.
debian@beaglebone:~/adafruit-beaglebone-io-python$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.4 (jessie)
Release: 8.4
Codename: jessie
debian@beaglebone:~/adafruit-beaglebone-io-python$ dpkg -l linux-libc-dev
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=====================================-=======================-=======================-===============================================================================
ii linux-libc-dev:armhf 3.16.7-ckt25-2 armhf Linux support headers for userspace development
debian@beaglebone:~/adafruit-beaglebone-io-python$ cat /etc/dogtag
BeagleBoard.org Debian Image 2016-02-07
debian@beaglebone:~/adafruit-beaglebone-io-python$ dpkg -l |grep kernel |grep 4.1
ii linux-headers-4.1.17-ti-rt-r46 1jessie armhf Linux kernel headers for 4.1.17-ti-rt-r46 on armhf
ii linux-image-4.1.17-ti-rt-r46 1jessie armhf Linux kernel, version 4.1.17-ti-rt-r46
ii linux-image-4.1.25-ti-r62 1jessie
https://groups.google.com/forum/#!search/peter$20bbio/beagleboard/Vx5U15tcwlw/e2Gjj-rwBAAJ
Robert: I'm hoping you might have some advice for this issue I'm encountering.
Peter's pull request for Adafruit_BBIO uses LINUX_VERSION_CODE to determine if the kernel is 4.1 or newer:
adafruit/adafruit-beaglebone-io-python#96 (comment)
When I build Adafruit_BBIO, LINUX_VERSION_CODE is set to old version 200711. It appears to come from:
/usr/include/linux/version.h:#define LINUX_VERSION_CODE 200711
/usr/src/linux-headers-4.1.17-ti-rt-r46/include/generated/uapi/linux/version.h:#define LINUX_VERSION_CODE 262417
I'm using image "BeagleBoard.org Debian Image 2016-02-07" with Linux kernel 4.1.25-ti-r62 and Debian 8.4. "/usr/include/linux/version.h" appears to come from linux-libc-dev:armhf 3.16.7-ckt25-2. "/usr/src/linux-headers-4.1.17-ti-rt-r46/include/generated/uapi/linux/version.h" comes from linux-headers-4.1.17-ti-rt-r46.
What would be the proper way to update /usr/include/linux/version.h to reflect 4.1+?
Related gist:
https://gist.github.com/pdp7/193cb6252440850926297ac79ed39acc
Thanks,
Drew
On Thursday, April 28, 2016 at 9:36:36 PM UTC-5, Peter Lawler wrote:
Hi folks,
Just a quick note to let you know I've spent some time tracking down the
differences between 3.8 and later versions for the Adafruit BBIO Python
library.
I first noted this post
https://forums.adafruit.com/viewtopic.php?f=49&t=91903&p=468811#p469266
which discusses that the 3.8 Adafruit library won't work on 4.1, and
that there were some fixes out in the wild so to speak but that Adafruit
weren't in a rush to get them happening.
So I took a look at one of the solutions, by grizmio, and it Just Worked
for me.
I've now shoved a bunch of ifdef's around the changes in the C code that
grizmio made, so I am *hoping* it's simultaneously 3.8 and 4.1 friendly.
I don't have a spare 3.8 machine at hand right now, but if there's
anyone out there who could try it out and see what happens, it'd be
appreciated. All I know is bad C and that it compiles. Please don't
shoot me for doing things wrong ;)
https://github.com/PeteLawler/adafruit-beaglebone-io-python
Regards,
Pete.